diff options
12 files changed, 185 insertions, 91 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeConnectionTool.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeConnectionTool.java index da502fab3c1..8432fa82e21 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeConnectionTool.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeConnectionTool.java @@ -24,9 +24,6 @@ import java.util.Map; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.Request; @@ -35,8 +32,6 @@ import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.requests.CreateConnectionRequest; import org.eclipse.gef.requests.CreateRequest; import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; -import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; -import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredCreateConnectionViewCommand; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; @@ -55,7 +50,6 @@ import org.eclipse.gmf.runtime.diagram.ui.util.INotationType; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.IHintedType; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferences; import org.eclipse.papyrus.infra.gmfdiag.common.utils.LayoutUtils; @@ -63,6 +57,7 @@ import org.w3c.dom.Node; /** * Connection tool that adds stereotype application after creation actions. + * * @since 3.0 */ public class AspectUnspecifiedTypeConnectionTool extends UnspecifiedTypeConnectionTool { @@ -153,16 +148,11 @@ public class AspectUnspecifiedTypeConnectionTool extends UnspecifiedTypeConnecti @Override protected void createConnection() { List<?> selectedEditParts = getCurrentViewer().getSelectedEditParts(); - List<EObject> eobjects = new ArrayList<EObject>(); - List<NotificationListener> listeners = new ArrayList<NotificationListener>(); - DiagramEventBroker eventBroker = null; final EditPartViewer viewer = getCurrentViewer(); // only attempt to create connection if there are two shapes selected if (!selectedEditParts.isEmpty()) { IGraphicalEditPart targetEditPart = (IGraphicalEditPart) selectedEditParts.get(selectedEditParts.size() - 1); - // allow add the listener only one time the target - boolean done = false; for (int i = 0; i < selectedEditParts.size(); i++) { IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) selectedEditParts.get(i); if (i != 0) { @@ -196,18 +186,11 @@ public class AspectUnspecifiedTypeConnectionTool extends UnspecifiedTypeConnecti setTargetRequest(connectionRequest); - // inits the listener - View eObject = targetEditPart.getAdapter(View.class); - - NotificationListener listener = null; - Command command = targetEditPart.getCommand(connectionRequest); if (command != null) { Command completeCommand = getCompleteCommand(command); - setCurrentCommand(completeCommand); - executeCurrentCommand(); } @@ -250,26 +233,8 @@ public class AspectUnspecifiedTypeConnectionTool extends UnspecifiedTypeConnecti return false; } - // inits the listener - View eObject = getTargetEditPart().getAdapter(View.class); - DiagramEventBroker eventBroker = null; - NotificationListener listener = null; - boolean requiresPostCommitRun = true; final EditPartViewer currentViewer = getCurrentViewer(); - // adds the listener - if (requiresPostCommitRun) { - // register a listener to have information about element creation - // retrieves editing domain - TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(eObject); - eventBroker = DiagramEventBroker.getInstance(domain); - - - if (eventBroker != null &&listener!=null) { - eventBroker.addNotificationListener(eObject, listener); - } - } - Command endCommand = getCommand(); if (endCommand != null) { @@ -280,10 +245,6 @@ public class AspectUnspecifiedTypeConnectionTool extends UnspecifiedTypeConnecti executeCurrentCommand(); } - if (requiresPostCommitRun && eventBroker != null) { - eventBroker.removeNotificationListener(eObject, listener); - } - selectAddedObject(currentViewer, DiagramCommandStack.getReturnValues(endCommand)); setAvoidDeactivation(false); diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java index b24cc20edd4..67b173396fa 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java @@ -35,8 +35,6 @@ import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.requests.CreateRequest; import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; -import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; -import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedAdapter; @@ -56,6 +54,7 @@ import org.eclipse.swt.SWT; /** * Creation tool for papyrus. + * * @since 3.0 */ public class AspectUnspecifiedTypeCreationTool extends UnspecifiedTypeCreationTool { @@ -83,20 +82,13 @@ public class AspectUnspecifiedTypeCreationTool extends UnspecifiedTypeCreationTo @Override protected void performCreation(int button) { antiScroll = true; - // EObject to listen - View eObject = getTargetEditPart().getAdapter(View.class); - DiagramEventBroker eventBroker = null; - NotificationListener listener = null; final EditPartViewer currentViewer = getCurrentViewer(); - Command command = getCurrentCommand(); if (command != null) { Command completeCommand = getCompleteCommand(command); - setCurrentCommand(completeCommand); - executeCurrentCommand(); } diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF index 125eccaa6dd..e1a52548218 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF @@ -34,3 +34,4 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)", org.eclipse.papyrus.infra.types;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)" Bundle-ActivationPolicy: lazy +Import-Package: com.google.common.base diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/Messages.java b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/editor/messages/Messages.java index 8d54193d156..cd3ceec181d 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/Messages.java +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/editor/messages/Messages.java @@ -9,15 +9,14 @@ * Contributors: * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation *****************************************************************************/ -package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.messages; +package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor.messages; import org.eclipse.osgi.util.NLS; public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.messages.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor.messages.messages"; //$NON-NLS-1$ public static String CustomPaletteconfigurationEditor_NewTool; - public static String CustomPaletteconfigurationEditor_Create_Drawer_Tooltip; public static String CustomPaletteconfigurationEditor_RemoveButtonTooltip; public static String CustomPaletteconfigurationEditor_Create_Separator_Tooltip; @@ -25,13 +24,15 @@ public class Messages extends NLS { public static String CustomPaletteconfigurationEditor_Create_Tool_Tooltip; public static String CustomPaletteCreationPage_Palette_Identifier_Tooltip; public static String ReferenceDialog_EditValue; - public static String PaletteToolActionsPropertyEditor_AddAction; public static String PaletteToolActionsPropertyEditor_AppliedActions; public static String PaletteToolActionsPropertyEditor_DownAction; public static String PaletteToolActionsPropertyEditor_invalidAdvice; public static String PaletteToolActionsPropertyEditor_RemoveAction; + public static String PaletteToolActionsPropertyEditor_selectElementTypeSetModelMessage; + public static String PaletteToolActionsPropertyEditor_selectElementTypeSetModelTitle; public static String PaletteToolActionsPropertyEditor_UpAction; + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/editor/messages/messages.properties index 7bb7e017291..e5d78ae3607 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/editor/messages/messages.properties @@ -20,3 +20,5 @@ PaletteToolActionsPropertyEditor_DownAction=Move selected action down PaletteToolActionsPropertyEditor_invalidAdvice=<Invalid Advice> PaletteToolActionsPropertyEditor_RemoveAction=Remove selected action PaletteToolActionsPropertyEditor_UpAction=Move selected action up +PaletteToolActionsPropertyEditor_selectElementTypeSetModelMessage=Select the model where you want to save actions. +PaletteToolActionsPropertyEditor_selectElementTypeSetModelTitle=Select Element types model to set
\ No newline at end of file diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteCreationPage.java b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteCreationPage.java index a21400061da..5d811eb9fd7 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteCreationPage.java +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteCreationPage.java @@ -30,7 +30,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.WorkspaceExtende import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Activator; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteconfigurationPackage; -import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.messages.Messages; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor.messages.Messages; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.utils.CreatePaletteItemUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java index 664e59ee214..877ec7b5b1b 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java @@ -62,7 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Paletteconfigurati import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.SeparatorConfiguration; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.StackConfiguration; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ToolConfiguration; -import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.messages.Messages; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor.messages.Messages; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.provider.CustomPaletteconfigurationItemProviderAdapterFactory; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.utils.CreatePaletteItemUtil; import org.eclipse.swt.SWT; diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/widgets/editors/PaletteToolActionsPropertyEditor.java b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/widgets/editors/PaletteToolActionsPropertyEditor.java index f99f3a72e4c..70db2677b02 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/widgets/editors/PaletteToolActionsPropertyEditor.java +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/widgets/editors/PaletteToolActionsPropertyEditor.java @@ -35,7 +35,7 @@ import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; +import org.eclipse.gmf.runtime.common.ui.dialogs.PopupDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; @@ -44,11 +44,12 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Activator; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ElementDescriptor; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteRessourcesConstants; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ToolConfiguration; -import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.messages.Messages; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor.messages.Messages; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.provider.ToolConfigurationItemProvider; import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.utils.CreatePaletteItemUtil; import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource; @@ -63,12 +64,10 @@ import org.eclipse.papyrus.infra.types.AbstractAdviceBindingConfiguration; import org.eclipse.papyrus.infra.types.AdviceConfiguration; import org.eclipse.papyrus.infra.types.ElementTypeConfiguration; import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration; -import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration; import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration; import org.eclipse.papyrus.infra.types.core.extensionpoints.IAdviceKindExtensionPoint; import org.eclipse.papyrus.infra.types.core.factories.impl.AbstractAdviceBindingFactory; -import org.eclipse.papyrus.infra.types.core.factories.impl.MetamodelTypeFactory; -import org.eclipse.papyrus.infra.types.core.factories.impl.SpecializationTypeFactory; +import org.eclipse.papyrus.infra.types.core.utils.ElementTypeConfigurationUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -81,6 +80,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; @@ -140,9 +140,6 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi /** List of actions descriptor */ private List<ActionDescriptor> actionsDesciptors = new ArrayList<ActionDescriptor>(); - /** Element type set configuration model for ui level. */ - private ElementTypeSetConfiguration elementTypeSetConfigurationUI; - /** Element type set configuration model for semantic level. */ private ElementTypeSetConfiguration elementTypeSetConfigurationSemantic; @@ -236,6 +233,7 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi actionsComposite.setLayout(layout); GridData data = new GridData(SWT.FILL, SWT.FILL, false, true); data.widthHint = 215; + data.heightHint = 178; actionsComposite.setLayoutData(data); } @@ -632,25 +630,17 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi List<AbstractAdviceBindingConfiguration> actions = new ArrayList<AbstractAdviceBindingConfiguration>(); // If there is element descriptors in selected tool configuration - if (!toolSource.getElementDescriptors().isEmpty() && null != elementTypeSetConfigurationSemantic && null != elementTypeSetConfigurationUI) { + if (!toolSource.getElementDescriptors().isEmpty() && null != elementTypeSetConfigurationSemantic) { // String elementTypeId_UI = toolSource.getElementDescriptors().get(0).getElementTypeId(); ElementTypeConfiguration elementType = toolSource.getElementDescriptors().get(0).getElementType(); if (elementType instanceof SpecializationTypeConfiguration) { // Gets specialized types - EList<ElementTypeConfiguration> elementTypesSem = ((SpecializationTypeConfiguration) elementType).getSpecializedTypes(); - - // for each gets advice configuration - for (ElementTypeConfiguration elementTypeConfiguration : elementTypesSem) { - IHintedType createElementType = null; - if (elementTypeConfiguration instanceof SpecializationTypeConfiguration) { - createElementType = new SpecializationTypeFactory().createElementType((SpecializationTypeConfiguration) elementTypeConfiguration); - } else if (elementTypeConfiguration instanceof MetamodelTypeConfiguration) { - createElementType = new MetamodelTypeFactory().createElementType((MetamodelTypeConfiguration) elementTypeConfiguration); - } - - editingDomain.getResourceSet().getLoadOptions().put(SOURCE_ECLASS, createElementType.getEClass()); - actions.addAll(elementTypeSetConfigurationSemantic.getAdviceBindingsConfigurations().stream().filter(p -> null != p.getTarget() && p.getTarget().equals(elementTypeConfiguration)).collect(Collectors.toList())); - } + editingDomain.getResourceSet().getLoadOptions().put(SOURCE_ECLASS, ElementTypeConfigurationUtil.getFirstCreatedElementEClass((SpecializationTypeConfiguration) elementType)); + + // Get All advice(actions) which have the target as the elementType of the Element descriptor. + actions.addAll(elementTypeSetConfigurationSemantic.getAdviceBindingsConfigurations().stream() + .filter(p -> null != p.getTarget() && ElementTypeConfigurationUtil.isTypeOf(elementType, p.getTarget())) + .collect(Collectors.toList())); } } return actions.toArray(); @@ -719,6 +709,7 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi public void setInput(final DataSource input) { this.input = input; initialize(); + } /** @@ -746,8 +737,8 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi ModelElement modelElement = input.getModelElement(property); if (modelElement instanceof EMFModelElement) { setEditingDomain((AdapterFactoryEditingDomain) ((EMFModelElement) modelElement).getDomain()); - setElementTypeModels(); setToolSource(modelElement); + setElementTypeModels(); initActionsViewer(); } } @@ -770,24 +761,70 @@ public class PaletteToolActionsPropertyEditor implements CustomizablePropertyEdi */ protected void setElementTypeModels() { // Look for element types Models on the resource set - Object UIRessource = editingDomain.getResourceSet().getLoadOptions().get(PaletteRessourcesConstants.ELEMENTTYPE_UI_RESSOURCE_IDENTIFIER); Object SemanticRessource = editingDomain.getResourceSet().getLoadOptions().get(PaletteRessourcesConstants.ELEMENTTYPE_SEMENTIC_RESSOURCE_IDENTIFIER); - EObject UIModel = null; - if (UIRessource instanceof Resource && !((Resource) UIRessource).getContents().isEmpty()) { - UIModel = ((Resource) UIRessource).getContents().get(0); - } EObject SemanticModel = null; if (SemanticRessource instanceof Resource && !((Resource) SemanticRessource).getContents().isEmpty()) { SemanticModel = ((Resource) SemanticRessource).getContents().get(0); } - if (SemanticModel instanceof ElementTypeSetConfiguration && UIModel instanceof ElementTypeSetConfiguration) { - elementTypeSetConfigurationUI = (ElementTypeSetConfiguration) UIModel; + if (SemanticModel instanceof ElementTypeSetConfiguration) { elementTypeSetConfigurationSemantic = (ElementTypeSetConfiguration) SemanticModel; - setReadOnly(false); } else { - setReadOnly(true); + // We are in the "standealone editor" context + // we search not readonly elementType then ask to the user to choose the file. + + // gets writable element types referred by the selected tools + List<ElementTypeConfiguration> writableElementTypes = toolSource.getElementDescriptors().stream() + .map(ed -> ed.getElementType()) + .filter(elt -> !EMFHelper.isReadOnly(elt)) + .collect(Collectors.toList()); + + List<ElementTypeConfiguration> elementTypes = new ArrayList<ElementTypeConfiguration>(); + elementTypes.addAll(writableElementTypes); + do { + elementTypes = elementTypes.stream() + .filter(SpecializationTypeConfiguration.class::isInstance) + .map(SpecializationTypeConfiguration.class::cast) + .flatMap(elt -> elt.getSpecializedTypes().stream()) + .map(ElementTypeConfiguration.class::cast) + .filter(elt -> !EMFHelper.isReadOnly(elt)) + .collect(Collectors.toList()); + writableElementTypes.addAll(elementTypes); + + } while (!elementTypes.isEmpty()); + + List<ElementTypeSetConfiguration> elementTypeSetConfiguration = writableElementTypes.stream() + .map(elt -> elt.eContainer()) + .filter(ElementTypeSetConfiguration.class::isInstance) + .map(ElementTypeSetConfiguration.class::cast) + .distinct() + .collect(Collectors.toList()); + + LabelProvider labelProvider = new LabelProvider() { + public String getText(Object element) { + String text; + if (element instanceof ElementTypeSetConfiguration) { + text = ((ElementTypeSetConfiguration) element).getIdentifier(); + } else { + text = super.getText(element); + } + return text; + + }; + }; + PopupDialog dialog = new PopupDialog(Display.getCurrent().getActiveShell(), elementTypeSetConfiguration, labelProvider); + dialog.setMessage(Messages.PaletteToolActionsPropertyEditor_selectElementTypeSetModelMessage); + dialog.setTitle(Messages.PaletteToolActionsPropertyEditor_selectElementTypeSetModelTitle); + dialog.open(); + Object[] result = dialog.getResult(); + if (null != result && 0 < result.length) { + elementTypeSetConfigurationSemantic = (ElementTypeSetConfiguration) result[0]; + editingDomain.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_SEMENTIC_RESSOURCE_IDENTIFIER, elementTypeSetConfigurationSemantic.eResource()); + setReadOnly(false); + } else { + setReadOnly(true); + } } } diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties index 5297793515f..1b804e75af5 100644 --- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties +++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/messages/messages.properties @@ -1,3 +1,11 @@ ConfigurationModelElement_ErrorNotString=The {0} must be a String. ConfigurationModelElement_WarningNotSet=The {0} must be set. IconDescriptorObservableValue_Undefined=<Undefined> +PaletteToolActionsPropertyEditor_AddAction= +PaletteToolActionsPropertyEditor_AppliedActions= +PaletteToolActionsPropertyEditor_DownAction= +PaletteToolActionsPropertyEditor_invalidAdvice= +PaletteToolActionsPropertyEditor_RemoveAction= +PaletteToolActionsPropertyEditor_selectElementTypeSetModelMessage=Select the Semantic ElementTypeSetConfiguration model to add Actions +PaletteToolActionsPropertyEditor_selectElementTypeSetModelTitle=Select the Semantic ElementTypeSetConfiguration +PaletteToolActionsPropertyEditor_UpAction= diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/utils/ElementTypeConfigurationUtil.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/utils/ElementTypeConfigurationUtil.java new file mode 100644 index 00000000000..7ef0d029160 --- /dev/null +++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/utils/ElementTypeConfigurationUtil.java @@ -0,0 +1,91 @@ +/***************************************************************************** + * 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.infra.types.core.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.infra.types.ElementTypeConfiguration; +import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration; +import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration; + +/** + * Utilities Class for {@link ElementTypeConfiguration} element. + */ +public class ElementTypeConfigurationUtil { + + /** + * @return true element is type of type to match + */ + public static boolean isTypeOf(final ElementTypeConfiguration elementType, final ElementTypeConfiguration elementTypeConfiguration) { + boolean isTypeOf = false; + + if (elementTypeConfiguration.equals(elementType)) { + isTypeOf = true; + } + + List<ElementTypeConfiguration> supers = getAllSpecializedTypes(elementType); + if (supers.contains(elementTypeConfiguration)) { + isTypeOf = true; + } + return isTypeOf; + } + + /** + * Get all specialized types recursively. + * + * @param elementType + * the {@link ElementTypeConfiguration} + * @return the list of all Children of specialized type. + */ + public static List<ElementTypeConfiguration> getAllSpecializedTypes(final ElementTypeConfiguration elementType) { + List<ElementTypeConfiguration> result = new ArrayList<>(); + + result.add(elementType); + if (elementType instanceof SpecializationTypeConfiguration) { + EList<ElementTypeConfiguration> specializedTypes = ((SpecializationTypeConfiguration) elementType).getSpecializedTypes(); + if (!specializedTypes.isEmpty()) { + for (ElementTypeConfiguration elementTypeConfiguration : specializedTypes) { + result.addAll(getAllSpecializedTypes(elementTypeConfiguration)); + } + } + } + return result; + } + + /** + * Gets the EClass of the first find created semantic element. + * + * @param elementTypesSem + * the {@link SpecializationTypeConfiguration} + * @return the EClass founded + */ + public static EClass getFirstCreatedElementEClass(final SpecializationTypeConfiguration elementType) { + EClass eClass = null; + Optional<MetamodelTypeConfiguration> findFirst = getAllSpecializedTypes(elementType).stream() + .filter(MetamodelTypeConfiguration.class::isInstance) + .map(MetamodelTypeConfiguration.class::cast) + .distinct() + .findFirst(); + + if (findFirst.isPresent()) { + MetamodelTypeConfiguration elementTypeConfiguration = findFirst.get(); + eClass = elementTypeConfiguration.getEClass(); + } + + return eClass; + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF index 7ae31f08278..82793dcb02c 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF @@ -34,4 +34,5 @@ Bundle-Activator: org.eclipse.papyrus.uml.profile.Activator Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.profile;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: com.google.common.base;version="21.0.0" +Import-Package: com.google.common.base;version="[21.0.0,22.0.0)",
+ com.google.common.util.concurrent;version="[21.0.0,22.0.0)"
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeQualifyNamePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeQualifyNamePropertyEditor.java index 51aa8131082..37d78301b15 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeQualifyNamePropertyEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeQualifyNamePropertyEditor.java @@ -13,7 +13,7 @@ package org.eclipse.papyrus.uml.properties.widgets; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; @@ -59,7 +59,7 @@ public class StereotypeQualifyNamePropertyEditor extends AbstractPropertyEditor EMFHelper.resolveEditingDomain(input.getSelection().getFirstElement()); if (modelElement instanceof EMFModelElement) { - TransactionalEditingDomain domain = (TransactionalEditingDomain) ((EMFModelElement) modelElement).getDomain(); + EditingDomain domain = (EditingDomain) ((EMFModelElement) modelElement).getDomain(); Object eClass = domain.getResourceSet().getLoadOptions().get(SOURCE_ECLASS); if (eClass instanceof EClass) { try { |