Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Java Code Reverse Developer Guide"

m (Class Diagram)
(ui)
Line 24: Line 24:
 
**CreateAssociationFromPropertyHandler, which find association of a component.
 
**CreateAssociationFromPropertyHandler, which find association of a component.
 
*plugin.xml, which contains buttons, pop menu … . Each component call an handler. Morehover, there components are only available when selected resource is generable, according to xml « when » condition.
 
*plugin.xml, which contains buttons, pop menu … . Each component call an handler. Morehover, there components are only available when selected resource is generable, according to xml « when » condition.
 +
 +
=== drag and drop ===
 +
A drag & drop way to reverse is implemented. It is decomposed into:
 +
* '''DndReverseCodeDialog''': a popup dialog extends from ReverseCodeDialog, which just add some buttons to allow user to display or not reversed components into diagram,
 +
* '''DndReverseCodeHandler''': a special handler which search for reversed elements to display into diagram.
 +
* '''DropReverseCommand''' & '''DropReverseStrategy''', which check if drag & drop is possible. It is possible if (please see DropReverseCommand.canExecute() ):
 +
** selected java resources are only composed by Compilation Unit (Classes, Interfaces, Enumerations), packages, and java source folder. Any other item (a payrus model file for example) automatically disable the drag and drop.
 +
** Selection is dropped into a papyrus diagram.
  
 
== Class Diagram ==
 
== Class Diagram ==
 
The following is a class diagram of this plugin. While it don't show every classes of the project, it offer a good overview of main classes.
 
The following is a class diagram of this plugin. While it don't show every classes of the project, it offer a good overview of main classes.
 
[[Image:JavaCodeReverseClassDiagram.png]]
 
[[Image:JavaCodeReverseClassDiagram.png]]

Revision as of 10:21, 6 August 2014

Overview

Papyrus provides an extra plugin named org.eclipse.papyrus.java.reverse which allows to generate papyrus model from java source code. It is divided in 3 projects:

  • reverse : parse and visit the Eclipse AST of the reversed project.
  • reverse.ui : provides user graphical interface to run the reverse plugin
  • reverse.utils : provides handlers for reverse.

Dependencies

The following schema shows dependencies between java code reverse plugins:

JavaCodeReverseDependenciesDiagram.png

reverse

The reverse project uses the japa parser to visit the Eclipse AST (Abstract Syntax Tree). This AST allows to plugin to add reverse action for each element (project, class, field, method etc.). For more details, please see the Eclipse AST

In particular, it use a Catalog to find already existing uml components (for example a previous reverse result), and just add non existing components. Note that, as it never remove any component, it leave components of a previous reverse, even if java source code doesn’t exist anymore (for example if user remove this code).

ui

The ui project provides Eclipse user interface for the entire plugin. It is divided in two parts:

  • Handlers, which call commands:
    • ReverseCodeHandler, which call the reverse command,
    • CreateAssociationFromPropertyHandler, which find association of a component.
  • plugin.xml, which contains buttons, pop menu … . Each component call an handler. Morehover, there components are only available when selected resource is generable, according to xml « when » condition.

drag and drop

A drag & drop way to reverse is implemented. It is decomposed into:

  • DndReverseCodeDialog: a popup dialog extends from ReverseCodeDialog, which just add some buttons to allow user to display or not reversed components into diagram,
  • DndReverseCodeHandler: a special handler which search for reversed elements to display into diagram.
  • DropReverseCommand & DropReverseStrategy, which check if drag & drop is possible. It is possible if (please see DropReverseCommand.canExecute() ):
    • selected java resources are only composed by Compilation Unit (Classes, Interfaces, Enumerations), packages, and java source folder. Any other item (a payrus model file for example) automatically disable the drag and drop.
    • Selection is dropped into a papyrus diagram.

Class Diagram

The following is a class diagram of this plugin. While it don't show every classes of the project, it offer a good overview of main classes. JavaCodeReverseClassDiagram.png

Back to the top