Author: bbrodt
Date: 2011-04-07 18:22:30 -0400 (Thu, 07 Apr 2011)
New Revision: 30429
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/AbstractDeclarationAction.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateCorrelationSetAction.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateMessageExchangeAction.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreatePartnerLinkAction.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateVariableAction.java
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/ProcessContextMenuProvider.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ProcessAdapter.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java
Log:
https://issues.jboss.org/browse/JBIDE-7953
Added the ability to create variables, partnerLinks, messageExchanges and correlationSets
via the context menu
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/ProcessContextMenuProvider.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/ProcessContextMenuProvider.java 2011-04-07
20:47:00 UTC (rev 30428)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/ProcessContextMenuProvider.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -13,6 +13,7 @@
import java.util.List;
import org.eclipse.bpel.common.ui.tray.AddChildInTrayAction;
+import org.eclipse.bpel.ui.actions.AbstractDeclarationAction;
import org.eclipse.bpel.ui.actions.AutoArrangeFlowsAction;
import org.eclipse.bpel.ui.actions.BPELCopyAction;
import org.eclipse.bpel.ui.actions.BPELCutAction;
@@ -40,7 +41,6 @@
import org.eclipse.bpel.ui.util.BPELUtil;
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.DefaultEditDomain;
-import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.gef.ui.actions.SelectionAction;
@@ -121,6 +121,11 @@
menu.appendToGroup(GEFActionConstants.GROUP_COPY,
actionRegistry.getAction(BPELPasteAction.ID));
menu.appendToGroup(GEFActionConstants.GROUP_COPY,
actionRegistry.getAction(BPELDuplicateAction.ACTION_ID));
+ //
https://issues.jboss.org/browse/JBIDE-7953
+ // create the "Add" sub-menu before we iterate through all the
EditPartActions;
+ // some of these will go in the main context menu, some in the "Add"
sub-menu
+ MenuManager addMenu = new MenuManager(Messages.ProcessContextMenuProvider_Add_1);
+
// Frequently-used actions
List selected = getViewer().getSelectedEditParts();
if (selected.size() == 1) {// any more than 1 is ambiguous
@@ -140,7 +145,12 @@
//Image image = epAction.getIconImg();
if (s != null && imageDes != null) {
EditPartContextAction conAction = new EditPartContextAction(null, p, epAction);
- menu.appendToGroup(EDITPART_ACTIONS, conAction);
+ // if the action creates a declaration element (variables, partnerLinks, etc.)
+ // then add it to the "Add" sub-menu, instead of cluttering up the main
context menu
+ if ( epAction instanceof AbstractDeclarationAction )
+ addMenu.add(conAction);
+ else
+ menu.appendToGroup(EDITPART_ACTIONS, conAction);
}
}
}
@@ -148,7 +158,8 @@
}
// Add and Insert actions
- MenuManager addMenu = new MenuManager(Messages.ProcessContextMenuProvider_Add_1);
+ if (addMenu.getItems().length>0)
+ addMenu.add(new Separator());
MenuManager insertMenu = new
MenuManager(Messages.ProcessContextMenuProvider_Insert_Before_2);
// TODO: There should be a better way to do this
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/AbstractDeclarationAction.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/AbstractDeclarationAction.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/AbstractDeclarationAction.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -0,0 +1,58 @@
+package org.eclipse.bpel.ui.actions;
+
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.PartnerLinks;
+import org.eclipse.bpel.ui.actions.editpart.AbstractAction;
+import org.eclipse.bpel.ui.commands.CompoundCommand;
+import org.eclipse.bpel.ui.commands.InsertInContainerCommand;
+import org.eclipse.bpel.ui.commands.SetNameAndDirectEditCommand;
+import org.eclipse.bpel.ui.commands.SetSelectionCommand;
+import org.eclipse.bpel.ui.util.ModelHelper;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * A class for actions that create scope "declarations", i.e. variables,
partnerlinks,
+ * messageExchanges and correlationSets.
+ *
+ * @author bbrodt
+ * @see
https://issues.jboss.org/browse/JBIDE-7953
+ *
+ */
+public abstract class AbstractDeclarationAction extends AbstractAction {
+
+ protected EObject parent;
+ protected EObject child;
+
+ public AbstractDeclarationAction(EditPart anEditPart) {
+ super(anEditPart);
+ }
+
+ @Override
+ public boolean onButtonPressed() {
+ parent = getParent();
+ child = getChild();
+ if (parent==null || child==null)
+ return false;
+
+ InsertInContainerCommand insertCmd = new InsertInContainerCommand(parent, child,
null);
+ CompoundCommand command = new CompoundCommand(insertCmd.getLabel());
+ command.add( insertCmd );
+ command.add( new SetSelectionCommand ( parent, true ) );
+ command.add( new SetSelectionCommand ( child, false ) );
+ command.add(new SetNameAndDirectEditCommand(child, viewer));
+ ModelHelper.getBPELEditor(modelObject).getCommandStack().execute(command);
+ return true;
+ }
+
+ @Override
+ public String getToolTip() {
+ return getChild().eClass().getName();
+ }
+
+ public abstract EObject getParent();
+ public abstract EObject getChild();
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateCorrelationSetAction.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateCorrelationSetAction.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateCorrelationSetAction.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -0,0 +1,38 @@
+package org.eclipse.bpel.ui.actions;
+
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class CreateCorrelationSetAction extends AbstractDeclarationAction {
+
+
+ public CreateCorrelationSetAction(EditPart anEditPart) {
+ super(anEditPart);
+ }
+
+ @Override
+ public ImageDescriptor getIcon() {
+ return
BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_CORRELATIONSET_16);
+ }
+
+ @Override
+ public EObject getParent() {
+ EStructuralFeature feature =
((EObject)modelObject).eClass().getEStructuralFeature("correlationSets");
+ if (feature!=null) {
+ parent = (EObject) ((EObject)modelObject).eGet(feature);
+ }
+ return parent;
+ }
+
+ @Override
+ public EObject getChild() {
+ if (child==null)
+ child = BPELFactory.eINSTANCE.createCorrelationSet();
+ return child;
+ }
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateMessageExchangeAction.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateMessageExchangeAction.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateMessageExchangeAction.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -0,0 +1,37 @@
+package org.eclipse.bpel.ui.actions;
+
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class CreateMessageExchangeAction extends AbstractDeclarationAction {
+
+ public CreateMessageExchangeAction(EditPart anEditPart) {
+ super(anEditPart);
+ }
+
+ @Override
+ public ImageDescriptor getIcon() {
+ return
BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_MESSAGEEXCHANGE_16);
+ }
+
+ @Override
+ public EObject getParent() {
+ EStructuralFeature feature =
((EObject)modelObject).eClass().getEStructuralFeature("messageExchanges");
+ if (feature!=null) {
+ parent = (EObject) ((EObject)modelObject).eGet(feature);
+ }
+ return parent;
+ }
+
+ @Override
+ public EObject getChild() {
+ if (child==null)
+ child = BPELFactory.eINSTANCE.createMessageExchange();
+ return child;
+ }
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreatePartnerLinkAction.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreatePartnerLinkAction.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreatePartnerLinkAction.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -0,0 +1,37 @@
+package org.eclipse.bpel.ui.actions;
+
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class CreatePartnerLinkAction extends AbstractDeclarationAction {
+
+ public CreatePartnerLinkAction(EditPart anEditPart) {
+ super(anEditPart);
+ }
+
+ @Override
+ public ImageDescriptor getIcon() {
+ return
BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_ACTION_PARTNERLINK);
+ }
+
+ @Override
+ public EObject getParent() {
+ EStructuralFeature feature =
((EObject)modelObject).eClass().getEStructuralFeature("partnerLinks");
+ if (feature!=null) {
+ parent = (EObject) ((EObject)modelObject).eGet(feature);
+ }
+ return parent;
+ }
+
+ @Override
+ public EObject getChild() {
+ if (child==null)
+ child = BPELFactory.eINSTANCE.createPartnerLink();
+ return child;
+ }
+}
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateVariableAction.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateVariableAction.java
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/CreateVariableAction.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -0,0 +1,37 @@
+package org.eclipse.bpel.ui.actions;
+
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class CreateVariableAction extends AbstractDeclarationAction {
+
+ public CreateVariableAction(EditPart anEditPart) {
+ super(anEditPart);
+ }
+
+ @Override
+ public ImageDescriptor getIcon() {
+ return BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_VARIABLE_16);
+ }
+
+ @Override
+ public EObject getParent() {
+ EStructuralFeature feature =
((EObject)modelObject).eClass().getEStructuralFeature("variables");
+ if (feature!=null) {
+ parent = (EObject) ((EObject)modelObject).eGet(feature);
+ }
+ return parent;
+ }
+
+ @Override
+ public EObject getChild() {
+ if (child==null)
+ child = BPELFactory.eINSTANCE.createVariable();
+ return child;
+ }
+}
\ No newline at end of file
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ProcessAdapter.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ProcessAdapter.java 2011-04-07
20:47:00 UTC (rev 30428)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ProcessAdapter.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.bpel.ui.adapters;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.EventHandler;
import org.eclipse.bpel.model.FaultHandler;
@@ -17,6 +20,12 @@
import org.eclipse.bpel.ui.BPELUIPlugin;
import org.eclipse.bpel.ui.IBPELUIConstants;
import org.eclipse.bpel.ui.Messages;
+import org.eclipse.bpel.ui.actions.CreateCorrelationSetAction;
+import org.eclipse.bpel.ui.actions.CreateMessageExchangeAction;
+import org.eclipse.bpel.ui.actions.CreateVariableAction;
+import org.eclipse.bpel.ui.actions.CreatePartnerLinkAction;
+import org.eclipse.bpel.ui.actions.editpart.AbstractAction;
+import org.eclipse.bpel.ui.actions.editpart.IEditPartAction;
import org.eclipse.bpel.ui.adapters.delegates.ActivityContainer;
import org.eclipse.bpel.ui.adapters.delegates.IndirectContainer;
import org.eclipse.bpel.ui.adapters.delegates.MultiContainer;
@@ -36,7 +45,7 @@
public class ProcessAdapter extends ContainerAdapter implements INamedElement,
EditPartFactory, IOutlineEditPartFactory, IFaultHandlerHolder,
ILabeledElement, IEventHandlerHolder, ITrayEditPartFactory,
- IExtensionFactory
+ IExtensionFactory, IEditPartActionContributor
{
/* IContainer delegate */
@@ -144,5 +153,19 @@
public EObject createExtension(EObject object) {
return UiextensionmodelFactory.eINSTANCE.createProcessExtension();
+ }
+
+ /*
+ * Overrides the base class actions and appends the declaration actions
+ * @see
https://issues.jboss.org/browse/JBIDE-7953
+ */
+ @Override
+ public List<? extends IEditPartAction> getEditPartActions(EditPart editPart) {
+ List<AbstractAction> actions = new ArrayList<AbstractAction>();
+ actions.add(new CreatePartnerLinkAction(editPart));
+ actions.add(new CreateVariableAction(editPart));
+ actions.add(new CreateCorrelationSetAction(editPart));
+ actions.add(new CreateMessageExchangeAction(editPart));
+ return actions;
}
}
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java 2011-04-07
20:47:00 UTC (rev 30428)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java 2011-04-07
22:22:30 UTC (rev 30429)
@@ -24,6 +24,11 @@
import org.eclipse.bpel.model.Scope;
import org.eclipse.bpel.model.TerminationHandler;
import org.eclipse.bpel.model.Variables;
+import org.eclipse.bpel.ui.actions.CreateCorrelationSetAction;
+import org.eclipse.bpel.ui.actions.CreateMessageExchangeAction;
+import org.eclipse.bpel.ui.actions.CreatePartnerLinkAction;
+import org.eclipse.bpel.ui.actions.CreateVariableAction;
+import org.eclipse.bpel.ui.actions.editpart.AbstractAction;
import org.eclipse.bpel.ui.adapters.delegates.ActivityContainer;
import org.eclipse.bpel.ui.adapters.delegates.MultiContainer;
import org.eclipse.bpel.ui.adapters.delegates.OptionalIndirectContainer;
@@ -151,4 +156,18 @@
result.setModel(model);
return result;
}
+
+ /*
+ * Overrides the base class actions and appends the declaration actions
+ * @see
https://issues.jboss.org/browse/JBIDE-7953
+ */
+ @Override
+ public List<AbstractAction> getEditPartActions(final EditPart editPart) {
+ List<AbstractAction> actions = super.getEditPartActions(editPart);
+ actions.add(new CreatePartnerLinkAction(editPart));
+ actions.add(new CreateVariableAction(editPart));
+ actions.add(new CreateCorrelationSetAction(editPart));
+ actions.add(new CreateMessageExchangeAction(editPart));
+ return actions;
+ }
}
\ No newline at end of file