Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2017-03-21 10:54:02 -0400
committerGerrit Code Review @ Eclipse.org2017-04-14 05:47:41 -0400
commit4cb2981a4c989a031eb145291a8d7faf66308f56 (patch)
tree015ff8f602db273ca13db1f29418e828ad4b9b27 /plugins/developer
parent8ca14a59e728ebc6c36e80b1b95efac0bb2cd6e1 (diff)
downloadorg.eclipse.papyrus-4cb2981a4c989a031eb145291a8d7faf66308f56.tar.gz
org.eclipse.papyrus-4cb2981a4c989a031eb145291a8d7faf66308f56.tar.xz
org.eclipse.papyrus-4cb2981a4c989a031eb145291a8d7faf66308f56.zip
Bug 512343 - [Palette] Papyrus Palette framework should be refactored
Change-Id: I4170f878f144bc9e47ed21f1f3beaeb53911a887 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/developer')
-rw-r--r--plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusCodegenEmitters.java22
-rw-r--r--plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusExecuteTemplatesOperation.java6
-rw-r--r--plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusGenerator.java93
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF4
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend21
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/PaletteConfiguration.xtend113
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/Utils_qvto.xtend259
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorLabelProvider.xtend4
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/plugin/plugin.xtend38
-rwxr-xr-xplugins/developer/org.eclipse.papyrus.releng.main.release/release.digestbin29666 -> 29670 bytes
-rwxr-xr-xplugins/developer/org.eclipse.papyrus.releng.main.release/release.xml11
11 files changed, 481 insertions, 90 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusCodegenEmitters.java b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusCodegenEmitters.java
index fa080f800e6..fa7a713d06f 100644
--- a/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusCodegenEmitters.java
+++ b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusCodegenEmitters.java
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2008 Atos Origin.
+ * Copyright (c) 2008, 2017 Atos Origin, CEA, ALL4TEC.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Thibault Landre (Atos Origin) - Initial API and implementation
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 510587: the palette must not be generated by using GMF gen
*
*****************************************************************************/
package org.eclipse.papyrus.codegen;
@@ -15,6 +16,7 @@ package org.eclipse.papyrus.codegen;
import org.eclipse.gmf.codegen.xtend.ui.handlers.CodegenEmittersWithXtend2;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.internal.common.codegen.JavaClassEmitter;
+import org.eclipse.gmf.internal.common.codegen.TextEmitter;
@SuppressWarnings("restriction")
public class PapyrusCodegenEmitters extends CodegenEmittersWithXtend2 {
@@ -93,4 +95,22 @@ public class PapyrusCodegenEmitters extends CodegenEmittersWithXtend2 {
public JavaClassEmitter getLinkItemSemanticEditPolicyEmitter() {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ * Overridden to disable code generation of old palette framework.
+ *
+ * @see org.eclipse.gmf.codegen.util.CodegenEmitters#getPaletteEmitter()
+ */
+ @Override
+ public JavaClassEmitter getPaletteEmitter() throws UnexpectedBehaviourException {
+ return null;
+ }
+
+ /**
+ * Get the {@link TextEmitter} to generate palette configuration model for papyrus diagrams.
+ */
+ public TextEmitter getPaletteConfigurationEmitter() {
+ return createJavaClassEmitter("aspects::xpt::editor::palette::PaletteConfiguration", "PaletteConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
diff --git a/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusExecuteTemplatesOperation.java b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusExecuteTemplatesOperation.java
index de6a145fcdd..f898635b67e 100644
--- a/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusExecuteTemplatesOperation.java
+++ b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusExecuteTemplatesOperation.java
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2008 Atos Origin.
+ * Copyright (c) 2008, 2017 Atos Origin, CEA, ALL4TEC and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,13 +8,13 @@
*
* Contributors:
* Thibault Landre (Atos Origin) - Initial API and implementation
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 510587: the palette must not be generated by using GMF gen
*
*****************************************************************************/
package org.eclipse.papyrus.codegen;
import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
import org.eclipse.gmf.codegen.util.Generator;
-import org.eclipse.gmf.codegen.xtend.ui.handlers.GeneratorWithXtend2;
import org.eclipse.gmf.internal.codegen.popup.actions.ExecuteTemplatesOperation;
/**
@@ -31,7 +31,7 @@ public class PapyrusExecuteTemplatesOperation extends ExecuteTemplatesOperation
@Override
protected Generator createGenerator() {
GenEditorGenerator genModel = getGenModel();
- return new GeneratorWithXtend2(genModel, new PapyrusCodegenEmitters(!genModel.isDynamicTemplates(), genModel.getTemplateDirectory(), genModel.getModelAccess() != null));
+ return new PapyrusGenerator(genModel, new PapyrusCodegenEmitters(!genModel.isDynamicTemplates(), genModel.getTemplateDirectory(), genModel.getModelAccess() != null));
}
}
diff --git a/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusGenerator.java b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusGenerator.java
new file mode 100644
index 00000000000..0ad66e9e136
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.codegen/src/org/eclipse/papyrus/codegen/PapyrusGenerator.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST,ALL4TEC and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.codegen;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.xtend.ui.handlers.GeneratorWithXtend2;
+import org.eclipse.gmf.common.UnexpectedBehaviourException;
+
+/**
+ * Papyrus gmf generator.
+ */
+public class PapyrusGenerator extends GeneratorWithXtend2 {
+
+ /**
+ * The Papyrus codegen Emitters.
+ */
+ private final PapyrusCodegenEmitters emitters;
+
+ /**
+ * The editor gen model.
+ */
+ private GenEditorGenerator editorGen;
+
+ /**
+ * Constructor.
+ */
+ public PapyrusGenerator(final GenEditorGenerator genModel, final PapyrusCodegenEmitters codegenEmitters) {
+ super(genModel, codegenEmitters);
+ editorGen = genModel;
+ emitters = codegenEmitters;
+ }
+
+ /**
+ * @see org.eclipse.gmf.codegen.xtend.ui.handlers.GeneratorWithXtend2#customRun()
+ *
+ * @throws InterruptedException
+ * @throws UnexpectedBehaviourException
+ */
+ @Override
+ protected void customRun() throws InterruptedException, UnexpectedBehaviourException {
+ super.customRun();
+ generatePaletteConfiguration();
+ }
+
+ /**
+ * Generate palette configuration model.
+ *
+ * @throws UnexpectedBehaviourException
+ * @throws InterruptedException
+ */
+ @SuppressWarnings("restriction")
+ protected void generatePaletteConfiguration() throws UnexpectedBehaviourException, InterruptedException {
+ if (null == editorGen.getDiagram().getPalette()) {
+ return;
+ }
+ doGenerateFile(emitters.getPaletteConfigurationEmitter(), new Path(getRelativePath() + File.separator + editorGen.getModelID() + ".paletteconfiguration"), editorGen); //$NON-NLS-1$
+ }
+
+ /**
+ * @return The relative path of the model's resource.
+ */
+ protected String getRelativePath() {
+ String path = null;
+
+ URI resourceURI = editorGen.eResource().getURI();
+ if (resourceURI.isPlatformResource()) {
+ String platformString = resourceURI.toPlatformString(true);
+ IPath workspacePath = new Path(platformString);
+ workspacePath = workspacePath.removeFirstSegments(1);
+ workspacePath = workspacePath.removeLastSegments(1);
+ path = workspacePath.toString();
+ } else {
+ path = "model";//$NON-NLS-1$
+ }
+ return path;
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
index 09af434aa68..528000a1d4e 100644
--- a/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
+++ b/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
@@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
org.eclipse.xtext.builder;bundle-version="[2.10.0,3.0.0)",
org.eclipse.xtend.lib;bundle-version="[2.10.0,3.0.0)",
org.eclipse.gmf.codegen.xtend;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.gmfgenextension;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.gmfgenextension;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0.0)",
+ org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %providerName
Bundle-ClassPath: .
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend
index de7c284c572..435690d4f88 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2006, 2014 Borland Software Corporation, CEA, and others
+ * Copyright (c) 2006, 2017 Borland Software Corporation, CEA, and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Emilien Perico (Atos Origin) - add code to refactor some classes
* Christian W. Damus (CEA) - bug 430648
* Christian W. Damus (CEA) - bug 431023
+ * Mickal ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 512343
*/
package aspects.xpt.editor
@@ -66,7 +67,7 @@ public static final String CONTEXT_ID = "contextID"; nonNLS
Documentation. adds listener for papyrus palette service
// adds a listener to the palette service, which reacts to palette customizations
- org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().addProviderChangeListener(this);
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().addProviderChangeListener(this);
Share the same editing domain
// Share the same editing provider
@@ -96,9 +97,9 @@ override createPaletteRoot (Palette it)'''
protected org.eclipse.gef.palette.PaletteRoot createPaletteRoot(org.eclipse.gef.palette.PaletteRoot existingPaletteRoot) {
org.eclipse.gef.palette.PaletteRoot paletteRoot;
if (existingPaletteRoot == null) {
- paletteRoot = org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
+ paletteRoot = org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
} else {
- org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
paletteRoot = existingPaletteRoot;
}
applyCustomizationsToPalette(paletteRoot);
@@ -109,7 +110,7 @@ override createPaletteRoot (Palette it)'''
def createPaletteCustomizer (GenEditorView it)'''
generatedMemberComment
protected org.eclipse.gef.ui.palette.PaletteCustomizer createPaletteCustomizer() {
- return new org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteCustomizer(getPreferenceStore());
+ return new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteCustomizer(getPreferenceStore());
}
'''
@@ -153,8 +154,8 @@ def handlePaletteChange (GenEditorView it) '''
generatedMemberComment
public void providerChanged(org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent event) {
// update the palette if the palette service has changed
- if (org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().equals(event.getSource())) {
- org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this,
+ if (org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().equals(event.getSource())) {
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this,
getDefaultPaletteContent());
}
}
@@ -163,7 +164,7 @@ def handlePaletteChange (GenEditorView it) '''
def constructPaletteViewer (GenEditorView it) '''
generatedMemberComment
protected org.eclipse.gef.ui.palette.PaletteViewer constructPaletteViewer() {
- return new org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteViewer();
+ return new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteViewer();
}
'''
@@ -172,7 +173,7 @@ override dispose(GenEditorView it)'''
public void dispose() {
// remove palette service listener
// remove preference listener
- org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
if(dirtyState != null) {
dirtyState.dispose();
@@ -219,7 +220,7 @@ protected org.eclipse.gef.ui.palette.PaletteViewerProvider createPaletteViewerPr
super.configurePaletteViewer(viewer);
// customize menu...
- viewer.setContextMenu(new org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteContextMenuProvider(viewer));
+ viewer.setContextMenu(new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteContextMenuProvider(viewer));
viewer.getKeyHandler().setParent(getPaletteKeyHandler());
viewer.getControl().addMouseListener(getPaletteMouseListener());
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/PaletteConfiguration.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/PaletteConfiguration.xtend
new file mode 100644
index 00000000000..5dedb6064ea
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/PaletteConfiguration.xtend
@@ -0,0 +1,113 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST, ALL4TEC and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickal ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package aspects.xpt.editor.palette
+
+import javax.inject.Inject
+import javax.inject.Singleton
+import org.eclipse.emf.ecore.xmi.XMLResource
+import org.eclipse.gmf.codegen.gmfgen.AbstractToolEntry
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator
+import org.eclipse.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.gmf.codegen.gmfgen.ToolGroup
+import xpt.Common
+import xpt.Common_qvto
+
+/**
+ * Template for generation of palette configuration model from gmfgen.
+ */
+@Singleton class PaletteConfiguration {
+
+ @Inject extension Common
+ @Inject extension Common_qvto;
+ @Inject extension Utils_qvto;
+
+ /**
+ * Generate a palette configuration.
+ */
+ def PaletteConfiguration(GenEditorGenerator it) '''
+<?xml version="1.0" encoding="ASCII"?>
+xmlGeneratedTag
+<paletteconfiguration:PaletteConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.8"
+ xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2"
+ id="plugin.ID.paletteconfiguration"
+ label="plugin.name Palette"
+ description="This is the palette of plugin.name">
+ FOR tool : diagram.palette.groups
+ addDrawerConfigurations(tool)
+ ENDFOR
+</paletteconfiguration:PaletteConfiguration>
+ '''
+
+ /**
+ * Generate drawer configurations.
+ */
+ def addDrawerConfigurations(ToolGroup it) '''
+<drawerConfigurations
+ id=IF isQuoted(id,'"')idELSE"id"ENDIF
+ label="it.title"
+ description="description">
+ <icon pluginID="retrieveBundleId(smallIconPath,palette.diagram.editorGen.plugin.ID)" iconPath="retrieveLocalPath(smallIconPath)"/>
+ FOR entry : entries
+ IF entry instanceof ToolEntry && isValidTool(entry as AbstractToolEntry)
+ addToolConfiguration(entry as ToolEntry)
+ ENDIF
+ IF entry instanceof ToolGroup
+ addStackConfiguration(entry as ToolGroup)
+ ENDIF
+ ENDFOR
+</drawerConfigurations>
+'''
+
+ /**
+ * Add tool configuration.
+ */
+ def addToolConfiguration(ToolEntry it) '''
+<ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration"
+ id=IF isQuoted(id,'"')idELSE"id"ENDIF
+ label="title"
+ IF null!=qualifiedToolName && !qualifiedToolName.empty
+ toolClassName="qualifiedToolName"
+ ENDIF
+ description="description"IF genNodes.empty && !genLinks.empty kind="ConnectionTool"ENDIF>
+ <icon pluginID="retrieveBundleId(smallIconPath,group.palette.diagram.editorGen.plugin.ID)" iconPath="retrieveLocalPath(smallIconPath)"/>
+ IF elements.empty && (null==qualifiedToolName || qualifiedToolName.empty)
+ ERROR('No elements for tool generation (Palette):'+title)
+ ENDIF
+ FOR e : elements
+ val href = getElementTypeConfHRef(e.elementType.uniqueIdentifier,eResource as XMLResource)
+ IF null!=href && !href.empty
+ <elementDescriptors>
+ <elementType
+ xsi:type="getConfigurationXsiType(e.elementType.uniqueIdentifier,eResource as XMLResource)"
+ href="href"/>
+ </elementDescriptors>
+ ELSEIF null==qualifiedToolName || qualifiedToolName.empty
+ ERROR('No element type configuration or classToolName for tool generation (Palette):' + title)
+ ENDIF
+ ENDFOR
+</ownedConfigurations>
+ '''
+
+ /**
+ * Add stack configuration.
+ */
+ def addStackConfiguration(ToolGroup it) '''
+<ownedConfigurations xsi:type="paletteconfiguration:StackConfiguration" id=IF isQuoted(id,'"')idELSE"id"ENDIF label="Stack">
+ FOR entry : entries
+ IF entry instanceof ToolEntry && isValidTool(entry as AbstractToolEntry)
+ addToolConfiguration(entry as ToolEntry)
+ ENDIF
+ ENDFOR
+</ownedConfigurations>
+ '''
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/Utils_qvto.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/Utils_qvto.xtend
index ce3d685e6e1..076d98204a9 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/Utils_qvto.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/palette/Utils_qvto.xtend
@@ -1,76 +1,205 @@
/**
- * Copyright (c) 2006, 2010, 2013 Borland Software Corporation and others
+ * Copyright (c) 2006, 2017 Borland Software Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
-package aspects.xpt.editor.palette
-
-import com.google.inject.Singleton
-import org.eclipse.gmf.codegen.gmfgen.AbstractToolEntry
-import org.eclipse.gmf.codegen.gmfgen.Palette
-import org.eclipse.gmf.codegen.gmfgen.ToolEntry
-
-@Singleton class Utils_qvto extends xpt.editor.palette.Utils_qvto {
-
+ * Mickal ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 510587
+ */
+package aspects.xpt.editor.palette
+
+import com.google.inject.Singleton
+import org.eclipse.core.runtime.IPath
+import org.eclipse.core.runtime.Path
+import org.eclipse.emf.common.util.URI
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.xmi.XMLResource
+import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl
+import org.eclipse.gmf.codegen.gmfgen.AbstractToolEntry
+import org.eclipse.gmf.codegen.gmfgen.Palette
+import org.eclipse.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry
+import org.eclipse.papyrus.infra.types.ExternallyRegisteredType
+import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration
+import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration
+import org.eclipse.papyrus.infra.types.core.IConfiguredHintedElementType
+import java.util.HashMap
+import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
+
+@Singleton class Utils_qvto extends xpt.editor.palette.Utils_qvto {
+
/**
* collect all tools availables and valid to generate the palette. A tool is not valid when it does not create either a link or a node
- */
- override Iterable<AbstractToolEntry> collectTools(Palette palette) {
- return collectGroups(palette).map[g|g.entries.filter(typeof(AbstractToolEntry))].flatten.filter[tool|isValidTool(tool)]
- }
-
- def boolean isValidTool(AbstractToolEntry entry) {
-
- if(entry instanceof ToolEntry) {
- val nodes = (entry as ToolEntry).genNodes.size;
- val links = (entry as ToolEntry).genLinks.size;
-
- return nodes + links != 0;
- } else {
- return true;
- }
- }
-
- def String getToolPath(String it) {
- var String result = null
-
- /** returns the '/' separator and then the id of the parent group path */
- if(isQuoted(it,'"')) {
- result = it.substring(1, it.length - 1)
- } else {
- result = it
- }
-
- return "/" + result;
- }
-
- def boolean isQuoted(String source, String quoteStr) {
-
- if(quoteStr == null) {
- return false;
- }
-
- return source.length() >= (quoteStr.length() * 2) && source.startsWith(quoteStr) && source.endsWith(quoteStr);
-
- }
-
- def getConstantIDName(String it) {
- if(isQuoted(it,'"')) {
- return getUpperAndUnderscoreString(it.substring(1, it.length() - 1))
- } else {
- return getUpperAndUnderscoreString(it)
- }
- }
-
- def String getUpperAndUnderscoreString(String value) {
- return value.toUpperCase.replace(".", "_")
- }
-
-}
+ */
+ override Iterable<AbstractToolEntry> collectTools(Palette palette) {
+ return collectGroups(palette).map[g|g.entries.filter(typeof(AbstractToolEntry))].flatten.filter [ tool |
+ isValidTool(tool)
+ ]
+ }
+
+ def boolean isValidTool(AbstractToolEntry entry) {
+
+ if (entry instanceof ToolEntry) {
+ if (null != entry.qualifiedToolName && !entry.qualifiedToolName.empty) {
+ return true;
+ }
+
+ val links = (entry as ToolEntry).genLinks.size;
+ val nodes = (entry as ToolEntry).genNodes.size;
+ return nodes + links != 0;
+ } else {
+ return true;
+ }
+ }
+
+ def String getToolPath(String it) {
+ var String result = null
+
+ /** returns the '/' separator and then the id of the parent group path */
+ if (isQuoted(it, '"')) {
+ result = it.substring(1, it.length - 1)
+ } else {
+ result = it
+ }
+
+ return "/" + result;
+ }
+
+ def boolean isQuoted(String source, String quoteStr) {
+
+ if (quoteStr == null) {
+ return false;
+ }
+
+ return source.length() >= (quoteStr.length() * 2) && source.startsWith(quoteStr) && source.endsWith(quoteStr);
+
+ }
+
+ def getConstantIDName(String it) {
+ if (isQuoted(it, '"')) {
+ return getUpperAndUnderscoreString(it.substring(1, it.length() - 1))
+ } else {
+ return getUpperAndUnderscoreString(it)
+ }
+ }
+
+ def String getUpperAndUnderscoreString(String value) {
+ return value.toUpperCase.replace(".", "_")
+ }
+
+ /**
+ * The plateform protocol prefix.
+ */
+ var static String PLUGIN_PROTOCOL = "platform:/plugin/"
+
+ /**
+ * Retrieve the bundle id of a platform/plug-in path.
+ *
+ * @param initialValue
+ * The initial value from which the bundle has to be retrieved
+ * @param defaultValue
+ * The default bundle id value if bundle id not found
+ * @return the bundle id
+ */
+ def String retrieveBundleId(String initialValue, String defaultValue) {
+ var String result = null
+ if (initialValue.startsWith(PLUGIN_PROTOCOL)) {
+ var String tmp = initialValue.substring(PLUGIN_PROTOCOL.length())
+ var int bundleIdEndIndex = tmp.indexOf("/")
+ result = tmp.substring(0, bundleIdEndIndex)
+ } else {
+ result = defaultValue
+ }
+ return result
+ }
+
+ /**
+ * Retrieve the local path of a platform/plug-in path.
+ *
+ * @param initialValue
+ * the initial value from which the local path has to be retrieved
+ * @return the local path
+ */
+ def String retrieveLocalPath(String initialValue) {
+ var String result = ""
+ if (initialValue.startsWith(PLUGIN_PROTOCOL)) {
+ var String tmp = initialValue.substring(PLUGIN_PROTOCOL.length())
+ var int bundleIdEndIndex = tmp.indexOf("/")
+ result = tmp.substring(bundleIdEndIndex)
+ } else {
+ result = initialValue
+ }
+ return result
+ }
+
+ /**
+ * @return The relative path of the model's resource
+ *
+ * @param it
+ * the EObject to get the relative path
+
+ */
+ def String getRelativePath(EObject it) {
+ var String path = null;
+ var URI resourceURI = eResource().getURI()
+ if (resourceURI.isPlatformResource()) {
+ var String platformString = resourceURI.toPlatformString(true)
+ var IPath workspacePath = new Path(platformString)
+ workspacePath = workspacePath.removeFirstSegments(1)
+ workspacePath = workspacePath.removeLastSegments(1)
+ path = workspacePath.toString()
+ } else {
+ path = "model"
+ }
+ return path;
+ }
+
+ /**
+ * Get the href string for the elementTypeConfiguration model of the unique identifier.
+ */
+ def String getElementTypeConfHRef(String uniqueIdentifier, XMLResource resource) {
+
+ //Load element type registry
+ org.eclipse.papyrus.infra.types.core.registries.ElementTypeSetConfigurationRegistry.getInstance().getClass()
+
+ var String href = null
+ val type = ElementTypeRegistry.getInstance().getType(uniqueIdentifier)
+
+ if (type instanceof IConfiguredHintedElementType) {
+ val xmlHelper = new XMLHelperImpl(resource)
+ val options = new HashMap<Object, Object>()
+ //Set option to have platform:/ sheme instead of ../../..
+ options.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware())
+ xmlHelper.options = options;
+ href = xmlHelper.getHREF(type.configuration as EObject)
+ }
+ return href;
+
+ }
+
+ /**
+ * Get the href string for the elementTypeConfiguration model of the unique identifier.
+ */
+ def String getConfigurationXsiType(String uniqueIdentifier, XMLResource resource) {
+ var String type = null
+ val eltype = ElementTypeRegistry.getInstance().getType(uniqueIdentifier)
+ if (eltype instanceof IConfiguredHintedElementType) {
+ var configuration = eltype.configuration
+ if (configuration instanceof SpecializationTypeConfiguration) {
+ type = "elementtypesconfigurations:SpecializationTypeConfiguration"
+ } else if (configuration instanceof MetamodelTypeConfiguration) {
+ type = "elementtypesconfigurations:MetamodelTypeConfiguration"
+ } else if (configuration instanceof ExternallyRegisteredType) {
+ type = "elementtypesconfigurations:ExternallyRegisteredType"
+ }
+ }
+ return type;
+
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorLabelProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorLabelProvider.xtend
index 5c663399a04..828e09e6396 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorLabelProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorLabelProvider.xtend
@@ -49,7 +49,7 @@ import xpt.navigator.Utils_qvto
IF null != genClass && null != genClass.labelFeature
xptMetaModel.DeclareAndAssign(genClass, 'domainModelElement', 'view.getElement()')
if (domainModelElement != null) {
- return IF !isStringFeature(genClass.labelFeature)String.valueOf(ENDIFxptMetaModel.getFeatureValue(genClass.labelFeature, 'domainModelElement', genClass)IF !isStringFeature(genClass.labelFeature))ENDIF;
+ return IF !isStringFeature(genClass.labelFeature)String.valueOf(ENDIFUMLLabelInternationalization.getInstance().getLabel(domainModelElement)IF !isStringFeature(genClass.labelFeature))ENDIF;
} else {
xptActivator.qualifiedClassName(getDiagram().editorGen.plugin).getInstance().logError("No domain element for view with visualID = stringVisualID"); nonNLS(1)
returnEmptyString()
@@ -58,4 +58,6 @@ import xpt.navigator.Utils_qvto
returnEmptyString()
ENDIF
'''
+
+
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/plugin/plugin.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/plugin/plugin.xtend
index 48e18aef61c..999aafca44d 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/plugin/plugin.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/plugin/plugin.xtend
@@ -1,3 +1,15 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST, ALL4TEC and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - initial API and implementation
+ * Mickal ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 510587: the palette must not be generated by using GMF gen
+ *****************************************************************************/
package aspects.xpt.plugin
import aspects.xpt.Common
@@ -20,6 +32,7 @@ import org.eclipse.papyrus.papyrusgmfgenextension.ExtendedGenView
import org.eclipse.papyrus.papyrusgmfgenextension.LabelVisibilityPreference
import xpt.editor.extensions
import xpt.plugin.pluginUtils
+import java.io.File
@Singleton class plugin extends xpt.plugin.plugin {
@@ -49,8 +62,8 @@ import xpt.plugin.pluginUtils
validation(it.editorGen.diagram)
IF it.editorGen.metrics != nullmetrics(it.editorGen.metrics)ENDIF
RS: redefine palette generation
- palettePredefinedEntries(editorGen)
- paletteEntries(editorGen)
+ palettePredefinedEntries(editorGen)
+ paletteEntries(editorGen)
xptPreferencesExtension.extensions(it.editorGen.diagram)
IF it.editorGen.propertySheet != nullxptPropsheetExtension.extensions(it.editorGen.propertySheet)ENDIF
xptProvidersExtension.extensions(it.editorGen.diagram)
@@ -61,7 +74,28 @@ import xpt.plugin.pluginUtils
xptActionExtension.Main(it.editorGen)
additions(it)
notationTypesMap(editorGen)
+ paletteConfiguration(editorGen)
</plugin>
+ '''
+
+ def paletteConfiguration(GenEditorGenerator it) '''
+<extension point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition">
+ xmlGeneratedTag
+ <paletteDefinition
+ ID="plugin.ID.paletteconfiguration"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider"
+ name="plugin.name Palette"
+ path="relativePathFile.separatormodelID.paletteconfiguration"
+ provider="Eclipse Modeling Project">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <!-- Specify diagram to which this palette tool relates -->
+ <editor
+ id="plugin.ID">
+ </editor>
+ </paletteDefinition>
+</extension>
'''
override additions(GenPlugin it) ''''''
diff --git a/plugins/developer/org.eclipse.papyrus.releng.main.release/release.digest b/plugins/developer/org.eclipse.papyrus.releng.main.release/release.digest
index 07208d10e3d..cd799f2adfa 100755
--- a/plugins/developer/org.eclipse.papyrus.releng.main.release/release.digest
+++ b/plugins/developer/org.eclipse.papyrus.releng.main.release/release.digest
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.releng.main.release/release.xml b/plugins/developer/org.eclipse.papyrus.releng.main.release/release.xml
index 8448fb29fae..d50d74e3111 100755
--- a/plugins/developer/org.eclipse.papyrus.releng.main.release/release.xml
+++ b/plugins/developer/org.eclipse.papyrus.releng.main.release/release.xml
@@ -340,15 +340,14 @@
<plugin name="org.eclipse.papyrus.uml.diagram.clazz" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.common" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.common.groups" version="2.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.common.palette.customaction" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.component" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.deployment" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.icons" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.menu" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.modelexplorer" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.navigation" version="2.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.paletteconfiguration" version="3.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.paletteconfiguration.edit" version="3.0.0"/>
+ <plugin name="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration" version="3.0.0"/>
+ <plugin name="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.edit" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.profile" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.statemachine" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.usecase" version="3.0.0"/>
@@ -486,7 +485,6 @@
<plugin name="org.eclipse.papyrus.cdo.ui.doc" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.copypaste.ui.doc" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.customization.palette" version="3.0.0"/>
- <plugin name="org.eclipse.papyrus.customization.paletteconfiguration" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.dsml.validation.doc" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.eclipse.project.editors" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.editor" version="2.0.0"/>
@@ -705,7 +703,6 @@
<plugin name="org.eclipse.papyrus.uml.diagram.common" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.common.doc" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.common.groups" version="2.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.common.palette.customaction" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.communication" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.component" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.composite" version="3.0.0"/>
@@ -719,8 +716,8 @@
<plugin name="org.eclipse.papyrus.uml.diagram.menu" version="2.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.modelexplorer" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.navigation" version="2.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.paletteconfiguration" version="3.0.0"/>
- <plugin name="org.eclipse.papyrus.uml.diagram.paletteconfiguration.edit" version="3.0.0"/>
+ <plugin name="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration" version="3.0.0"/>
+ <plugin name="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.edit" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.profile" version="3.0.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.profile.doc" version="1.2.0"/>
<plugin name="org.eclipse.papyrus.uml.diagram.sequence" version="3.0.0"/>

Back to the top