Skip to content

Commit 606bbfd

Browse files
committed
Initial commit
0 parents  commit 606bbfd

8 files changed

+201
-0
lines changed

.classpath

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/openapi.jar">
5+
<attributes>
6+
<attribute name="javadoc_location" value="file:/C:/Users/30695/Downloads/vp-plugin-javadoc/"/>
7+
<attribute name="module" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
11+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/jniwrap.jar"/>
12+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib01.jar"/>
13+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib02.jar"/>
14+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib03.jar"/>
15+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib04.jar"/>
16+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib05.jar"/>
17+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib06.jar"/>
18+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib07.jar"/>
19+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/lib09.jar"/>
20+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/vpplatform.jar"/>
21+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/lib/winpack.jar"/>
22+
<classpathentry kind="lib" path="C:/Program Files/Visual Paradigm 17.2/ormlib/orm.jar"/>
23+
<classpathentry kind="output" path="classes"/>
24+
</classpath>

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>plugins.plantUML</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

.settings/org.eclipse.jdt.core.prefs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
10+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
11+
org.eclipse.jdt.core.compiler.release=disabled
12+
org.eclipse.jdt.core.compiler.source=1.8

classes/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/plugins/

plugin.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<plugin
2+
id="plugins.plantUML"
3+
name="PlantUML Support"
4+
description="Import from / Export to PlantUML"
5+
provider="Natalia Bourdi"
6+
class="plugins.plantUML.PlantUML">
7+
8+
<actionSets>
9+
<actionSet id="plugins.plantUML.actionset">
10+
<action
11+
id="plugins.plantUML.actions.PlantUMLActionController"
12+
actionType="generalAction"
13+
label="TODO"
14+
tooltip="TODO"
15+
style="normal"
16+
menuPath="Tools/Report">
17+
<actionController
18+
class="plugins.plantUML.actions.PlantUMLActionController"/>
19+
</action>
20+
</actionSet>
21+
</actionSets>
22+
</plugin>
23+

src/plugins/plantUML/PlantUML.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package plugins.plantUML;
2+
3+
import com.vp.plugin.VPPlugin;
4+
import com.vp.plugin.VPPluginInfo;
5+
6+
public class PlantUML implements VPPlugin {
7+
8+
@Override
9+
public void loaded(VPPluginInfo pluginInfo) {
10+
// TODO Auto-generated method stub
11+
12+
}
13+
14+
@Override
15+
public void unloaded() {
16+
// TODO Auto-generated method stub
17+
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package plugins.plantUML.actions;
2+
3+
import java.awt.Component;
4+
import java.io.File;
5+
import java.io.FileWriter;
6+
import java.io.IOException;
7+
8+
import javax.swing.JFileChooser;
9+
import javax.swing.filechooser.FileFilter;
10+
11+
import com.vp.plugin.ApplicationManager;
12+
import com.vp.plugin.ProjectManager;
13+
import com.vp.plugin.ViewManager;
14+
import com.vp.plugin.action.VPAction;
15+
import com.vp.plugin.action.VPActionController;
16+
import com.vp.plugin.model.IModelElement;
17+
import com.vp.plugin.model.IStep;
18+
import com.vp.plugin.model.IStepContainer;
19+
import com.vp.plugin.model.IUseCase;
20+
import com.vp.plugin.model.factory.IModelElementFactory;
21+
22+
public class PlantUMLActionController implements VPActionController{
23+
24+
public void performAction(VPAction action) {
25+
// get the view manager and the parent component for modal the dialog.
26+
ViewManager viewManager = ApplicationManager.instance().getViewManager();
27+
Component parentFrame = viewManager.getRootFrame();
28+
29+
// popup a file chooser for choosing the output file
30+
JFileChooser fileChooser = viewManager.createJFileChooser();
31+
fileChooser.setFileFilter(new FileFilter() {
32+
33+
public String getDescription() {
34+
return "*.htm";
35+
}
36+
37+
public boolean accept(File file) {
38+
return file.isDirectory() || file.getName().toLowerCase().endsWith(".htm");
39+
}
40+
41+
});
42+
fileChooser.showSaveDialog(parentFrame);
43+
File file = fileChooser.getSelectedFile();
44+
45+
if (file!=null && !file.isDirectory()) {
46+
String htmlContent = "";
47+
String result = "";
48+
49+
// Retrieve all use cases from project
50+
ProjectManager projectManager = ApplicationManager.instance().getProjectManager();
51+
IModelElement[] models = projectManager.getProject().toModelElementArray(IModelElementFactory.MODEL_TYPE_USE_CASE);
52+
53+
// Retrieve an HTML string of flow of events info from every use case
54+
for (int i = 0; i < models.length; i++) {
55+
IModelElement modelElement = models[i];
56+
IUseCase useCase = (IUseCase)modelElement;
57+
htmlContent += generate(useCase);
58+
}
59+
60+
// write to file
61+
try {
62+
FileWriter writer = new FileWriter(fileChooser.getSelectedFile());
63+
System.out.println(file.getAbsolutePath());
64+
writer.write(htmlContent);
65+
writer.close();
66+
result = "Success! HTML generated to "+file.getAbsolutePath();
67+
} catch (IOException e) {
68+
}
69+
70+
// show the generation result
71+
viewManager.showMessageDialog(parentFrame, result);
72+
}
73+
}
74+
75+
public String generate(IUseCase useCase) {
76+
String content = "";
77+
78+
// Retrieve flow of events sets from use case. Each IStepContainer is a set of flow of events
79+
IStepContainer[] stepContainers = useCase.toStepContainerArray();
80+
for (int i = 0; i < stepContainers.length; i++) {
81+
IStepContainer stepContainer = stepContainers[i];
82+
83+
// Print the name of use case and flow of events to HTML string
84+
content += "<table border=\"1\" width=\"500\"><tr><th>" + useCase.getName() + " - " + stepContainer.getName() + "</th></tr>";
85+
86+
// Print the flow of events content to HTML string
87+
IStep[] stepArray = stepContainer.toStepArray();
88+
for (int j = 0; j < stepArray.length; j++) {
89+
IStep step = stepArray[j];
90+
content += "<tr><td>"+ (j+1) + ". " + step.getName()+"</td></tr>";
91+
}
92+
content += "</table><br>";
93+
}
94+
95+
return content;
96+
97+
}
98+
99+
public void update(VPAction action) {
100+
}
101+
102+
}

0 commit comments

Comments
 (0)