Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2005-11-16 03:37:41 -0500
committerashatalin2005-11-16 03:37:41 -0500
commita5330af06ce68d829ef99e6a520846bb8a776375 (patch)
treed8e8b028da44b4089c0e349282c85bb0843f17d7
parent7828803483f1fe032c7f3e262746042a5d666bab (diff)
downloadorg.eclipse.gmf-tooling-a5330af06ce68d829ef99e6a520846bb8a776375.tar.gz
org.eclipse.gmf-tooling-a5330af06ce68d829ef99e6a520846bb8a776375.tar.xz
org.eclipse.gmf-tooling-a5330af06ce68d829ef99e6a520846bb8a776375.zip
#116622
Supporting infinite ChildNode hierarchy in InitDiagramFileAction
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java578
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java492
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet337
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet289
4 files changed, 980 insertions, 716 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java
index 24f2a7f45..67c1c64ff 100644
--- a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java
+++ b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java
@@ -19,74 +19,136 @@ public class InitDiagramFileActionGenerator
protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "package ";
- protected final String TEXT_2 = ";";
- protected final String TEXT_3 = NL + "import java.io.IOException;" + NL + "import java.util.Collection;" + NL + "import java.util.Collections;" + NL + "import java.util.HashMap;" + NL + "import java.util.Iterator;" + NL + "import java.util.LinkedList;" + NL + "import java.util.Map;" + NL + "" + NL + "import org.eclipse.core.resources.IFile;" + NL + "import org.eclipse.core.resources.IResource;" + NL + "import org.eclipse.core.resources.ResourcesPlugin;" + NL + "import org.eclipse.core.runtime.IStatus;" + NL + "import org.eclipse.core.runtime.Path;" + NL + "import org.eclipse.emf.ecore.EClass;" + NL + "import org.eclipse.emf.ecore.EObject;" + NL + "import org.eclipse.emf.ecore.EStructuralFeature;" + NL + "import org.eclipse.emf.ecore.resource.Resource;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.DiagramUtil;" + NL + "import org.eclipse.gmf.runtime.emf.core.edit.MRunnable;" + NL + "import org.eclipse.gmf.runtime.emf.core.util.OperationUtil;" + NL + "import org.eclipse.gmf.runtime.emf.core.util.ResourceUtil;" + NL + "import org.eclipse.gmf.runtime.notation.Diagram;" + NL + "import org.eclipse.gmf.runtime.notation.Node;" + NL + "import org.eclipse.gmf.runtime.notation.View;" + NL + "import org.eclipse.jface.action.IAction;" + NL + "import org.eclipse.jface.dialogs.IInputValidator;" + NL + "import org.eclipse.jface.dialogs.InputDialog;" + NL + "import org.eclipse.jface.dialogs.MessageDialog;" + NL + "import org.eclipse.jface.viewers.ISelection;" + NL + "import org.eclipse.jface.viewers.IStructuredSelection;" + NL + "import org.eclipse.swt.widgets.Shell;" + NL + "import org.eclipse.ui.IObjectActionDelegate;" + NL + "import org.eclipse.ui.IWorkbenchPart;" + NL + "import org.eclipse.ui.PartInitException;" + NL + "import org.eclipse.ui.ide.IDE;";
- protected final String TEXT_4 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
- protected final String TEXT_5 = " implements IObjectActionDelegate, IInputValidator {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + " private static final String FILE_EXT = \"";
- protected final String TEXT_6 = "\";" + NL + " " + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IWorkbenchPart myPart;" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFile mySelection;" + NL + " " + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Map myLinkWithClassVID2EObject = new HashMap();" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Map myEObject2NodeMap = new HashMap();" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void setActivePart(IAction action, IWorkbenchPart targetPart) {" + NL + "\t\tmyPart = targetPart;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate Shell getShell() {" + NL + "\t\treturn myPart.getSite().getShell();" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void selectionChanged(IAction action, ISelection selection) {" + NL + "\t\tmySelection = null;" + NL + "\t\taction.setEnabled(false);" + NL + "\t\tif (selection instanceof IStructuredSelection == false || selection.isEmpty()) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tmySelection = (IFile) ((IStructuredSelection) selection).getFirstElement();" + NL + "\t\taction.setEnabled(true);" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */\t" + NL + "\tpublic String isValid(String newText) {" + NL + "\t\tIStatus status = ResourcesPlugin.getWorkspace().validateName(newText, IResource.FILE);" + NL + "\t\tif (!status.isOK()) {" + NL + "\t\t\treturn status.getMessage();" + NL + "\t\t}" + NL + "\t\tif (mySelection.getParent().getFile(new Path(newText).addFileExtension(FILE_EXT)).exists()) {" + NL + "\t\t\treturn \"File already exists, choose another name\";" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void run(IAction action) {" + NL + "\t\tfinal InputDialog outputFileNameDialog = new InputDialog(getShell(), \"Diagram file name\", \"Please provide diagram file name\", mySelection.getProjectRelativePath().removeFileExtension().addFileExtension(FILE_EXT).lastSegment(), this);" + NL + "\t\tif (outputFileNameDialog.open() != InputDialog.OK) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tfinal EObject diagramModelObject = load();" + NL + "\t\tif (diagramModelObject == null) {" + NL + "\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to load user model\");" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tOperationUtil.runAsUnchecked(new MRunnable() {" + NL + "\t\t\tpublic Object run() {" + NL + "\t\t\t\tEObject diagram = create(diagramModelObject);" + NL + "\t\t\t\tif (diagram == null) {" + NL + "\t\t\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to create diagram object\");" + NL + "\t\t\t\t\treturn null;" + NL + "\t\t\t\t}" + NL + "\t\t\t\tIFile destFile = mySelection.getParent().getFile(new Path(outputFileNameDialog.getValue()));" + NL + "\t\t\t\tsave(destFile.getLocation().toOSString(), diagram);" + NL + "\t\t\t\ttry {" + NL + "\t\t\t\t\tIDE.openEditor(myPart.getSite().getPage(), destFile);" + NL + "\t\t\t\t} catch (PartInitException ex) {" + NL + "\t\t\t\t\tex.printStackTrace();" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn null;" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate EObject load() {";
- protected final String TEXT_7 = NL + "\t\t";
- protected final String TEXT_8 = " resourceSet = new ";
- protected final String TEXT_9 = "();" + NL + "\t\tResource resource = resourceSet.getResource(";
- protected final String TEXT_10 = ".createPlatformResourceURI(mySelection.getFullPath().toString()), true);" + NL + "\t\ttry {" + NL + "\t\t\tresource.load(Collections.EMPTY_MAP);" + NL + "\t\t\treturn (EObject) resource.getContents().get(0);" + NL + "\t\t} catch (IOException ex) {" + NL + "\t\t\tex.printStackTrace();" + NL + "\t\t}" + NL + "\t\treturn null;";
- protected final String TEXT_11 = NL + "\t\tResource modelResource = ResourceUtil.load(mySelection.getLocation().toOSString());" + NL + "\t\treturn (EObject) modelResource.getContents().get(0);";
- protected final String TEXT_12 = NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void save(String filePath, EObject canvas) {" + NL + "\t\tResource resource = ResourceUtil.create(filePath, null);";
- protected final String TEXT_13 = NL + "\t\tresource.getContents().add(((Diagram) canvas).getElement());";
- protected final String TEXT_14 = NL + "\t\tresource.getContents().add(canvas);" + NL + "\t\ttry {" + NL + "\t\t\tresource.save(Collections.EMPTY_MAP);" + NL + "\t\t} catch (IOException ex) {" + NL + "\t\t\tex.printStackTrace();" + NL + "\t\t}" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate EObject create(EObject diagramModel) {" + NL + "\t\tint diagramVID = ";
- protected final String TEXT_15 = ".INSTANCE.getDiagramVisualID(diagramModel);" + NL + "\t\tif (diagramVID == -1) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\tmyLinkWithClassVID2EObject.clear();" + NL + "\t\tmyEObject2NodeMap.clear();";
- protected final String TEXT_16 = NL + "\t\tmyLinkWithClassVID2EObject.put(new Integer(";
- protected final String TEXT_17 = "), new LinkedList());";
- protected final String TEXT_18 = NL + "\t\tDiagram diagram = DiagramUtil.createDiagram(diagramModel, \"";
- protected final String TEXT_19 = "\", ";
- protected final String TEXT_20 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\tcreateDiagramChildren(diagram, diagramModel);" + NL + "\t\t" + NL + "\t\tcreateLinks();" + NL + "\t\t" + NL + "\t return diagram;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createDiagramChildren(Diagram diagram, EObject diagramObject) {" + NL + "\t\tfor (Iterator it = diagramObject.eContents().iterator(); it.hasNext();) {" + NL + "\t\t\tEObject nextChild = (EObject) it.next();" + NL + "\t\t\tstoreLinkReferenceOnly(nextChild);" + NL + "\t\t\tint nodeVID = ";
- protected final String TEXT_21 = ".INSTANCE.getNodeVisualID(nextChild);" + NL + "\t\t\tif (nodeVID == -1) {" + NL + "\t\t\t\tstoreLinkWithClass(nextChild);" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tNode nextNode = DiagramUtil.createNode(diagram, nextChild, null, ";
- protected final String TEXT_22 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextChild, nextNode);" + NL + "\t\t\tswitch (nodeVID) {";
- protected final String TEXT_23 = "\t\t" + NL + "\t\t\tcase ";
- protected final String TEXT_24 = ":" + NL + "\t\t\t\tcreate";
- protected final String TEXT_25 = "Children(nextNode, nextChild);" + NL + "\t\t\t\tbreak;";
- protected final String TEXT_26 = NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "\t";
- protected final String TEXT_27 = "\t\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void create";
- protected final String TEXT_28 = "Children(Node node, EObject nodeObject) {" + NL + "\t\tfor (Iterator it = nodeObject.eContents().iterator(); it.hasNext();) {" + NL + "\t\t\tEObject nextChild = (EObject) it.next();" + NL + "\t\t\tstoreLinkReferenceOnly(nextChild);" + NL + "\t\t\tint nodeVID = ";
- protected final String TEXT_29 = ".INSTANCE.getChildNodeVisualID(nextChild);" + NL + "\t\t\tif (nodeVID == -1) {" + NL + "\t\t\t\tstoreLinkWithClass(nextChild);" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\t" + NL + "\t\t\tNode container;" + NL + "\t\t\tswitch (nodeVID) {";
- protected final String TEXT_30 = "\t\t" + NL + "\t\t\tcase ";
- protected final String TEXT_31 = ":";
- protected final String TEXT_32 = "\t\t\t" + NL + "\t\t\t\tcontainer = getCompartment(node, \"";
- protected final String TEXT_33 = "\");";
- protected final String TEXT_34 = NL + "\t\t\t\tcontainer = node;";
- protected final String TEXT_35 = NL + "\t\t\t\tbreak;";
- protected final String TEXT_36 = NL + "\t\t\tdefault:" + NL + "\t\t\t\tcontainer = node;" + NL + "\t\t\t\tbreak;" + NL + "\t\t\t}" + NL + "\t\t\tNode nextNode = DiagramUtil.createNode(container, nextChild, null, ";
- protected final String TEXT_37 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextChild, nextNode);" + NL + "\t\t}" + NL + "\t}";
- protected final String TEXT_38 = NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate Node getCompartment(Node node, String name) {" + NL + "\t\tfor (Iterator it = node.getChildren().iterator(); it.hasNext();) {" + NL + "\t\t\tView nextView = (View) it.next();" + NL + "\t\t\tif (nextView instanceof Node && name.equals(nextView.getType())) {" + NL + "\t\t\t\treturn (Node) nextView;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn node;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void storeLinkWithClass(EObject link) {" + NL + "\t\tint linkVID = ";
- protected final String TEXT_39 = ".INSTANCE.getLinkWithClassVisualID(link);" + NL + "\t\tif (linkVID == -1) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\t((Collection) myLinkWithClassVID2EObject.get(new Integer(linkVID))).add(link);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeLinkReferenceOnly(EObject container) {" + NL + "\t\tEClass containerMetaclass = container.eClass();" + NL + "\t\tfor (Iterator it = containerMetaclass.getEAllStructuralFeatures().iterator(); it.hasNext();) {" + NL + "\t\t\tEStructuralFeature nextFeature = (EStructuralFeature) it.next();";
- protected final String TEXT_40 = NL + "\t\t\tif (";
- protected final String TEXT_41 = ".eINSTANCE.get";
- protected final String TEXT_42 = "().equals(nextFeature)) {" + NL + "\t\t\t\t((Collection) myLinkWithClassVID2EObject.get(new Integer(";
- protected final String TEXT_43 = "))).add(container);" + NL + "\t\t\t}";
- protected final String TEXT_44 = NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createLinks() {" + NL + "\t\tCollection linkElements;";
- protected final String TEXT_45 = NL + "\t\tlinkElements = (Collection) myLinkWithClassVID2EObject.get(new Integer(";
- protected final String TEXT_46 = "));" + NL + "\t\tfor (Iterator it = linkElements.iterator(); it.hasNext();) {" + NL + "\t\t\tEObject linkElement = (EObject) it.next();";
- protected final String TEXT_47 = NL + "\t\t\tEObject src = linkElement.eContainer();";
- protected final String TEXT_48 = NL + "\t\t\tEObject src = linkElement;";
- protected final String TEXT_49 = NL + "\t\t\tNode srcNode = (Node) myEObject2NodeMap.get(src);" + NL + "\t\t\tif (srcNode == null) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tEStructuralFeature structuralFeature = ";
- protected final String TEXT_50 = ".eINSTANCE.get";
- protected final String TEXT_51 = "();" + NL + "\t\t\tObject structuralFeatureResult = linkElement.eGet(structuralFeature);";
- protected final String TEXT_52 = NL + "\t\t\tif (structuralFeatureResult instanceof EObject == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tEObject dst = (EObject) structuralFeatureResult;";
- protected final String TEXT_53 = NL + "\t\t\tif (structuralFeatureResult instanceof Collection == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tfor (Iterator destinations = ((Collection) structuralFeatureResult).iterator(); destinations.hasNext();) {" + NL + "\t\t\t\tEObject dst = (EObject) destinations.next();";
- protected final String TEXT_54 = NL + "\t\t\tNode dstNode = (Node) myEObject2NodeMap.get(dst);" + NL + "\t\t\tif (dstNode != null) {";
- protected final String TEXT_55 = NL + "\t\t\t\tDiagramUtil.createEdge(srcNode, dstNode, linkElement, null, ";
- protected final String TEXT_56 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t}";
- protected final String TEXT_57 = NL + "\t\t\t\t\t";
- protected final String TEXT_58 = " edge = (";
- protected final String TEXT_59 = ") ";
- protected final String TEXT_60 = ".getInstance().createEdge(new ";
- protected final String TEXT_61 = "() {" + NL + "\t\t\t\t\t\tpublic Object getAdapter(Class adapter) {" + NL + "\t\t\t\t\t\t\tif (";
- protected final String TEXT_62 = ".class.equals(adapter)) {" + NL + "\t\t\t\t\t\t\t\treturn ";
- protected final String TEXT_63 = ".";
- protected final String TEXT_64 = ";" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\treturn null;" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}, srcNode.getDiagram(), \"\", ";
- protected final String TEXT_65 = ".APPEND, ";
- protected final String TEXT_66 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\t\tif (edge != null) {" + NL + "\t\t\t\t\t\tedge.setSource(srcNode);" + NL + "\t\t\t\t\t\tedge.setTarget(dstNode);" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t}";
- protected final String TEXT_67 = NL + "\t\t}";
- protected final String TEXT_68 = NL + "\t}" + NL + "\t" + NL + "}";
- protected final String TEXT_69 = NL;
+ protected final String TEXT_2 = ";" + NL;
+ protected final String TEXT_3 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
+ protected final String TEXT_4 = " implements IObjectActionDelegate, IInputValidator {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + " private static final String FILE_EXT = \"";
+ protected final String TEXT_5 = "\";" + NL + " " + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IWorkbenchPart myPart;" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFile mySelection;" + NL + " " + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Map myLinkVID2EObjectMap = new HashMap();" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Map myEObject2NodeMap = new HashMap();" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void setActivePart(IAction action, IWorkbenchPart targetPart) {" + NL + "\t\tmyPart = targetPart;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate Shell getShell() {" + NL + "\t\treturn myPart.getSite().getShell();" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void selectionChanged(IAction action, ISelection selection) {" + NL + "\t\tmySelection = null;" + NL + "\t\taction.setEnabled(false);" + NL + "\t\tif (selection instanceof IStructuredSelection == false || selection.isEmpty()) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tmySelection = (IFile) ((IStructuredSelection) selection).getFirstElement();" + NL + "\t\taction.setEnabled(true);" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */\t" + NL + "\tpublic String isValid(String newText) {" + NL + "\t\tIStatus status = ResourcesPlugin.getWorkspace().validateName(newText, IResource.FILE);" + NL + "\t\tif (!status.isOK()) {" + NL + "\t\t\treturn status.getMessage();" + NL + "\t\t}" + NL + "\t\tif (mySelection.getParent().getFile(new Path(newText).addFileExtension(FILE_EXT)).exists()) {" + NL + "\t\t\treturn \"File already exists, choose another name\";" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tpublic void run(IAction action) {" + NL + "\t\tfinal InputDialog outputFileNameDialog = new InputDialog(getShell(), \"Diagram file name\", \"Please provide diagram file name\", mySelection.getProjectRelativePath().removeFileExtension().addFileExtension(FILE_EXT).lastSegment(), this);" + NL + "\t\tif (outputFileNameDialog.open() != InputDialog.OK) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tfinal EObject diagramModelObject = load();" + NL + "\t\tif (diagramModelObject == null) {" + NL + "\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to load user model\");" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tOperationUtil.runAsUnchecked(new MRunnable() {" + NL + "\t\t\tpublic Object run() {" + NL + "\t\t\t\tEObject diagram = create(diagramModelObject);" + NL + "\t\t\t\tif (diagram == null) {" + NL + "\t\t\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to create diagram object\");" + NL + "\t\t\t\t\treturn null;" + NL + "\t\t\t\t}" + NL + "\t\t\t\tIFile destFile = mySelection.getParent().getFile(new Path(outputFileNameDialog.getValue()));" + NL + "\t\t\t\tsave(destFile.getLocation().toOSString(), diagram);" + NL + "\t\t\t\ttry {" + NL + "\t\t\t\t\tIDE.openEditor(myPart.getSite().getPage(), destFile);" + NL + "\t\t\t\t} catch (PartInitException ex) {" + NL + "\t\t\t\t\tex.printStackTrace();" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn null;" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate EObject load() {";
+ protected final String TEXT_6 = NL + "\t\t";
+ protected final String TEXT_7 = " resourceSet = new ";
+ protected final String TEXT_8 = "();" + NL + "\t\tResource resource = resourceSet.getResource(";
+ protected final String TEXT_9 = ".createPlatformResourceURI(mySelection.getFullPath().toString()), true);" + NL + "\t\ttry {" + NL + "\t\t\tresource.load(Collections.EMPTY_MAP);" + NL + "\t\t\treturn (EObject) resource.getContents().get(0);" + NL + "\t\t} catch (IOException ex) {" + NL + "\t\t\tex.printStackTrace();" + NL + "\t\t}" + NL + "\t\treturn null;";
+ protected final String TEXT_10 = NL + "\t\tResource modelResource = ResourceUtil.load(mySelection.getLocation().toOSString());" + NL + "\t\treturn (EObject) modelResource.getContents().get(0);";
+ protected final String TEXT_11 = NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void save(String filePath, EObject canvas) {" + NL + "\t\tResource resource = ResourceUtil.create(filePath, null);";
+ protected final String TEXT_12 = NL + "\t\tresource.getContents().add(((Diagram) canvas).getElement());";
+ protected final String TEXT_13 = NL + "\t\tresource.getContents().add(canvas);" + NL + "\t\ttry {" + NL + "\t\t\tresource.save(Collections.EMPTY_MAP);" + NL + "\t\t} catch (IOException ex) {" + NL + "\t\t\tex.printStackTrace();" + NL + "\t\t}" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate EObject create(EObject diagramModel) {" + NL + "\t\tint diagramVID = ";
+ protected final String TEXT_14 = ".INSTANCE.getDiagramVisualID(diagramModel);" + NL + "\t\tif (diagramVID != ";
+ protected final String TEXT_15 = ") {" + NL + "\t\t\treturn null;" + NL + "\t\t}";
+ protected final String TEXT_16 = NL + "\t\tmyLinkVID2EObjectMap.put(new Integer(";
+ protected final String TEXT_17 = "), new ";
+ protected final String TEXT_18 = "());";
+ protected final String TEXT_19 = NL + "\t\tDiagram diagram = DiagramUtil.createDiagram(diagramModel, \"";
+ protected final String TEXT_20 = "\", ";
+ protected final String TEXT_21 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\tcreateDiagramChildren(diagram, diagramModel);" + NL + "\t\tcreateLinks();" + NL + "\t\tmyLinkVID2EObjectMap.clear();" + NL + "\t\tmyEObject2NodeMap.clear();\t\t" + NL + "\t return diagram;" + NL + "\t}" + NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createDiagramChildren(Diagram diagram, EObject diagramModel) {";
+ protected final String TEXT_22 = NL + "\t\tObject featureValue;";
+ protected final String TEXT_23 = "\t" + NL + "\t\tfeatureValue = ((";
+ protected final String TEXT_24 = ") diagramModel).";
+ protected final String TEXT_25 = "();";
+ protected final String TEXT_26 = "\t\t" + NL + "\t\tfor (";
+ protected final String TEXT_27 = " values = ((";
+ protected final String TEXT_28 = ") featureValue).iterator(); values.hasNext();) {" + NL + "\t\t\tEObject nextValue = ((EObject) values.next());";
+ protected final String TEXT_29 = NL + "\t\tEObject nextValue = (EObject) featureValue;";
+ protected final String TEXT_30 = NL + "\t\tint nodeVID = ";
+ protected final String TEXT_31 = ".INSTANCE.getNodeVisualID(diagram, nextValue, \"\");" + NL + "\t\tif (";
+ protected final String TEXT_32 = " == nodeVID) {" + NL + "\t\t\t";
+ protected final String TEXT_33 = " nextNode = DiagramUtil.createNode(diagram, nextValue, null, ";
+ protected final String TEXT_34 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\tcreate";
+ protected final String TEXT_35 = "Children(nextNode, nextValue);" + NL + "\t\t}";
+ protected final String TEXT_36 = NL + "\t\t}";
+ protected final String TEXT_37 = NL + "\t}";
+ protected final String TEXT_38 = "\t" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void create";
+ protected final String TEXT_39 = "Children(";
+ protected final String TEXT_40 = " viewObject, EObject modelObject) {";
+ protected final String TEXT_41 = NL + "\t\tObject featureValue;" + NL + "\t\t";
+ protected final String TEXT_42 = " nextNode;";
+ protected final String TEXT_43 = NL + "\t\t";
+ protected final String TEXT_44 = " nextNode;";
+ protected final String TEXT_45 = NL + "\t\tfeatureValue = ((";
+ protected final String TEXT_46 = ") modelObject).";
+ protected final String TEXT_47 = "();";
+ protected final String TEXT_48 = "\t\t" + NL + "\t\tfor (";
+ protected final String TEXT_49 = " values = ((";
+ protected final String TEXT_50 = ") featureValue).iterator(); values.hasNext();) {" + NL + "\t\t\tEObject nextValue = ((EObject) values.next());";
+ protected final String TEXT_51 = NL + "\t\tEObject nextValue = (EObject) featureValue;";
+ protected final String TEXT_52 = NL + "\t\tint nodeVID = ";
+ protected final String TEXT_53 = ".INSTANCE.getNodeVisualID(viewObject, nextValue, \"\");" + NL + "\t\tif (";
+ protected final String TEXT_54 = " == nodeVID) {" + NL + "\t\t\tnextNode = DiagramUtil.createNode(viewObject, nextValue, null, ";
+ protected final String TEXT_55 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\tcreate";
+ protected final String TEXT_56 = "Children(nextNode, nextValue);" + NL + "\t\t}";
+ protected final String TEXT_57 = NL + "\t\t}";
+ protected final String TEXT_58 = NL + "\t\tnextNode = getCompartment(viewObject, \"";
+ protected final String TEXT_59 = "\");" + NL + "\t\tif (nextNode != null) {" + NL + "\t\t\tcreate";
+ protected final String TEXT_60 = "Children(nextNode, modelObject);" + NL + "\t\t}";
+ protected final String TEXT_61 = NL + "\t\tstoreLinks(modelObject);";
+ protected final String TEXT_62 = NL + "\t}";
+ protected final String TEXT_63 = NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate ";
+ protected final String TEXT_64 = " getCompartment(";
+ protected final String TEXT_65 = " node, String name) {" + NL + "\t\tfor (";
+ protected final String TEXT_66 = " it = node.getChildren().iterator(); it.hasNext();) {" + NL + "\t\t\t";
+ protected final String TEXT_67 = " nextView = (";
+ protected final String TEXT_68 = ") it.next();" + NL + "\t\t\tif (nextView instanceof ";
+ protected final String TEXT_69 = " && name.equals(nextView.getType())) {" + NL + "\t\t\t\treturn (";
+ protected final String TEXT_70 = ") nextView;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}";
+ protected final String TEXT_71 = NL + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeLinks(EObject container) {" + NL + "\t\tEClass containerMetaclass = container.eClass();" + NL + "\t\tstoreFeatureModelFacetLinks(container, containerMetaclass);" + NL + "\t\tstoreTypeModelFacetLinks(container, containerMetaclass);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void storeTypeModelFacetLinks(EObject container, EClass containerMetaclass) {\t";
+ protected final String TEXT_72 = "\t\t" + NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
+ protected final String TEXT_73 = ".eINSTANCE.get";
+ protected final String TEXT_74 = "())) {" + NL + "\t\t\tObject featureValue = ((";
+ protected final String TEXT_75 = ") container).";
+ protected final String TEXT_76 = "();";
+ protected final String TEXT_77 = "\t\t" + NL + "\t\t\tfor (";
+ protected final String TEXT_78 = " values = ((";
+ protected final String TEXT_79 = ") featureValue).iterator(); values.hasNext();) {" + NL + "\t\t\t\tEObject nextValue = ((EObject) values.next());";
+ protected final String TEXT_80 = NL + "\t\t\tEObject nextValue = (EObject) featureValue;";
+ protected final String TEXT_81 = NL + "\t\t\tint linkVID = ";
+ protected final String TEXT_82 = ".INSTANCE.getLinkWithClassVisualID(nextValue);" + NL + "\t\t\tif (";
+ protected final String TEXT_83 = " == linkVID) {" + NL + "\t\t\t\t((";
+ protected final String TEXT_84 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_85 = "))).add(nextValue);" + NL + "\t\t\t}";
+ protected final String TEXT_86 = NL + "\t\t\t}";
+ protected final String TEXT_87 = NL + "\t\t}";
+ protected final String TEXT_88 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass) {";
+ protected final String TEXT_89 = NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
+ protected final String TEXT_90 = ".eINSTANCE.get";
+ protected final String TEXT_91 = "())) {" + NL + "\t\t\t((";
+ protected final String TEXT_92 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_93 = "))).add(container);" + NL + "\t\t}";
+ protected final String TEXT_94 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createLinks() {";
+ protected final String TEXT_95 = NL + "\t\t";
+ protected final String TEXT_96 = " linkElements;";
+ protected final String TEXT_97 = NL + "\t\tlinkElements = (";
+ protected final String TEXT_98 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_99 = "));" + NL + "\t\tfor (";
+ protected final String TEXT_100 = " it = linkElements.iterator(); it.hasNext();) {" + NL + "\t\t\tEObject linkElement = (EObject) it.next();";
+ protected final String TEXT_101 = NL + "\t\t\tEObject src = linkElement.eContainer();";
+ protected final String TEXT_102 = NL + "\t\t\tEObject src = linkElement;";
+ protected final String TEXT_103 = NL + "\t\t\t";
+ protected final String TEXT_104 = " srcNode = (";
+ protected final String TEXT_105 = ") myEObject2NodeMap.get(src);" + NL + "\t\t\tif (srcNode == null) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\t";
+ protected final String TEXT_106 = " structuralFeature = ";
+ protected final String TEXT_107 = ".eINSTANCE.get";
+ protected final String TEXT_108 = "();" + NL + "\t\t\tObject structuralFeatureResult = linkElement.eGet(structuralFeature);";
+ protected final String TEXT_109 = NL + "\t\t\tif (structuralFeatureResult instanceof EObject == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tEObject dst = (EObject) structuralFeatureResult;";
+ protected final String TEXT_110 = NL + "\t\t\tif (structuralFeatureResult instanceof ";
+ protected final String TEXT_111 = " == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tfor (";
+ protected final String TEXT_112 = " destinations = ((";
+ protected final String TEXT_113 = ") structuralFeatureResult).iterator(); destinations.hasNext();) {" + NL + "\t\t\t\tEObject dst = (EObject) destinations.next();";
+ protected final String TEXT_114 = NL + "\t\t\t";
+ protected final String TEXT_115 = " dstNode = (";
+ protected final String TEXT_116 = ") myEObject2NodeMap.get(dst);" + NL + "\t\t\tif (dstNode != null) {";
+ protected final String TEXT_117 = NL + "\t\t\t\tDiagramUtil.createEdge(srcNode, dstNode, linkElement, null, ";
+ protected final String TEXT_118 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t}";
+ protected final String TEXT_119 = NL + "\t\t\t\t\t";
+ protected final String TEXT_120 = " edge = (";
+ protected final String TEXT_121 = ") ";
+ protected final String TEXT_122 = ".getInstance().createEdge(new ";
+ protected final String TEXT_123 = "() {" + NL + "\t\t\t\t\t\tpublic Object getAdapter(Class adapter) {" + NL + "\t\t\t\t\t\t\tif (";
+ protected final String TEXT_124 = ".class.equals(adapter)) {" + NL + "\t\t\t\t\t\t\t\treturn ";
+ protected final String TEXT_125 = ".";
+ protected final String TEXT_126 = ";" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\treturn null;" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}, srcNode.getDiagram(), \"\", ";
+ protected final String TEXT_127 = ".APPEND, ";
+ protected final String TEXT_128 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\t\tif (edge != null) {" + NL + "\t\t\t\t\t\tedge.setSource(srcNode);" + NL + "\t\t\t\t\t\tedge.setTarget(dstNode);" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t}";
+ protected final String TEXT_129 = NL + "\t\t}";
+ protected final String TEXT_130 = NL + "\t}" + NL + "\t" + NL + "}";
+ protected final String TEXT_131 = NL;
public String generate(Object argument)
{
@@ -95,35 +157,71 @@ public class InitDiagramFileActionGenerator
GenDiagram genDiagram = (GenDiagram) argument;
List genNodes = genDiagram.getNodes();
List genLinks = genDiagram.getLinks();
+Collection allContainers = AccessUtil.getAllContainers(genDiagram);
+
+boolean generateGetCompartment = false;
stringBuffer.append(TEXT_1);
stringBuffer.append(genDiagram.getEditorPackageName());
stringBuffer.append(TEXT_2);
- ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+importManager.addImport("java.io.IOException");
+importManager.addImport("java.util.Collections");
+importManager.addImport("java.util.HashMap");
+importManager.addImport("java.util.Map");
+importManager.addImport("org.eclipse.core.resources.IFile");
+importManager.addImport("org.eclipse.core.resources.IResource");
+importManager.addImport("org.eclipse.core.resources.ResourcesPlugin");
+importManager.addImport("org.eclipse.core.runtime.IStatus");
+importManager.addImport("org.eclipse.core.runtime.Path");
+importManager.addImport("org.eclipse.emf.ecore.EClass");
+importManager.addImport("org.eclipse.emf.ecore.EObject");
+importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
+importManager.addImport("org.eclipse.gmf.runtime.diagram.ui.DiagramUtil");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.edit.MRunnable");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.util.OperationUtil");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.util.ResourceUtil");
+importManager.addImport("org.eclipse.gmf.runtime.notation.Diagram");
+importManager.addImport("org.eclipse.jface.action.IAction");
+importManager.addImport("org.eclipse.jface.dialogs.IInputValidator");
+importManager.addImport("org.eclipse.jface.dialogs.InputDialog");
+importManager.addImport("org.eclipse.jface.dialogs.MessageDialog");
+importManager.addImport("org.eclipse.jface.viewers.ISelection");
+importManager.addImport("org.eclipse.jface.viewers.IStructuredSelection");
+importManager.addImport("org.eclipse.swt.widgets.Shell");
+importManager.addImport("org.eclipse.ui.IObjectActionDelegate");
+importManager.addImport("org.eclipse.ui.IWorkbenchPart");
+importManager.addImport("org.eclipse.ui.PartInitException");
+importManager.addImport("org.eclipse.ui.ide.IDE");
+
+importManager.markImportLocation(stringBuffer);
+
stringBuffer.append(TEXT_3);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_4);
stringBuffer.append(genDiagram.getInitDiagramFileActionClassName());
- stringBuffer.append(TEXT_5);
+ stringBuffer.append(TEXT_4);
stringBuffer.append(genDiagram.getDiagramFileExtension());
- stringBuffer.append(TEXT_6);
+ stringBuffer.append(TEXT_5);
if (genDiagram.isSameFileForDiagramAndModel()) {
- stringBuffer.append(TEXT_7);
+ stringBuffer.append(TEXT_6);
stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet"));
- stringBuffer.append(TEXT_8);
+ stringBuffer.append(TEXT_7);
stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl"));
- stringBuffer.append(TEXT_9);
+ stringBuffer.append(TEXT_8);
stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.util.URI"));
- stringBuffer.append(TEXT_10);
+ stringBuffer.append(TEXT_9);
} else {
- stringBuffer.append(TEXT_11);
+ stringBuffer.append(TEXT_10);
}
- stringBuffer.append(TEXT_12);
+ stringBuffer.append(TEXT_11);
if (genDiagram.isSameFileForDiagramAndModel()) {
- stringBuffer.append(TEXT_13);
+ stringBuffer.append(TEXT_12);
}
- stringBuffer.append(TEXT_14);
+ stringBuffer.append(TEXT_13);
stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(genDiagram.getVisualID());
stringBuffer.append(TEXT_15);
for (Iterator it = genLinks.iterator(); it.hasNext();) {
@@ -132,168 +230,360 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) {
stringBuffer.append(TEXT_16);
stringBuffer.append(nextLink.getVisualID());
stringBuffer.append(TEXT_17);
+ stringBuffer.append(importManager.getImportedName("java.util.LinkedList"));
+ stringBuffer.append(TEXT_18);
}
- stringBuffer.append(TEXT_18);
- stringBuffer.append(genDiagram.getEMFGenModel().getModelName());
stringBuffer.append(TEXT_19);
- stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
+ stringBuffer.append(genDiagram.getEMFGenModel().getModelName());
stringBuffer.append(TEXT_20);
- stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
- stringBuffer.append(TEXT_21);
stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
+ stringBuffer.append(TEXT_21);
+
+if (genNodes.size() > 0) {
+
stringBuffer.append(TEXT_22);
-for (Iterator it = genNodes.iterator(); it.hasNext();) {
- GenNode nextGenNode = (GenNode) it.next();
+}
+
+for (Iterator diagramNodes = genNodes.iterator(); diagramNodes.hasNext();) {
+ GenNode nextNode = (GenNode) diagramNodes.next();
+ TypeModelFacet typeModelFacet = nextNode.getModelFacet();
+ GenFeature childMetaFeature = typeModelFacet.getChildMetaFeature();
stringBuffer.append(TEXT_23);
- stringBuffer.append(nextGenNode.getVisualID());
+ stringBuffer.append(importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName()));
stringBuffer.append(TEXT_24);
- stringBuffer.append(nextGenNode.getUniqueIdentifier());
+ stringBuffer.append(childMetaFeature.getGetAccessor());
stringBuffer.append(TEXT_25);
-}
+ if (childMetaFeature.isListType()) {
stringBuffer.append(TEXT_26);
-
-for (Iterator genNodesIt = genNodes.iterator(); genNodesIt.hasNext();) {
- GenNode nextGenNode = (GenNode) genNodesIt.next();
-
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
stringBuffer.append(TEXT_27);
- stringBuffer.append(nextGenNode.getUniqueIdentifier());
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
stringBuffer.append(TEXT_28);
- stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
- stringBuffer.append(TEXT_29);
- for (Iterator childGenNodesIt = AccessUtil.getAllChildNodes(nextGenNode).iterator(); childGenNodesIt.hasNext();) {
- GenChildNode nextChildGenNode = (GenChildNode) childGenNodesIt.next();
+ } else if (!childMetaFeature.isPrimitiveType()) {
+
+ stringBuffer.append(TEXT_29);
+
+ }
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
stringBuffer.append(TEXT_30);
- stringBuffer.append(nextChildGenNode.getVisualID());
+ stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
stringBuffer.append(TEXT_31);
-
- if (nextChildGenNode.getContainer() instanceof GenCompartment) {
- GenCompartment compartment = (GenCompartment) nextChildGenNode.getContainer();
-
+ stringBuffer.append(nextNode.getVisualID());
stringBuffer.append(TEXT_32);
- stringBuffer.append(compartment.getTitle());
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
stringBuffer.append(TEXT_33);
+ stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
+ stringBuffer.append(TEXT_34);
+ stringBuffer.append(nextNode.getUniqueIdentifier());
+ stringBuffer.append(TEXT_35);
- } else {
+ }
+ if (childMetaFeature.isListType()) {
- stringBuffer.append(TEXT_34);
+ stringBuffer.append(TEXT_36);
- }
+ }
+}
- stringBuffer.append(TEXT_35);
+ stringBuffer.append(TEXT_37);
+
+for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
+ GenChildContainer nextContainer = (GenChildContainer) containers.next();
+
+ stringBuffer.append(TEXT_38);
+ stringBuffer.append(nextContainer.getUniqueIdentifier());
+ stringBuffer.append(TEXT_39);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_40);
+
+ if (nextContainer.getChildNodes().size() > 0) {
+
+ stringBuffer.append(TEXT_41);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_42);
+
+ } else if (nextContainer instanceof GenNode && ((GenNode) nextContainer).getCompartments().size() > 0) {
+
+ stringBuffer.append(TEXT_43);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_44);
}
+
+ for (Iterator children = nextContainer.getChildNodes().iterator(); children.hasNext();) {
+ GenChildNode nextChild = (GenChildNode) children.next();
+ TypeModelFacet typeModelFacet = nextChild.getModelFacet();
+ GenFeature childMetaFeature = typeModelFacet.getChildMetaFeature();
- stringBuffer.append(TEXT_36);
+ stringBuffer.append(TEXT_45);
+ stringBuffer.append(importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName()));
+ stringBuffer.append(TEXT_46);
+ stringBuffer.append(childMetaFeature.getGetAccessor());
+ stringBuffer.append(TEXT_47);
+
+ if (childMetaFeature.isListType()) {
+
+ stringBuffer.append(TEXT_48);
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
+ stringBuffer.append(TEXT_49);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_50);
+
+ } else if (!childMetaFeature.isPrimitiveType()) {
+
+ stringBuffer.append(TEXT_51);
+
+ }
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
+
+ stringBuffer.append(TEXT_52);
+ stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
+ stringBuffer.append(TEXT_53);
+ stringBuffer.append(nextChild.getVisualID());
+ stringBuffer.append(TEXT_54);
stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
- stringBuffer.append(TEXT_37);
+ stringBuffer.append(TEXT_55);
+ stringBuffer.append(nextChild.getUniqueIdentifier());
+ stringBuffer.append(TEXT_56);
+
+ }
+ if (childMetaFeature.isListType()) {
+
+ stringBuffer.append(TEXT_57);
+
+ }
+ }
+
+ if (nextContainer instanceof GenNode) {
+ GenNode nextNode = (GenNode) nextContainer;
+ for (Iterator compartments = nextNode.getCompartments().iterator(); compartments.hasNext();) {
+ GenCompartment nextCompartment = (GenCompartment) compartments.next();
+ generateGetCompartment = true;
+
+ stringBuffer.append(TEXT_58);
+ stringBuffer.append(nextCompartment.getTitle());
+ stringBuffer.append(TEXT_59);
+ stringBuffer.append(nextCompartment.getUniqueIdentifier());
+ stringBuffer.append(TEXT_60);
+
+ }
+
+ stringBuffer.append(TEXT_61);
+
+ }
+
+ stringBuffer.append(TEXT_62);
}
- stringBuffer.append(TEXT_38);
+if (generateGetCompartment) {
+
+ stringBuffer.append(TEXT_63);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_64);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_65);
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
+ stringBuffer.append(TEXT_66);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View"));
+ stringBuffer.append(TEXT_67);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View"));
+ stringBuffer.append(TEXT_68);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_69);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_70);
+
+}
+
+ stringBuffer.append(TEXT_71);
+
+for (Iterator it = genLinks.iterator(); it.hasNext();) {
+ GenLink nextLink = (GenLink) it.next();
+ if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
+ TypeLinkModelFacet typeLinkModelFacet = (TypeLinkModelFacet) nextLink.getModelFacet();
+ GenFeature childMetaFeature = typeLinkModelFacet.getChildMetaFeature();
+
+ stringBuffer.append(TEXT_72);
+ stringBuffer.append(importManager.getImportedName(childMetaFeature.getGenPackage().getQualifiedPackageInterfaceName()));
+ stringBuffer.append(TEXT_73);
+ stringBuffer.append(childMetaFeature.getFeatureAccessorName());
+ stringBuffer.append(TEXT_74);
+ stringBuffer.append(importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName()));
+ stringBuffer.append(TEXT_75);
+ stringBuffer.append(childMetaFeature.getGetAccessor());
+ stringBuffer.append(TEXT_76);
+
+ if (childMetaFeature.isListType()) {
+
+ stringBuffer.append(TEXT_77);
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
+ stringBuffer.append(TEXT_78);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_79);
+
+ } else if (!childMetaFeature.isPrimitiveType()) {
+
+ stringBuffer.append(TEXT_80);
+
+ }
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
+
+ stringBuffer.append(TEXT_81);
stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
- stringBuffer.append(TEXT_39);
+ stringBuffer.append(TEXT_82);
+ stringBuffer.append(nextLink.getVisualID());
+ stringBuffer.append(TEXT_83);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_84);
+ stringBuffer.append(nextLink.getVisualID());
+ stringBuffer.append(TEXT_85);
+
+ }
+ if (childMetaFeature.isListType()) {
+
+ stringBuffer.append(TEXT_86);
+
+ }
+
+ stringBuffer.append(TEXT_87);
+
+ }
+}
+
+ stringBuffer.append(TEXT_88);
for (Iterator it = genLinks.iterator(); it.hasNext();) {
GenLink nextLink = (GenLink) it.next();
if (nextLink.getModelFacet() instanceof FeatureModelFacet) {
GenFeature genFeature = ((FeatureModelFacet) nextLink.getModelFacet()).getMetaFeature();
- stringBuffer.append(TEXT_40);
+ stringBuffer.append(TEXT_89);
stringBuffer.append(importManager.getImportedName(genFeature.getGenPackage().getQualifiedPackageInterfaceName()));
- stringBuffer.append(TEXT_41);
+ stringBuffer.append(TEXT_90);
stringBuffer.append(genFeature.getFeatureAccessorName());
- stringBuffer.append(TEXT_42);
+ stringBuffer.append(TEXT_91);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_92);
stringBuffer.append(nextLink.getVisualID());
- stringBuffer.append(TEXT_43);
+ stringBuffer.append(TEXT_93);
}
}
- stringBuffer.append(TEXT_44);
+ stringBuffer.append(TEXT_94);
+if (genLinks.size() > 0) {
+
+ stringBuffer.append(TEXT_95);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_96);
+
+}
+
for (Iterator it = genLinks.iterator(); it.hasNext();) {
GenLink nextLink = (GenLink) it.next();
GenFeature domainLinkTargetGenFeature;
- stringBuffer.append(TEXT_45);
+ stringBuffer.append(TEXT_97);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_98);
stringBuffer.append(nextLink.getVisualID());
- stringBuffer.append(TEXT_46);
+ stringBuffer.append(TEXT_99);
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
+ stringBuffer.append(TEXT_100);
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
domainLinkTargetGenFeature = ((TypeLinkModelFacet) nextLink.getModelFacet()).getTargetMetaFeature();
- stringBuffer.append(TEXT_47);
+ stringBuffer.append(TEXT_101);
} else {
domainLinkTargetGenFeature = ((FeatureModelFacet) nextLink.getModelFacet()).getMetaFeature();
- stringBuffer.append(TEXT_48);
+ stringBuffer.append(TEXT_102);
}
- stringBuffer.append(TEXT_49);
+ stringBuffer.append(TEXT_103);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_104);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_105);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EStructuralFeature"));
+ stringBuffer.append(TEXT_106);
stringBuffer.append(importManager.getImportedName(domainLinkTargetGenFeature.getGenPackage().getQualifiedPackageInterfaceName()));
- stringBuffer.append(TEXT_50);
+ stringBuffer.append(TEXT_107);
stringBuffer.append(domainLinkTargetGenFeature.getFeatureAccessorName());
- stringBuffer.append(TEXT_51);
+ stringBuffer.append(TEXT_108);
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
- stringBuffer.append(TEXT_52);
+ stringBuffer.append(TEXT_109);
} else {
- stringBuffer.append(TEXT_53);
+ stringBuffer.append(TEXT_110);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_111);
+ stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
+ stringBuffer.append(TEXT_112);
+ stringBuffer.append(importManager.getImportedName("java.util.Collection"));
+ stringBuffer.append(TEXT_113);
}
- stringBuffer.append(TEXT_54);
+ stringBuffer.append(TEXT_114);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_115);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node"));
+ stringBuffer.append(TEXT_116);
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
- stringBuffer.append(TEXT_55);
+ stringBuffer.append(TEXT_117);
stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
- stringBuffer.append(TEXT_56);
+ stringBuffer.append(TEXT_118);
} else {
- stringBuffer.append(TEXT_57);
+ stringBuffer.append(TEXT_119);
stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Edge"));
- stringBuffer.append(TEXT_58);
+ stringBuffer.append(TEXT_120);
stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Edge"));
- stringBuffer.append(TEXT_59);
+ stringBuffer.append(TEXT_121);
stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.internal.services.view.ViewService"));
- stringBuffer.append(TEXT_60);
+ stringBuffer.append(TEXT_122);
stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IAdaptable"));
- stringBuffer.append(TEXT_61);
+ stringBuffer.append(TEXT_123);
stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.emf.type.core.IElementType"));
- stringBuffer.append(TEXT_62);
+ stringBuffer.append(TEXT_124);
stringBuffer.append(importManager.getImportedName(genDiagram.getElementTypesQualifiedClassName()));
- stringBuffer.append(TEXT_63);
+ stringBuffer.append(TEXT_125);
stringBuffer.append(nextLink.getUniqueIdentifier());
- stringBuffer.append(TEXT_64);
+ stringBuffer.append(TEXT_126);
stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
- stringBuffer.append(TEXT_65);
+ stringBuffer.append(TEXT_127);
stringBuffer.append(importManager.getImportedName(genDiagram.getPluginQualifiedClassName()));
- stringBuffer.append(TEXT_66);
+ stringBuffer.append(TEXT_128);
}
- stringBuffer.append(TEXT_67);
+ stringBuffer.append(TEXT_129);
}
- stringBuffer.append(TEXT_68);
+ stringBuffer.append(TEXT_130);
importManager.emitSortedImports();
- stringBuffer.append(TEXT_69);
+ stringBuffer.append(TEXT_131);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java
index bc9fb7de6..ac4fc926b 100644
--- a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java
+++ b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java
@@ -18,117 +18,102 @@ public class VisualIDRegistryGenerator
protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "package ";
- protected final String TEXT_2 = ";";
- protected final String TEXT_3 = NL + "import org.eclipse.emf.ecore.EClass;" + NL + "import org.eclipse.emf.ecore.EObject;" + NL + "" + NL + "import org.eclipse.gmf.runtime.notation.View;";
- protected final String TEXT_4 = NL + "\t" + NL + "/**" + NL + " * This registry is used to determine which type of visual object should be" + NL + " * created for the corresponding Diagram, Node, ChildNode or Link represented " + NL + " * by a domain model object." + NL + " *" + NL + " * @generated" + NL + " */" + NL + "public class ";
- protected final String TEXT_5 = " {" + NL + "" + NL + "\tpublic static final ";
- protected final String TEXT_6 = " INSTANCE = new ";
- protected final String TEXT_7 = "();" + NL + "\t\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getDiagramVisualID(EObject domainElement) {" + NL + "\t\tif (domainElement == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getDiagramVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getDiagramVisualID(EObject domainElement, EClass domainElementMetaclass) {";
- protected final String TEXT_8 = NL + "\t\tif (";
- protected final String TEXT_9 = ".eINSTANCE.get";
- protected final String TEXT_10 = "().equals(domainElementMetaclass) && (domainElement != null ? isDiagram";
- protected final String TEXT_11 = "((";
- protected final String TEXT_12 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
- protected final String TEXT_13 = ";" + NL + "\t\t}" + NL + "\t\treturn getUnrecognizedDiagramID(domainElement);";
- protected final String TEXT_14 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedDiagramID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "//================================================================================================================";
- protected final String TEXT_15 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getNodeVisualID(View containerView, EObject domainElement, EClass domainElementMetaclass, String semanticHint) {" + NL + "\t\tint containerVisualID = getVisualID(containerView);" + NL + "\t\tswitch (containerVisualID) {" + NL + "\t\tcase ";
- protected final String TEXT_16 = ":";
- protected final String TEXT_17 = NL + "\t\t\tif (";
- protected final String TEXT_18 = ".eINSTANCE.get";
- protected final String TEXT_19 = "().equals(domainElementMetaclass) && (domainElement != null ? isNode";
- protected final String TEXT_20 = "((";
- protected final String TEXT_21 = ") domainElement) : true)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_22 = ";" + NL + "\t\t\t} ";
- protected final String TEXT_23 = NL + "\t\t\treturn getUnrecognizedDiagramChildID(domainElement);";
- protected final String TEXT_24 = NL + "\t\tcase ";
- protected final String TEXT_25 = ":";
- protected final String TEXT_26 = NL + "\t\t\tif (";
- protected final String TEXT_27 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_28 = ";" + NL + "\t\t\t} ";
- protected final String TEXT_29 = NL + "\t\t\tif (";
- protected final String TEXT_30 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_31 = ";" + NL + "\t\t\t} ";
- protected final String TEXT_32 = NL + "\t\t\tif (!\"\".equals(semanticHint)) {" + NL + "\t\t\t\treturn getUnrecognized";
- protected final String TEXT_33 = "ChildNodeID(semanticHint);" + NL + "\t\t\t} ";
- protected final String TEXT_34 = "\t\t" + NL + "\t\t\tif (";
- protected final String TEXT_35 = ".eINSTANCE.get";
- protected final String TEXT_36 = "().equals(domainElementMetaclass) && (domainElement != null ? isChildNode";
- protected final String TEXT_37 = "((";
- protected final String TEXT_38 = ") domainElement) : true)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_39 = ";" + NL + "\t\t\t} ";
- protected final String TEXT_40 = NL + "\t\t\treturn getUnrecognized";
- protected final String TEXT_41 = "ChildNodeID(domainElement);";
- protected final String TEXT_42 = NL + "\t\tcase ";
- protected final String TEXT_43 = ":";
- protected final String TEXT_44 = NL + "\t\t\tif (";
- protected final String TEXT_45 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_46 = ";" + NL + "\t\t\t}";
- protected final String TEXT_47 = NL + "\t\t\treturn getUnrecognized";
- protected final String TEXT_48 = "LinkLabelID(semanticHint);";
- protected final String TEXT_49 = NL + "\t\tcase ";
- protected final String TEXT_50 = ":" + NL + "\t\t\tif (";
- protected final String TEXT_51 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
- protected final String TEXT_52 = ";" + NL + "\t\t\t}" + NL + "\t\t\treturn getUnrecognized";
- protected final String TEXT_53 = "LinkLabelTextID(semanticHint);";
- protected final String TEXT_54 = NL + "\t\t}" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t";
- protected final String TEXT_55 = NL;
- protected final String TEXT_56 = "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getVisualID(View containerView) {" + NL + "\t\t";
- protected final String TEXT_57 = " annotation = containerView.getEAnnotation(\"VisualID\");" + NL + "\t\tif (annotation == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\tString visualID = (String) annotation.getDetails().get(\"value\");" + NL + "\t\tif (visualID == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\ttry {" + NL + "\t\t\treturn Integer.parseInt(visualID);" + NL + "\t\t} catch (NumberFormatException e) {" + NL + "\t\t\te.printStackTrace();\t\t" + NL + "\t\t}" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognizedDiagramChildID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t";
- protected final String TEXT_58 = NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
- protected final String TEXT_59 = "ChildNodeID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
- protected final String TEXT_60 = "ChildNodeID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t";
- protected final String TEXT_61 = NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
- protected final String TEXT_62 = "LinkLabelID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
- protected final String TEXT_63 = "LinkLabelTextID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}";
- protected final String TEXT_64 = NL + "\t" + NL + "//================================================================================================================" + NL + "" + NL + "\t/**" + NL + "\t * @deprecated" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getNodeVisualID(EObject domainElement) {" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getNodeVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "" + NL + "" + NL + "\t/**" + NL + "\t * @deprecated" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getNodeVisualID(EObject domainElement, EClass domainElementMetaclass) {";
- protected final String TEXT_65 = NL + "\t\tif (";
- protected final String TEXT_66 = ".eINSTANCE.get";
- protected final String TEXT_67 = "().equals(domainElementMetaclass) && (domainElement != null ? isNode";
- protected final String TEXT_68 = "((";
- protected final String TEXT_69 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
- protected final String TEXT_70 = ";" + NL + "\t\t} else";
- protected final String TEXT_71 = NL + "\t\t{" + NL + "\t\t\treturn getUnrecognizedNodeID(domainElement);" + NL + "\t\t}" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedNodeID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getChildNodeVisualID(EObject domainElement) {" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getChildNodeVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getChildNodeVisualID(EObject domainElement, EClass domainElementMetaclass) {";
- protected final String TEXT_72 = NL + "\t\tif (";
- protected final String TEXT_73 = ".eINSTANCE.get";
- protected final String TEXT_74 = "().equals(domainElementMetaclass) && (domainElement != null ? isChildNode";
- protected final String TEXT_75 = "((";
- protected final String TEXT_76 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
- protected final String TEXT_77 = ";" + NL + "\t\t} else ";
- protected final String TEXT_78 = NL + "\t\t{" + NL + "\t\t\treturn getUnrecognizedChildNodeID(domainElement);" + NL + "\t\t}" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedChildNodeID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getLinkWithClassVisualID(EObject domainElement) {" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getLinkWithClassVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getLinkWithClassVisualID(EObject domainElement, EClass domainElementMetaclass) {";
- protected final String TEXT_79 = NL + "\t\tif (";
- protected final String TEXT_80 = ".eINSTANCE.get";
- protected final String TEXT_81 = "().equals(domainElementMetaclass) && (domainElement != null ? isLinkWithClass";
- protected final String TEXT_82 = "((";
- protected final String TEXT_83 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
- protected final String TEXT_84 = ";" + NL + "\t\t} else ";
- protected final String TEXT_85 = NL + "\t\t{" + NL + "\t\t\treturn getUnrecognizedLinkWithClassID(domainElement);" + NL + "\t\t}" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedLinkWithClassID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isDiagram";
- protected final String TEXT_86 = "(";
- protected final String TEXT_87 = " element) {" + NL + "\t\treturn true;" + NL + "\t}" + NL + "\t\t";
- protected final String TEXT_88 = NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isNode";
- protected final String TEXT_89 = "(";
- protected final String TEXT_90 = " element) {" + NL + "\t\treturn ElementSelectors.";
- protected final String TEXT_91 = ".matches(element);" + NL + "\t}" + NL;
- protected final String TEXT_92 = NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isChildNode";
- protected final String TEXT_93 = "(";
- protected final String TEXT_94 = " element) {" + NL + "\t\treturn ElementSelectors.";
- protected final String TEXT_95 = ".matches(element);" + NL + "\t}" + NL;
- protected final String TEXT_96 = NL + "\t";
- protected final String TEXT_97 = NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isLinkWithClass";
- protected final String TEXT_98 = "(";
- protected final String TEXT_99 = " element) {" + NL + "\t\treturn ElementSelectors.";
- protected final String TEXT_100 = ".matches(element);" + NL + "\t}";
- protected final String TEXT_101 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static class ElementSelectors {\t";
- protected final String TEXT_102 = NL + NL + "\t\t/**" + NL + "\t\t * Element matching condition for ";
- protected final String TEXT_103 = "." + NL + "\t\t * <pre>language: ";
- protected final String TEXT_104 = "</pre>\t" + NL + "\t\t * <pre>body : ";
- protected final String TEXT_105 = "</pre>" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate static final Matcher ";
- protected final String TEXT_106 = " = new Matcher(\"";
- protected final String TEXT_107 = "\");";
- protected final String TEXT_108 = NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate ElementSelectors() {" + NL + "\t\t}";
- protected final String TEXT_109 = "\t\t\t" + NL + "\t\t/**" + NL + "\t\t* @generated\t" + NL + "\t\t*/" + NL + "\t\tstatic class Matcher {" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t" + NL + "\t\t\tprivate EClass evalContext;" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tprivate ";
- protected final String TEXT_110 = " condition;" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tprivate String body;\t\t" + NL + "\t\t\t\t\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t" + NL + "\t\t\tMatcher(String expressionBody) {\t\t\t" + NL + "\t\t\t\tbody = expressionBody;" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tboolean matches(EObject object) {\t\t" + NL + "\t\t\t\ttry {" + NL + "\t\t\t\t\tBoolean result = (object != null) ? evaluate(object) : Boolean.FALSE;" + NL + "\t\t\t\t\treturn result.booleanValue();" + NL + "\t\t\t\t} catch(IllegalArgumentException e) {" + NL + "\t\t\t\t\t// TODO - add log entry" + NL + "\t\t\t\t\te.printStackTrace();" + NL + "\t\t\t\t\treturn false;" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t" + NL + "\t\t\tprivate Boolean evaluate(EObject context) {" + NL + "\t\t\t\tthis.evalContext = context.eClass();" + NL + "\t\t\t\tif(condition == null) {\t\t\t\t\t" + NL + "\t\t\t\t\tcondition = new OclConstraintCondition(body, evalContext);" + NL + "\t\t\t\t}" + NL + "\t\t\t\tif(condition != null) {" + NL + "\t\t\t\t\treturn booleanCast(condition.evaluate(context));" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn Boolean.FALSE;" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t" + NL + "\t\t\tprivate static Boolean booleanCast(Object value) {" + NL + "\t\t\t\tif(value == null) {" + NL + "\t\t\t\t\treturn null;" + NL + "\t\t\t\t} else if(value instanceof Boolean) {" + NL + "\t\t\t\t\t return (Boolean)value;\t" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn Boolean.FALSE;" + NL + "\t\t\t}" + NL + "\t\t} // end of Matcher";
- protected final String TEXT_111 = "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tstatic class AcceptAllMatcher {" + NL + "\t\t\t/**" + NL + "\t\t\t * @generated" + NL + "\t\t\t */\t\t" + NL + "\t\t\tstatic final AcceptAllMatcher INSTANCE = new AcceptAllMatcher();" + NL + "\t\t\t/**" + NL + "\t\t\t * @generated" + NL + "\t\t\t */\t\t\t\t\t" + NL + "\t\t\tboolean matches(Object element) {" + NL + "\t\t\t\treturn true;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */\t\t" + NL + "\t\tstatic AcceptAllMatcher acceptAllMatcher() {" + NL + "\t\t\treturn AcceptAllMatcher.INSTANCE;" + NL + "\t\t}" + NL + "\t} // end of ElementSelectors" + NL + "}" + NL + "\t";
- protected final String TEXT_112 = NL;
+ protected final String TEXT_2 = ";" + NL;
+ protected final String TEXT_3 = NL + "\t" + NL + "/**" + NL + " * This registry is used to determine which type of visual object should be" + NL + " * created for the corresponding Diagram, Node, ChildNode or Link represented " + NL + " * by a domain model object." + NL + " *" + NL + " * @generated" + NL + " */" + NL + "public class ";
+ protected final String TEXT_4 = " {" + NL + "" + NL + "\tpublic static final ";
+ protected final String TEXT_5 = " INSTANCE = new ";
+ protected final String TEXT_6 = "();" + NL + "\t\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getDiagramVisualID(EObject domainElement) {" + NL + "\t\tif (domainElement == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getDiagramVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getDiagramVisualID(EObject domainElement, EClass domainElementMetaclass) {";
+ protected final String TEXT_7 = NL + "\t\tif (";
+ protected final String TEXT_8 = ".eINSTANCE.get";
+ protected final String TEXT_9 = "().equals(domainElementMetaclass) && (domainElement != null ? isDiagram";
+ protected final String TEXT_10 = "((";
+ protected final String TEXT_11 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
+ protected final String TEXT_12 = ";" + NL + "\t\t}" + NL + "\t\treturn getUnrecognizedDiagramID(domainElement);";
+ protected final String TEXT_13 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getNodeVisualID(View containerView, EObject domainElement, String semanticHint) {" + NL + "\t\tif (domainElement == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getNodeVisualID(containerView, domainElement, domainElementMetaclass, semanticHint);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getNodeVisualID(View containerView, EObject domainElement, EClass domainElementMetaclass, String semanticHint) {" + NL + "\t\tint containerVisualID = getVisualID(containerView);" + NL + "\t\tswitch (containerVisualID) {" + NL + "\t\tcase ";
+ protected final String TEXT_14 = ":";
+ protected final String TEXT_15 = NL + "\t\t\tif (";
+ protected final String TEXT_16 = ".eINSTANCE.get";
+ protected final String TEXT_17 = "().equals(domainElementMetaclass) && (domainElement != null ? isNode";
+ protected final String TEXT_18 = "((";
+ protected final String TEXT_19 = ") domainElement) : true)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_20 = ";" + NL + "\t\t\t} ";
+ protected final String TEXT_21 = NL + "\t\t\treturn getUnrecognizedDiagramChildID(domainElement);";
+ protected final String TEXT_22 = NL + "\t\tcase ";
+ protected final String TEXT_23 = ":";
+ protected final String TEXT_24 = NL + "\t\t\tif (";
+ protected final String TEXT_25 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_26 = ";" + NL + "\t\t\t} ";
+ protected final String TEXT_27 = NL + "\t\t\tif (";
+ protected final String TEXT_28 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_29 = ";" + NL + "\t\t\t} ";
+ protected final String TEXT_30 = NL + "\t\t\tif (!\"\".equals(semanticHint)) {" + NL + "\t\t\t\treturn getUnrecognized";
+ protected final String TEXT_31 = "ChildNodeID(semanticHint);" + NL + "\t\t\t} ";
+ protected final String TEXT_32 = "\t\t" + NL + "\t\t\tif (";
+ protected final String TEXT_33 = ".eINSTANCE.get";
+ protected final String TEXT_34 = "().equals(domainElementMetaclass) && (domainElement != null ? isChildNode";
+ protected final String TEXT_35 = "((";
+ protected final String TEXT_36 = ") domainElement) : true)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_37 = ";" + NL + "\t\t\t} ";
+ protected final String TEXT_38 = NL + "\t\t\treturn getUnrecognized";
+ protected final String TEXT_39 = "ChildNodeID(domainElement);";
+ protected final String TEXT_40 = NL + "\t\tcase ";
+ protected final String TEXT_41 = ":";
+ protected final String TEXT_42 = NL + "\t\t\tif (";
+ protected final String TEXT_43 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_44 = ";" + NL + "\t\t\t}";
+ protected final String TEXT_45 = NL + "\t\t\treturn getUnrecognized";
+ protected final String TEXT_46 = "LinkLabelID(semanticHint);";
+ protected final String TEXT_47 = NL + "\t\tcase ";
+ protected final String TEXT_48 = ":" + NL + "\t\t\tif (";
+ protected final String TEXT_49 = ".equals(semanticHint)) {" + NL + "\t\t\t\treturn ";
+ protected final String TEXT_50 = ";" + NL + "\t\t\t}" + NL + "\t\t\treturn getUnrecognized";
+ protected final String TEXT_51 = "LinkLabelTextID(semanticHint);";
+ protected final String TEXT_52 = NL + "\t\t}" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getLinkWithClassVisualID(EObject domainElement) {" + NL + "\t\tEClass domainElementMetaclass = domainElement.eClass();" + NL + "\t\treturn getLinkWithClassVisualID(domainElement, domainElementMetaclass);" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getLinkWithClassVisualID(EObject domainElement, EClass domainElementMetaclass) {";
+ protected final String TEXT_53 = NL + "\t\tif (";
+ protected final String TEXT_54 = ".eINSTANCE.get";
+ protected final String TEXT_55 = "().equals(domainElementMetaclass) && (domainElement != null ? isLinkWithClass";
+ protected final String TEXT_56 = "((";
+ protected final String TEXT_57 = ") domainElement) : true)) {" + NL + "\t\t\treturn ";
+ protected final String TEXT_58 = ";" + NL + "\t\t} else ";
+ protected final String TEXT_59 = NL + "\t\t{" + NL + "\t\t\treturn getUnrecognizedLinkWithClassID(domainElement);" + NL + "\t\t}" + NL + "\t}\t" + NL + "\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional " + NL + "\t * conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isDiagram";
+ protected final String TEXT_60 = "(";
+ protected final String TEXT_61 = " element) {" + NL + "\t\treturn true;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedDiagramID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_62 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional " + NL + "\t * conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isNode";
+ protected final String TEXT_63 = "(";
+ protected final String TEXT_64 = " element) {" + NL + "\t\treturn ElementSelectors.";
+ protected final String TEXT_65 = ".matches(element);" + NL + "\t}";
+ protected final String TEXT_66 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional " + NL + "\t * conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isChildNode";
+ protected final String TEXT_67 = "(";
+ protected final String TEXT_68 = " element) {" + NL + "\t\treturn ElementSelectors.";
+ protected final String TEXT_69 = ".matches(element);" + NL + "\t}" + NL;
+ protected final String TEXT_70 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognizedDiagramChildID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_71 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
+ protected final String TEXT_72 = "ChildNodeID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
+ protected final String TEXT_73 = "ChildNodeID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_74 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
+ protected final String TEXT_75 = "LinkLabelID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_76 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */\t" + NL + "\tprivate int getUnrecognized";
+ protected final String TEXT_77 = "LinkLabelTextID(String semanticHint) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_78 = NL + "\t\t" + NL + "\t/**" + NL + "\t * User can change implementation of this method to handle some specific" + NL + "\t * situations not covered by default logic." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate int getUnrecognizedLinkWithClassID(EObject domainElement) {" + NL + "\t\treturn -1;" + NL + "\t}";
+ protected final String TEXT_79 = NL + NL + "\t/**" + NL + "\t * User can change implementation of this method to check some additional " + NL + "\t * conditions here." + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isLinkWithClass";
+ protected final String TEXT_80 = "(";
+ protected final String TEXT_81 = " element) {" + NL + "\t\treturn ElementSelectors.";
+ protected final String TEXT_82 = ".matches(element);" + NL + "\t}";
+ protected final String TEXT_83 = NL;
+ protected final String TEXT_84 = NL;
+ protected final String TEXT_85 = "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic int getVisualID(View containerView) {" + NL + "\t\t";
+ protected final String TEXT_86 = " annotation = containerView.getEAnnotation(\"VisualID\");" + NL + "\t\tif (annotation == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\tString visualID = (String) annotation.getDetails().get(\"value\");" + NL + "\t\tif (visualID == null) {" + NL + "\t\t\treturn -1;" + NL + "\t\t}" + NL + "\t\ttry {" + NL + "\t\t\treturn Integer.parseInt(visualID);" + NL + "\t\t} catch (NumberFormatException e) {" + NL + "\t\t\te.printStackTrace();\t\t" + NL + "\t\t}" + NL + "\t\treturn -1;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static class ElementSelectors {\t";
+ protected final String TEXT_87 = NL + NL + "\t\t/**" + NL + "\t\t * Element matching condition for ";
+ protected final String TEXT_88 = "." + NL + "\t\t * <pre>language: ";
+ protected final String TEXT_89 = "</pre>\t" + NL + "\t\t * <pre>body : ";
+ protected final String TEXT_90 = "</pre>" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate static final Matcher ";
+ protected final String TEXT_91 = " = new Matcher(\"";
+ protected final String TEXT_92 = "\");";
+ protected final String TEXT_93 = NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate ElementSelectors() {" + NL + "\t\t}";
+ protected final String TEXT_94 = "\t\t\t" + NL + "\t\t/**" + NL + "\t\t* @generated\t" + NL + "\t\t*/" + NL + "\t\tstatic class Matcher {" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t" + NL + "\t\t\tprivate EClass evalContext;" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tprivate ";
+ protected final String TEXT_95 = " condition;" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tprivate String body;\t\t" + NL + "\t\t\t\t\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t" + NL + "\t\t\tMatcher(String expressionBody) {\t\t\t" + NL + "\t\t\t\tbody = expressionBody;" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t\t" + NL + "\t\t\tboolean matches(EObject object) {\t\t" + NL + "\t\t\t\ttry {" + NL + "\t\t\t\t\tBoolean result = (object != null) ? evaluate(object) : Boolean.FALSE;" + NL + "\t\t\t\t\treturn result.booleanValue();" + NL + "\t\t\t\t} catch(IllegalArgumentException e) {" + NL + "\t\t\t\t\t// TODO - add log entry" + NL + "\t\t\t\t\te.printStackTrace();" + NL + "\t\t\t\t\treturn false;" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t" + NL + "\t\t\tprivate Boolean evaluate(EObject context) {" + NL + "\t\t\t\tthis.evalContext = context.eClass();" + NL + "\t\t\t\tif(condition == null) {\t\t\t\t\t" + NL + "\t\t\t\t\tcondition = new OclConstraintCondition(body, evalContext);" + NL + "\t\t\t\t}" + NL + "\t\t\t\tif(condition != null) {" + NL + "\t\t\t\t\treturn booleanCast(condition.evaluate(context));" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn Boolean.FALSE;" + NL + "\t\t\t}" + NL + "\t" + NL + "\t\t\t/**" + NL + "\t\t\t* @generated\t" + NL + "\t\t\t*/\t\t\t\t\t" + NL + "\t\t\tprivate static Boolean booleanCast(Object value) {" + NL + "\t\t\t\tif(value == null) {" + NL + "\t\t\t\t\treturn null;" + NL + "\t\t\t\t} else if(value instanceof Boolean) {" + NL + "\t\t\t\t\t return (Boolean)value;\t" + NL + "\t\t\t\t}" + NL + "\t\t\t\treturn Boolean.FALSE;" + NL + "\t\t\t}" + NL + "\t\t} // end of Matcher";
+ protected final String TEXT_96 = "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tstatic class AcceptAllMatcher {" + NL + "\t\t\t/**" + NL + "\t\t\t * @generated" + NL + "\t\t\t */\t\t" + NL + "\t\t\tstatic final AcceptAllMatcher INSTANCE = new AcceptAllMatcher();" + NL + "\t\t\t/**" + NL + "\t\t\t * @generated" + NL + "\t\t\t */\t\t\t\t\t" + NL + "\t\t\tboolean matches(Object element) {" + NL + "\t\t\t\treturn true;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */\t\t" + NL + "\t\tstatic AcceptAllMatcher acceptAllMatcher() {" + NL + "\t\t\treturn AcceptAllMatcher.INSTANCE;" + NL + "\t\t}" + NL + "\t} // end of ElementSelectors" + NL + "}" + NL + "\t";
+ protected final String TEXT_97 = NL;
public String generate(Object argument)
{
@@ -137,20 +122,27 @@ public class VisualIDRegistryGenerator
GenDiagram genDiagram = (GenDiagram) argument;
List genNodes = genDiagram.getNodes();
List genLinks = genDiagram.getLinks();
+Collection allContainers = AccessUtil.getAllContainers(genDiagram);
stringBuffer.append(TEXT_1);
stringBuffer.append(genDiagram.getEditorPackageName());
stringBuffer.append(TEXT_2);
- ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+importManager.addImport("org.eclipse.emf.ecore.EClass");
+importManager.addImport("org.eclipse.emf.ecore.EObject");
+importManager.addImport("org.eclipse.gmf.runtime.notation.View");
+
+importManager.markImportLocation(stringBuffer);
+
stringBuffer.append(TEXT_3);
- importManager.markImportLocation(stringBuffer);
+ stringBuffer.append(genDiagram.getVisualIDRegistryClassName());
stringBuffer.append(TEXT_4);
stringBuffer.append(genDiagram.getVisualIDRegistryClassName());
stringBuffer.append(TEXT_5);
stringBuffer.append(genDiagram.getVisualIDRegistryClassName());
stringBuffer.append(TEXT_6);
- stringBuffer.append(genDiagram.getVisualIDRegistryClassName());
- stringBuffer.append(TEXT_7);
GenPackage genPackage = genDiagram.getDomainMetaModel();
String semanticPackageInterfaceName = importManager.getImportedName(genPackage.getQualifiedPackageInterfaceName());
@@ -158,55 +150,51 @@ String semanticPackageInterfaceName = importManager.getImportedName(genPackage.g
String classifierAccessorName = genDiagram.getDomainDiagramElement().getClassifierAccessorName();
String interfaceName = importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName());
- stringBuffer.append(TEXT_8);
+ stringBuffer.append(TEXT_7);
stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_9);
+ stringBuffer.append(TEXT_8);
stringBuffer.append(classifierAccessorName);
- stringBuffer.append(TEXT_10);
+ stringBuffer.append(TEXT_9);
stringBuffer.append(genDiagram.getUniqueIdentifier());
- stringBuffer.append(TEXT_11);
+ stringBuffer.append(TEXT_10);
stringBuffer.append(interfaceName);
- stringBuffer.append(TEXT_12);
+ stringBuffer.append(TEXT_11);
stringBuffer.append(genDiagram.getVisualID());
- stringBuffer.append(TEXT_13);
+ stringBuffer.append(TEXT_12);
}
- stringBuffer.append(TEXT_14);
-
-Collection allContainers = AccessUtil.getAllContainers(genDiagram);
-
- stringBuffer.append(TEXT_15);
+ stringBuffer.append(TEXT_13);
stringBuffer.append(genDiagram.getVisualID());
- stringBuffer.append(TEXT_16);
+ stringBuffer.append(TEXT_14);
for (int i = 0; i < genNodes.size(); i++) {
GenNode genNode = (GenNode) genNodes.get(i);
String classifierAccessorName = genNode.getDomainMetaClass().getClassifierAccessorName();
String interfaceName = importManager.getImportedName(genNode.getDomainMetaClass().getQualifiedInterfaceName());
- stringBuffer.append(TEXT_17);
+ stringBuffer.append(TEXT_15);
stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_18);
+ stringBuffer.append(TEXT_16);
stringBuffer.append(classifierAccessorName);
- stringBuffer.append(TEXT_19);
+ stringBuffer.append(TEXT_17);
stringBuffer.append(genNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_20);
+ stringBuffer.append(TEXT_18);
stringBuffer.append(interfaceName);
- stringBuffer.append(TEXT_21);
+ stringBuffer.append(TEXT_19);
stringBuffer.append(genNode.getVisualID());
- stringBuffer.append(TEXT_22);
+ stringBuffer.append(TEXT_20);
}
- stringBuffer.append(TEXT_23);
+ stringBuffer.append(TEXT_21);
for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
GenChildContainer nextContainer = (GenChildContainer) containers.next();
- stringBuffer.append(TEXT_24);
+ stringBuffer.append(TEXT_22);
stringBuffer.append(nextContainer.getVisualID());
- stringBuffer.append(TEXT_25);
+ stringBuffer.append(TEXT_23);
if (nextContainer instanceof GenNode) {
GenNode node = (GenNode) nextContainer;
@@ -215,169 +203,96 @@ for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
GenNodeLabel label = (GenNodeLabel) labels.next();
String labelTextViewId = semanticHintsClassName + '.' + node.getUniqueIdentifier() + "Labels." + AccessUtil.getLabelTextId(label);
- stringBuffer.append(TEXT_26);
+ stringBuffer.append(TEXT_24);
stringBuffer.append(labelTextViewId);
- stringBuffer.append(TEXT_27);
+ stringBuffer.append(TEXT_25);
stringBuffer.append(label.getVisualID());
- stringBuffer.append(TEXT_28);
+ stringBuffer.append(TEXT_26);
}
for (Iterator compartments = node.getCompartments().iterator(); compartments.hasNext();) {
GenCompartment compartment = (GenCompartment) compartments.next();
String compartmentId = semanticHintsClassName + '.' + node.getUniqueIdentifier() + "Compartments." + AccessUtil.getCompartmentId(compartment);
- stringBuffer.append(TEXT_29);
+ stringBuffer.append(TEXT_27);
stringBuffer.append(compartmentId);
- stringBuffer.append(TEXT_30);
+ stringBuffer.append(TEXT_28);
stringBuffer.append(compartment.getVisualID());
- stringBuffer.append(TEXT_31);
+ stringBuffer.append(TEXT_29);
}
}
- stringBuffer.append(TEXT_32);
+ stringBuffer.append(TEXT_30);
stringBuffer.append(nextContainer.getUniqueIdentifier());
- stringBuffer.append(TEXT_33);
+ stringBuffer.append(TEXT_31);
for (Iterator childNodes = nextContainer.getChildNodes().iterator(); childNodes.hasNext();) {
GenNode childNode = (GenNode) childNodes.next();
String classifierAccessorName = childNode.getDomainMetaClass().getClassifierAccessorName();
String interfaceName = importManager.getImportedName(childNode.getDomainMetaClass().getQualifiedInterfaceName());
- stringBuffer.append(TEXT_34);
+ stringBuffer.append(TEXT_32);
stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_35);
+ stringBuffer.append(TEXT_33);
stringBuffer.append(classifierAccessorName);
- stringBuffer.append(TEXT_36);
+ stringBuffer.append(TEXT_34);
stringBuffer.append(childNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_37);
+ stringBuffer.append(TEXT_35);
stringBuffer.append(interfaceName);
- stringBuffer.append(TEXT_38);
+ stringBuffer.append(TEXT_36);
stringBuffer.append(childNode.getVisualID());
- stringBuffer.append(TEXT_39);
+ stringBuffer.append(TEXT_37);
}
- stringBuffer.append(TEXT_40);
+ stringBuffer.append(TEXT_38);
stringBuffer.append(nextContainer.getUniqueIdentifier());
- stringBuffer.append(TEXT_41);
+ stringBuffer.append(TEXT_39);
}
for (Iterator links = genLinks.iterator(); links.hasNext();) {
GenLink link = (GenLink) links.next();
String semanticHintsClassName = importManager.getImportedName(genDiagram.getSemanticHintsQualifiedClassName());
- stringBuffer.append(TEXT_42);
+ stringBuffer.append(TEXT_40);
stringBuffer.append(link.getVisualID());
- stringBuffer.append(TEXT_43);
+ stringBuffer.append(TEXT_41);
for (Iterator linkLabels = link.getLabels().iterator(); linkLabels.hasNext();) {
GenLinkLabel linkLabel = (GenLinkLabel) linkLabels.next();
String labelViewId = semanticHintsClassName + '.' + link.getUniqueIdentifier() + "Labels." + AccessUtil.getLabelId(linkLabel);
- stringBuffer.append(TEXT_44);
+ stringBuffer.append(TEXT_42);
stringBuffer.append(labelViewId);
- stringBuffer.append(TEXT_45);
+ stringBuffer.append(TEXT_43);
stringBuffer.append(linkLabel.getVisualID());
- stringBuffer.append(TEXT_46);
+ stringBuffer.append(TEXT_44);
}
- stringBuffer.append(TEXT_47);
+ stringBuffer.append(TEXT_45);
stringBuffer.append(link.getUniqueIdentifier());
- stringBuffer.append(TEXT_48);
+ stringBuffer.append(TEXT_46);
for (Iterator linkLabels = link.getLabels().iterator(); linkLabels.hasNext();) {
GenLinkLabel linkLabel = (GenLinkLabel) linkLabels.next();
String labelTextViewId = semanticHintsClassName + '.' + link.getUniqueIdentifier() + "Labels." + AccessUtil.getLabelTextId(linkLabel);
- stringBuffer.append(TEXT_49);
+ stringBuffer.append(TEXT_47);
stringBuffer.append(linkLabel.getVisualID());
- stringBuffer.append(TEXT_50);
+ stringBuffer.append(TEXT_48);
stringBuffer.append(labelTextViewId);
- stringBuffer.append(TEXT_51);
+ stringBuffer.append(TEXT_49);
stringBuffer.append(linkLabel.getVisualID());
- stringBuffer.append(TEXT_52);
+ stringBuffer.append(TEXT_50);
stringBuffer.append(link.getUniqueIdentifier());
- stringBuffer.append(TEXT_53);
+ stringBuffer.append(TEXT_51);
}
}
- stringBuffer.append(TEXT_54);
- stringBuffer.append(TEXT_55);
- stringBuffer.append(TEXT_56);
- stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation"));
- stringBuffer.append(TEXT_57);
-
-for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
- GenChildContainer nextContainer = (GenChildContainer) containers.next();
-
- stringBuffer.append(TEXT_58);
- stringBuffer.append(nextContainer.getUniqueIdentifier());
- stringBuffer.append(TEXT_59);
- stringBuffer.append(nextContainer.getUniqueIdentifier());
- stringBuffer.append(TEXT_60);
-
-}
-
-for (Iterator links = genLinks.iterator(); links.hasNext();) {
- GenLink link = (GenLink) links.next();
-
- stringBuffer.append(TEXT_61);
- stringBuffer.append(link.getUniqueIdentifier());
- stringBuffer.append(TEXT_62);
- stringBuffer.append(link.getUniqueIdentifier());
- stringBuffer.append(TEXT_63);
-
-}
-
- stringBuffer.append(TEXT_64);
-
-for (int i = 0; i < genNodes.size(); i++) {
- GenNode genNode = (GenNode) genNodes.get(i);
- String semanticNodeInterfaceName = genNode.getDomainMetaClass().getClassifierAccessorName();
- String qualifiedInterfaceName = genNode.getDomainMetaClass().getQualifiedInterfaceName();
-
- stringBuffer.append(TEXT_65);
- stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_66);
- stringBuffer.append(semanticNodeInterfaceName);
- stringBuffer.append(TEXT_67);
- stringBuffer.append(genNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_68);
- stringBuffer.append(importManager.getImportedName(qualifiedInterfaceName));
- stringBuffer.append(TEXT_69);
- stringBuffer.append(genNode.getVisualID());
- stringBuffer.append(TEXT_70);
-
-}
-
- stringBuffer.append(TEXT_71);
-
-for (int i = 0; i < genNodes.size(); i++) {
- GenNode genNode = (GenNode) genNodes.get(i);
- List genChildNodes = AccessUtil.getAllChildNodes(genNode);
- for (int j = 0; j < genChildNodes.size(); j++) {
- GenChildNode genChildNode = (GenChildNode) genChildNodes.get(j);
- String semanticChildNodeInterfaceName = genChildNode.getDomainMetaClass().getClassifierAccessorName();
- String qualifiedInterfaceName = genChildNode.getDomainMetaClass().getQualifiedInterfaceName();
-
- stringBuffer.append(TEXT_72);
- stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_73);
- stringBuffer.append(semanticChildNodeInterfaceName);
- stringBuffer.append(TEXT_74);
- stringBuffer.append(genChildNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_75);
- stringBuffer.append(importManager.getImportedName(qualifiedInterfaceName));
- stringBuffer.append(TEXT_76);
- stringBuffer.append(genChildNode.getVisualID());
- stringBuffer.append(TEXT_77);
- }
-}
-
- stringBuffer.append(TEXT_78);
+ stringBuffer.append(TEXT_52);
for (int i = 0; i < genLinks.size(); i++) {
GenLink genLink = (GenLink) genLinks.get(i);
@@ -386,26 +301,26 @@ for (int i = 0; i < genLinks.size(); i++) {
String semanticLinkInterfaceName = modelFacet.getMetaClass().getClassifierAccessorName();
String qualifiedInterfaceName = modelFacet.getMetaClass().getQualifiedInterfaceName();
- stringBuffer.append(TEXT_79);
+ stringBuffer.append(TEXT_53);
stringBuffer.append(semanticPackageInterfaceName);
- stringBuffer.append(TEXT_80);
+ stringBuffer.append(TEXT_54);
stringBuffer.append(semanticLinkInterfaceName);
- stringBuffer.append(TEXT_81);
+ stringBuffer.append(TEXT_55);
stringBuffer.append(genLink.getUniqueIdentifier());
- stringBuffer.append(TEXT_82);
+ stringBuffer.append(TEXT_56);
stringBuffer.append(importManager.getImportedName(qualifiedInterfaceName));
- stringBuffer.append(TEXT_83);
+ stringBuffer.append(TEXT_57);
stringBuffer.append(genLink.getVisualID());
- stringBuffer.append(TEXT_84);
+ stringBuffer.append(TEXT_58);
}
}
- stringBuffer.append(TEXT_85);
+ stringBuffer.append(TEXT_59);
stringBuffer.append(genDiagram.getUniqueIdentifier());
- stringBuffer.append(TEXT_86);
+ stringBuffer.append(TEXT_60);
stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
- stringBuffer.append(TEXT_87);
+ stringBuffer.append(TEXT_61);
String acceptAllMatcherAccessor = "acceptAllMatcher()"; //$NON-NLS-1$
for (int i = 0; i < genNodes.size(); i++) {
@@ -413,13 +328,13 @@ for (int i = 0; i < genNodes.size(); i++) {
String qualifiedNodeInterfaceName = genNode.getDomainMetaClass().getQualifiedInterfaceName();
String nodeSelector = genNode.getModelFacet() != null && genNode.getModelFacet().getModelElementSelector() != null ? genNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
- stringBuffer.append(TEXT_88);
+ stringBuffer.append(TEXT_62);
stringBuffer.append(genNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_89);
+ stringBuffer.append(TEXT_63);
stringBuffer.append(importManager.getImportedName(qualifiedNodeInterfaceName));
- stringBuffer.append(TEXT_90);
+ stringBuffer.append(TEXT_64);
stringBuffer.append(nodeSelector);
- stringBuffer.append(TEXT_91);
+ stringBuffer.append(TEXT_65);
List genChildNodes = AccessUtil.getAllChildNodes(genNode);
for (int j = 0; j < genChildNodes.size(); j++) {
@@ -427,17 +342,46 @@ for (int i = 0; i < genNodes.size(); i++) {
String qualifiedChildNodeInterfaceName = genChildNode.getDomainMetaClass().getQualifiedInterfaceName();
String childNodeSelector = genChildNode.getModelFacet() != null && genChildNode.getModelFacet().getModelElementSelector() != null ? genChildNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
- stringBuffer.append(TEXT_92);
+ stringBuffer.append(TEXT_66);
stringBuffer.append(genChildNode.getUniqueIdentifier());
- stringBuffer.append(TEXT_93);
+ stringBuffer.append(TEXT_67);
stringBuffer.append(importManager.getImportedName(qualifiedChildNodeInterfaceName));
- stringBuffer.append(TEXT_94);
+ stringBuffer.append(TEXT_68);
stringBuffer.append(childNodeSelector);
- stringBuffer.append(TEXT_95);
+ stringBuffer.append(TEXT_69);
}
}
- stringBuffer.append(TEXT_96);
+ stringBuffer.append(TEXT_70);
+
+for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
+ GenChildContainer nextContainer = (GenChildContainer) containers.next();
+
+ stringBuffer.append(TEXT_71);
+ stringBuffer.append(nextContainer.getUniqueIdentifier());
+ stringBuffer.append(TEXT_72);
+ stringBuffer.append(nextContainer.getUniqueIdentifier());
+ stringBuffer.append(TEXT_73);
+
+}
+
+for (Iterator links = genLinks.iterator(); links.hasNext();) {
+ GenLink link = (GenLink) links.next();
+
+ stringBuffer.append(TEXT_74);
+ stringBuffer.append(link.getUniqueIdentifier());
+ stringBuffer.append(TEXT_75);
+
+ if (link.getLabels().size() > 0) {
+
+ stringBuffer.append(TEXT_76);
+ stringBuffer.append(link.getUniqueIdentifier());
+ stringBuffer.append(TEXT_77);
+
+ }
+}
+
+ stringBuffer.append(TEXT_78);
for (int i = 0; i < genLinks.size(); i++) {
GenLink genLink = (GenLink) genLinks.get(i);
@@ -446,18 +390,22 @@ for (int i = 0; i < genLinks.size(); i++) {
String qualifiedInterfaceName = modelFacet.getMetaClass().getQualifiedInterfaceName();
String linkSelector = modelFacet.getModelElementSelector() != null ? genLink.getUniqueIdentifier() : acceptAllMatcherAccessor;
- stringBuffer.append(TEXT_97);
+ stringBuffer.append(TEXT_79);
stringBuffer.append(genLink.getUniqueIdentifier());
- stringBuffer.append(TEXT_98);
+ stringBuffer.append(TEXT_80);
stringBuffer.append(importManager.getImportedName(qualifiedInterfaceName));
- stringBuffer.append(TEXT_99);
+ stringBuffer.append(TEXT_81);
stringBuffer.append(linkSelector);
- stringBuffer.append(TEXT_100);
+ stringBuffer.append(TEXT_82);
}
}
- stringBuffer.append(TEXT_101);
+ stringBuffer.append(TEXT_83);
+ stringBuffer.append(TEXT_84);
+ stringBuffer.append(TEXT_85);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation"));
+ stringBuffer.append(TEXT_86);
int selectorCounter = 0;
for (Iterator it = genDiagram.eAllContents(); it.hasNext();) {
@@ -477,27 +425,27 @@ for (Iterator it = genDiagram.eAllContents(); it.hasNext();) {
ModelElementSelector selector = modelFacet.getModelElementSelector();
selectorCounter++;
- stringBuffer.append(TEXT_102);
+ stringBuffer.append(TEXT_87);
stringBuffer.append(id);
- stringBuffer.append(TEXT_103);
+ stringBuffer.append(TEXT_88);
stringBuffer.append(selector.getLanguage());
- stringBuffer.append(TEXT_104);
+ stringBuffer.append(TEXT_89);
stringBuffer.append(selector.getBody());
- stringBuffer.append(TEXT_105);
+ stringBuffer.append(TEXT_90);
stringBuffer.append(id);
- stringBuffer.append(TEXT_106);
+ stringBuffer.append(TEXT_91);
stringBuffer.append(selector.getBody());
- stringBuffer.append(TEXT_107);
+ stringBuffer.append(TEXT_92);
}
- stringBuffer.append(TEXT_108);
+ stringBuffer.append(TEXT_93);
if(selectorCounter > 0) {
- stringBuffer.append(TEXT_109);
+ stringBuffer.append(TEXT_94);
stringBuffer.append(importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OclConstraintCondition"));
- stringBuffer.append(TEXT_110);
+ stringBuffer.append(TEXT_95);
}
- stringBuffer.append(TEXT_111);
+ stringBuffer.append(TEXT_96);
importManager.emitSortedImports();
- stringBuffer.append(TEXT_112);
+ stringBuffer.append(TEXT_97);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet b/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet
index b9643f035..a6b5fecc6 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet
+++ b/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet
@@ -4,45 +4,46 @@
GenDiagram genDiagram = (GenDiagram) argument;
List genNodes = genDiagram.getNodes();
List genLinks = genDiagram.getLinks();
+Collection allContainers = AccessUtil.getAllContainers(genDiagram);
+
+boolean generateGetCompartment = false;
%>
package <%=genDiagram.getEditorPackageName()%>;
-<%ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());%>
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.runtime.diagram.ui.DiagramUtil;
-import org.eclipse.gmf.runtime.emf.core.edit.MRunnable;
-import org.eclipse.gmf.runtime.emf.core.util.OperationUtil;
-import org.eclipse.gmf.runtime.emf.core.util.ResourceUtil;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
-<%importManager.markImportLocation(stringBuffer);%>
+<%
+ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+importManager.addImport("java.io.IOException");
+importManager.addImport("java.util.Collections");
+importManager.addImport("java.util.HashMap");
+importManager.addImport("java.util.Map");
+importManager.addImport("org.eclipse.core.resources.IFile");
+importManager.addImport("org.eclipse.core.resources.IResource");
+importManager.addImport("org.eclipse.core.resources.ResourcesPlugin");
+importManager.addImport("org.eclipse.core.runtime.IStatus");
+importManager.addImport("org.eclipse.core.runtime.Path");
+importManager.addImport("org.eclipse.emf.ecore.EClass");
+importManager.addImport("org.eclipse.emf.ecore.EObject");
+importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
+importManager.addImport("org.eclipse.gmf.runtime.diagram.ui.DiagramUtil");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.edit.MRunnable");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.util.OperationUtil");
+importManager.addImport("org.eclipse.gmf.runtime.emf.core.util.ResourceUtil");
+importManager.addImport("org.eclipse.gmf.runtime.notation.Diagram");
+importManager.addImport("org.eclipse.jface.action.IAction");
+importManager.addImport("org.eclipse.jface.dialogs.IInputValidator");
+importManager.addImport("org.eclipse.jface.dialogs.InputDialog");
+importManager.addImport("org.eclipse.jface.dialogs.MessageDialog");
+importManager.addImport("org.eclipse.jface.viewers.ISelection");
+importManager.addImport("org.eclipse.jface.viewers.IStructuredSelection");
+importManager.addImport("org.eclipse.swt.widgets.Shell");
+importManager.addImport("org.eclipse.ui.IObjectActionDelegate");
+importManager.addImport("org.eclipse.ui.IWorkbenchPart");
+importManager.addImport("org.eclipse.ui.PartInitException");
+importManager.addImport("org.eclipse.ui.ide.IDE");
+
+importManager.markImportLocation(stringBuffer);
+%>
/**
* @generated
@@ -67,7 +68,7 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj
/**
* @generated
*/
- private Map myLinkWithClassVID2EObject = new HashMap();
+ private Map myLinkVID2EObjectMap = new HashMap();
/**
* @generated
@@ -188,168 +189,256 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj
*/
private EObject create(EObject diagramModel) {
int diagramVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getDiagramVisualID(diagramModel);
- if (diagramVID == -1) {
+ if (diagramVID != <%=genDiagram.getVisualID()%>) {
return null;
}
-
- myLinkWithClassVID2EObject.clear();
- myEObject2NodeMap.clear();
<%
for (Iterator it = genLinks.iterator(); it.hasNext();) {
GenLink nextLink = (GenLink) it.next();
%>
- myLinkWithClassVID2EObject.put(new Integer(<%=nextLink.getVisualID()%>), new LinkedList());
+ myLinkVID2EObjectMap.put(new Integer(<%=nextLink.getVisualID()%>), new <%=importManager.getImportedName("java.util.LinkedList")%>());
<%
}
%>
Diagram diagram = DiagramUtil.createDiagram(diagramModel, "<%=genDiagram.getEMFGenModel().getModelName()%>", <%=importManager.getImportedName(genDiagram.getPluginQualifiedClassName())%>.DIAGRAM_PREFERENCES_HINT);
createDiagramChildren(diagram, diagramModel);
-
createLinks();
-
+ myLinkVID2EObjectMap.clear();
+ myEObject2NodeMap.clear();
return diagram;
}
/**
* @generated
*/
- private void createDiagramChildren(Diagram diagram, EObject diagramObject) {
- for (Iterator it = diagramObject.eContents().iterator(); it.hasNext();) {
- EObject nextChild = (EObject) it.next();
- storeLinkReferenceOnly(nextChild);
- int nodeVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getNodeVisualID(nextChild);
- if (nodeVID == -1) {
- storeLinkWithClass(nextChild);
- continue;
- }
- Node nextNode = DiagramUtil.createNode(diagram, nextChild, null, <%=importManager.getImportedName(genDiagram.getPluginQualifiedClassName())%>.DIAGRAM_PREFERENCES_HINT);
- myEObject2NodeMap.put(nextChild, nextNode);
- switch (nodeVID) {
+ private void createDiagramChildren(Diagram diagram, EObject diagramModel) {
<%
-for (Iterator it = genNodes.iterator(); it.hasNext();) {
- GenNode nextGenNode = (GenNode) it.next();
-%>
- case <%=nextGenNode.getVisualID()%>:
- create<%=nextGenNode.getUniqueIdentifier()%>Children(nextNode, nextChild);
- break;
+if (genNodes.size() > 0) {
+%>
+ Object featureValue;
<%
}
+
+for (Iterator diagramNodes = genNodes.iterator(); diagramNodes.hasNext();) {
+ GenNode nextNode = (GenNode) diagramNodes.next();
+ TypeModelFacet typeModelFacet = nextNode.getModelFacet();
+ GenFeature childMetaFeature = typeModelFacet.getChildMetaFeature();
+%>
+ featureValue = ((<%=importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName())%>) diagramModel).<%=childMetaFeature.getGetAccessor()%>();
+<%
+ if (childMetaFeature.isListType()) {
+%>
+ for (<%=importManager.getImportedName("java.util.Iterator")%> values = ((<%=importManager.getImportedName("java.util.Collection")%>) featureValue).iterator(); values.hasNext();) {
+ EObject nextValue = ((EObject) values.next());
+<%
+ } else if (!childMetaFeature.isPrimitiveType()) {
%>
- }
+ EObject nextValue = (EObject) featureValue;
+<%
+ }
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
+%>
+ int nodeVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getNodeVisualID(diagram, nextValue, "");
+ if (<%=nextNode.getVisualID()%> == nodeVID) {
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> nextNode = DiagramUtil.createNode(diagram, nextValue, null, <%=importManager.getImportedName(genDiagram.getPluginQualifiedClassName())%>.DIAGRAM_PREFERENCES_HINT);
+ myEObject2NodeMap.put(nextValue, nextNode);
+ create<%=nextNode.getUniqueIdentifier()%>Children(nextNode, nextValue);
}
+<%
}
-
+ if (childMetaFeature.isListType()) {
+%>
+ }
<%
-for (Iterator genNodesIt = genNodes.iterator(); genNodesIt.hasNext();) {
- GenNode nextGenNode = (GenNode) genNodesIt.next();
-%>
+ }
+}
+%>
+ }
+<%
+for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
+ GenChildContainer nextContainer = (GenChildContainer) containers.next();
+%>
+
/**
* @generated
*/
- private void create<%=nextGenNode.getUniqueIdentifier()%>Children(Node node, EObject nodeObject) {
- for (Iterator it = nodeObject.eContents().iterator(); it.hasNext();) {
- EObject nextChild = (EObject) it.next();
- storeLinkReferenceOnly(nextChild);
- int nodeVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getChildNodeVisualID(nextChild);
- if (nodeVID == -1) {
- storeLinkWithClass(nextChild);
- continue;
- }
-
- Node container;
- switch (nodeVID) {
+ private void create<%=nextContainer.getUniqueIdentifier()%>Children(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> viewObject, EObject modelObject) {
<%
- for (Iterator childGenNodesIt = AccessUtil.getAllChildNodes(nextGenNode).iterator(); childGenNodesIt.hasNext();) {
- GenChildNode nextChildGenNode = (GenChildNode) childGenNodesIt.next();
-%>
- case <%=nextChildGenNode.getVisualID()%>:
+ if (nextContainer.getChildNodes().size() > 0) {
+%>
+ Object featureValue;
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> nextNode;
+<%
+ } else if (nextContainer instanceof GenNode && ((GenNode) nextContainer).getCompartments().size() > 0) {
+%>
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> nextNode;
+<%
+ }
+
+ for (Iterator children = nextContainer.getChildNodes().iterator(); children.hasNext();) {
+ GenChildNode nextChild = (GenChildNode) children.next();
+ TypeModelFacet typeModelFacet = nextChild.getModelFacet();
+ GenFeature childMetaFeature = typeModelFacet.getChildMetaFeature();
+%>
+ featureValue = ((<%=importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName())%>) modelObject).<%=childMetaFeature.getGetAccessor()%>();
<%
- if (nextChildGenNode.getContainer() instanceof GenCompartment) {
- GenCompartment compartment = (GenCompartment) nextChildGenNode.getContainer();
-%>
- container = getCompartment(node, "<%=compartment.getTitle()%>");
+ if (childMetaFeature.isListType()) {
+%>
+ for (<%=importManager.getImportedName("java.util.Iterator")%> values = ((<%=importManager.getImportedName("java.util.Collection")%>) featureValue).iterator(); values.hasNext();) {
+ EObject nextValue = ((EObject) values.next());
<%
- } else {
+ } else if (!childMetaFeature.isPrimitiveType()) {
+%>
+ EObject nextValue = (EObject) featureValue;
+<%
+ }
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
%>
- container = node;
+ int nodeVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getNodeVisualID(viewObject, nextValue, "");
+ if (<%=nextChild.getVisualID()%> == nodeVID) {
+ nextNode = DiagramUtil.createNode(viewObject, nextValue, null, <%=importManager.getImportedName(genDiagram.getPluginQualifiedClassName())%>.DIAGRAM_PREFERENCES_HINT);
+ myEObject2NodeMap.put(nextValue, nextNode);
+ create<%=nextChild.getUniqueIdentifier()%>Children(nextNode, nextValue);
+ }
<%
}
+ if (childMetaFeature.isListType()) {
%>
- break;
+ }
<%
+ }
}
+
+ if (nextContainer instanceof GenNode) {
+ GenNode nextNode = (GenNode) nextContainer;
+ for (Iterator compartments = nextNode.getCompartments().iterator(); compartments.hasNext();) {
+ GenCompartment nextCompartment = (GenCompartment) compartments.next();
+ generateGetCompartment = true;
%>
- default:
- container = node;
- break;
- }
- Node nextNode = DiagramUtil.createNode(container, nextChild, null, <%=importManager.getImportedName(genDiagram.getPluginQualifiedClassName())%>.DIAGRAM_PREFERENCES_HINT);
- myEObject2NodeMap.put(nextChild, nextNode);
+ nextNode = getCompartment(viewObject, "<%=nextCompartment.getTitle()%>");
+ if (nextNode != null) {
+ create<%=nextCompartment.getUniqueIdentifier()%>Children(nextNode, modelObject);
}
+<%
+ }
+%>
+ storeLinks(modelObject);
+<%
+ }
+%>
}
<%
}
+
+if (generateGetCompartment) {
%>
/**
* @generated
*/
- private Node getCompartment(Node node, String name) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
- View nextView = (View) it.next();
- if (nextView instanceof Node && name.equals(nextView.getType())) {
- return (Node) nextView;
+ private <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> getCompartment(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> node, String name) {
+ for (<%=importManager.getImportedName("java.util.Iterator")%> it = node.getChildren().iterator(); it.hasNext();) {
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")%> nextView = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")%>) it.next();
+ if (nextView instanceof <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> && name.equals(nextView.getType())) {
+ return (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%>) nextView;
}
}
- return node;
+ return null;
+ }
+<%
+}
+%>
+
+ /**
+ *@generated
+ */
+ private void storeLinks(EObject container) {
+ EClass containerMetaclass = container.eClass();
+ storeFeatureModelFacetLinks(container, containerMetaclass);
+ storeTypeModelFacetLinks(container, containerMetaclass);
}
/**
* @generated
*/
- private void storeLinkWithClass(EObject link) {
- int linkVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getLinkWithClassVisualID(link);
- if (linkVID == -1) {
- return;
+ private void storeTypeModelFacetLinks(EObject container, EClass containerMetaclass) {
+<%
+for (Iterator it = genLinks.iterator(); it.hasNext();) {
+ GenLink nextLink = (GenLink) it.next();
+ if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
+ TypeLinkModelFacet typeLinkModelFacet = (TypeLinkModelFacet) nextLink.getModelFacet();
+ GenFeature childMetaFeature = typeLinkModelFacet.getChildMetaFeature();
+%>
+ if (-1 != containerMetaclass.getFeatureID(<%=importManager.getImportedName(childMetaFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=childMetaFeature.getFeatureAccessorName()%>())) {
+ Object featureValue = ((<%=importManager.getImportedName(childMetaFeature.getGenClass().getQualifiedInterfaceName())%>) container).<%=childMetaFeature.getGetAccessor()%>();
+<%
+ if (childMetaFeature.isListType()) {
+%>
+ for (<%=importManager.getImportedName("java.util.Iterator")%> values = ((<%=importManager.getImportedName("java.util.Collection")%>) featureValue).iterator(); values.hasNext();) {
+ EObject nextValue = ((EObject) values.next());
+<%
+ } else if (!childMetaFeature.isPrimitiveType()) {
+%>
+ EObject nextValue = (EObject) featureValue;
+<%
}
- ((Collection) myLinkWithClassVID2EObject.get(new Integer(linkVID))).add(link);
+ if (childMetaFeature.isListType() || !childMetaFeature.isPrimitiveType()) {
+%>
+ int linkVID = <%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.INSTANCE.getLinkWithClassVisualID(nextValue);
+ if (<%=nextLink.getVisualID()%> == linkVID) {
+ ((<%=importManager.getImportedName("java.util.Collection")%>) myLinkVID2EObjectMap.get(new Integer(<%=nextLink.getVisualID()%>))).add(nextValue);
+ }
+<%
+ }
+ if (childMetaFeature.isListType()) {
+%>
+ }
+<%
+ }
+%>
+ }
+<%
}
-
+}
+%>
+ }
+
/**
*@generated
*/
- private void storeLinkReferenceOnly(EObject container) {
- EClass containerMetaclass = container.eClass();
- for (Iterator it = containerMetaclass.getEAllStructuralFeatures().iterator(); it.hasNext();) {
- EStructuralFeature nextFeature = (EStructuralFeature) it.next();
+ private void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass) {
<%
for (Iterator it = genLinks.iterator(); it.hasNext();) {
GenLink nextLink = (GenLink) it.next();
if (nextLink.getModelFacet() instanceof FeatureModelFacet) {
GenFeature genFeature = ((FeatureModelFacet) nextLink.getModelFacet()).getMetaFeature();
%>
- if (<%=importManager.getImportedName(genFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=genFeature.getFeatureAccessorName()%>().equals(nextFeature)) {
- ((Collection) myLinkWithClassVID2EObject.get(new Integer(<%=nextLink.getVisualID()%>))).add(container);
- }
+ if (-1 != containerMetaclass.getFeatureID(<%=importManager.getImportedName(genFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=genFeature.getFeatureAccessorName()%>())) {
+ ((<%=importManager.getImportedName("java.util.Collection")%>) myLinkVID2EObjectMap.get(new Integer(<%=nextLink.getVisualID()%>))).add(container);
+ }
<%
}
}
%>
- }
}
/**
* @generated
*/
private void createLinks() {
- Collection linkElements;
<%
+if (genLinks.size() > 0) {
+%>
+ <%=importManager.getImportedName("java.util.Collection")%> linkElements;
+<%
+}
+
for (Iterator it = genLinks.iterator(); it.hasNext();) {
GenLink nextLink = (GenLink) it.next();
GenFeature domainLinkTargetGenFeature;
%>
- linkElements = (Collection) myLinkWithClassVID2EObject.get(new Integer(<%=nextLink.getVisualID()%>));
- for (Iterator it = linkElements.iterator(); it.hasNext();) {
+ linkElements = (<%=importManager.getImportedName("java.util.Collection")%>) myLinkVID2EObjectMap.get(new Integer(<%=nextLink.getVisualID()%>));
+ for (<%=importManager.getImportedName("java.util.Iterator")%> it = linkElements.iterator(); it.hasNext();) {
EObject linkElement = (EObject) it.next();
<%
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
@@ -364,11 +453,11 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) {
<%
}
%>
- Node srcNode = (Node) myEObject2NodeMap.get(src);
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> srcNode = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%>) myEObject2NodeMap.get(src);
if (srcNode == null) {
continue;
}
- EStructuralFeature structuralFeature = <%=importManager.getImportedName(domainLinkTargetGenFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=domainLinkTargetGenFeature.getFeatureAccessorName()%>();
+ <%=importManager.getImportedName("org.eclipse.emf.ecore.EStructuralFeature")%> structuralFeature = <%=importManager.getImportedName(domainLinkTargetGenFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=domainLinkTargetGenFeature.getFeatureAccessorName()%>();
Object structuralFeatureResult = linkElement.eGet(structuralFeature);
<%
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
@@ -380,15 +469,15 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) {
<%
} else {
%>
- if (structuralFeatureResult instanceof Collection == false) {
+ if (structuralFeatureResult instanceof <%=importManager.getImportedName("java.util.Collection")%> == false) {
continue;
}
- for (Iterator destinations = ((Collection) structuralFeatureResult).iterator(); destinations.hasNext();) {
+ for (<%=importManager.getImportedName("java.util.Iterator")%> destinations = ((<%=importManager.getImportedName("java.util.Collection")%>) structuralFeatureResult).iterator(); destinations.hasNext();) {
EObject dst = (EObject) destinations.next();
<%
}
%>
- Node dstNode = (Node) myEObject2NodeMap.get(dst);
+ <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%> dstNode = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%>) myEObject2NodeMap.get(dst);
if (dstNode != null) {
<%
if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) {
diff --git a/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet b/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet
index a6e0f3ede..024bf5553 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet
+++ b/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet
@@ -4,14 +4,19 @@
GenDiagram genDiagram = (GenDiagram) argument;
List genNodes = genDiagram.getNodes();
List genLinks = genDiagram.getLinks();
+Collection allContainers = AccessUtil.getAllContainers(genDiagram);
%>
package <%=genDiagram.getEditorPackageName()%>;
-<%ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());%>
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.View;
-<%importManager.markImportLocation(stringBuffer);%>
+<%
+ImportUtil importManager = new ImportUtil(genDiagram.getEditorPackageName());
+
+importManager.addImport("org.eclipse.emf.ecore.EClass");
+importManager.addImport("org.eclipse.emf.ecore.EObject");
+importManager.addImport("org.eclipse.gmf.runtime.notation.View");
+
+importManager.markImportLocation(stringBuffer);
+%>
/**
* This registry is used to determine which type of visual object should be
@@ -56,19 +61,16 @@ String semanticPackageInterfaceName = importManager.getImportedName(genPackage.g
}
/**
- * User can change implementation of this method to handle some specific
- * situations not covered by default logic.
- *
* @generated
*/
- private int getUnrecognizedDiagramID(EObject domainElement) {
- return -1;
+ public int getNodeVisualID(View containerView, EObject domainElement, String semanticHint) {
+ if (domainElement == null) {
+ return -1;
+ }
+ EClass domainElementMetaclass = domainElement.eClass();
+ return getNodeVisualID(containerView, domainElement, domainElementMetaclass, semanticHint);
}
-
-//================================================================================================================
-<%
-Collection allContainers = AccessUtil.getAllContainers(genDiagram);
-%>
+
/**
* @generated
*/
@@ -171,241 +173,172 @@ for (Iterator links = genLinks.iterator(); links.hasNext();) {
return -1;
}
-<%@ include file="getVisualID.jetinc" %>
-
/**
* @generated
- */
- private int getUnrecognizedDiagramChildID(EObject domainElement) {
- return -1;
+ */
+ public int getLinkWithClassVisualID(EObject domainElement) {
+ EClass domainElementMetaclass = domainElement.eClass();
+ return getLinkWithClassVisualID(domainElement, domainElementMetaclass);
}
-
-<%
-for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
- GenChildContainer nextContainer = (GenChildContainer) containers.next();
-%>
+
/**
- * User can change implementation of this method to handle some specific
- * situations not covered by default logic.
- *
* @generated
- */
- private int getUnrecognized<%=nextContainer.getUniqueIdentifier()%>ChildNodeID(EObject domainElement) {
- return -1;
+ */
+ public int getLinkWithClassVisualID(EObject domainElement, EClass domainElementMetaclass) {
+<%
+for (int i = 0; i < genLinks.size(); i++) {
+ GenLink genLink = (GenLink) genLinks.get(i);
+ if (genLink.getModelFacet() instanceof TypeLinkModelFacet) {
+ TypeLinkModelFacet modelFacet = (TypeLinkModelFacet) genLink.getModelFacet();
+ String semanticLinkInterfaceName = modelFacet.getMetaClass().getClassifierAccessorName();
+ String qualifiedInterfaceName = modelFacet.getMetaClass().getQualifiedInterfaceName();
+%>
+ if (<%=semanticPackageInterfaceName%>.eINSTANCE.get<%=semanticLinkInterfaceName%>().equals(domainElementMetaclass) && (domainElement != null ? isLinkWithClass<%=genLink.getUniqueIdentifier()%>((<%=importManager.getImportedName(qualifiedInterfaceName)%>) domainElement) : true)) {
+ return <%=genLink.getVisualID()%>;
+ } else
+<%
+ }
}
+%>
+ {
+ return getUnrecognizedLinkWithClassID(domainElement);
+ }
+ }
/**
- * User can change implementation of this method to handle some specific
- * situations not covered by default logic.
+ * User can change implementation of this method to check some additional
+ * conditions here.
*
* @generated
- */
- private int getUnrecognized<%=nextContainer.getUniqueIdentifier()%>ChildNodeID(String semanticHint) {
- return -1;
+ */
+ private boolean isDiagram<%=genDiagram.getUniqueIdentifier()%>(<%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%> element) {
+ return true;
}
-
-<%
-}
-for (Iterator links = genLinks.iterator(); links.hasNext();) {
- GenLink link = (GenLink) links.next();
-%>
/**
* User can change implementation of this method to handle some specific
* situations not covered by default logic.
*
* @generated
- */
- private int getUnrecognized<%=link.getUniqueIdentifier()%>LinkLabelID(String semanticHint) {
+ */
+ private int getUnrecognizedDiagramID(EObject domainElement) {
return -1;
}
+<%
+String acceptAllMatcherAccessor = "acceptAllMatcher()"; //$NON-NLS-1$
+for (int i = 0; i < genNodes.size(); i++) {
+ GenNode genNode = (GenNode) genNodes.get(i);
+ String qualifiedNodeInterfaceName = genNode.getDomainMetaClass().getQualifiedInterfaceName();
+ String nodeSelector = genNode.getModelFacet() != null && genNode.getModelFacet().getModelElementSelector() != null ? genNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
+%>
/**
- * User can change implementation of this method to handle some specific
- * situations not covered by default logic.
+ * User can change implementation of this method to check some additional
+ * conditions here.
*
* @generated
- */
- private int getUnrecognized<%=link.getUniqueIdentifier()%>LinkLabelTextID(String semanticHint) {
- return -1;
+ */
+ private boolean isNode<%=genNode.getUniqueIdentifier()%>(<%=importManager.getImportedName(qualifiedNodeInterfaceName)%> element) {
+ return ElementSelectors.<%=nodeSelector%>.matches(element);
}
<%
-}
+ List genChildNodes = AccessUtil.getAllChildNodes(genNode);
+ for (int j = 0; j < genChildNodes.size(); j++) {
+ GenChildNode genChildNode = (GenChildNode) genChildNodes.get(j);
+ String qualifiedChildNodeInterfaceName = genChildNode.getDomainMetaClass().getQualifiedInterfaceName();
+ String childNodeSelector = genChildNode.getModelFacet() != null && genChildNode.getModelFacet().getModelElementSelector() != null ? genChildNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
%>
-
-//================================================================================================================
/**
- * @deprecated
+ * User can change implementation of this method to check some additional
+ * conditions here.
+ *
* @generated
*/
- public int getNodeVisualID(EObject domainElement) {
- EClass domainElementMetaclass = domainElement.eClass();
- return getNodeVisualID(domainElement, domainElementMetaclass);
+ private boolean isChildNode<%=genChildNode.getUniqueIdentifier()%>(<%=importManager.getImportedName(qualifiedChildNodeInterfaceName)%> element) {
+ return ElementSelectors.<%=childNodeSelector%>.matches(element);
}
-
- /**
- * @deprecated
- * @generated
- */
- public int getNodeVisualID(EObject domainElement, EClass domainElementMetaclass) {
-<%
-for (int i = 0; i < genNodes.size(); i++) {
- GenNode genNode = (GenNode) genNodes.get(i);
- String semanticNodeInterfaceName = genNode.getDomainMetaClass().getClassifierAccessorName();
- String qualifiedInterfaceName = genNode.getDomainMetaClass().getQualifiedInterfaceName();
-%>
- if (<%=semanticPackageInterfaceName%>.eINSTANCE.get<%=semanticNodeInterfaceName%>().equals(domainElementMetaclass) && (domainElement != null ? isNode<%=genNode.getUniqueIdentifier()%>((<%=importManager.getImportedName(qualifiedInterfaceName)%>) domainElement) : true)) {
- return <%=genNode.getVisualID()%>;
- } else
-<%
+<% }
}
%>
- {
- return getUnrecognizedNodeID(domainElement);
- }
- }
-
+
/**
* User can change implementation of this method to handle some specific
* situations not covered by default logic.
*
* @generated
- */
- private int getUnrecognizedNodeID(EObject domainElement) {
+ */
+ private int getUnrecognizedDiagramChildID(EObject domainElement) {
return -1;
}
-
- /**
- * @generated
- */
- public int getChildNodeVisualID(EObject domainElement) {
- EClass domainElementMetaclass = domainElement.eClass();
- return getChildNodeVisualID(domainElement, domainElementMetaclass);
- }
-
- /**
- * @generated
- */
- public int getChildNodeVisualID(EObject domainElement, EClass domainElementMetaclass) {
<%
-for (int i = 0; i < genNodes.size(); i++) {
- GenNode genNode = (GenNode) genNodes.get(i);
- List genChildNodes = AccessUtil.getAllChildNodes(genNode);
- for (int j = 0; j < genChildNodes.size(); j++) {
- GenChildNode genChildNode = (GenChildNode) genChildNodes.get(j);
- String semanticChildNodeInterfaceName = genChildNode.getDomainMetaClass().getClassifierAccessorName();
- String qualifiedInterfaceName = genChildNode.getDomainMetaClass().getQualifiedInterfaceName();
-%>
- if (<%=semanticPackageInterfaceName%>.eINSTANCE.get<%=semanticChildNodeInterfaceName%>().equals(domainElementMetaclass) && (domainElement != null ? isChildNode<%=genChildNode.getUniqueIdentifier()%>((<%=importManager.getImportedName(qualifiedInterfaceName)%>) domainElement) : true)) {
- return <%=genChildNode.getVisualID()%>;
- } else
-<% }
-}
+for (Iterator containers = allContainers.iterator(); containers.hasNext();) {
+ GenChildContainer nextContainer = (GenChildContainer) containers.next();
%>
- {
- return getUnrecognizedChildNodeID(domainElement);
- }
- }
-
+
/**
* User can change implementation of this method to handle some specific
* situations not covered by default logic.
*
* @generated
- */
- private int getUnrecognizedChildNodeID(EObject domainElement) {
+ */
+ private int getUnrecognized<%=nextContainer.getUniqueIdentifier()%>ChildNodeID(EObject domainElement) {
return -1;
}
-
+
/**
+ * User can change implementation of this method to handle some specific
+ * situations not covered by default logic.
+ *
* @generated
- */
- public int getLinkWithClassVisualID(EObject domainElement) {
- EClass domainElementMetaclass = domainElement.eClass();
- return getLinkWithClassVisualID(domainElement, domainElementMetaclass);
+ */
+ private int getUnrecognized<%=nextContainer.getUniqueIdentifier()%>ChildNodeID(String semanticHint) {
+ return -1;
}
-
- /**
- * @generated
- */
- public int getLinkWithClassVisualID(EObject domainElement, EClass domainElementMetaclass) {
<%
-for (int i = 0; i < genLinks.size(); i++) {
- GenLink genLink = (GenLink) genLinks.get(i);
- if (genLink.getModelFacet() instanceof TypeLinkModelFacet) {
- TypeLinkModelFacet modelFacet = (TypeLinkModelFacet) genLink.getModelFacet();
- String semanticLinkInterfaceName = modelFacet.getMetaClass().getClassifierAccessorName();
- String qualifiedInterfaceName = modelFacet.getMetaClass().getQualifiedInterfaceName();
-%>
- if (<%=semanticPackageInterfaceName%>.eINSTANCE.get<%=semanticLinkInterfaceName%>().equals(domainElementMetaclass) && (domainElement != null ? isLinkWithClass<%=genLink.getUniqueIdentifier()%>((<%=importManager.getImportedName(qualifiedInterfaceName)%>) domainElement) : true)) {
- return <%=genLink.getVisualID()%>;
- } else
-<%
- }
- }
+}
+
+for (Iterator links = genLinks.iterator(); links.hasNext();) {
+ GenLink link = (GenLink) links.next();
%>
- {
- return getUnrecognizedLinkWithClassID(domainElement);
- }
- }
-
+
/**
* User can change implementation of this method to handle some specific
* situations not covered by default logic.
*
* @generated
- */
- private int getUnrecognizedLinkWithClassID(EObject domainElement) {
+ */
+ private int getUnrecognized<%=link.getUniqueIdentifier()%>LinkLabelID(String semanticHint) {
return -1;
}
-
- /**
- * User can change implementation of this method to check some additional conditions here.
- *
- * @generated
- */
- private boolean isDiagram<%=genDiagram.getUniqueIdentifier()%>(<%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%> element) {
- return true;
- }
-
<%
-String acceptAllMatcherAccessor = "acceptAllMatcher()"; //$NON-NLS-1$
-for (int i = 0; i < genNodes.size(); i++) {
- GenNode genNode = (GenNode) genNodes.get(i);
- String qualifiedNodeInterfaceName = genNode.getDomainMetaClass().getQualifiedInterfaceName();
- String nodeSelector = genNode.getModelFacet() != null && genNode.getModelFacet().getModelElementSelector() != null ? genNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
+ if (link.getLabels().size() > 0) {
%>
+
/**
- * User can change implementation of this method to check some additional conditions here.
+ * User can change implementation of this method to handle some specific
+ * situations not covered by default logic.
*
* @generated
- */
- private boolean isNode<%=genNode.getUniqueIdentifier()%>(<%=importManager.getImportedName(qualifiedNodeInterfaceName)%> element) {
- return ElementSelectors.<%=nodeSelector%>.matches(element);
+ */
+ private int getUnrecognized<%=link.getUniqueIdentifier()%>LinkLabelTextID(String semanticHint) {
+ return -1;
}
-
<%
- List genChildNodes = AccessUtil.getAllChildNodes(genNode);
- for (int j = 0; j < genChildNodes.size(); j++) {
- GenChildNode genChildNode = (GenChildNode) genChildNodes.get(j);
- String qualifiedChildNodeInterfaceName = genChildNode.getDomainMetaClass().getQualifiedInterfaceName();
- String childNodeSelector = genChildNode.getModelFacet() != null && genChildNode.getModelFacet().getModelElementSelector() != null ? genChildNode.getUniqueIdentifier() : acceptAllMatcherAccessor;
+ }
+}
%>
+
/**
- * User can change implementation of this method to check some additional conditions here.
+ * User can change implementation of this method to handle some specific
+ * situations not covered by default logic.
*
* @generated
*/
- private boolean isChildNode<%=genChildNode.getUniqueIdentifier()%>(<%=importManager.getImportedName(qualifiedChildNodeInterfaceName)%> element) {
- return ElementSelectors.<%=childNodeSelector%>.matches(element);
+ private int getUnrecognizedLinkWithClassID(EObject domainElement) {
+ return -1;
}
-
-<% }
-}
-%>
-
<%
for (int i = 0; i < genLinks.size(); i++) {
GenLink genLink = (GenLink) genLinks.get(i);
@@ -414,8 +347,10 @@ for (int i = 0; i < genLinks.size(); i++) {
String qualifiedInterfaceName = modelFacet.getMetaClass().getQualifiedInterfaceName();
String linkSelector = modelFacet.getModelElementSelector() != null ? genLink.getUniqueIdentifier() : acceptAllMatcherAccessor;
%>
+
/**
- * User can change implementation of this method to check some additional conditions here.
+ * User can change implementation of this method to check some additional
+ * conditions here.
*
* @generated
*/
@@ -427,6 +362,8 @@ for (int i = 0; i < genLinks.size(); i++) {
}
%>
+<%@ include file="getVisualID.jetinc" %>
+
/**
* @generated
*/

Back to the top