Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-03-25 13:23:59 +0000
committerCamille Letavernier2014-03-25 13:23:59 +0000
commiteb2c0e5135c25d5b8325350dcf628588fdc99c0c (patch)
tree6a93e978153293cc782a7912c56d9b942cb68152
parent09e4f849ca7e01e0f430a727192ec6f117399909 (diff)
parent06e5460efb6c2883dd6541f6498d0f193904585e (diff)
downloadorg.eclipse.papyrus-eb2c0e5135c25d5b8325350dcf628588fdc99c0c.tar.gz
org.eclipse.papyrus-eb2c0e5135c25d5b8325350dcf628588fdc99c0c.tar.xz
org.eclipse.papyrus-eb2c0e5135c25d5b8325350dcf628588fdc99c0c.zip
Integrate contribution from G. Pascual
Conflicts: plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java453
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java78
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java6
3 files changed, 277 insertions, 260 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java
index f94c0271d15..367ca077a6d 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java
@@ -1,237 +1,216 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.resource.JFaceColors;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
-import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Composite allows displaying applied stereotypes from the model, but allows also displaying it in the associated view.
- */
-public class AppliedStereotypeCompositeWithView extends org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel implements IViewComposite {
-
- /**
- * The selection.
- */
- protected ISelection selection;
-
- /**
- * The property composite.
- */
- protected MultipleReferenceEditor propertyComposite;
-
- private EModelElement diagramElement;
-
- private ISelectionChangedListener propertySelectionChangeListener;
-
- /**
- * The Constructor.
- *
- * @param parent
- * the parent
- */
- public AppliedStereotypeCompositeWithView(Composite parent) {
- super(parent);
- this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
- }
-
- /**
- * Creates the content.
- *
- * @param parent
- * the parent
- * @param factory
- * the factory
- *
- * @return the composite
- */
- @Override
- public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super.createContent(parent, factory);
-
- // Replace label and content providers in treeViewers
- treeViewer.setContentProvider(new ProfileElementWithDisplayContentProvider(diagramElement));
- treeViewer.setLabelProvider(new ProfileElementWithDisplayLabelProvider());
-
- refresh();
- return this;
- }
-
- /**
- * Sets the selection.
- *
- * @param selection
- * the selection
- */
- public void setSelection(ISelection selection) {
- this.selection = selection;
- }
-
- /**
- * Sets the diagram element.
- *
- * @param diagramElement
- * the diagram element
- */
- public void setDiagramElement(EModelElement diagramElement) {
- this.diagramElement = diagramElement;
- ((ProfileElementWithDisplayContentProvider)treeViewer.getContentProvider()).setDiagramElement(diagramElement);
- }
-
- /**
- * Sets the property composite associated to this stereotype composite
- *
- * @param propertyComposite
- * the composite associated to this stereotype composite used for stereotype property display.
- */
- public void setPropertySelectionChangeListener(ISelectionChangedListener propertySelectionChangeListener) {
- this.propertySelectionChangeListener = propertySelectionChangeListener;
- }
-
- /**
- * Gets the selected.
- *
- * @return the selected
- * @deprecated
- */
- @Deprecated
- @Override
- public Element getSelected() {
- return getElement();
- }
-
- /**
- * Adds the button pressed.
- */
- @Override
- public void addButtonPressed() {
- super.addButtonPressed();
- }
-
- /**
- * Display the stereotype once it is applied
- *
- * @param st
- * the stereotype to add
- */
- @Override
- public void applyStereotype(final Element elt, final Stereotype st) {
- super.applyStereotype(elt, st);
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return;
- }
- try {
- final TransactionalEditingDomain domain = getEditingDomain(elt);
- domain.runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
-
- String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeCommand(domain, diagramElement, st.getQualifiedName(), presentationKind);
- domain.getCommandStack().execute(command);
- }
- });
- }
- });
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- /**
- * Remove a stereotype from the list of stereotypes to display.
- *
- * @param st
- * the stereotype to remove
- */
- @Override
- protected void unapplyStereotype(final Element elt, final Stereotype st) {
- super.unapplyStereotype(elt, st);
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return;
- }
-
- final TransactionalEditingDomain domain = getEditingDomain(elt);
-
- try {
- domain.runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(domain, diagramElement, st.getQualifiedName(), presentationKind);
-
- domain.getCommandStack().execute(command);
- }
- });
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.profile.ui.composites.StereotypeComposite#removeButtonPressed()
- */
- @Override
- public void removeButtonPressed() {
- superRemoveButton();
- }
-
- /**
- * Calls super method
- */
- private void superRemoveButton() {
- super.removeButtonPressed();
- }
-
- /**
- * Selection changed.
- *
- * @param event
- * the event
- */
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- propertySelectionChangeListener.selectionChanged(event);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * 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:
+ * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
+ * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.profile.ui.compositeforview;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
+import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * This Composite allows displaying applied stereotypes from the model, but allows also displaying it in the associated view.
+ */
+public class AppliedStereotypeCompositeWithView extends org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel implements IViewComposite {
+
+ /**
+ * The selection.
+ */
+ protected ISelection selection;
+
+ /**
+ * The property composite.
+ */
+ protected MultipleReferenceEditor propertyComposite;
+
+ private EModelElement diagramElement;
+
+ private ISelectionChangedListener propertySelectionChangeListener;
+
+ /**
+ * The Constructor.
+ *
+ * @param parent
+ * the parent
+ */
+ public AppliedStereotypeCompositeWithView(Composite parent) {
+ super(parent);
+ this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ * @param factory
+ * the factory
+ *
+ * @return the composite
+ */
+ @Override
+ public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) {
+ super.createContent(parent, factory);
+
+ // Replace label and content providers in treeViewers
+ treeViewer.setContentProvider(new ProfileElementWithDisplayContentProvider(diagramElement));
+ treeViewer.setLabelProvider(new ProfileElementWithDisplayLabelProvider());
+
+ refresh();
+ return this;
+ }
+
+ /**
+ * Sets the selection.
+ *
+ * @param selection
+ * the selection
+ */
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ }
+
+ /**
+ * Sets the diagram element.
+ *
+ * @param diagramElement
+ * the diagram element
+ */
+ public void setDiagramElement(EModelElement diagramElement) {
+ this.diagramElement = diagramElement;
+ ((ProfileElementWithDisplayContentProvider)treeViewer.getContentProvider()).setDiagramElement(diagramElement);
+ }
+
+ /**
+ * Sets the property composite associated to this stereotype composite
+ *
+ * @param propertyComposite
+ * the composite associated to this stereotype composite used for stereotype property display.
+ */
+ public void setPropertySelectionChangeListener(ISelectionChangedListener propertySelectionChangeListener) {
+ this.propertySelectionChangeListener = propertySelectionChangeListener;
+ }
+
+ /**
+ * Gets the selected.
+ *
+ * @return the selected
+ * @deprecated
+ */
+ @Deprecated
+ @Override
+ public Element getSelected() {
+ return getElement();
+ }
+
+ /**
+ * Adds the button pressed.
+ */
+ @Override
+ public void addButtonPressed() {
+ super.addButtonPressed();
+ }
+
+
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.cea.papyrus.profile.ui.composites.StereotypeComposite#removeButtonPressed()
+ */
+ @Override
+ public void removeButtonPressed() {
+ superRemoveButton();
+ }
+
+ /**
+ * Calls super method
+ */
+ private void superRemoveButton() {
+ super.removeButtonPressed();
+ }
+
+ /**
+ * Selection changed.
+ *
+ * @param event
+ * the event
+ */
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ propertySelectionChangeListener.selectionChanged(event);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel#getApplyStereotypeCommmand(org.eclipse.uml2.uml.Element,
+ * org.eclipse.uml2.uml.Stereotype, org.eclipse.emf.transaction.TransactionalEditingDomain)
+ *
+ * @param elt
+ * @param st
+ * @param domain
+ * @return
+ */
+ @Override
+ protected Command getApplyStereotypeCommmand(Element elt, Stereotype st, TransactionalEditingDomain domain) {
+ CompoundCommand compoundCommand = new CompoundCommand("applyStereotypeCommand");
+
+ Command parentCommmand = super.getApplyStereotypeCommmand(elt, st, domain);
+ compoundCommand.append(parentCommmand);
+
+ String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
+ RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeCommand(domain, diagramElement, st.getQualifiedName(), presentationKind);
+
+ compoundCommand.append(command);
+
+ return parentCommmand;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel#getUnapplyStereotypeCommand(org.eclipse.uml2.uml.Element,
+ * org.eclipse.uml2.uml.Stereotype, org.eclipse.emf.transaction.TransactionalEditingDomain)
+ *
+ * @param elt
+ * @param st
+ * @param domain
+ * @return
+ */
+ @Override
+ protected Command getUnapplyStereotypeCommand(Element elt, Stereotype st, TransactionalEditingDomain domain) {
+ CompoundCommand compoundCommand = new CompoundCommand("UnapplyStereotypeCommand");
+
+ Command parentCommand = super.getUnapplyStereotypeCommand(elt, st, domain);
+ compoundCommand.append(parentCommand);
+
+ String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
+ RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(domain, diagramElement, st.getQualifiedName(), presentationKind);
+ compoundCommand.append(command);
+
+ return compoundCommand;
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java
index a58f353ba98..f063d3f90ba 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.NotificationImpl;
import org.eclipse.emf.common.util.BasicEList;
@@ -435,7 +436,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
}
/**
- *
+ *
* @see org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel.DecoratedTreeComposite#keepSelection(org.eclipse.jface.viewers.ISelection)
*
* @param pSelection
@@ -463,14 +464,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
- domain.getCommandStack().execute(new RecordingCommand(domain) {
-
- @Override
- protected void doExecute() {
- elt.applyStereotype(st);
- refresh();
- }
- });
+ domain.getCommandStack().execute(getApplyStereotypeCommmand(elt, st, domain));
}
});
}
@@ -501,15 +495,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
- domain.getCommandStack().execute(new RecordingCommand(domain) {
-
- @Override
- protected void doExecute() {
- elt.unapplyStereotype(st);
- elt.eNotify(new NotificationImpl(Notification.SET, true, true, true));
- refresh();
- }
- });
+ domain.getCommandStack().execute(getUnapplyStereotypeCommand(elt, st, domain));
}
});
}
@@ -559,7 +545,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
}
/**
- *
+ *
* @author gpascual
*
*/
@@ -569,7 +555,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
ISelection selection = null;
/**
- *
+ *
* Constructor.
*
*/
@@ -626,5 +612,57 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im
}
}
+ /**
+ * Create command to execute during apply stereotype action.
+ *
+ * @param elt
+ * Element where stereotype was applied
+ * @param st
+ * Stereotype to apply on element
+ *
+ * @param domain
+ * Transaction domain to execute command
+ * @return Command to execute to apply stereotype on element
+ */
+ protected Command getApplyStereotypeCommmand(final Element elt, final Stereotype st, final TransactionalEditingDomain domain) {
+ return new RecordingCommand(domain) {
+
+ /**
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ */
+ @Override
+ protected void doExecute() {
+ elt.applyStereotype(st);
+ refresh();
+ }
+ };
+ }
+
+ /**
+ * Create command execute during unapply stereotype action.
+ *
+ * @param elt
+ * element where stereotype was unapplied
+ * @param st
+ * Stereotype to unapply on element
+ * @param domain
+ * Transaction domain to execute command
+ * @return Command to execute to unapply stereotype on element
+ */
+ protected Command getUnapplyStereotypeCommand(final Element elt, final Stereotype st, final TransactionalEditingDomain domain) {
+ return new RecordingCommand(domain) {
+
+ /**
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ */
+ @Override
+ protected void doExecute() {
+ elt.unapplyStereotype(st);
+ elt.eNotify(new NotificationImpl(Notification.SET, true, true, true));
+ refresh();
+ }
+ };
+ }
+
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java
index af77bddb4b7..f57dfc5bc3e 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java
@@ -180,7 +180,7 @@ public abstract class DecoratedTreeComposite extends Composite implements ISecti
/*
* (non-Javadoc)
- *
+ *
* @see com.cea.papyrus.ui.composites.ISectionComposite#createContent(org.eclipse.swt.widgets.Composite,
* org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory)
*/
@@ -470,7 +470,7 @@ public abstract class DecoratedTreeComposite extends Composite implements ISecti
*/
public void mouseUp(MouseEvent e) {
ISelection selection = treeViewer.getSelection();
- downButtonPressed();
+ upButtonPressed();
refresh();
// Keep selection
keepSelection(selection);
@@ -511,7 +511,7 @@ public abstract class DecoratedTreeComposite extends Composite implements ISecti
public void mouseUp(MouseEvent e) {
ISelection vSelection = treeViewer.getSelection();
- upButtonPressed();
+ downButtonPressed();
refresh();
// Keep selection
keepSelection(vSelection);

Back to the top