diff options
author | ashatalin | 2006-02-13 17:19:55 +0000 |
---|---|---|
committer | ashatalin | 2006-02-13 17:19:55 +0000 |
commit | 261179db3dc08ef4618d968b6a79e7dd7097e115 (patch) | |
tree | 9dc34796526693713a2bbe7772353dc730c0adf3 /plugins | |
parent | ecbc345c467e4ae99fecad96bb95cfd80f082ad4 (diff) | |
download | org.eclipse.gmf-tooling-261179db3dc08ef4618d968b6a79e7dd7097e115.tar.gz org.eclipse.gmf-tooling-261179db3dc08ef4618d968b6a79e7dd7097e115.tar.xz org.eclipse.gmf-tooling-261179db3dc08ef4618d968b6a79e7dd7097e115.zip |
#127497 Creating diagram file by InitDiagramFileAction in arbitrary location
+ correcting the case of OCL-related classes
Diffstat (limited to 'plugins')
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 final String TEXT_112 = NL + "\t\t\tEObject src = linkElement.eContainer();"; + protected final String TEXT_113 = NL + "\t\t\tEObject src = linkElement;"; + protected final String TEXT_114 = NL + "\t\t\t"; + protected final String TEXT_115 = " srcNode = ("; + protected final String TEXT_116 = ") 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_117 = ";"; + protected final String TEXT_118 = 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_119 = NL + "\t\t\tif (structuralFeatureResult instanceof "; + protected final String TEXT_120 = " == false) {" + NL + "\t\t\t\tcontinue;" + NL + "\t\t\t}" + NL + "\t\t\tfor ("; + protected final String TEXT_121 = " destinations = (("; + protected final String TEXT_122 = ") structuralFeatureResult).iterator(); destinations.hasNext();) {" + NL + "\t\t\t\tEObject dst = (EObject) destinations.next();"; + protected final String TEXT_123 = 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_124 = NL + "\t\t\t"; + protected final String TEXT_125 = " dstNode = ("; + protected final String TEXT_126 = ") myEObject2NodeMap.get(dst);" + NL + "\t\t\tif (dstNode != null) {"; + protected final String TEXT_127 = NL + "\t\t\t\tViewService.createEdge(srcNode, dstNode, linkElement, null, "; + protected final String TEXT_128 = ".DIAGRAM_PREFERENCES_HINT);" + NL + "\t\t\t}"; + protected final String TEXT_129 = NL + "\t\t\t\t\t"; + protected final String TEXT_130 = " edge = ("; + protected final String TEXT_131 = ") ViewService.getInstance().createEdge(new "; + protected final String TEXT_132 = "() {" + NL + "\t\t\t\t\t\tpublic Object getAdapter(Class adapter) {" + NL + "\t\t\t\t\t\t\tif ("; + protected final String TEXT_133 = ".class.equals(adapter)) {" + NL + "\t\t\t\t\t\t\t\treturn "; + protected final String TEXT_134 = "."; + protected final String TEXT_135 = ";" + 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_136 = ".APPEND, "; + protected final String TEXT_137 = ".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_138 = NL + "\t\t\t\t}"; + protected final String TEXT_139 = NL + "\t\t\t}"; + protected final String TEXT_140 = NL + "\t\t}"; + protected final String TEXT_141 = NL + "\t}" + NL + "\t" + NL + "}"; + protected final String TEXT_142 = NL; protected final String getFeatureValueGetter(String containerName, GenFeature feature, boolean isContainerEObject, ImportAssistant importManager) { StringBuffer result = new StringBuffer(); @@ -297,16 +301,20 @@ 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.jface.viewers.StructuredSelection"); 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.addImport("org.eclipse.gmf.runtime.diagram.core.services.ViewService"); +importManager.addImport("org.eclipse.jface.dialogs.IDialogSettings"); +importManager.addImport("org.eclipse.jface.wizard.WizardDialog"); +importManager.addImport("org.eclipse.jface.wizard.Wizard"); +importManager.addImport("org.eclipse.ui.dialogs.WizardNewFileCreationPage"); importManager.markImportLocation(stringBuffer); @@ -315,99 +323,107 @@ importManager.markImportLocation(stringBuffer); stringBuffer.append(TEXT_3); stringBuffer.append(pluginActivatorClass); stringBuffer.append(TEXT_4); - if (editorGen.isSameFileForDiagramAndModel()) { + stringBuffer.append(genDiagram.getEditorGen().getModelID()); stringBuffer.append(TEXT_5); - stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet")); + stringBuffer.append(editorGen.getDiagramFileExtension()); stringBuffer.append(TEXT_6); - stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl")); + stringBuffer.append(genDiagram.getEditorGen().getModelID()); stringBuffer.append(TEXT_7); - stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.util.URI")); - stringBuffer.append(TEXT_8); stringBuffer.append(pluginActivatorClass); + stringBuffer.append(TEXT_8); + if (editorGen.isSameFileForDiagramAndModel()) { stringBuffer.append(TEXT_9); - } else { + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet")); stringBuffer.append(TEXT_10); - stringBuffer.append(pluginActivatorClass); + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl")); stringBuffer.append(TEXT_11); - } + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.util.URI")); stringBuffer.append(TEXT_12); - if (editorGen.isSameFileForDiagramAndModel()) { + stringBuffer.append(pluginActivatorClass); stringBuffer.append(TEXT_13); - } + } else { stringBuffer.append(TEXT_14); stringBuffer.append(pluginActivatorClass); stringBuffer.append(TEXT_15); - stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); + } stringBuffer.append(TEXT_16); - stringBuffer.append(genDiagram.getVisualID()); + if (editorGen.isSameFileForDiagramAndModel()) { stringBuffer.append(TEXT_17); + } + stringBuffer.append(TEXT_18); + stringBuffer.append(pluginActivatorClass); + stringBuffer.append(TEXT_19); + stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); + stringBuffer.append(TEXT_20); + stringBuffer.append(genDiagram.getVisualID()); + stringBuffer.append(TEXT_21); for (Iterator it = genLinks.iterator(); it.hasNext();) { GenLink nextLink = (GenLink) it.next(); - stringBuffer.append(TEXT_18); + stringBuffer.append(TEXT_22); stringBuffer.append(nextLink.getVisualID()); - stringBuffer.append(TEXT_19); + stringBuffer.append(TEXT_23); stringBuffer.append(importManager.getImportedName("java.util.LinkedList")); - stringBuffer.append(TEXT_20); + stringBuffer.append(TEXT_24); } - stringBuffer.append(TEXT_21); + stringBuffer.append(TEXT_25); stringBuffer.append(modelID); - stringBuffer.append(TEXT_22); + stringBuffer.append(TEXT_26); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_23); + stringBuffer.append(TEXT_27); stringBuffer.append(genDiagram.getUniqueIdentifier()); - stringBuffer.append(TEXT_24); + stringBuffer.append(TEXT_28); if (!genClass2Phantom.isEmpty()) { - stringBuffer.append(TEXT_25); + stringBuffer.append(TEXT_29); for (Iterator phantoms = genClass2Phantom.values().iterator(); phantoms.hasNext();) { GenTopLevelNode phantomNode = (GenTopLevelNode) phantoms.next(); - stringBuffer.append(TEXT_26); + stringBuffer.append(TEXT_30); stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); - stringBuffer.append(TEXT_27); + stringBuffer.append(TEXT_31); stringBuffer.append(phantomNode.getVisualID()); - stringBuffer.append(TEXT_28); + stringBuffer.append(TEXT_32); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_29); + stringBuffer.append(TEXT_33); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_30); + stringBuffer.append(TEXT_34); stringBuffer.append(phantomNode.getUniqueIdentifier()); - stringBuffer.append(TEXT_31); + stringBuffer.append(TEXT_35); } - stringBuffer.append(TEXT_32); + stringBuffer.append(TEXT_36); } - stringBuffer.append(TEXT_33); + stringBuffer.append(TEXT_37); for (Iterator containers = genDiagram.getAllContainers().iterator(); containers.hasNext();) { GenContainerBase nextContainer = (GenContainerBase) containers.next(); - stringBuffer.append(TEXT_34); + stringBuffer.append(TEXT_38); stringBuffer.append(nextContainer.getUniqueIdentifier()); - stringBuffer.append(TEXT_35); + stringBuffer.append(TEXT_39); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")); - stringBuffer.append(TEXT_36); + stringBuffer.append(TEXT_40); if (nextContainer.getContainedNodes().size() > 0) { - stringBuffer.append(TEXT_37); + stringBuffer.append(TEXT_41); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_38); + stringBuffer.append(TEXT_42); } else if (nextContainer instanceof GenNode && ((GenNode) nextContainer).getCompartments().size() > 0) { - stringBuffer.append(TEXT_39); + stringBuffer.append(TEXT_43); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_40); + stringBuffer.append(TEXT_44); } @@ -421,33 +437,33 @@ for (Iterator containers = genDiagram.getAllContainers().iterator(); containers. GenFeature childMetaFeature = typeModelFacet.getChildMetaFeature(); if (childMetaFeature.isListType()) { - stringBuffer.append(TEXT_41); + stringBuffer.append(TEXT_45); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_42); + stringBuffer.append(TEXT_46); stringBuffer.append(getFeatureValueGetter("modelObject", childMetaFeature, true, importManager)); - stringBuffer.append(TEXT_43); + stringBuffer.append(TEXT_47); } else { - stringBuffer.append(TEXT_44); + stringBuffer.append(TEXT_48); stringBuffer.append(getFeatureValueGetter("modelObject", childMetaFeature, true, importManager)); - stringBuffer.append(TEXT_45); + stringBuffer.append(TEXT_49); } - stringBuffer.append(TEXT_46); + stringBuffer.append(TEXT_50); stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); - stringBuffer.append(TEXT_47); + stringBuffer.append(TEXT_51); stringBuffer.append(nextChild.getVisualID()); - stringBuffer.append(TEXT_48); + stringBuffer.append(TEXT_52); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_49); + stringBuffer.append(TEXT_53); stringBuffer.append(nextChild.getUniqueIdentifier()); - stringBuffer.append(TEXT_50); + stringBuffer.append(TEXT_54); if (childMetaFeature.isListType()) { - stringBuffer.append(TEXT_51); + stringBuffer.append(TEXT_55); } } @@ -458,40 +474,40 @@ for (Iterator containers = genDiagram.getAllContainers().iterator(); containers. GenCompartment nextCompartment = (GenCompartment) compartments.next(); generateGetCompartment = true; - stringBuffer.append(TEXT_52); + stringBuffer.append(TEXT_56); stringBuffer.append(nextCompartment.getTitle()); - stringBuffer.append(TEXT_53); + stringBuffer.append(TEXT_57); stringBuffer.append(nextCompartment.getUniqueIdentifier()); - stringBuffer.append(TEXT_54); + stringBuffer.append(TEXT_58); } } - stringBuffer.append(TEXT_55); + stringBuffer.append(TEXT_59); } if (generateGetCompartment) { - stringBuffer.append(TEXT_56); + stringBuffer.append(TEXT_60); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_57); + stringBuffer.append(TEXT_61); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")); - stringBuffer.append(TEXT_58); + stringBuffer.append(TEXT_62); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_59); + stringBuffer.append(TEXT_63); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")); - stringBuffer.append(TEXT_60); + stringBuffer.append(TEXT_64); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")); - stringBuffer.append(TEXT_61); + stringBuffer.append(TEXT_65); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_62); + stringBuffer.append(TEXT_66); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_63); + stringBuffer.append(TEXT_67); } - stringBuffer.append(TEXT_64); + stringBuffer.append(TEXT_68); for (Iterator it = genLinks.iterator(); it.hasNext();) { GenLink nextLink = (GenLink) it.next(); @@ -499,50 +515,50 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) { TypeLinkModelFacet typeLinkModelFacet = (TypeLinkModelFacet) nextLink.getModelFacet(); GenFeature childMetaFeature = typeLinkModelFacet.getChildMetaFeature(); - stringBuffer.append(TEXT_65); + stringBuffer.append(TEXT_69); stringBuffer.append(importManager.getImportedName(childMetaFeature.getGenPackage().getQualifiedPackageInterfaceName())); - stringBuffer.append(TEXT_66); + stringBuffer.append(TEXT_70); stringBuffer.append(childMetaFeature.getFeatureAccessorName()); - stringBuffer.append(TEXT_67); + stringBuffer.append(TEXT_71); stringBuffer.append(getFeatureValueGetter("container", childMetaFeature, true, importManager)); - stringBuffer.append(TEXT_68); + stringBuffer.append(TEXT_72); if (childMetaFeature.isListType()) { - stringBuffer.append(TEXT_69); + stringBuffer.append(TEXT_73); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_70); + stringBuffer.append(TEXT_74); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_71); + stringBuffer.append(TEXT_75); } else { - stringBuffer.append(TEXT_72); + stringBuffer.append(TEXT_76); } - stringBuffer.append(TEXT_73); + stringBuffer.append(TEXT_77); stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); - stringBuffer.append(TEXT_74); + stringBuffer.append(TEXT_78); stringBuffer.append(nextLink.getVisualID()); - stringBuffer.append(TEXT_75); + stringBuffer.append(TEXT_79); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_76); + stringBuffer.append(TEXT_80); stringBuffer.append(nextLink.getVisualID()); - stringBuffer.append(TEXT_77); + stringBuffer.append(TEXT_81); if (childMetaFeature.isListType()) { - stringBuffer.append(TEXT_78); + stringBuffer.append(TEXT_82); } - stringBuffer.append(TEXT_79); + stringBuffer.append(TEXT_83); } } - stringBuffer.append(TEXT_80); + stringBuffer.append(TEXT_84); for (Iterator it = genLinks.iterator(); it.hasNext();) { GenLink nextLink = (GenLink) it.next(); @@ -550,15 +566,15 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) { FeatureModelFacet linkFMF = (FeatureModelFacet) nextLink.getModelFacet(); GenFeature genFeature = linkFMF.getMetaFeature(); - stringBuffer.append(TEXT_81); + stringBuffer.append(TEXT_85); stringBuffer.append(importManager.getImportedName(genFeature.getGenPackage().getQualifiedPackageInterfaceName())); - stringBuffer.append(TEXT_82); + stringBuffer.append(TEXT_86); stringBuffer.append(genFeature.getFeatureAccessorName()); - stringBuffer.append(TEXT_83); + stringBuffer.append(TEXT_87); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_84); + stringBuffer.append(TEXT_88); stringBuffer.append(nextLink.getVisualID()); - stringBuffer.append(TEXT_85); + stringBuffer.append(TEXT_89); if (genFeature.isContains()) { // Processing phantom elements @@ -567,52 +583,52 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) { if (phantomNode != null) { if (genFeature.isListType()) { - stringBuffer.append(TEXT_86); + stringBuffer.append(TEXT_90); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_87); + stringBuffer.append(TEXT_91); stringBuffer.append(getFeatureValueGetter("container", genFeature, true, importManager)); - stringBuffer.append(TEXT_88); + stringBuffer.append(TEXT_92); } else { - stringBuffer.append(TEXT_89); + stringBuffer.append(TEXT_93); stringBuffer.append(getFeatureValueGetter("container", genFeature, true, importManager)); - stringBuffer.append(TEXT_90); + stringBuffer.append(TEXT_94); } - stringBuffer.append(TEXT_91); + stringBuffer.append(TEXT_95); stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())); - stringBuffer.append(TEXT_92); + stringBuffer.append(TEXT_96); stringBuffer.append(phantomNode.getVisualID()); - stringBuffer.append(TEXT_93); + stringBuffer.append(TEXT_97); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_94); + stringBuffer.append(TEXT_98); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_95); + stringBuffer.append(TEXT_99); stringBuffer.append(phantomNode.getUniqueIdentifier()); - stringBuffer.append(TEXT_96); + stringBuffer.append(TEXT_100); if (genFeature.isListType()) { - stringBuffer.append(TEXT_97); + stringBuffer.append(TEXT_101); } } } - stringBuffer.append(TEXT_98); + stringBuffer.append(TEXT_102); } } - stringBuffer.append(TEXT_99); + stringBuffer.append(TEXT_103); if (genLinks.size() > 0) { - stringBuffer.append(TEXT_100); + stringBuffer.append(TEXT_104); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_101); + stringBuffer.append(TEXT_105); } @@ -620,114 +636,114 @@ for (Iterator it = genLinks.iterator(); it.hasNext();) { GenLink nextLink = (GenLink) it.next(); GenFeature domainLinkTargetGenFeature; - stringBuffer.append(TEXT_102); + stringBuffer.append(TEXT_106); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_103); + stringBuffer.append(TEXT_107); stringBuffer.append(nextLink.getVisualID()); - stringBuffer.append(TEXT_104); + stringBuffer.append(TEXT_108); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_105); + stringBuffer.append(TEXT_109); if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) { TypeLinkModelFacet typeLinkModelFacet = (TypeLinkModelFacet) nextLink.getModelFacet(); domainLinkTargetGenFeature = typeLinkModelFacet.getTargetMetaFeature(); if (typeLinkModelFacet.getSourceMetaFeature() != null) { - stringBuffer.append(TEXT_106); + stringBuffer.append(TEXT_110); stringBuffer.append(getFeatureValueGetter("linkElement", typeLinkModelFacet.getSourceMetaFeature(), true, importManager)); - stringBuffer.append(TEXT_107); + stringBuffer.append(TEXT_111); } else { - stringBuffer.append(TEXT_108); + stringBuffer.append(TEXT_112); } } else { domainLinkTargetGenFeature = ((FeatureModelFacet) nextLink.getModelFacet()).getMetaFeature(); - stringBuffer.append(TEXT_109); + stringBuffer.append(TEXT_113); } - stringBuffer.append(TEXT_110); + stringBuffer.append(TEXT_114); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_111); + stringBuffer.append(TEXT_115); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_112); + stringBuffer.append(TEXT_116); stringBuffer.append(getFeatureValueGetter("linkElement", domainLinkTargetGenFeature, true, importManager)); - stringBuffer.append(TEXT_113); + stringBuffer.append(TEXT_117); if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) { - stringBuffer.append(TEXT_114); + stringBuffer.append(TEXT_118); } else { if (domainLinkTargetGenFeature.isListType()) { - stringBuffer.append(TEXT_115); + stringBuffer.append(TEXT_119); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_116); + stringBuffer.append(TEXT_120); stringBuffer.append(importManager.getImportedName("java.util.Iterator")); - stringBuffer.append(TEXT_117); + stringBuffer.append(TEXT_121); stringBuffer.append(importManager.getImportedName("java.util.Collection")); - stringBuffer.append(TEXT_118); + stringBuffer.append(TEXT_122); } else { - stringBuffer.append(TEXT_119); + stringBuffer.append(TEXT_123); } } - stringBuffer.append(TEXT_120); + stringBuffer.append(TEXT_124); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_121); + stringBuffer.append(TEXT_125); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")); - stringBuffer.append(TEXT_122); + stringBuffer.append(TEXT_126); if (nextLink.getModelFacet() instanceof TypeLinkModelFacet) { - stringBuffer.append(TEXT_123); + stringBuffer.append(TEXT_127); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_124); + stringBuffer.append(TEXT_128); } else { - stringBuffer.append(TEXT_125); + stringBuffer.append(TEXT_129); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Edge")); - stringBuffer.append(TEXT_126); + stringBuffer.append(TEXT_130); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Edge")); - stringBuffer.append(TEXT_127); + stringBuffer.append(TEXT_131); stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IAdaptable")); - stringBuffer.append(TEXT_128); + stringBuffer.append(TEXT_132); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.emf.type.core.IElementType")); - stringBuffer.append(TEXT_129); + stringBuffer.append(TEXT_133); stringBuffer.append(importManager.getImportedName(genDiagram.getElementTypesQualifiedClassName())); - stringBuffer.append(TEXT_130); + stringBuffer.append(TEXT_134); stringBuffer.append(nextLink.getUniqueIdentifier()); - stringBuffer.append(TEXT_131); + stringBuffer.append(TEXT_135); stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil")); - stringBuffer.append(TEXT_132); + stringBuffer.append(TEXT_136); stringBuffer.append(pluginActivatorClass); - stringBuffer.append(TEXT_133); + stringBuffer.append(TEXT_137); if (domainLinkTargetGenFeature.isListType()) { - stringBuffer.append(TEXT_134); + stringBuffer.append(TEXT_138); } - stringBuffer.append(TEXT_135); + stringBuffer.append(TEXT_139); } - stringBuffer.append(TEXT_136); + stringBuffer.append(TEXT_140); } - stringBuffer.append(TEXT_137); + stringBuffer.append(TEXT_141); importManager.emitSortedImports(); - stringBuffer.append(TEXT_138); + stringBuffer.append(TEXT_142); return stringBuffer.toString(); } }
\ No newline at end of file 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 4368cdff1..ea81d71f6 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 @@ -115,9 +115,10 @@ public class VisualIDRegistryGenerator protected final String TEXT_97 = NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate ElementSelectors() {" + NL + "\t\t}"; protected final String TEXT_98 = "\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_99 = " 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"; - protected final String TEXT_100 = ".getInstance().logError(null, e);" + 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_101 = "\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_102 = NL; + protected final String TEXT_100 = ".getInstance().logError(null, e);" + 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 "; + protected final String TEXT_101 = "(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_102 = "\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_103 = NL; public String generate(Object argument) { @@ -462,14 +463,16 @@ for (Iterator it = genDiagram.eAllContents(); it.hasNext();) { stringBuffer.append(TEXT_97); if(selectorCounter > 0) { stringBuffer.append(TEXT_98); - stringBuffer.append(importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OclConstraintCondition")); + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OCLConstraintCondition")); stringBuffer.append(TEXT_99); stringBuffer.append(importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName())); stringBuffer.append(TEXT_100); - } + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OCLConstraintCondition")); stringBuffer.append(TEXT_101); - importManager.emitSortedImports(); + } stringBuffer.append(TEXT_102); + importManager.emitSortedImports(); + stringBuffer.append(TEXT_103); return stringBuffer.toString(); } } diff --git a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/policies/ItemSemanticEditPolicyGenerator.java b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/policies/ItemSemanticEditPolicyGenerator.java index ecde031bf..6fca6b087 100644 --- a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/policies/ItemSemanticEditPolicyGenerator.java +++ b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/policies/ItemSemanticEditPolicyGenerator.java @@ -223,7 +223,7 @@ if(diagram.hasLinkCreationConstraints()) { stringBuffer.append(TEXT_22); stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ocl.expressions.VariableDeclaration")); stringBuffer.append(TEXT_23); - stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ocl.helper.IOclHelper")); + stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ocl.helper.IOCLHelper")); stringBuffer.append(TEXT_24); stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ocl.helper.HelperUtil")); stringBuffer.append(TEXT_25); diff --git a/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet b/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet index dec5ea566..7c63916cc 100644 --- a/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet +++ b/plugins/org.eclipse.gmf.codegen/templates/editor/InitDiagramFileAction.javajet @@ -43,16 +43,20 @@ 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.jface.viewers.StructuredSelection"); 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.addImport("org.eclipse.gmf.runtime.diagram.core.services.ViewService"); +importManager.addImport("org.eclipse.jface.dialogs.IDialogSettings"); +importManager.addImport("org.eclipse.jface.wizard.WizardDialog"); +importManager.addImport("org.eclipse.jface.wizard.Wizard"); +importManager.addImport("org.eclipse.ui.dialogs.WizardNewFileCreationPage"); importManager.markImportLocation(stringBuffer); %> @@ -70,7 +74,12 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj /** * @generated */ - private IFile mySelection; + private IFile mySelectedModelFile; + + /** + * @generated + */ + private IStructuredSelection mySelection; /** * @generated @@ -100,12 +109,14 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj * @generated */ public void selectionChanged(IAction action, ISelection selection) { - mySelection = null; + mySelectedModelFile = null; + mySelection = StructuredSelection.EMPTY; action.setEnabled(false); if (selection instanceof IStructuredSelection == false || selection.isEmpty()) { return; } - mySelection = (IFile) ((IStructuredSelection) selection).getFirstElement(); + mySelection = (IStructuredSelection) selection; + mySelectedModelFile = (IFile) ((IStructuredSelection) selection).getFirstElement(); action.setEnabled(true); } @@ -117,7 +128,7 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj if (!status.isOK()) { return status.getMessage(); } - if (mySelection.getParent().getFile(new Path(newText).addFileExtension("editorGen.getDiagramFileExtension()")).exists()) { + if (mySelectedModelFile.getParent().getFile(new Path(newText).addFileExtension("editorGen.getDiagramFileExtension()")).exists()) { return "File already exists, choose another name"; } return null; @@ -127,50 +138,94 @@ public class <%=genDiagram.getInitDiagramFileActionClassName()%> implements IObj * @generated */ public void run(IAction action) { - final InputDialog outputFileNameDialog = new InputDialog(getShell(), "Diagram file name", "Please provide diagram file name", mySelection.getProjectRelativePath().removeFileExtension().addFileExtension("editorGen.getDiagramFileExtension()").lastSegment(), this); - if (outputFileNameDialog.open() != InputDialog.OK) { - return; - } - final EObject diagramModelObject = load(); - if (diagramModelObject == null) { - MessageDialog.openError(getShell(), "Error", "Failed to load user model"); - return; + NewDiagramFileWizard wizard = new NewDiagramFileWizard(); + IDialogSettings pluginDialogSettings = <%=pluginActivatorClass%>.getInstance().getDialogSettings(); + IDialogSettings initDiagramFileSettings = pluginDialogSettings.getSection("InisDiagramFile"); //$NON-NLS-1$ + if (initDiagramFileSettings == null) { + initDiagramFileSettings = pluginDialogSettings.addNewSection("InisDiagramFile"); //$NON-NLS-1$ + } + wizard.setDialogSettings(initDiagramFileSettings); + wizard.setForcePreviousAndNextButtons(false); + wizard.setWindowTitle("Initialize new <%=genDiagram.getEditorGen().getModelID()%> diagram file"); + + WizardDialog dialog = new WizardDialog(myPart.getSite().getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500); + dialog.open(); + } + + /** + * @generated + */ + private class NewDiagramFileWizard extends Wizard { + + /** + * @generated + */ + private WizardNewFileCreationPage myFileCreationPage; + + /** + * @generated + */ + public void addPages() { + myFileCreationPage = new WizardNewFileCreationPage("Initialize new Ecore diagram file", mySelection); + myFileCreationPage.setFileName(mySelectedModelFile.getProjectRelativePath().removeFileExtension().addFileExtension("<%=editorGen.getDiagramFileExtension()%>").lastSegment()); + myFileCreationPage.setTitle("Diagram file"); + myFileCreationPage.setDescription("Create new diagram and initialize it using specified <%=genDiagram.getEditorGen().getModelID()%> model content"); + addPage(myFileCreationPage); } - OperationUtil.runAsUnchecked(new MRunnable() { - public Object run() { - EObject diagram = create(diagramModelObject); - if (diagram == null) { - MessageDialog.openError(getShell(), "Error", "Failed to create diagram object"); + + /** + * @generated + */ + public boolean performFinish() { + final EObject diagramModelObject = load(); + if (diagramModelObject == null) { + MessageDialog.openError(getShell(), "Error", "Failed to load user model"); + return false; + } + + myFileCreationPage.getFileName(); + + OperationUtil.runAsUnchecked(new MRunnable() { + + public Object run() { + EObject diagram = create(diagramModelObject); + if (diagram == null) { + MessageDialog.openError(getShell(), "Error", "Failed to create diagram object"); + return null; + } + IFile destFile = myFileCreationPage.createNewFile(); + save(destFile.getLocation().toOSString(), diagram); + try { + IDE.openEditor(myPart.getSite().getPage(), destFile); + } catch (PartInitException ex) { + <%=pluginActivatorClass%>.getInstance().logError("Unable to open editor", ex); + } return null; } - IFile destFile = mySelection.getParent().getFile(new Path(outputFileNameDialog.getValue())); - save(destFile.getLocation().toOSString(), diagram); - try { - IDE.openEditor(myPart.getSite().getPage(), destFile); - } catch (PartInitException ex) { - <%=pluginActivatorClass%>.getInstance().logError("Unable to open editor", ex); - } - return null; - } - }); + }); + return true; + } + } - + /** * @generated */ private EObject load() { <%if (editorGen.isSameFileForDiagramAndModel()) {%> <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet")%> resourceSet = new <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl")%>(); - Resource resource = resourceSet.getResource(<%=importManager.getImportedName("org.eclipse.emf.common.util.URI")%>.createPlatformResourceURI(mySelection.getFullPath().toString()), true); + Resource resource = resourceSet.getResource(<%=importManager.getImportedName("org.eclipse.emf.common.util.URI")%>.createPlatformResourceURI(mySelectedModelFile.getFullPath().toString()), true); try { resource.load(Collections.EMPTY_MAP); return (EObject) resource.getContents().get(0); } catch (IOException ex) { - <%=pluginActivatorClass%>.getInstance().logError("Unable to load resource: " + mySelection.getFullPath().toString(), ex); + <%=pluginActivatorClass%>.getInstance().logError("Unable to load resource: " + mySelectedModelFile.getFullPath().toString(), ex); } return null; <%} else {%> - String resourcePath = mySelection.getLocation().toOSString(); + String resourcePath = mySelectedModelFile.getLocation().toOSString(); Resource modelResource = ResourceUtil.findResource(resourcePath); if (modelResource == null) { modelResource = ResourceUtil.create(resourcePath); diff --git a/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet b/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet index 9c4dfca84..8b527ae40 100644 --- a/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet +++ b/plugins/org.eclipse.gmf.codegen/templates/editor/VisualIDRegistry.javajet @@ -428,7 +428,7 @@ for (Iterator it = genDiagram.eAllContents(); it.hasNext();) { /** * @generated */ - private <%=importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OclConstraintCondition")%> condition; + private <%=importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OCLConstraintCondition")%> condition; /** * @generated @@ -461,7 +461,7 @@ for (Iterator it = genDiagram.eAllContents(); it.hasNext();) { private Boolean evaluate(EObject context) { this.evalContext = context.eClass(); if(condition == null) { - condition = new OclConstraintCondition(body, evalContext); + condition = new <%=importManager.getImportedName("org.eclipse.emf.query.ocl.conditions.OCLConstraintCondition")%>(body, evalContext); } if(condition != null) { return booleanCast(condition.evaluate(context)); diff --git a/plugins/org.eclipse.gmf.codegen/templates/policies/ItemSemanticEditPolicy.javajet b/plugins/org.eclipse.gmf.codegen/templates/policies/ItemSemanticEditPolicy.javajet index 90e25e120..fdd0ff5bd 100644 --- a/plugins/org.eclipse.gmf.codegen/templates/policies/ItemSemanticEditPolicy.javajet +++ b/plugins/org.eclipse.gmf.codegen/templates/policies/ItemSemanticEditPolicy.javajet @@ -298,7 +298,7 @@ if(diagram.hasLinkCreationConstraints()) { private Query createQuery(LinkEndConstraint constraint, <%=importManager.getImportedName("org.eclipse.emf.ocl.expressions.VariableDeclaration")%> oppositeEndDecl) { final <%=importManager.getImportedName("org.eclipse.emf.ocl.expressions.VariableDeclaration")%> oppositeEndDeclLocal = oppositeEndDecl; try { - <%=importManager.getImportedName("org.eclipse.emf.ocl.helper.IOclHelper")%> oclHelper = + <%=importManager.getImportedName("org.eclipse.emf.ocl.helper.IOCLHelper")%> oclHelper = <%=importManager.getImportedName("org.eclipse.emf.ocl.helper.HelperUtil")%>.createOclHelper(new <%=importManager.getImportedName("org.eclipse.emf.ocl.parser.EcoreEnvironmentFactory")%>() { public <%=importManager.getImportedName("org.eclipse.emf.ocl.parser.Environment")%> createClassifierContext(Object context) { <%=importManager.getImportedName("org.eclipse.emf.ocl.parser.Environment")%> env = super.createClassifierContext(context); |