Author: koen.aers(a)jboss.com
Date: 2010-12-14 14:53:38 -0500 (Tue, 14 Dec 2010)
New Revision: 27480
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
Log:
add delete in details en definitions view, use a different PropertySheetEntry to work
around update problem
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java 2010-12-14
19:43:56 UTC (rev 27479)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java 2010-12-14
19:53:38 UTC (rev 27480)
@@ -1,16 +1,15 @@
package org.jboss.tools.bpmn2.process.diagram.sheet;
import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
-import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.gef.EditPart;
-import
org.eclipse.gmf.runtime.emf.ui.properties.sections.UndoableModelPropertySheetEntry;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.PropertySheetEntry;
import org.eclipse.ui.views.properties.PropertySheetPage;
import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
@@ -28,8 +27,9 @@
public Bpmn2PropertySheetPage(Bpmn2DiagramEditor editor) {
this.editor = editor;
- UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
- OperationHistoryFactory.getOperationHistory());
+ PropertySheetEntry root = new PropertySheetEntry();
+// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+// OperationHistoryFactory.getOperationHistory());
root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
setRootEntry(root);
}
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java 2010-12-14
19:43:56 UTC (rev 27479)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java 2010-12-14
19:53:38 UTC (rev 27480)
@@ -21,9 +21,11 @@
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.DeleteAction;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -45,6 +47,7 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.Page;
import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
@@ -73,6 +76,7 @@
private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+ private ImageDescriptor deleteImageDescriptor;
public Bpmn2DefinitionsPageImpl(Bpmn2DiagramEditor editor) {
this.editor = editor;
@@ -162,8 +166,39 @@
private void populatePopupMenu() {
createAddChildSubmenu();
createAddSiblingSubmenu();
+ if (!(selectedTreeObject instanceof Definitions)) {
+ createSeparator();
+ createDeleteMenuItem();
+ }
}
+ private void createSeparator() {
+ new MenuItem(popupMenu, SWT.SEPARATOR);
+ }
+
+ private ImageDescriptor getDeleteImageDescriptor() {
+ if (deleteImageDescriptor == null) {
+ ISharedImages sharedImages =
getSite().getWorkbenchWindow().getWorkbench().getSharedImages();
+ deleteImageDescriptor =
sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE);
+ }
+ return deleteImageDescriptor;
+ }
+
+ private void createDeleteMenuItem() {
+ MenuItem deleteMenuItem = new MenuItem(popupMenu, SWT.PUSH);
+ DeleteAction deleteAction = new DeleteAction(editor.getEditingDomain());
+ deleteMenuItem.setText(deleteAction.getText());
+ deleteMenuItem.setImage(getDeleteImageDescriptor().createImage());
+ ArrayList<EObject> selection = new ArrayList<EObject>();
+ selection.add(selectedTreeObject);
+ final Command deleteCommand = deleteAction.createCommand(selection);
+ deleteMenuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ editor.getEditingDomain().getCommandStack().execute(deleteCommand);
+ }
+ });
+ }
+
private void createAddChildSubmenu() {
MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
addChildMenuItem.setText("&New Child");
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java 2010-12-14
19:43:56 UTC (rev 27479)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java 2010-12-14
19:53:38 UTC (rev 27480)
@@ -18,11 +18,13 @@
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.DeleteAction;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -44,6 +46,7 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
@@ -83,6 +86,7 @@
private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+ private ImageDescriptor deleteImageDescriptor;
public Bpmn2DetailsPageImpl(Bpmn2DiagramEditor editor) {
this.editor = editor;
@@ -157,8 +161,43 @@
private void populatePopupMenu() {
createAddChildSubmenu();
createAddSiblingSubmenu();
+ if (!rootSelected()) {
+ createSeparator();
+ createDeleteMenuItem();
+ }
}
+ private boolean rootSelected() {
+ return selectedTreeObject == selectedEditorObject;
+ }
+
+ private void createSeparator() {
+ new MenuItem(popupMenu, SWT.SEPARATOR);
+ }
+
+ private ImageDescriptor getDeleteImageDescriptor() {
+ if (deleteImageDescriptor == null) {
+ ISharedImages sharedImages =
getSite().getWorkbenchWindow().getWorkbench().getSharedImages();
+ deleteImageDescriptor =
sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE);
+ }
+ return deleteImageDescriptor;
+ }
+
+ private void createDeleteMenuItem() {
+ MenuItem deleteMenuItem = new MenuItem(popupMenu, SWT.PUSH);
+ DeleteAction deleteAction = new DeleteAction(editor.getEditingDomain());
+ deleteMenuItem.setText(deleteAction.getText());
+ deleteMenuItem.setImage(getDeleteImageDescriptor().createImage());
+ ArrayList<EObject> selection = new ArrayList<EObject>();
+ selection.add(selectedTreeObject);
+ final Command deleteCommand = deleteAction.createCommand(selection);
+ deleteMenuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ editor.getEditingDomain().getCommandStack().execute(deleteCommand);
+ }
+ });
+ }
+
private void createAddChildSubmenu() {
MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
addChildMenuItem.setText("&New Child");
@@ -171,7 +210,7 @@
if (descriptor instanceof CommandParameter) {
CommandParameter commandParameter = (CommandParameter)descriptor;
Object value = commandParameter.getValue();
- if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
EObject)) continue;
actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
}
}
@@ -181,7 +220,6 @@
menuItem.setText(action.getText());
menuItem.setImage(action.getImageDescriptor().createImage());
menuItem.addSelectionListener(new SelectionAdapter() {
- @Override
public void widgetSelected(SelectionEvent e) {
action.run();
}