How to perform Instant Reverse using Plugin API

Visual Paradigm’s Plugin API not just allows you access to the models and diagrams in your project, it also allows you to trigger various functions in the application. In this article we will show you how to trigger Instant Reverse to reverse your source code into model using plugin.

In the plugin the first step need to perform is to create the InstantReverseOption. The InstantReverseOption is the configuration for perform Instant Reverse. Once it being created we start to configure it, including setting the language for perform reverse engineering, what kind of source path it is (source file or folder), source file type (source code files or binary files), and of course the source path.

// Create new InstantReverseOption
InstantReverseOption iro = new InstantReverseOption();
// Specify Java as the language to be reverse
iro.setLanguage(InstantReverseOption.LANGUAGE_JAVA);
// Specify the input as read from a folder
iro.setJavaPathType(InstantReverseOption.JAVA_PATH_TYPE_FOLDER);
// Specify the input is source file
iro.setJavaSourceType(InstantReverseOption.JAVA_SOURCE_TYPE_SOURCE);
// Specify the source location
iro.setReversePath(new File("G://src_demo"));

Once the configuration is done we obtain the ModelConversionManager from ApplicationManager, and trigger the Instant Reverse by providing the InstantReverseOption.

// Obtain ModelConvertionManager from ApplicationManager and trigger Instant Reverse
ModelConvertionManager cm = ApplicationManager.instance().getModelConvertionManager();
cm.instantReverse(iro);

When the reverse engineering is done the source/binaries will be reversed into UML class models. They can be access from Model Explorer or Class Repository trees. You can then drag & drop them into diagram for visualization, or further manipulate by extend the plugin.

Download Sample Plugin

You can download the source code of this sample plugin from GitHub.

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply