Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/InitDiagramFileActionGenerator.java556
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/VisualIDRegistryGenerator.java15
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/policies/ItemSemanticEditPolicyGenerator.java2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet119
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/policies/ItemSemanticEditPolicy.javajet2
6 files changed, 386 insertions, 312 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 1c211474a..a65535ab8 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,142 +19,146 @@ public class InitDiagramFileActionGenerator {
protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "";
protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
- protected final String TEXT_3 = " implements IObjectActionDelegate, IInputValidator {" + 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(\"editorGen.getDiagramFileExtension()\")).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(\"editorGen.getDiagramFileExtension()\").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\t";
- protected final String TEXT_4 = ".getInstance().logError(\"Unable to open editor\", ex);" + 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_5 = NL + "\t\t";
- protected final String TEXT_6 = " resourceSet = new ";
- protected final String TEXT_7 = "();" + NL + "\t\tResource resource = resourceSet.getResource(";
- protected final String TEXT_8 = ".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\t";
- protected final String TEXT_9 = ".getInstance().logError(\"Unable to load resource: \" + mySelection.getFullPath().toString(), ex);" + NL + "\t\t}" + NL + "\t\treturn null;";
- protected final String TEXT_10 = NL + "\t\tString resourcePath = mySelection.getLocation().toOSString();" + NL + "\t\tResource modelResource = ResourceUtil.findResource(resourcePath);" + NL + "\t\tif (modelResource == null) {" + NL + "\t\t\tmodelResource = ResourceUtil.create(resourcePath);" + NL + "\t\t}" + NL + "\t\tif (!modelResource.isLoaded()) {" + NL + "\t\t\ttry {" + NL + "\t\t\t\tResourceUtil.load(modelResource);" + NL + "\t\t\t} catch (Exception e) {" + NL + "\t\t\t\t";
- protected final String TEXT_11 = ".getInstance().logError(\"Unable to load resource: \" + resourcePath, e);" + NL + "\t\t\t\treturn null;" + NL + "\t\t\t}" + NL + "\t\t}" + 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\t";
- protected final String TEXT_15 = ".getInstance().logError(\"Save operation failed for: \" + filePath, ex);" + 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_16 = ".INSTANCE.getDiagramVisualID(diagramModel);" + NL + "\t\tif (diagramVID != ";
- protected final String TEXT_17 = ") {" + NL + "\t\t\treturn null;" + NL + "\t\t}";
- protected final String TEXT_18 = NL + "\t\tmyLinkVID2EObjectMap.put(new Integer(";
- protected final String TEXT_19 = "), new ";
- protected final String TEXT_20 = "());";
- protected final String TEXT_21 = NL + "\t\tDiagram diagram = ViewService.createDiagram(diagramModel, \"";
- protected final String TEXT_22 = "\", ";
- protected final String TEXT_23 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\tcreate";
- protected final String TEXT_24 = "Children(diagram, diagramModel);";
- protected final String TEXT_25 = NL + "\t\tResource resource = diagramModel.eResource();" + NL + "\t\tint nodeVID;" + NL + "\t\tfor (Iterator it = resource.getContents().iterator(); it.hasNext();) {" + NL + "\t\t\tEObject nextResourceObject = (EObject) it.next();" + NL + "\t\t\tif (nextResourceObject == diagramModel) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}";
- protected final String TEXT_26 = NL + "\t\t\tnodeVID = ";
- protected final String TEXT_27 = ".INSTANCE.getNodeVisualID(diagram, nextResourceObject, \"\");" + NL + "\t\t\tif (";
- protected final String TEXT_28 = " == nodeVID) {" + NL + "\t\t\t\t";
- protected final String TEXT_29 = " nextNode = ViewService.createNode(diagram, nextResourceObject, null, ";
- protected final String TEXT_30 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\tmyEObject2NodeMap.put(nextResourceObject, nextNode);" + NL + "\t\t\t\tcreate";
- protected final String TEXT_31 = "Children(nextNode, nextResourceObject);" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}";
- protected final String TEXT_32 = NL + "\t\t}";
- protected final String TEXT_33 = "\t\t" + NL + "\t\tcreateLinks();" + NL + "\t\tmyLinkVID2EObjectMap.clear();" + NL + "\t\tmyEObject2NodeMap.clear();\t\t" + NL + "\t return diagram;" + NL + "\t}" + NL + "\t";
- protected final String TEXT_34 = "\t" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void create";
- protected final String TEXT_35 = "Children(";
- protected final String TEXT_36 = " viewObject, EObject modelObject) {";
- protected final String TEXT_37 = NL + "\t\tEObject nextValue;" + NL + "\t\t";
- protected final String TEXT_38 = " nextNode;" + NL + "\t\tint nodeVID;";
- protected final String TEXT_39 = NL + "\t\t";
- protected final String TEXT_40 = " nextNode;";
- protected final String TEXT_41 = NL + "\t\tfor (";
- protected final String TEXT_42 = " values = ";
- protected final String TEXT_43 = ".iterator(); values.hasNext();) {" + NL + "\t\t\tnextValue = (EObject) values.next();" + NL;
- protected final String TEXT_44 = NL + "\t\tnextValue = ";
- protected final String TEXT_45 = ";";
- protected final String TEXT_46 = NL + "\t\tnodeVID = ";
- protected final String TEXT_47 = ".INSTANCE.getNodeVisualID(viewObject, nextValue, \"\");" + NL + "\t\tif (";
- protected final String TEXT_48 = " == nodeVID) {" + NL + "\t\t\tnextNode = ViewService.createNode(viewObject, nextValue, null, ";
- protected final String TEXT_49 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\tcreate";
- protected final String TEXT_50 = "Children(nextNode, nextValue);" + NL + "\t\t}";
- protected final String TEXT_51 = NL + "\t\t}";
- protected final String TEXT_52 = NL + "\t\tnextNode = getCompartment(viewObject, \"";
- protected final String TEXT_53 = "\");" + NL + "\t\tif (nextNode != null) {" + NL + "\t\t\tcreate";
- protected final String TEXT_54 = "Children(nextNode, modelObject);" + NL + "\t\t}";
- protected final String TEXT_55 = NL + "\t\tstoreLinks(modelObject, viewObject.getDiagram());" + NL + "\t}";
- protected final String TEXT_56 = NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate ";
- protected final String TEXT_57 = " getCompartment(";
- protected final String TEXT_58 = " node, String name) {" + NL + "\t\tfor (";
- protected final String TEXT_59 = " it = node.getChildren().iterator(); it.hasNext();) {" + NL + "\t\t\t";
- protected final String TEXT_60 = " nextView = (";
- protected final String TEXT_61 = ") it.next();" + NL + "\t\t\tif (nextView instanceof ";
- protected final String TEXT_62 = " && name.equals(nextView.getType())) {" + NL + "\t\t\t\treturn (";
- protected final String TEXT_63 = ") nextView;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}";
- protected final String TEXT_64 = NL + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeLinks(EObject container, Diagram diagram) {" + NL + "\t\tEClass containerMetaclass = container.eClass();" + NL + "\t\tstoreFeatureModelFacetLinks(container, containerMetaclass, diagram);" + 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_65 = "\t\t" + NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
- protected final String TEXT_66 = ".eINSTANCE.get";
- protected final String TEXT_67 = "())) {" + NL + "\t\t\tObject featureValue = ";
- protected final String TEXT_68 = ";";
- protected final String TEXT_69 = "\t\t" + NL + "\t\t\tfor (";
- protected final String TEXT_70 = " values = ((";
- protected final String TEXT_71 = ") featureValue).iterator(); values.hasNext();) {" + NL + "\t\t\t\tEObject nextValue = ((EObject) values.next());";
- protected final String TEXT_72 = NL + "\t\t\tEObject nextValue = (EObject) featureValue;";
- protected final String TEXT_73 = NL + "\t\t\tint linkVID = ";
- protected final String TEXT_74 = ".INSTANCE.getLinkWithClassVisualID(nextValue);" + NL + "\t\t\tif (";
- protected final String TEXT_75 = " == linkVID) {" + NL + "\t\t\t\t((";
- protected final String TEXT_76 = ") myLinkVID2EObjectMap.get(new Integer(";
- protected final String TEXT_77 = "))).add(nextValue);" + NL + "\t\t\t}";
- protected final String TEXT_78 = NL + "\t\t\t}";
- protected final String TEXT_79 = NL + "\t\t}";
- protected final String TEXT_80 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass, Diagram diagram) {";
- protected final String TEXT_81 = NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
- protected final String TEXT_82 = ".eINSTANCE.get";
- protected final String TEXT_83 = "())) {" + NL + "\t\t\t((";
- protected final String TEXT_84 = ") myLinkVID2EObjectMap.get(new Integer(";
- protected final String TEXT_85 = "))).add(container);";
- protected final String TEXT_86 = NL + "\t\t\tfor (";
- protected final String TEXT_87 = " values = ";
- protected final String TEXT_88 = ".iterator(); values.hasNext();) {" + NL + "\t\t\t\tEObject nextValue = (EObject) values.next();";
- protected final String TEXT_89 = NL + "\t\t\tEObject nextValue = ";
- protected final String TEXT_90 = ";";
- protected final String TEXT_91 = NL + "\t\t\tint nodeVID = ";
- protected final String TEXT_92 = ".INSTANCE.getNodeVisualID(diagram, nextValue, \"\");" + NL + "\t\t\tif (";
- protected final String TEXT_93 = " == nodeVID) {" + NL + "\t\t\t\t";
- protected final String TEXT_94 = " nextNode = ViewService.createNode(diagram, nextValue, null, ";
- protected final String TEXT_95 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\t\tcreate";
- protected final String TEXT_96 = "Children(nextNode, nextValue);" + NL + "\t\t\t}";
- protected final String TEXT_97 = NL + "\t\t\t}";
- protected final String TEXT_98 = NL + "\t\t}";
- protected final String TEXT_99 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createLinks() {";
- protected final String TEXT_100 = NL + "\t\t";
- protected final String TEXT_101 = " linkElements;";
- protected final String TEXT_102 = NL + "\t\tlinkElements = (";
- protected final String TEXT_103 = ") myLinkVID2EObjectMap.get(new Integer(";
- protected final String TEXT_104 = "));" + NL + "\t\tfor (";
- protected final String TEXT_105 = " it = linkElements.iterator(); it.hasNext();) {" + NL + "\t\t\tEObject linkElement = (EObject) it.next();";
- protected final String TEXT_106 = NL + "\t\t\tObject srcResult = ";
- protected final String TEXT_107 = ";" + NL + "\t\t\tif (srcResult instanceof EObject == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tEObject src = (EObject) srcResult;";
- protected final String TEXT_108 = NL + "\t\t\tEObject src = linkElement.eContainer();";
- protected final String TEXT_109 = NL + "\t\t\tEObject src = linkElement;";
- protected final String TEXT_110 = NL + "\t\t\t";
- protected final String TEXT_111 = " srcNode = (";
- protected final String TEXT_112 = ") myEObject2NodeMap.get(src);" + NL + "\t\t\tif (srcNode == null) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tObject structuralFeatureResult = ";
- protected final String TEXT_113 = ";";
- protected final String TEXT_114 = 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_115 = NL + "\t\t\tif (structuralFeatureResult instanceof ";
- protected final String TEXT_116 = " == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tfor (";
- protected final String TEXT_117 = " destinations = ((";
- protected final String TEXT_118 = ") structuralFeatureResult).iterator(); destinations.hasNext();) {" + NL + "\t\t\t\tEObject dst = (EObject) destinations.next();";
- protected final String TEXT_119 = 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_120 = NL + "\t\t\t";
- protected final String TEXT_121 = " dstNode = (";
- protected final String TEXT_122 = ") myEObject2NodeMap.get(dst);" + NL + "\t\t\tif (dstNode != null) {";
- protected final String TEXT_123 = NL + "\t\t\t\tViewService.createEdge(srcNode, dstNode, linkElement, null, ";
- protected final String TEXT_124 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t}";
- protected final String TEXT_125 = NL + "\t\t\t\t\t";
- protected final String TEXT_126 = " edge = (";
- protected final String TEXT_127 = ") ViewService.getInstance().createEdge(new ";
- protected final String TEXT_128 = "() {" + NL + "\t\t\t\t\t\tpublic Object getAdapter(Class adapter) {" + NL + "\t\t\t\t\t\t\tif (";
- protected final String TEXT_129 = ".class.equals(adapter)) {" + NL + "\t\t\t\t\t\t\t\treturn ";
- protected final String TEXT_130 = ".";
- protected final String TEXT_131 = ";" + 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_132 = ".APPEND, ";
- protected final String TEXT_133 = ".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}";
- protected final String TEXT_134 = NL + "\t\t\t\t}";
- protected final String TEXT_135 = NL + "\t\t\t}";
- protected final String TEXT_136 = NL + "\t\t}";
- protected final String TEXT_137 = NL + "\t}" + NL + "\t" + NL + "}";
- protected final String TEXT_138 = NL;
+ protected final String TEXT_3 = " implements IObjectActionDelegate, IInputValidator {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IWorkbenchPart myPart;" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFile mySelectedModelFile;" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IStructuredSelection 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\tmySelectedModelFile = null;" + NL + "\t\tmySelection = StructuredSelection.EMPTY;" + NL + "\t\taction.setEnabled(false);" + NL + "\t\tif (selection instanceof IStructuredSelection == false || selection.isEmpty()) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tmySelection = (IStructuredSelection) selection;" + NL + "\t\tmySelectedModelFile = (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 (mySelectedModelFile.getParent().getFile(new Path(newText).addFileExtension(\"editorGen.getDiagramFileExtension()\")).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\tNewDiagramFileWizard wizard = new NewDiagramFileWizard();" + NL + " IDialogSettings pluginDialogSettings = ";
+ protected final String TEXT_4 = ".getInstance().getDialogSettings();" + NL + " IDialogSettings initDiagramFileSettings = pluginDialogSettings.getSection(\"InisDiagramFile\"); //$NON-NLS-1$" + NL + " if (initDiagramFileSettings == null) {" + NL + " \tinitDiagramFileSettings = pluginDialogSettings.addNewSection(\"InisDiagramFile\"); //$NON-NLS-1$" + NL + " }" + NL + " wizard.setDialogSettings(initDiagramFileSettings);" + NL + "\t\twizard.setForcePreviousAndNextButtons(false);" + NL + "\t\twizard.setWindowTitle(\"Initialize new ";
+ protected final String TEXT_5 = " diagram file\");" + NL + "" + NL + " WizardDialog dialog = new WizardDialog(myPart.getSite().getShell(), wizard);" + NL + " dialog.create();" + NL + " dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);" + NL + " dialog.open();" + NL + "\t}" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate class NewDiagramFileWizard extends Wizard {" + NL + "\t\t" + NL + "\t /**" + NL + " \t * @generated" + NL + "\t\t */" + NL + "\t\tprivate WizardNewFileCreationPage myFileCreationPage;" + NL + "\t\t" + NL + "\t /**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t\tpublic void addPages() {" + NL + "\t\t\tmyFileCreationPage = new WizardNewFileCreationPage(\"Initialize new Ecore diagram file\", mySelection);" + NL + "\t\t\tmyFileCreationPage.setFileName(mySelectedModelFile.getProjectRelativePath().removeFileExtension().addFileExtension(\"";
+ protected final String TEXT_6 = "\").lastSegment());" + NL + "\t\t\tmyFileCreationPage.setTitle(\"Diagram file\");" + NL + "\t\t\tmyFileCreationPage.setDescription(\"Create new diagram and initialize it using specified ";
+ protected final String TEXT_7 = " model content\");" + NL + "\t\t\taddPage(myFileCreationPage);" + NL + "\t\t}" + NL + "" + NL + "\t /**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t\tpublic boolean performFinish() {" + NL + "\t\t\tfinal EObject diagramModelObject = load();" + NL + "\t\t\tif (diagramModelObject == null) {" + NL + "\t\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to load user model\");" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}" + NL + "\t\t\t" + NL + "\t\t\tmyFileCreationPage.getFileName();" + NL + "\t\t\t" + NL + "\t\t\tOperationUtil.runAsUnchecked(new MRunnable() {" + NL + "" + NL + "\t\t\t\tpublic Object run() {" + NL + "\t\t\t\t\tEObject diagram = create(diagramModelObject);" + NL + "\t\t\t\t\tif (diagram == null) {" + NL + "\t\t\t\t\t\tMessageDialog.openError(getShell(), \"Error\", \"Failed to create diagram object\");" + NL + "\t\t\t\t\t\treturn null;" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\tIFile destFile = myFileCreationPage.createNewFile();" + NL + "\t\t\t\t\tsave(destFile.getLocation().toOSString(), diagram);" + NL + "\t\t\t\t\ttry {" + NL + "\t\t\t\t\t\tIDE.openEditor(myPart.getSite().getPage(), destFile);" + NL + "\t\t\t\t\t} catch (PartInitException ex) {" + NL + "\t\t\t\t\t\t";
+ protected final String TEXT_8 = ".getInstance().logError(\"Unable to open editor\", ex);" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\treturn null;" + NL + "\t\t\t\t}" + NL + "\t\t\t});" + NL + "\t\t\treturn true;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t}" + NL + "" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate EObject load() {";
+ protected final String TEXT_9 = NL + "\t\t";
+ protected final String TEXT_10 = " resourceSet = new ";
+ protected final String TEXT_11 = "();" + NL + "\t\tResource resource = resourceSet.getResource(";
+ protected final String TEXT_12 = ".createPlatformResourceURI(mySelectedModelFile.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\t";
+ protected final String TEXT_13 = ".getInstance().logError(\"Unable to load resource: \" + mySelectedModelFile.getFullPath().toString(), ex);" + NL + "\t\t}" + NL + "\t\treturn null;";
+ protected final String TEXT_14 = NL + "\t\tString resourcePath = mySelectedModelFile.getLocation().toOSString();" + NL + "\t\tResource modelResource = ResourceUtil.findResource(resourcePath);" + NL + "\t\tif (modelResource == null) {" + NL + "\t\t\tmodelResource = ResourceUtil.create(resourcePath);" + NL + "\t\t}" + NL + "\t\tif (!modelResource.isLoaded()) {" + NL + "\t\t\ttry {" + NL + "\t\t\t\tResourceUtil.load(modelResource);" + NL + "\t\t\t} catch (Exception e) {" + NL + "\t\t\t\t";
+ protected final String TEXT_15 = ".getInstance().logError(\"Unable to load resource: \" + resourcePath, e);" + NL + "\t\t\t\treturn null;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn (EObject) modelResource.getContents().get(0);";
+ protected final String TEXT_16 = 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_17 = NL + "\t\tresource.getContents().add(((Diagram) canvas).getElement());";
+ protected final String TEXT_18 = 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\t";
+ protected final String TEXT_19 = ".getInstance().logError(\"Save operation failed for: \" + filePath, ex);" + 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_20 = ".INSTANCE.getDiagramVisualID(diagramModel);" + NL + "\t\tif (diagramVID != ";
+ protected final String TEXT_21 = ") {" + NL + "\t\t\treturn null;" + NL + "\t\t}";
+ protected final String TEXT_22 = NL + "\t\tmyLinkVID2EObjectMap.put(new Integer(";
+ protected final String TEXT_23 = "), new ";
+ protected final String TEXT_24 = "());";
+ protected final String TEXT_25 = NL + "\t\tDiagram diagram = ViewService.createDiagram(diagramModel, \"";
+ protected final String TEXT_26 = "\", ";
+ protected final String TEXT_27 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\tcreate";
+ protected final String TEXT_28 = "Children(diagram, diagramModel);";
+ protected final String TEXT_29 = NL + "\t\tResource resource = diagramModel.eResource();" + NL + "\t\tint nodeVID;" + NL + "\t\tfor (Iterator it = resource.getContents().iterator(); it.hasNext();) {" + NL + "\t\t\tEObject nextResourceObject = (EObject) it.next();" + NL + "\t\t\tif (nextResourceObject == diagramModel) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}";
+ protected final String TEXT_30 = NL + "\t\t\tnodeVID = ";
+ protected final String TEXT_31 = ".INSTANCE.getNodeVisualID(diagram, nextResourceObject, \"\");" + NL + "\t\t\tif (";
+ protected final String TEXT_32 = " == nodeVID) {" + NL + "\t\t\t\t";
+ protected final String TEXT_33 = " nextNode = ViewService.createNode(diagram, nextResourceObject, null, ";
+ protected final String TEXT_34 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\tmyEObject2NodeMap.put(nextResourceObject, nextNode);" + NL + "\t\t\t\tcreate";
+ protected final String TEXT_35 = "Children(nextNode, nextResourceObject);" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}";
+ protected final String TEXT_36 = NL + "\t\t}";
+ protected final String TEXT_37 = "\t\t" + NL + "\t\tcreateLinks();" + NL + "\t\tmyLinkVID2EObjectMap.clear();" + NL + "\t\tmyEObject2NodeMap.clear();\t\t" + NL + "\t return diagram;" + NL + "\t}" + 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\tEObject nextValue;" + NL + "\t\t";
+ protected final String TEXT_42 = " nextNode;" + NL + "\t\tint nodeVID;";
+ protected final String TEXT_43 = NL + "\t\t";
+ protected final String TEXT_44 = " nextNode;";
+ protected final String TEXT_45 = NL + "\t\tfor (";
+ protected final String TEXT_46 = " values = ";
+ protected final String TEXT_47 = ".iterator(); values.hasNext();) {" + NL + "\t\t\tnextValue = (EObject) values.next();" + NL;
+ protected final String TEXT_48 = NL + "\t\tnextValue = ";
+ protected final String TEXT_49 = ";";
+ protected final String TEXT_50 = NL + "\t\tnodeVID = ";
+ protected final String TEXT_51 = ".INSTANCE.getNodeVisualID(viewObject, nextValue, \"\");" + NL + "\t\tif (";
+ protected final String TEXT_52 = " == nodeVID) {" + NL + "\t\t\tnextNode = ViewService.createNode(viewObject, nextValue, null, ";
+ protected final String TEXT_53 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\tcreate";
+ protected final String TEXT_54 = "Children(nextNode, nextValue);" + NL + "\t\t}";
+ protected final String TEXT_55 = NL + "\t\t}";
+ protected final String TEXT_56 = NL + "\t\tnextNode = getCompartment(viewObject, \"";
+ protected final String TEXT_57 = "\");" + NL + "\t\tif (nextNode != null) {" + NL + "\t\t\tcreate";
+ protected final String TEXT_58 = "Children(nextNode, modelObject);" + NL + "\t\t}";
+ protected final String TEXT_59 = NL + "\t\tstoreLinks(modelObject, viewObject.getDiagram());" + NL + "\t}";
+ protected final String TEXT_60 = NL + "\t" + NL + " /**" + NL + " * @generated" + NL + " */" + NL + "\tprivate ";
+ protected final String TEXT_61 = " getCompartment(";
+ protected final String TEXT_62 = " node, String name) {" + NL + "\t\tfor (";
+ protected final String TEXT_63 = " it = node.getChildren().iterator(); it.hasNext();) {" + NL + "\t\t\t";
+ protected final String TEXT_64 = " nextView = (";
+ protected final String TEXT_65 = ") it.next();" + NL + "\t\t\tif (nextView instanceof ";
+ protected final String TEXT_66 = " && name.equals(nextView.getType())) {" + NL + "\t\t\t\treturn (";
+ protected final String TEXT_67 = ") nextView;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}";
+ protected final String TEXT_68 = NL + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeLinks(EObject container, Diagram diagram) {" + NL + "\t\tEClass containerMetaclass = container.eClass();" + NL + "\t\tstoreFeatureModelFacetLinks(container, containerMetaclass, diagram);" + 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_69 = "\t\t" + NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
+ protected final String TEXT_70 = ".eINSTANCE.get";
+ protected final String TEXT_71 = "())) {" + NL + "\t\t\tObject featureValue = ";
+ protected final String TEXT_72 = ";";
+ protected final String TEXT_73 = "\t\t" + NL + "\t\t\tfor (";
+ protected final String TEXT_74 = " values = ((";
+ protected final String TEXT_75 = ") featureValue).iterator(); values.hasNext();) {" + NL + "\t\t\t\tEObject nextValue = ((EObject) values.next());";
+ protected final String TEXT_76 = NL + "\t\t\tEObject nextValue = (EObject) featureValue;";
+ protected final String TEXT_77 = NL + "\t\t\tint linkVID = ";
+ protected final String TEXT_78 = ".INSTANCE.getLinkWithClassVisualID(nextValue);" + NL + "\t\t\tif (";
+ protected final String TEXT_79 = " == linkVID) {" + NL + "\t\t\t\t((";
+ protected final String TEXT_80 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_81 = "))).add(nextValue);" + NL + "\t\t\t}";
+ protected final String TEXT_82 = NL + "\t\t\t}";
+ protected final String TEXT_83 = NL + "\t\t}";
+ protected final String TEXT_84 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t *@generated" + NL + "\t */" + NL + "\tprivate void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass, Diagram diagram) {";
+ protected final String TEXT_85 = NL + "\t\tif (-1 != containerMetaclass.getFeatureID(";
+ protected final String TEXT_86 = ".eINSTANCE.get";
+ protected final String TEXT_87 = "())) {" + NL + "\t\t\t((";
+ protected final String TEXT_88 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_89 = "))).add(container);";
+ protected final String TEXT_90 = NL + "\t\t\tfor (";
+ protected final String TEXT_91 = " values = ";
+ protected final String TEXT_92 = ".iterator(); values.hasNext();) {" + NL + "\t\t\t\tEObject nextValue = (EObject) values.next();";
+ protected final String TEXT_93 = NL + "\t\t\tEObject nextValue = ";
+ protected final String TEXT_94 = ";";
+ protected final String TEXT_95 = NL + "\t\t\tint nodeVID = ";
+ protected final String TEXT_96 = ".INSTANCE.getNodeVisualID(diagram, nextValue, \"\");" + NL + "\t\t\tif (";
+ protected final String TEXT_97 = " == nodeVID) {" + NL + "\t\t\t\t";
+ protected final String TEXT_98 = " nextNode = ViewService.createNode(diagram, nextValue, null, ";
+ protected final String TEXT_99 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t\tmyEObject2NodeMap.put(nextValue, nextNode);" + NL + "\t\t\t\tcreate";
+ protected final String TEXT_100 = "Children(nextNode, nextValue);" + NL + "\t\t\t}";
+ protected final String TEXT_101 = NL + "\t\t\t}";
+ protected final String TEXT_102 = NL + "\t\t}";
+ protected final String TEXT_103 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + " * @generated" + NL + " */" + NL + "\tprivate void createLinks() {";
+ protected final String TEXT_104 = NL + "\t\t";
+ protected final String TEXT_105 = " linkElements;";
+ protected final String TEXT_106 = NL + "\t\tlinkElements = (";
+ protected final String TEXT_107 = ") myLinkVID2EObjectMap.get(new Integer(";
+ protected final String TEXT_108 = "));" + NL + "\t\tfor (";
+ protected final String TEXT_109 = " it = linkElements.iterator(); it.hasNext();) {" + NL + "\t\t\tEObject linkElement = (EObject) it.next();";
+ protected final String TEXT_110 = NL + "\t\t\tObject srcResult = ";
+ protected final String TEXT_111 = ";" + NL + "\t\t\tif (srcResult instanceof EObject == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tEObject src = (EObject) srcResult;";
+ protected f