Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvelten2013-04-11 14:35:44 +0000
committermvelten2013-04-11 14:35:44 +0000
commit7ef517921170c4a06b341588835f6d5c0afaede5 (patch)
tree8b911f0e8c47c66cc2c551c668bfa8849ec4cedd /plugins/customization
parente7b5911f92f27620d6c82d5879357dad75542bb7 (diff)
downloadorg.eclipse.papyrus-7ef517921170c4a06b341588835f6d5c0afaede5.tar.gz
org.eclipse.papyrus-7ef517921170c4a06b341588835f6d5c0afaede5.tar.xz
org.eclipse.papyrus-7ef517921170c4a06b341588835f6d5c0afaede5.zip
389247: [Palette framework] the current implementation bypass the command framework which brakes undo/redo
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389247 376276: Palette entry should use IPreAction interface https://bugs.eclipse.org/bugs/show_bug.cgi?id=376276
Diffstat (limited to 'plugins/customization')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java53
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java6
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/PaletteAspectToolEntryProxy.java26
3 files changed, 38 insertions, 47 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];
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
index 33533015f24..8e02014cde3 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
@@ -1994,6 +1994,12 @@ public class LocalPaletteContentPage extends WizardPage implements Listener {
action.save(postActionNode);
element.appendChild(postActionNode);
}
+ for(IAspectAction action : ((PaletteAspectToolEntryProxy)containerProxy).getPreActions()) {
+ Element preActionNode = document.createElement(IPapyrusPaletteConstant.PRE_ACTION);
+ preActionNode.setAttribute(IPapyrusPaletteConstant.ID, action.getFactoryId());
+ action.save(preActionNode);
+ element.appendChild(preActionNode);
+ }
}
default:
break;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/PaletteAspectToolEntryProxy.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/PaletteAspectToolEntryProxy.java
index 0a2f8f5e657..f19a2852d2f 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/PaletteAspectToolEntryProxy.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/PaletteAspectToolEntryProxy.java
@@ -17,17 +17,15 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.part.PaletteUtil;
import org.eclipse.papyrus.uml.diagram.common.service.AspectCreationEntry;
import org.eclipse.papyrus.uml.diagram.common.service.IPapyrusPaletteConstant;
-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.papyrus.uml.diagram.common.service.palette.StereotypePostAction;
import org.eclipse.swt.graphics.Image;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
@@ -41,7 +39,6 @@ public class PaletteAspectToolEntryProxy extends PaletteEntryProxy implements IP
/** list of pre actions executed by the tool */
protected List<IPreAction> preActions = new ArrayList<IPreAction>();
-
/**
* Creates a new {@link PaletteAspectToolEntryProxy}
*
@@ -81,7 +78,7 @@ public class PaletteAspectToolEntryProxy extends PaletteEntryProxy implements IP
*
* @return the list of pre actions attached to this {@link PaletteAspectToolEntryProxy}
*/
- protected List<IPreAction> getPreActions() {
+ public List<IPreAction> getPreActions() {
return preActions;
}
@@ -115,25 +112,8 @@ public class PaletteAspectToolEntryProxy extends PaletteEntryProxy implements IP
protected void initAspectActions() {
Object value = getEntry().getAspectProperties(IPapyrusPaletteConstant.ASPECT_ACTION_KEY);
if(value instanceof NodeList) {
- NodeList nodeList = ((NodeList)value);
- for(int i = 0; i < nodeList.getLength(); i++) {
- Node childNode = nodeList.item(i);
- String childName = childNode.getNodeName();
- if(IPapyrusPaletteConstant.POST_ACTION.equals(childName)) {
- // node is a post action => retrieve the id of the factory in charge of this configuration
- IAspectActionProvider provider = AspectToolService.getInstance().getProvider(AspectToolService.getProviderId(childNode));
- if(provider != null) {
- IPostAction action = (IPostAction)provider.createAction(childNode);
- postActions.add(action);
- } else {
- Activator.log.error("impossible to find factory with id: " + AspectToolService.getProviderId(childNode), null);
- }
- } else if(IPapyrusPaletteConstant.PRE_ACTION.equals(childName)) {
- // no implementation yet
- }
- }
+ PaletteUtil.initAspectActions((NodeList)value, postActions, preActions);
}
-
}
/**

Back to the top