Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-05-23 10:03:44 -0400
committerptessier2014-05-23 10:03:44 -0400
commit947ecc8a092eb9739b9d01567850e88151f9dd96 (patch)
tree80406e704e5c38194e2cb9cfbe928cc034cecf25 /plugins/developer/org.eclipse.papyrus.gmfgenextension
parentf956b546c6399169680498b162b9fea3c8aec8f0 (diff)
downloadorg.eclipse.papyrus-947ecc8a092eb9739b9d01567850e88151f9dd96.tar.gz
org.eclipse.papyrus-947ecc8a092eb9739b9d01567850e88151f9dd96.tar.xz
org.eclipse.papyrus-947ecc8a092eb9739b9d01567850e88151f9dd96.zip
434626: [Diagram] change gmfgen to ensure that shape are generated
https://bugs.eclipse.org/bugs/show_bug.cgi?id=434626 Change-Id: Id6d26edb819e33f16750575fe8b0b2672cad7dda
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.gmfgenextension')
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml17
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/TestCodeSetGeneration.java208
2 files changed, 225 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml b/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml
index ee3efe208d7..40d84d21c23 100644
--- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml
@@ -274,6 +274,23 @@
</or>
</enablement>
</action>
+ <action
+ class="org.eclipse.papyrus.papyrusgmfgenextension.popupaction.TestCodeSetGeneration"
+ enablesFor="*"
+ id="org.eclipse.papyrus.papyrusgmfgenextension.popupaction.TopNodeRepor"
+ label="Display test subsetCode"
+ menubarPath="org.eclipse.papyrus.papyrusgmfgenextension.popupaction.MenuPapyrus/testSubsetCode">
+ <enablement>
+ <or>
+ <objectClass
+ name="org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator">
+ </objectClass>
+ <objectClass
+ name="org.eclipse.gmf.codegen.gmfgen.GenDiagram">
+ </objectClass>
+ </or>
+ </enablement>
+ </action>
</objectContribution>
</extension>
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/TestCodeSetGeneration.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/TestCodeSetGeneration.java
new file mode 100644
index 00000000000..4f4b8cb25af
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/TestCodeSetGeneration.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA LIST - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.codegen.gmfgen.GenChildLabelNode;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenChildSideAffixedNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Display the lis of nodes
+ */
+public class TestCodeSetGeneration extends Action {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ // NO OP
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+
+ Iterator<EObject> it = getSelectedEObject().iterator();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+
+ // Action should not be available on objects that are not GenCommonBase
+ if(eObject instanceof GenCommonBase) {
+ GenCommonBase genCommonBase = (GenCommonBase)eObject;
+ StringBuffer out = getTopNodes(genCommonBase.eResource());
+ Shell shell= new Shell(Display.getCurrent());
+
+ shell.setText("report");
+ shell.setLayout(new FillLayout());
+ Text text1 = new Text(shell, SWT.MULTI | SWT.BORDER| SWT.H_SCROLL|SWT.V_SCROLL);
+ text1.setText(out.toString());
+ shell.pack();
+ shell.open();
+
+ }
+
+ }
+ }
+
+ public StringBuffer getTopNodes(Resource gmfgen) {
+ StringBuffer out= new StringBuffer();
+ // Find the highest VisualID used by the chosen kind of node (given by clazz)
+ Iterator<EObject> it = gmfgen.getAllContents();
+ out=out.append("\n*************************************************\nTopNode\n******************************************************\n");
+ //topNode
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenTopLevelNode ){
+ GenTopLevelNode genTopLevelNode= (GenTopLevelNode)eObject;
+ if( genTopLevelNode.getModelFacet()!= null){
+ String name=genTopLevelNode.getModelFacet().getMetaClass().getEcoreClass().getName();
+ String visalId=""+genTopLevelNode.getVisualID();
+ out=out.append(
+ "/**\n"+
+ "* Test to manage "+name+".\n"+
+ "*/\n"+
+ "@Test\n"+
+ "public void testTo"+name+"() {\n"+
+ " testToManageNode(UMLElementTypes."+name+"_"+visalId+", UMLPackage.eINSTANCE.get"+name+"(), UMLElementTypes."+name+"_"+visalId+", false);\n"+
+ "}\n"
+ );
+ }
+ }
+ }
+
+ out=out.append("\n************************************************************************************************************************\n"
+ + "ChildNode\n"
+ + "************************************************************************************************************************\n");
+ it = gmfgen.getAllContents();
+ //topNode
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenChildNode &&!(eObject instanceof GenChildLabelNode)&&!(eObject instanceof GenChildSideAffixedNode)){
+ GenChildNode genTopLevelNode= (GenChildNode)eObject;
+ if( genTopLevelNode.getModelFacet()!= null){
+ String name=genTopLevelNode.getModelFacet().getMetaClass().getEcoreClass().getName();
+ String visalId=""+genTopLevelNode.getVisualID();
+ out=out.append(
+ "/**\n"+
+ "* Test to manage "+name+".\n"+
+ "*/\n"+
+ "@Test\n"+
+ "public void testTo"+name+"() {\n"+
+ " testToManageNode(UMLElementTypes."+name+"_"+visalId+", UMLPackage.eINSTANCE.get"+name+"(), container, true);\n"+
+
+ "}\n"
+ );
+ }
+ }
+ }
+
+ out=out.append("\n********************************************************************************************************************"
+ + "*\nChildLabelNode\n"
+ + "******************************************************************************************************************************\n");
+ it = gmfgen.getAllContents();
+ //topNode
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenChildLabelNode){
+ GenChildLabelNode genTopLevelNode= (GenChildLabelNode)eObject;
+ if( genTopLevelNode.getModelFacet()!= null){
+ String name=genTopLevelNode.getModelFacet().getMetaClass().getEcoreClass().getName();
+ String visalId=""+genTopLevelNode.getVisualID();
+ out=out.append(
+ "/**\n"+
+ "* Test to manage "+name+".\n"+
+ "*/\n"+
+ "@Test\n"+
+ "public void testTo"+name+"() {\n"+
+ "testToManageTopNodeWithMask(UMLElementTypes.Container,UMLElementTypes."+name+"_"+visalId+", Compartment.VISUAL_ID,null);\n"+
+ "}\n"
+ );
+ }
+ }
+ }
+
+ out=out.append("\n**************************************************************************************************************\n"
+ + "AffixedNode\n"
+ + "*************************************************************************************************************************\n");
+ it = gmfgen.getAllContents();
+ //topNode
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenChildSideAffixedNode){
+ GenChildSideAffixedNode genTopLevelNode= (GenChildSideAffixedNode)eObject;
+ if( genTopLevelNode.getModelFacet()!= null){
+ String name=genTopLevelNode.getModelFacet().getMetaClass().getEcoreClass().getName();
+ String visalId=""+genTopLevelNode.getVisualID();
+ out=out.append(
+ "/**\n"+
+ "* Test to manage "+name+".\n"+
+ "*/\n"+
+ "@Test\n"+
+ "public void testTo"+name+"() {\n"+
+ "setTestAffixedNode(true);\n"+
+ " testToManageNode(UMLElementTypes."+name+"_"+visalId+", UMLPackage.eINSTANCE.get"+name+"(), container, true);\n"+
+ "setTestAffixedNode(false);\n"+
+ "}\n"
+ );
+
+ }
+ }
+ }
+ out=out.append("\n************************************************************************************************************\n"
+ + "Link\n"
+ + "*****************************************************************************************************************************\n");
+ it = gmfgen.getAllContents();
+ //topNode
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenLink ){
+ GenLink genTopLevelNode= (GenLink)eObject;
+ if( genTopLevelNode.getModelFacet()!= null){
+ if(genTopLevelNode.getModelFacet() instanceof TypeLinkModelFacet){
+ String name=((TypeLinkModelFacet)genTopLevelNode.getModelFacet()).getMetaClass().getEcoreClass().getName();
+ String visalId=""+genTopLevelNode.getVisualID();
+ out=out.append(
+ "/**\n"+
+ "* Test to manage component.\n"+
+ "*/\n"+
+ "@Test\n"+
+ "public void testTo"+name+"() {\n"+
+ "testToManageLink(UMLElementTypes.source, UMLElementTypes.target, UMLElementTypes."+name+"_"+visalId+", container, true);\n"+
+ "}\n"
+ );
+ }
+ }
+ }
+ }
+ return out;
+ }
+
+}

Back to the top