Skip to main content
Jump to: navigation, search

Difference between revisions of "Java reverse engineering"

 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The Java Reverse Engineering is available in the extra plugins of Papyrus. It allows to reverse java filles or packages to a Papyrus class diagram.
+
Through Eclipse Mars, the Java Reverse Engineering was available in the Papyrus extra plugins. Since Eclipse Neon, they are now in a separate Papyrus component, called Papyrus software designer.
 +
The Java reverse tools allow Java files or packages to be reverse-engineered into a Papyrus class diagram.
  
== Installation Instructions==
+
== Installation instructions==
The Java Reverse Engineering will be available as a Papyrus extra plugin.
+
The Java features of Papyrus are available as part of the [http://wiki.eclipse.org/Papyrus_Software_Designer Papyrus Software Designer] extra feature.
  
Actually, you can install it from the Papyrus extra plugins nightly builds.
+
You can install it by using the Papyrus Software Designer update-site (for Oxygen):
Use the following update site:
+
* http://download.eclipse.org/modeling/mdt/papyrus/components/designer/
*http://download.eclipse.org/modeling/mdt/papyrus/updates/nightly/luna/extra/
+
Or you can use the nightly build update site for Oxygen (paste following url in eclipse update site):
Then :
+
* https://hudson.eclipse.org/papyrus/job/papyrus-designer-photon/lastSuccessfulBuild/artifact/releng/org.eclipse.papyrus.designer.p2/target/repository/
*Unsellect 'Group item by category'
+
 
*Select  '  Papyrus Java Reverse (Incubation)'
+
Then select "Papyrus Java profile, library and code generation (Incubation)" feature. You need JDT installed (which comes with most Eclipse packages).
*Finish
+
 
 +
[[Image:InstallSWDesignerJavaFeature.png]]
  
 
== How to use Reverse ==
 
== How to use Reverse ==
 
=== Using Command ===
 
=== Using Command ===
==== Reverse a Java class ====
+
==== Reverse-engineer a Java class ====
A java class can be reversed into a Papyrus class diagram:
+
A Java class can be reverse-engineered into a Papyrus class diagram:
 
*open the class diagram,
 
*open the class diagram,
*select a java package from a project
+
*select a Java package from a project
* click into the Reverse button [[File:ReverseButton.jpg]]
+
* click the Reverse button [[File:ReverseButton.jpg]]
  
A UML class has been created into the Model Explorer. Your can now add it into your diagram.
+
A UML class is created in Model Explorer. You can now add it into your diagram.
Note that all associated classes are also been added into the model.  
+
Note that all associated classes have also been added to the model.  
  
==== Reverse a package ====
+
==== Reverse-engineer a package ====
A java package (and all classes included) can be reversed into a Papyrus class diagram:
+
A Java package (and all classes included) can be reverse-engineered into a Papyrus class diagram:
 
*open the class diagram,
 
*open the class diagram,
*select a java package from a project,
+
*select a Java package from a project,
*click into the Reverse button [[File:ReverseButton.jpg]]
+
*click the Reverse button [[File:ReverseButton.jpg]]
  
Package and classes have been created into the Model Explorer. Your can now add them into your diagram.
+
Packages and classes have been created in Model Explorer. Your can now add them to your diagram.
Note that all associated classes are also been added into the model.  
+
Note that all associated classes have also been added to the model.  
  
==== Reverse settings ====
+
==== Reverse-engineering settings ====
By default, a package named "generated" is created for the reverse engineering. You can choose another package name on the options menu.
+
By default, a package named "generated" is created for reverse-engineering. You can choose another package name on the options menu.
  
 
[[Image:JavaReverseOptionsMenu.jpg]]   
 
[[Image:JavaReverseOptionsMenu.jpg]]   
  
This options menu allows to:
+
This option menu allows one to:
* change the default package of the reverse engineering,
+
* change the default package of the reverse-engineering,
* add or remove search path. The reverse generator search existing uml classes and regenerate them.
+
* add or remove search path. The reverse generator search existing UML classes and regenerate them.
* add or remove creation path. The reverse generator search on existing java classes to generate a uml class. Useful for creating java imports (ex: String, Integer).
+
* add or remove creation path. The reverse generator search on existing Java classes to generate a UML class. Useful for creating Java imports (e.g.: String, Integer).
  
 
=== Using Drag & Drop ===
 
=== Using Drag & Drop ===
You can reverse a class or a package by just drag & drop it into a papyrus diagram:
+
You can reverse-engineer a class or a package by just dragging & dropping it on a Papyrus diagram:
* Drag one or more classes/packages,
+
* Drag one or more classes and/or packages,
* Drop the selection into an opened diagram.   
+
* Drop the selection into an open diagram.   
  
 
[[Image:JavaReverseDragAndDrop.png]]
 
[[Image:JavaReverseDragAndDrop.png]]
  
A settings dialog is opened. You can modify settings (please see Reverse settings).  
+
A settings dialog is opened. You can modify settings (please see Reverse settings).
In case when you're reversing by using drag & drop way, you can also choose to display model, packages, and classes / interfaces / enumerations into the papyrus diagram. To enable displaying, just click into the check-boxes:   
+
When you're reverse-engineering via the drag & drop method, you can also choose to display model, packages, and classes / interfaces / enumerations in the Papyrus diagram. To enable display, just click the check-boxes:   
  
 
[[Image:JavaReverseDnDPopUp.png]]
 
[[Image:JavaReverseDnDPopUp.png]]
  
When you clicked on ''Ok'' button, your components are displayed into papyrus diagram. Note while, all selected components are reversed, only components which are in selection, but not into papyrus diagram are displayed.   
+
When you click on the ''OK'' button, your components are displayed in the Papyrus diagram. Note: while all selected components are reversed-engineered, only components which are selected, but not in the Papyrus diagram are displayed.   
  
 
[[Image:JavaReverseDnDResult.png]]
 
[[Image:JavaReverseDnDResult.png]]
  
== Change default reverse settings ==
+
== Change default reverse-engineering settings ==
The java code reverse plugin allows you to change default settings on eclipse preferences:
+
The Java code reverse-engineering plugin allows you to change default settings on eclipse preferences:
 
*Open ''Eclipse Preferences'',
 
*Open ''Eclipse Preferences'',
*Search for ''Papyrus'' section,
+
*Search for the ''Papyrus'' section,
 
*Choose ''Java Code Reverse'' sub-section
 
*Choose ''Java Code Reverse'' sub-section
  
Line 67: Line 69:
 
*default search path values,
 
*default search path values,
 
*default creation path values.
 
*default creation path values.
Note that there are default values; if you have changed these values for a project, your changes are saved, and default values are not used.
+
Note that there are default values; if you have changed these values for a project, your changes are saved, and default values are not used.
  
 
[[Image:JavaCodeReversePreferences.png]]
 
[[Image:JavaCodeReversePreferences.png]]
 +
 +
== Developer resources ==
 +
 +
* Git repo: http://git.eclipse.org/c/papyrus/org.eclipse.papyrus-designer.git
 +
* Java plugins path: languages/java/
 +
* Java reverse plugins:
 +
** org.eclipse.papyrus.designer.languages.java.reverse.ui
 +
*** Starting points when called from toolbar UI:
 +
*** org.eclipse.papyrus.designer.languages.java.reverse.ui.handlers.JavaCodeReverseInJobHandler.doPrepareExecute(ExecutionEvent)
 +
*** org.eclipse.papyrus.designer.languages.java.reverse.ui.handlers.JavaCodeReverseInJobHandler.doExecuteTransactionInJob(IProgressMonitor)
 +
** org.eclipse.papyrus.designer.languages.java.reverse
 +
*** Project explorer walker visits the project explorer resources recursively, until we reach a compilation unit called a "node" in this context.
 +
**** org.eclipse.papyrus.designer.languages.java.reverse.ui.ProjectExplorerNodeWalkerWithIProgress.doSwitch(Object, SubMonitor)
 +
**** org.eclipse.papyrus.designer.languages.java.reverse.ui.ProjectExplorerNodeWalkerWithIProgress.visitICompilationUnit(ICompilationUnit, SubMonitor)
 +
*** Then we use a node visitor to visit its JDT elements.
 +
***** org.eclipse.papyrus.designer.languages.java.reverse.ui.ReverseSelectedNodeVisitor.visitICompilationUnit(ICompilationUnit)
 +
*** Which uses its compilation unit analyzer to analyze and create UML elements
 +
**** org.eclipse.papyrus.designer.languages.java.reverse.umlparser.CompilationUnitAnalyser.processCompilationUnit(CompilationUnit)
 +
*** The compilation unit analyzer uses other classes which are all in the following package:
 +
**** org.eclipse.papyrus.designer.languages.java.reverse.umlparser
 +
** Java Parser and JDT Parser
 +
*** To reverse Java code, it is parsed by Java Parser and an AST is built.
 +
*** Java Parser is embedded in: org.eclipse.papyrus.designer.languages.java.reverse.javaparser
 +
*** We are also experimenting with JDT Parser (currently deactivated for the user)
 +
*** JDT Parser files are in: org.eclipse.papyrus.designer.languages.java.reverse.jdt
 +
 +
[[Category:Modeling]]
 +
[[Category:Papyrus]]
 +
[[Category:Papyrus-Software-Designer]]

Latest revision as of 04:59, 11 June 2019

Through Eclipse Mars, the Java Reverse Engineering was available in the Papyrus extra plugins. Since Eclipse Neon, they are now in a separate Papyrus component, called Papyrus software designer. The Java reverse tools allow Java files or packages to be reverse-engineered into a Papyrus class diagram.

Installation instructions

The Java features of Papyrus are available as part of the Papyrus Software Designer extra feature.

You can install it by using the Papyrus Software Designer update-site (for Oxygen):

Or you can use the nightly build update site for Oxygen (paste following url in eclipse update site):

Then select "Papyrus Java profile, library and code generation (Incubation)" feature. You need JDT installed (which comes with most Eclipse packages).

InstallSWDesignerJavaFeature.png

How to use Reverse

Using Command

Reverse-engineer a Java class

A Java class can be reverse-engineered into a Papyrus class diagram:

  • open the class diagram,
  • select a Java package from a project
  • click the Reverse button ReverseButton.jpg

A UML class is created in Model Explorer. You can now add it into your diagram. Note that all associated classes have also been added to the model.

Reverse-engineer a package

A Java package (and all classes included) can be reverse-engineered into a Papyrus class diagram:

  • open the class diagram,
  • select a Java package from a project,
  • click the Reverse button ReverseButton.jpg

Packages and classes have been created in Model Explorer. Your can now add them to your diagram. Note that all associated classes have also been added to the model.

Reverse-engineering settings

By default, a package named "generated" is created for reverse-engineering. You can choose another package name on the options menu.

JavaReverseOptionsMenu.jpg

This option menu allows one to:

  • change the default package of the reverse-engineering,
  • add or remove search path. The reverse generator search existing UML classes and regenerate them.
  • add or remove creation path. The reverse generator search on existing Java classes to generate a UML class. Useful for creating Java imports (e.g.: String, Integer).

Using Drag & Drop

You can reverse-engineer a class or a package by just dragging & dropping it on a Papyrus diagram:

  • Drag one or more classes and/or packages,
  • Drop the selection into an open diagram.

JavaReverseDragAndDrop.png

A settings dialog is opened. You can modify settings (please see Reverse settings). When you're reverse-engineering via the drag & drop method, you can also choose to display model, packages, and classes / interfaces / enumerations in the Papyrus diagram. To enable display, just click the check-boxes:

JavaReverseDnDPopUp.png

When you click on the OK button, your components are displayed in the Papyrus diagram. Note: while all selected components are reversed-engineered, only components which are selected, but not in the Papyrus diagram are displayed.

JavaReverseDnDResult.png

Change default reverse-engineering settings

The Java code reverse-engineering plugin allows you to change default settings on eclipse preferences:

  • Open Eclipse Preferences,
  • Search for the Papyrus section,
  • Choose Java Code Reverse sub-section

In this preferences page, you can change:

  • default search path values,
  • default creation path values.

Note that there are default values; if you have changed these values for a project, your changes are saved, and default values are not used.

JavaCodeReversePreferences.png

Developer resources

  • Git repo: http://git.eclipse.org/c/papyrus/org.eclipse.papyrus-designer.git
  • Java plugins path: languages/java/
  • Java reverse plugins:
    • org.eclipse.papyrus.designer.languages.java.reverse.ui
      • Starting points when called from toolbar UI:
      • org.eclipse.papyrus.designer.languages.java.reverse.ui.handlers.JavaCodeReverseInJobHandler.doPrepareExecute(ExecutionEvent)
      • org.eclipse.papyrus.designer.languages.java.reverse.ui.handlers.JavaCodeReverseInJobHandler.doExecuteTransactionInJob(IProgressMonitor)
    • org.eclipse.papyrus.designer.languages.java.reverse
      • Project explorer walker visits the project explorer resources recursively, until we reach a compilation unit called a "node" in this context.
        • org.eclipse.papyrus.designer.languages.java.reverse.ui.ProjectExplorerNodeWalkerWithIProgress.doSwitch(Object, SubMonitor)
        • org.eclipse.papyrus.designer.languages.java.reverse.ui.ProjectExplorerNodeWalkerWithIProgress.visitICompilationUnit(ICompilationUnit, SubMonitor)
      • Then we use a node visitor to visit its JDT elements.
          • org.eclipse.papyrus.designer.languages.java.reverse.ui.ReverseSelectedNodeVisitor.visitICompilationUnit(ICompilationUnit)
      • Which uses its compilation unit analyzer to analyze and create UML elements
        • org.eclipse.papyrus.designer.languages.java.reverse.umlparser.CompilationUnitAnalyser.processCompilationUnit(CompilationUnit)
      • The compilation unit analyzer uses other classes which are all in the following package:
        • org.eclipse.papyrus.designer.languages.java.reverse.umlparser
    • Java Parser and JDT Parser
      • To reverse Java code, it is parsed by Java Parser and an AST is built.
      • Java Parser is embedded in: org.eclipse.papyrus.designer.languages.java.reverse.javaparser
      • We are also experimenting with JDT Parser (currently deactivated for the user)
      • JDT Parser files are in: org.eclipse.papyrus.designer.languages.java.reverse.jdt

Back to the top