Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java53
1 files changed, 29 insertions, 24 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
index 92c4440a2d6..d1d3ca29430 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
@@ -11,6 +11,7 @@
*****************************************************************************/
package org.eclipse.papyrus.customization.palette.dialog;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -29,6 +30,7 @@ import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.service.palette.AspectToolService;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IAspectAction;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IAspectActionProvider;
+import org.eclipse.papyrus.uml.diagram.common.service.palette.IPaletteAspectToolEntryProxy;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IPostAction;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IPreAction;
import org.eclipse.swt.SWT;
@@ -164,8 +166,10 @@ public class AspectActionsInformationComposite {
ITreeSelection selection = (ITreeSelection)viewer.getSelection();
if(selection != null && selection.size() > 0) {
for(Object selected : selection.toList()) {
- if(selected instanceof IPostAction && selectedEntryProxy instanceof PaletteAspectToolEntryProxy) {
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().remove(selected);
+ if(selected instanceof IPostAction && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
+ ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().remove(selected);
+ } else if(selected instanceof IPreAction && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
+ ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().remove(selected);
}
}
}
@@ -196,10 +200,10 @@ public class AspectActionsInformationComposite {
*/
public void mouseUp(MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof PaletteAspectToolEntryProxy) {
+ if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
IAspectAction action = (IAspectAction)selection.getFirstElement();
- List<IPreAction> initialPreList = ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions();
- List<IPostAction> initialPostList = ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions();
+ List<IPreAction> initialPreList = ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions();
+ List<IPostAction> initialPostList = ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions();
if(action instanceof IPreAction) {
// move from pre action list
@@ -212,9 +216,6 @@ public class AspectActionsInformationComposite {
}
}
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).setPreActions(initialPreList);
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).setPostActions(initialPostList);
-
// update content
viewer.setInput(selectedEntryProxy);
// restore selection
@@ -247,10 +248,10 @@ public class AspectActionsInformationComposite {
*/
public void mouseUp(MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof PaletteAspectToolEntryProxy) {
+ if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
IAspectAction action = (IAspectAction)selection.getFirstElement();
- List<IPreAction> initialPreList = ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions();
- List<IPostAction> initialPostList = ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions();
+ List<IPreAction> initialPreList = ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions();
+ List<IPostAction> initialPostList = ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions();
if(action instanceof IPreAction) {
// move from pre action list
@@ -263,9 +264,6 @@ public class AspectActionsInformationComposite {
}
}
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).setPreActions(initialPreList);
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).setPostActions(initialPostList);
-
// update content
viewer.setInput(selectedEntryProxy);
// restore selection
@@ -334,11 +332,11 @@ public class AspectActionsInformationComposite {
public void widgetSelected(SelectionEvent e) {
IAspectActionProvider factory = (IAspectActionProvider)((MenuItem)e.getSource()).getData();
IAspectAction action = factory.createAction(null);
- if(selectedEntryProxy instanceof PaletteAspectToolEntryProxy) {
+ if(selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
if(action instanceof IPostAction) {
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().add((IPostAction)action);
- } else {
- ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().add((IPreAction)action);
+ ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().add((IPostAction)action);
+ } else if(action instanceof IPreAction) {
+ ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().add((IPreAction)action);
}
setSelectedEntryProxy(selectedEntryProxy);
}
@@ -397,8 +395,12 @@ public class AspectActionsInformationComposite {
handleActionListSelectionChanged(null);
// select first post action
- if(selectedEntryProxy instanceof PaletteAspectToolEntryProxy && ((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().size() > 0) {
- viewer.setSelection(new StructuredSelection(((PaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().get(0)), true);
+ if(selectedEntryProxy instanceof IPaletteAspectToolEntryProxy && ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().size() > 0) {
+ viewer.setSelection(new StructuredSelection(((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().get(0)), true);
+ }
+ //select first pre action
+ else if(selectedEntryProxy instanceof IPaletteAspectToolEntryProxy && ((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().size() > 0) {
+ viewer.setSelection(new StructuredSelection(((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().get(0)), true);
}
updateButtons();
@@ -409,9 +411,9 @@ public class AspectActionsInformationComposite {
* Call this method to update the buttons enablement.
*/
protected void updateButtons() {
- if(selectedEntryProxy instanceof PaletteAspectToolEntryProxy) {
+ if(selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
addActionButton.setEnabled(true);
- if(((PaletteAspectToolEntryProxy)selectedEntryProxy).getAspectActions().size() > 0) {
+ if(((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPreActions().isEmpty() && !((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().isEmpty()) {
removeActionButton.setEnabled(true);
moveUpActionButton.setEnabled(true);
moveDownActionButton.setEnabled(true);
@@ -438,8 +440,11 @@ public class AspectActionsInformationComposite {
* @{inheritDoc
*/
public Object[] getChildren(Object parentElement) {
- if(parentElement instanceof PaletteAspectToolEntryProxy) {
- return ((PaletteAspectToolEntryProxy)parentElement).getPostActions().toArray();
+ if(parentElement instanceof IPaletteAspectToolEntryProxy) {
+ List<IAspectAction> actions = new ArrayList<IAspectAction>();
+ actions.addAll(((IPaletteAspectToolEntryProxy)parentElement).getPostActions());
+ actions.addAll(((IPaletteAspectToolEntryProxy)parentElement).getPreActions());
+ return actions.toArray();
}
return new Object[0];
}

Back to the top