Author: koen.aers(a)jboss.com
Date: 2010-12-13 08:09:26 -0500 (Mon, 13 Dec 2010)
New Revision: 27408
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPageOld.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/plugin.xml
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/part/Bpmn2DiagramEditor.java
Log:
definitions, details and properties views working
Modified: trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/plugin.xml
===================================================================
--- trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/plugin.xml 2010-12-13
12:30:48 UTC (rev 27407)
+++ trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/plugin.xml 2010-12-13
13:09:26 UTC (rev 27408)
@@ -48,11 +48,13 @@
<extension point="org.eclipse.ui.newWizards"
id="creation-wizard">
<?gmfgen generated="false"?>
<wizard
- name="%newWizardName"
- icon="icons/obj16/jbpm_icon_16.png"
- category="org.jboss.tools.jbpm"
- class="org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizard"
-
id="org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizardID">
+ category="org.jboss.tools.jbpm"
+
class="org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizard"
+ finalPerspective="org.jboss.tools.bpmn2"
+ icon="icons/obj16/jbpm_icon_16.png"
+
id="org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizardID"
+ name="%newWizardName"
+ preferredPerspectives="org.jboss.tools.bpmn2">
<description>%newWizardDesc</description>
</wizard>
<category
@@ -880,5 +882,41 @@
</perspectiveExtension>
</extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.jboss.tools.bpmn2"
+ name="BPMN 2.0"/>
+ <view
+ category="org.jboss.tools.bpmn2"
+ class="org.jboss.tools.bpmn2.view.Bpmn2Details"
+ icon="icons/obj16/jbpm_icon_16.png"
+ id="org.jboss.tools.bpmn2.details"
+ name="Details"
+ restorable="true">
+ </view>
+ <view
+ category="org.jboss.tools.bpmn2"
+ class="org.jboss.tools.bpmn2.view.Bpmn2Definitions"
+ icon="icons/obj16/jbpm_icon_16.png"
+ id="org.jboss.tools.bpmn2.definitions"
+ name="Definitions"
+ restorable="true">
+ </view>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ name="BPMN 2.0"
+ icon="icons/obj16/jbpm_icon_16.png"
+ class="org.jboss.tools.bpmn2.Bpmn2PerspectiveFactory"
+ id="org.jboss.tools.bpmn2">
+ <description>
+ A perspective to facilitate creation of jBPM JPDL process definitions.
+ </description>
+ </perspective>
+ </extension>
+
<!-- optionally, specify keybindings -->
</plugin>
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/part/Bpmn2DiagramEditor.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/part/Bpmn2DiagramEditor.java 2010-12-13
12:30:48 UTC (rev 27407)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/part/Bpmn2DiagramEditor.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -44,6 +44,10 @@
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.jboss.tools.bpmn2.process.diagram.navigator.Bpmn2NavigatorItem;
import org.jboss.tools.bpmn2.process.diagram.sheet.Bpmn2PropertySheetPage;
+import org.jboss.tools.bpmn2.view.Bpmn2DefinitionsPageImpl;
+import org.jboss.tools.bpmn2.view.Bpmn2DetailsPageImpl;
+import org.jboss.tools.bpmn2.view.IBpmn2DefinitionsPage;
+import org.jboss.tools.bpmn2.view.IBpmn2DetailsPage;
/**
* @generated
@@ -109,12 +113,16 @@
return new String[] { ProjectExplorer.VIEW_ID };
}
};
+ } else if (type == IBpmn2DefinitionsPage.class) {
+ return new Bpmn2DefinitionsPageImpl(this);
+ } else if (type == IBpmn2DetailsPage.class) {
+ return new Bpmn2DetailsPageImpl(this);
} else if (type == IPropertySheetPage.class) {
return new Bpmn2PropertySheetPage(this);
}
return super.getAdapter(type);
}
-
+
/**
* @generated
*/
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.bpmn2;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.progress.IProgressConstants;
+
+public class Bpmn2PerspectiveFactory implements IPerspectiveFactory {
+
+ public void createInitialLayout(IPageLayout layout) {
+ String editorArea = layout.getEditorArea();
+
+ IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT,
(float)0.25, editorArea); //$NON-NLS-1$
+ folder.addView(JavaUI.ID_PACKAGES);
+ folder.addPlaceholder("org.eclipse.ui.navigator.ProjectExplorer");
+ folder.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY);
+ folder.addPlaceholder("org.eclipse.ui.views.ResourceNavigator");
+
+ layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.BOTTOM, (float)0.70,
"left");
+
+ IFolderLayout bpmnFolder = layout.createFolder("bpmn", IPageLayout.BOTTOM,
(float)0.70, editorArea);
+ bpmnFolder.addView("org.jboss.tools.bpmn2.details");
+ bpmnFolder.addView("org.jboss.tools.bpmn2.definitions");
+
+ IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.RIGHT,
(float)0.33, "bpmn"); //$NON-NLS-1$
+ outputfolder.addView(IPageLayout.ID_PROP_SHEET);
+ outputfolder.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
+ outputfolder.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
+ outputfolder.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
+ outputfolder.addPlaceholder("org.eclipse.search.ui.views.SearchView");
+ outputfolder.addPlaceholder("org.eclipse.ui.console.ConsoleView");
+ outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+ outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
+
+ layout.addActionSet("org.eclipse.debug.ui.launchActionSet");
+ layout.addActionSet(JavaUI.ID_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+ layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+
+ // views - java
+ layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+ layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+ layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+ layout.addShowViewShortcut(JavaUI.ID_JAVADOC_VIEW);
+
+ // views - search
+ layout.addShowViewShortcut("org.eclipse.search.ui.views.SearchView");
+
+ // views - debugging
+ layout.addShowViewShortcut("org.eclipse.ui.console.ConsoleView");
+
+ // views - standard workbench
+ layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
+ layout.addShowViewShortcut("org.jbpm.gd.jpdl.overview");
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+ layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+ layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
+
+ // new actions - Java project creation wizard
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewEnumCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.jbpm.ui.wizard.new.file"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizardID");//$NON-NLS-1$
+ }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java 2010-12-13
12:30:48 UTC (rev 27407)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -1,329 +1,317 @@
package org.jboss.tools.bpmn2.process.diagram.sheet;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.bpmn2.Artifact;
-import org.eclipse.bpmn2.BaseElement;
-import org.eclipse.bpmn2.FlowElement;
import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
import org.eclipse.core.commands.operations.OperationHistoryFactory;
-import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.EContentAdapter;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.command.CommandParameter;
-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.provider.AdapterFactoryContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
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.action.IAction;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
-public class Bpmn2PropertySheetPage implements IPropertySheetPage {
+public class Bpmn2PropertySheetPage extends PropertySheetPage {
- private EObject selectedEditorObject = null;
- private EObject selectedTreeObject = null;
+// private EObject selectedEditorObject = null;
+// private EObject selectedObject = null;
private Bpmn2DiagramEditor editor;
- private Composite mainControl, masterArea, detailsArea;
- private TreeViewer treeViewer;
- private PropertySheetPage propertySheetPage;
+// private Composite mainControl, masterArea, detailsArea;
+// private TreeViewer treeViewer;
+// private PropertySheetPage propertySheetPage;
+// private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+// private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
- private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
public Bpmn2PropertySheetPage(Bpmn2DiagramEditor editor) {
this.editor = editor;
- }
-
- @Override
- public void createControl(Composite parent) {
- mainControl = createMainControl(parent);
- createMasterArea(mainControl);
- createDetailsArea(mainControl);
- }
-
- public Composite createMainControl(Composite parent) {
- Composite composite = editor.getFormToolkit().createComposite(parent);
- FormLayout layout = new FormLayout();
- layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2;
- layout.marginHeight = ITabbedPropertyConstants.VSPACE;
- layout.spacing = ITabbedPropertyConstants.VMARGIN + 1;
- composite.setLayout(layout);
- return composite;
- }
-
- private void createMasterArea(Composite composite) {
- masterArea = editor.getFormToolkit().createComposite(composite);
- masterArea.setLayoutData(createMasterAreaLayoutData());
- masterArea.setLayout(new FormLayout());
- Tree eventTree = editor.getFormToolkit().createTree(
- masterArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION);
- eventTree.setLayoutData(createFillLayoutData());
- popupMenu = createPopupMenu(eventTree);
- eventTree.setMenu(popupMenu);
- treeViewer = new TreeViewer(eventTree);
- treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
- treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
- treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- handleTreeViewerSelectionChanged(event);
- }
- });
- }
-
- private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
- propertySheetPage.selectionChanged(null, event.getSelection());
- EObject object = unwrapTreeViewerSelection(event.getSelection());
- if (object != selectedTreeObject) {
- selectedTreeObject = object;
- }
- }
-
- private EObject unwrapTreeViewerSelection(ISelection selection) {
- EObject result = null;
- if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection)selection).getFirstElement();
- if (object != null && object instanceof EObject) {
- result = (EObject)object;
- }
- }
- return result;
- }
-
- private FormData createMasterAreaLayoutData() {
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(0, 200);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- return data;
- }
-
- private FormData createFillLayoutData() {
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- return data;
- }
-
- private void createDetailsArea(Composite composite) {
- detailsArea = editor.getFormToolkit().createComposite(composite, SWT.BORDER);
- detailsArea.setLayoutData(createDetailsAreaLayoutData());
- detailsArea.setLayout(new FormLayout());
- propertySheetPage = new PropertySheetPage();
UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
- OperationHistoryFactory.getOperationHistory());
+ OperationHistoryFactory.getOperationHistory());
root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
- propertySheetPage.setRootEntry(root);
- propertySheetPage.createControl(detailsArea);
- propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+ setRootEntry(root);
}
- private FormData createDetailsAreaLayoutData() {
- FormData data = new FormData();
- data.left = new FormAttachment(masterArea, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- return data;
- }
-
- private Menu createPopupMenu(Composite composite) {
- Menu popupMenu = new Menu(composite);
- composite.setMenu(popupMenu);
- popupMenu.addMenuListener(new MenuAdapter() {
- public void menuShown(MenuEvent e) {
- depopulatePopupMenu();
- populatePopupMenu();
- }
- });
- return popupMenu;
- }
-
- private Object getTreeViewerSelectionUnwrapped() {
- ISelection selection = treeViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- return ((IStructuredSelection)selection).getFirstElement();
- }
- return null;
- }
+// @Override
+// public void createControl(Composite parent) {
+//// propertySheetPage = new PropertySheetPage();
+//// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+//// OperationHistoryFactory.getOperationHistory());
+//// root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+//// propertySheetPage.setRootEntry(root);
+//// propertySheetPage.createControl(parent);
+//// propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+// mainControl = createMainControl(parent);
+// createMasterArea(mainControl);
+// createDetailsArea(mainControl);
+// }
+//
+// public Composite createMainControl(Composite parent) {
+// Composite composite = editor.getFormToolkit().createComposite(parent);
+// FormLayout layout = new FormLayout();
+// layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2;
+// layout.marginHeight = ITabbedPropertyConstants.VSPACE;
+// layout.spacing = ITabbedPropertyConstants.VMARGIN + 1;
+// composite.setLayout(layout);
+// return composite;
+// }
+//
+// private void createMasterArea(Composite composite) {
+// masterArea = editor.getFormToolkit().createComposite(composite);
+// masterArea.setLayoutData(createMasterAreaLayoutData());
+// masterArea.setLayout(new FormLayout());
+// Tree eventTree = editor.getFormToolkit().createTree(
+// masterArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION);
+// eventTree.setLayoutData(createFillLayoutData());
+// popupMenu = createPopupMenu(eventTree);
+// eventTree.setMenu(popupMenu);
+// treeViewer = new TreeViewer(eventTree);
+// treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+// treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+// treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+// treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+// @Override
+// public void selectionChanged(SelectionChangedEvent event) {
+// handleTreeViewerSelectionChanged(event);
+// }
+// });
+// }
+//
+// private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+// propertySheetPage.selectionChanged(null, event.getSelection());
+// EObject object = unwrapSelection(event.getSelection());
+// if (object != selectedObject) {
+// selectedObject = object;
+// }
+// }
+//
+// private EObject unwrapSelection(ISelection selection) {
+// EObject result = null;
+// if (selection instanceof IStructuredSelection) {
+// Object object = ((IStructuredSelection)selection).getFirstElement();
+// if (object != null && object instanceof EditPart) {
+// object = ((EditPart)object).getModel();
+// }
+// if (object != null && object instanceof View) {
+// result = ((View)object).getElement();
+// } else if (object instanceof EObject) {
+// result = (EObject)object;
+// }
+// }
+// return result;
+// }
+//
+// private FormData createMasterAreaLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(0, 0);
+// data.right = new FormAttachment(0, 200);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private FormData createFillLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(0, 0);
+// data.right = new FormAttachment(100, 0);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private void createDetailsArea(Composite composite) {
+// detailsArea = editor.getFormToolkit().createComposite(composite, SWT.BORDER);
+// detailsArea.setLayoutData(createDetailsAreaLayoutData());
+// detailsArea.setLayout(new FormLayout());
+// propertySheetPage = new PropertySheetPage();
+// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+// OperationHistoryFactory.getOperationHistory());
+// root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+// propertySheetPage.setRootEntry(root);
+// propertySheetPage.createControl(detailsArea);
+// propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+// }
+//
+// private FormData createDetailsAreaLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(masterArea, 0);
+// data.right = new FormAttachment(100, 0);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private Menu createPopupMenu(Composite composite) {
+// Menu popupMenu = new Menu(composite);
+// composite.setMenu(popupMenu);
+// popupMenu.addMenuListener(new MenuAdapter() {
+// public void menuShown(MenuEvent e) {
+// depopulatePopupMenu();
+// populatePopupMenu();
+// }
+// });
+// return popupMenu;
+// }
+//
+// private Object getTreeViewerSelectionUnwrapped() {
+// ISelection selection = treeViewer.getSelection();
+// if (selection instanceof IStructuredSelection) {
+// return ((IStructuredSelection)selection).getFirstElement();
+// }
+// return null;
+// }
+//
+// private void createAddChildSubmenu() {
+// MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+// addChildMenuItem.setText("&New Child");
+// addChildSubmenu = new Menu(addChildMenuItem);
+// addChildMenuItem.setMenu(addChildSubmenu);
+// Object obj = getTreeViewerSelectionUnwrapped();
+// Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(obj, null);
+// ArrayList<IAction> actions = new ArrayList<IAction>();
+// for (Object descriptor : descriptors) {
+// if (descriptor instanceof CommandParameter) {
+// CommandParameter commandParameter = (CommandParameter)descriptor;
+// Object value = commandParameter.getValue();
+// if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+// actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+// }
+// }
+// addChildMenuItem.setEnabled(!actions.isEmpty());
+// for (final IAction action : actions) {
+// MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+// menuItem.setText(action.getText());
+// menuItem.setImage(action.getImageDescriptor().createImage());
+// menuItem.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// action.run();
+// }
+// });
+// }
+// }
+//
+// private void createAddSiblingSubmenu() {
+// MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+// addSiblingMenuItem.setText("N&ew Sibling");
+// addSiblingSubmenu = new Menu(addSiblingMenuItem);
+// addSiblingMenuItem.setMenu(addSiblingSubmenu);
+// if (!canEnableAddSibling()) {
+// addSiblingMenuItem.setEnabled(false);
+// } else {
+// Object obj = getTreeViewerSelectionUnwrapped();
+// Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+// ArrayList<IAction> actions = new ArrayList<IAction>();
+// for (Object descriptor : descriptors) {
+// if (descriptor instanceof CommandParameter) {
+// CommandParameter commandParameter = (CommandParameter)descriptor;
+// Object value = commandParameter.getValue();
+// if (value instanceof FlowElement || value instanceof Artifact || !(value
instanceof BaseElement)) continue;
+// actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+// }
+// }
+// addSiblingMenuItem.setEnabled(!actions.isEmpty());
+// for (final IAction action : actions) {
+// MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+// menuItem.setText(action.getText());
+// menuItem.setImage(action.getImageDescriptor().createImage());
+// menuItem.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// action.run();
+// }
+// });
+// }
+// }
+// }
+//
+// private boolean canEnableAddSibling() {
+// ISelection selection = treeViewer.getSelection();
+// if (selection instanceof IStructuredSelection) {
+// Object object = ((IStructuredSelection)selection).getFirstElement();
+// if (object != null && object instanceof EObject) {
+// return ((EObject)object).eContainer() != treeViewer.getInput();
+// }
+// }
+// return false;
+// }
+//
+// private void depopulatePopupMenu() {
+// disposePopupMenuItems(popupMenu);
+// }
+//
+// private void disposePopupMenuItems(Menu menu) {
+// for (MenuItem menuItem : menu.getItems()) {
+// Menu nestedMenu = menuItem.getMenu();
+// if (nestedMenu != null) {
+// disposePopupMenuItems(nestedMenu);
+// }
+// menuItem.dispose();
+// }
+// }
+//
+// private void populatePopupMenu() {
+// createAddChildSubmenu();
+// createAddSiblingSubmenu();
+// }
+//
+// @Override
+// public void dispose() {
+// popupMenu.dispose();
+// detailsArea.dispose();
+// masterArea.dispose();
+// mainControl.dispose();
+// }
+//
+// @Override
+// public Control getControl() {
+// return mainControl;
+// }
+//
+// @Override
+// public void setActionBars(IActionBars actionBars) {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void setFocus() {
+// // TODO Auto-generated method stub
+//
+// }
- private void createAddChildSubmenu() {
- MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
- addChildMenuItem.setText("&New Child");
- addChildSubmenu = new Menu(addChildMenuItem);
- addChildMenuItem.setMenu(addChildSubmenu);
- Object obj = getTreeViewerSelectionUnwrapped();
- Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
- ArrayList<IAction> actions = new ArrayList<IAction>();
- for (Object descriptor : descriptors) {
- if (descriptor instanceof CommandParameter) {
- CommandParameter commandParameter = (CommandParameter)descriptor;
- Object value = commandParameter.getValue();
- if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
- actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
- }
- }
- addChildMenuItem.setEnabled(!actions.isEmpty());
- for (final IAction action : actions) {
- MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
- menuItem.setText(action.getText());
- menuItem.setImage(action.getImageDescriptor().createImage());
- menuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- action.run();
- }
- });
- }
- }
-
- private void createAddSiblingSubmenu() {
- MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
- addSiblingMenuItem.setText("N&ew Sibling");
- addSiblingSubmenu = new Menu(addSiblingMenuItem);
- addSiblingMenuItem.setMenu(addSiblingSubmenu);
- if (!canEnableAddSibling()) {
- addSiblingMenuItem.setEnabled(false);
- } else {
- Object obj = getTreeViewerSelectionUnwrapped();
- Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
- ArrayList<IAction> actions = new ArrayList<IAction>();
- for (Object descriptor : descriptors) {
- if (descriptor instanceof CommandParameter) {
- CommandParameter commandParameter = (CommandParameter)descriptor;
- Object value = commandParameter.getValue();
- if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
- actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
- }
- }
- addSiblingMenuItem.setEnabled(!actions.isEmpty());
- for (final IAction action : actions) {
- MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
- menuItem.setText(action.getText());
- menuItem.setImage(action.getImageDescriptor().createImage());
- menuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- action.run();
- }
- });
- }
- }
- }
-
- private boolean canEnableAddSibling() {
- ISelection selection = treeViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection)selection).getFirstElement();
- if (object != null && object instanceof EObject) {
- return ((EObject)object).eContainer() != treeViewer.getInput();
- }
- }
- return false;
- }
-
- private void depopulatePopupMenu() {
- disposePopupMenuItems(popupMenu);
- }
-
- private void disposePopupMenuItems(Menu menu) {
- for (MenuItem menuItem : menu.getItems()) {
- Menu nestedMenu = menuItem.getMenu();
- if (nestedMenu != null) {
- disposePopupMenuItems(nestedMenu);
- }
- menuItem.dispose();
- }
- }
-
- private void populatePopupMenu() {
- createAddChildSubmenu();
- createAddSiblingSubmenu();
- }
-
- @Override
- public void dispose() {
- popupMenu.dispose();
- detailsArea.dispose();
- masterArea.dispose();
- mainControl.dispose();
- }
-
@Override
- public Control getControl() {
- return mainControl;
- }
-
- @Override
- public void setActionBars(IActionBars actionBars) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setFocus() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (part == editor) {
- EObject object = unwrapEditorSelection(selection);
- if (object != selectedEditorObject) {
- if (selectedEditorObject != null) {
- selectedEditorObject.eAdapters().remove(selectedElementObserver);
- }
- selectedEditorObject = object;
- if (selectedEditorObject != null) {
- selectedEditorObject.eAdapters().add(selectedElementObserver);
- treeViewer.setInput(selectedEditorObject.eContainer());
- treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
- } else {
- treeViewer.setInput(null);
- treeViewer.setSelection(null);
- }
-
- }
- }
+ selection = new StructuredSelection(unwrapEditorSelection(selection));
+ }
+ super.selectionChanged(part, selection);
+// if (part == editor || part instanceof Bpmn2Details) {
+// EObject object = unwrapEditorSelection(selection);
+// if (object != selectedEditorObject) {
+// if (selectedEditorObject != null) {
+// selectedEditorObject.eAdapters().remove(selectedElementObserver);
+// }
+// selectedEditorObject = object;
+// if (selectedEditorObject != null) {
+// selectedEditorObject.eAdapters().add(selectedElementObserver);
+// treeViewer.setInput(selectedEditorObject.eContainer());
+// treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
+// } else {
+// treeViewer.setInput(null);
+// treeViewer.setSelection(null);
+// }
+//
+// }
+// }
+// propertySheetPage.selectionChanged(null, selection);
+// EObject object = unwrapSelection(selection);
+// if (object != selectedObject) {
+// selectedObject = object;
+// propertySheetPage.selectionChanged(null, selection);
+// }
}
private EObject unwrapEditorSelection(ISelection selection) {
@@ -341,60 +329,60 @@
return ((View)object).getElement();
}
- class RootFilter extends ViewerFilter {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
- return false;
- }
- return true;
- }
- }
-
- class FlowElementFilter extends ViewerFilter {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (parentElement != selectedEditorObject.eContainer() && (element instanceof
FlowElement || element instanceof Artifact)) {
- return false;
- }
- return true;
- }
- }
-
- private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
- class SelectedElementObserver extends EContentAdapter {
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- handleSelectedElementChanged(notification);
- }
- }
-
- private void handleSelectedElementChanged(Notification notification) {
- int eventType = notification.getEventType();
- if (eventType == Notification.ADD || eventType == Notification.SET) {
- Object object = notification.getNewValue();
- if (object instanceof EObject) {
- setIdIfNotSet((EObject)object);
- updateTreeSelection(object);
- }
- }
- }
-
- private void updateTreeSelection(final Object object) {
- getControl().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- treeViewer.setSelection(new StructuredSelection(object));
- }
- });
- }
-
- protected void setIdIfNotSet(EObject obj) {
- if (obj.eClass() != null) {
- EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
- if (idAttr != null && !obj.eIsSet(idAttr)) {
- CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
- Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
- editor.getEditingDomain().getCommandStack().execute(command);
- }
- }
- }
+// class RootFilter extends ViewerFilter {
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
+// return false;
+// }
+// return true;
+// }
+// }
+//
+// class FlowElementFilter extends ViewerFilter {
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (parentElement != selectedEditorObject.eContainer() && (element
instanceof FlowElement || element instanceof Artifact)) {
+// return false;
+// }
+// return true;
+// }
+// }
+//
+// private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+// class SelectedElementObserver extends EContentAdapter {
+// public void notifyChanged(Notification notification) {
+// super.notifyChanged(notification);
+// handleSelectedElementChanged(notification);
+// }
+// }
+//
+// private void handleSelectedElementChanged(Notification notification) {
+// int eventType = notification.getEventType();
+// if (eventType == Notification.ADD || eventType == Notification.SET) {
+// Object object = notification.getNewValue();
+// if (object instanceof EObject) {
+// setIdIfNotSet((EObject)object);
+// updateTreeSelection(object);
+// }
+// }
+// }
+//
+// private void updateTreeSelection(final Object object) {
+// getControl().getDisplay().asyncExec(new Runnable() {
+// @Override
+// public void run() {
+// treeViewer.setSelection(new StructuredSelection(object));
+// }
+// });
+// }
+//
+// protected void setIdIfNotSet(EObject obj) {
+// if (obj.eClass() != null) {
+// EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+// if (idAttr != null && !obj.eIsSet(idAttr)) {
+// CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+// Command command =
editor.getEditingDomain().createCommand(SetCommand.class, commandParameter);
+// editor.getEditingDomain().getCommandStack().execute(command);
+// }
+// }
+// }
}
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPageOld.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPageOld.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPageOld.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,422 @@
+package org.jboss.tools.bpmn2.process.diagram.sheet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.CommandParameter;
+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.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+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.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+import org.jboss.tools.bpmn2.view.Bpmn2Details;
+
+public class Bpmn2PropertySheetPageOld implements IPropertySheetPage {
+
+ private EObject selectedEditorObject = null;
+ private EObject selectedObject = null;
+ private Bpmn2DiagramEditor editor;
+ private Composite mainControl, masterArea, detailsArea;
+ private TreeViewer treeViewer;
+ private PropertySheetPage propertySheetPage;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+
+ public Bpmn2PropertySheetPageOld(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+// propertySheetPage = new PropertySheetPage();
+// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+// OperationHistoryFactory.getOperationHistory());
+// root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+// propertySheetPage.setRootEntry(root);
+// propertySheetPage.createControl(parent);
+// propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+ mainControl = createMainControl(parent);
+ createMasterArea(mainControl);
+ createDetailsArea(mainControl);
+ }
+
+ public Composite createMainControl(Composite parent) {
+ Composite composite = editor.getFormToolkit().createComposite(parent);
+ FormLayout layout = new FormLayout();
+ layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2;
+ layout.marginHeight = ITabbedPropertyConstants.VSPACE;
+ layout.spacing = ITabbedPropertyConstants.VMARGIN + 1;
+ composite.setLayout(layout);
+ return composite;
+ }
+
+ private void createMasterArea(Composite composite) {
+ masterArea = editor.getFormToolkit().createComposite(composite);
+ masterArea.setLayoutData(createMasterAreaLayoutData());
+ masterArea.setLayout(new FormLayout());
+ Tree eventTree = editor.getFormToolkit().createTree(
+ masterArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ popupMenu = createPopupMenu(eventTree);
+ eventTree.setMenu(popupMenu);
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTreeViewerSelectionChanged(event);
+ }
+ });
+ }
+
+ private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+ propertySheetPage.selectionChanged(null, event.getSelection());
+ EObject object = unwrapSelection(event.getSelection());
+ if (object != selectedObject) {
+ selectedObject = object;
+ }
+ }
+
+ private EObject unwrapSelection(ISelection selection) {
+ EObject result = null;
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EditPart) {
+ object = ((EditPart)object).getModel();
+ }
+ if (object != null && object instanceof View) {
+ result = ((View)object).getElement();
+ } else if (object instanceof EObject) {
+ result = (EObject)object;
+ }
+ }
+ return result;
+ }
+
+ private FormData createMasterAreaLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(0, 200);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private void createDetailsArea(Composite composite) {
+ detailsArea = editor.getFormToolkit().createComposite(composite, SWT.BORDER);
+ detailsArea.setLayoutData(createDetailsAreaLayoutData());
+ detailsArea.setLayout(new FormLayout());
+ propertySheetPage = new PropertySheetPage();
+ UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+ OperationHistoryFactory.getOperationHistory());
+ root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+ propertySheetPage.setRootEntry(root);
+ propertySheetPage.createControl(detailsArea);
+ propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+ }
+
+ private FormData createDetailsAreaLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(masterArea, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private Menu createPopupMenu(Composite composite) {
+ Menu popupMenu = new Menu(composite);
+ composite.setMenu(popupMenu);
+ popupMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ depopulatePopupMenu();
+ populatePopupMenu();
+ }
+ });
+ return popupMenu;
+ }
+
+ private Object getTreeViewerSelectionUnwrapped() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+ private void createAddChildSubmenu() {
+ MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addChildMenuItem.setText("&New Child");
+ addChildSubmenu = new Menu(addChildMenuItem);
+ addChildMenuItem.setMenu(addChildSubmenu);
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addChildMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+
+ private void createAddSiblingSubmenu() {
+ MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addSiblingMenuItem.setText("N&ew Sibling");
+ addSiblingSubmenu = new Menu(addSiblingMenuItem);
+ addSiblingMenuItem.setMenu(addSiblingSubmenu);
+ if (!canEnableAddSibling()) {
+ addSiblingMenuItem.setEnabled(false);
+ } else {
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addSiblingMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+ }
+
+ private boolean canEnableAddSibling() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ return ((EObject)object).eContainer() != treeViewer.getInput();
+ }
+ }
+ return false;
+ }
+
+ private void depopulatePopupMenu() {
+ disposePopupMenuItems(popupMenu);
+ }
+
+ private void disposePopupMenuItems(Menu menu) {
+ for (MenuItem menuItem : menu.getItems()) {
+ Menu nestedMenu = menuItem.getMenu();
+ if (nestedMenu != null) {
+ disposePopupMenuItems(nestedMenu);
+ }
+ menuItem.dispose();
+ }
+ }
+
+ private void populatePopupMenu() {
+ createAddChildSubmenu();
+ createAddSiblingSubmenu();
+ }
+
+ @Override
+ public void dispose() {
+ popupMenu.dispose();
+ detailsArea.dispose();
+ masterArea.dispose();
+ mainControl.dispose();
+ }
+
+ @Override
+ public Control getControl() {
+ return mainControl;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (part == editor || part instanceof Bpmn2Details) {
+ EObject object = unwrapEditorSelection(selection);
+ if (object != selectedEditorObject) {
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().remove(selectedElementObserver);
+ }
+ selectedEditorObject = object;
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().add(selectedElementObserver);
+ treeViewer.setInput(selectedEditorObject.eContainer());
+ treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
+ } else {
+ treeViewer.setInput(null);
+ treeViewer.setSelection(null);
+ }
+
+ }
+ }
+// propertySheetPage.selectionChanged(null, selection);
+// EObject object = unwrapSelection(selection);
+// if (object != selectedObject) {
+// selectedObject = object;
+// propertySheetPage.selectionChanged(null, selection);
+// }
+ }
+
+ private EObject unwrapEditorSelection(ISelection selection) {
+ if (!(selection instanceof StructuredSelection)) {
+ return null;
+ }
+ Object object = ((StructuredSelection)selection).getFirstElement();
+ if (object instanceof BaseElement) {
+ return (BaseElement)object;
+ }
+ if (object == null || !(object instanceof EditPart)) {
+ return null;
+ }
+ object = ((EditPart)object).getModel();
+ if (object == null || !(object instanceof View)) {
+ return null;
+ }
+ return ((View)object).getElement();
+ }
+
+ class RootFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement != selectedEditorObject.eContainer() && (element instanceof
FlowElement || element instanceof Artifact)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+ class SelectedElementObserver extends EContentAdapter {
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ handleSelectedElementChanged(notification);
+ }
+ }
+
+ private void handleSelectedElementChanged(Notification notification) {
+ int eventType = notification.getEventType();
+ if (eventType == Notification.ADD || eventType == Notification.SET) {
+ Object object = notification.getNewValue();
+ if (object instanceof EObject) {
+ setIdIfNotSet((EObject)object);
+ updateTreeSelection(object);
+ }
+ }
+ }
+
+ private void updateTreeSelection(final Object object) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ treeViewer.setSelection(new StructuredSelection(object));
+ }
+ });
+ }
+
+ protected void setIdIfNotSet(EObject obj) {
+ if (obj.eClass() != null) {
+ EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+ if (idAttr != null && !obj.eIsSet(idAttr)) {
+ CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+ Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
+ editor.getEditingDomain().getCommandStack().execute(command);
+ }
+ }
+ }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPageOld.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java 2010-12-13
12:30:48 UTC (rev 27407)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -3,20 +3,16 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.bpmn2.di.BPMNDiagram;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.XMLResource.ResourceHandler;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
import org.jboss.tools.bpmn2.gmf.notation.BpmnNotationFactory;
public class Bpmn2ResourceFactoryImpl extends
org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl {
@@ -63,16 +59,16 @@
Map<?, ?> options) {
}
- private View getParentView(View candidate, View view) {
- for (Object child : candidate.getVisibleChildren()) {
- if (child == view) {
- return candidate;
- } else {
- return getParentView((View)child, view);
- }
- }
- return null;
- }
+// private View getParentView(View candidate, View view) {
+// for (Object child : candidate.getVisibleChildren()) {
+// if (child == view) {
+// return candidate;
+// } else {
+// return getParentView((View)child, view);
+// }
+// }
+// return null;
+// }
@Override
public void postSave(XMLResource resource, OutputStream outputStream,
@@ -83,15 +79,15 @@
}
- private void prepareSave(Resource resource) {
- EObject cur;
- for (Iterator<EObject> iter = resource.getAllContents(); iter.hasNext();)
{
- cur = iter.next();
-
- EStructuralFeature idAttr = cur.eClass().getEIDAttribute();
- if (idAttr != null && !cur.eIsSet(idAttr)) {
- cur.eSet(idAttr, EcoreUtil.generateUUID());
- }
- }
- }
+// private void prepareSave(Resource resource) {
+// EObject cur;
+// for (Iterator<EObject> iter = resource.getAllContents(); iter.hasNext();)
{
+// cur = iter.next();
+//
+// EStructuralFeature idAttr = cur.eClass().getEIDAttribute();
+// if (idAttr != null && !cur.eIsSet(idAttr)) {
+// cur.eSet(idAttr, EcoreUtil.generateUUID());
+// }
+// }
+// }
}
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,21 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+public class Bpmn2Definitions extends Bpmn2Details {
+
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ Object obj = part.getAdapter(IBpmn2DefinitionsPage.class);
+ if (obj instanceof IBpmn2DefinitionsPage) {
+ IBpmn2DefinitionsPage page = (IBpmn2DefinitionsPage) obj;
+ if (page instanceof IPageBookViewPage) {
+ initPage((IPageBookViewPage) page);
+ }
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,344 @@
+package org.jboss.tools.bpmn2.view;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.Definitions;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.Process;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.dd.di.Diagram;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.CommandParameter;
+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.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.Page;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2DefinitionsPageImpl extends Page implements IBpmn2DefinitionsPage {
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof Process || element instanceof Diagram) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class SelectedElementObserver extends EContentAdapter {
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ handleSelectedElementChanged(notification);
+ }
+ }
+
+ private EObject selectedTreeObject = null;
+ private Bpmn2DiagramEditor editor;
+ private TreeViewer treeViewer;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+ private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+
+ public Bpmn2DefinitionsPageImpl(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Tree eventTree = editor.getFormToolkit().createTree(
+ parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ popupMenu = createPopupMenu(eventTree);
+ eventTree.setMenu(popupMenu);
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setAutoExpandLevel(2);
+ treeViewer.setFilters(new ViewerFilter[] { new FlowElementFilter() });
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTreeViewerSelectionChanged(event);
+ }
+ });
+ Definitions definitions = getDefinitions();
+ if (definitions != null) {
+ definitions.eAdapters().add(selectedElementObserver);
+ treeViewer.setInput(getDefinitions().eContainer());
+ treeViewer.setSelection(new StructuredSelection(definitions));
+ selectedTreeObject = definitions;
+ }
+ }
+
+ private Definitions getDefinitions() {
+ EObject object = editor.getDiagram().getElement();
+ if (object == null || !(object instanceof Process)) {
+ return null;
+ }
+ object = ((Process)object).eContainer();
+ if (!(object instanceof Definitions)) {
+ return null;
+ } else {
+ return (Definitions)object;
+ }
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private Menu createPopupMenu(Composite composite) {
+ Menu popupMenu = new Menu(composite);
+ composite.setMenu(popupMenu);
+ popupMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ depopulatePopupMenu();
+ populatePopupMenu();
+ }
+ });
+ return popupMenu;
+ }
+
+ private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(event.getSelection());
+ }
+ EObject object = unwrapTreeViewerSelection(event.getSelection());
+ if (object != selectedTreeObject) {
+ selectedTreeObject = object;
+ }
+ }
+
+ private EObject unwrapTreeViewerSelection(ISelection selection) {
+ EObject result = null;
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ result = (EObject)object;
+ }
+ }
+ return result;
+ }
+
+ private void populatePopupMenu() {
+ createAddChildSubmenu();
+ createAddSiblingSubmenu();
+ }
+
+ private void createAddChildSubmenu() {
+ MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addChildMenuItem.setText("&New Child");
+ addChildSubmenu = new Menu(addChildMenuItem);
+ addChildMenuItem.setMenu(addChildSubmenu);
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addChildMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+
+ private void createAddSiblingSubmenu() {
+ MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addSiblingMenuItem.setText("N&ew Sibling");
+ addSiblingSubmenu = new Menu(addSiblingMenuItem);
+ addSiblingMenuItem.setMenu(addSiblingSubmenu);
+ if (!canEnableAddSibling()) {
+ addSiblingMenuItem.setEnabled(false);
+ } else {
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addSiblingMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+ }
+
+ private boolean canEnableAddSibling() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ return ((EObject)object).eContainer() != treeViewer.getInput();
+ }
+ }
+ return false;
+ }
+
+ private Object getTreeViewerSelectionUnwrapped() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+ private void depopulatePopupMenu() {
+ disposePopupMenuItems(popupMenu);
+ }
+
+ private void disposePopupMenuItems(Menu menu) {
+ for (MenuItem menuItem : menu.getItems()) {
+ Menu nestedMenu = menuItem.getMenu();
+ if (nestedMenu != null) {
+ disposePopupMenuItems(nestedMenu);
+ }
+ menuItem.dispose();
+ }
+ }
+
+ @Override
+ public Control getControl() {
+ return treeViewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ // Nothing to do
+
+ }
+
+ @Override
+ public void dispose() {
+ popupMenu.dispose();
+ Definitions definitions = getDefinitions();
+ if (definitions != null) {
+ definitions.eAdapters().remove(selectedElementObserver);
+ }
+ super.dispose();
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ }
+
+ private void handleSelectedElementChanged(Notification notification) {
+ int eventType = notification.getEventType();
+ if (eventType == Notification.ADD || eventType == Notification.SET) {
+ Object object = notification.getNewValue();
+ if (object instanceof EObject) {
+ setIdIfNotSet((EObject)object);
+ updateTreeSelection(object);
+ }
+ }
+ }
+
+ private void updateTreeSelection(final Object object) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ treeViewer.setSelection(new StructuredSelection(object), true);
+ }
+ });
+ }
+
+ protected void setIdIfNotSet(EObject obj) {
+ if (obj.eClass() != null) {
+ EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+ if (idAttr != null && !obj.eIsSet(idAttr)) {
+ CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+ Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
+ editor.getEditingDomain().getCommandStack().execute(command);
+ }
+ }
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ treeViewer.addSelectionChangedListener(listener);
+ }
+
+ @Override
+ public ISelection getSelection() {
+ return treeViewer.getSelection();
+ }
+
+ @Override
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ treeViewer.removeSelectionChangedListener(listener);
+
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ // ignore
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,119 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2Details extends PageBookView implements ISelectionProvider,
+ ISelectionChangedListener {
+
+ private ISelection bootstrapSelection;
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ getSelectionProvider().addSelectionChangedListener(listener);
+ }
+
+ protected IPage createDefaultPage(PageBook book) {
+ MessagePage page = new MessagePage();
+ initPage(page);
+ page.createControl(book);
+ page.setMessage("Details are not available");
+ return page;
+ }
+
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ Object obj = part.getAdapter(IBpmn2DetailsPage.class);
+ if (obj instanceof IBpmn2DetailsPage) {
+ IBpmn2DetailsPage page = (IBpmn2DetailsPage) obj;
+ if (page instanceof IPageBookViewPage) {
+ initPage((IPageBookViewPage) page);
+ }
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+ return null;
+ }
+
+ protected void doDestroyPage(IWorkbenchPart part, PageRec rec) {
+ IBpmn2DetailsPage page = (IBpmn2DetailsPage) rec.page;
+ page.dispose();
+ rec.dispose();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class type) {
+ IWorkbenchPart currentPart = getCurrentContributingPart();
+ if (type == IPropertySheetPage.class && currentPart != null &&
currentPart instanceof Bpmn2DiagramEditor) {
+ return ((Bpmn2DiagramEditor)currentPart).getAdapter(type);
+ }
+ return super.getAdapter(type);
+ }
+
+ @Override
+ protected IWorkbenchPart getBootstrapPart() {
+ IWorkbenchPage page = getSite().getPage();
+ if (page != null) {
+ bootstrapSelection = page.getSelection();
+ return page.getActiveEditor();
+ }
+ return null;
+ }
+
+ @Override
+ public void partActivated(IWorkbenchPart part) {
+ super.partActivated(part);
+ if (bootstrapSelection != null) {
+ IPage page = getCurrentPage();
+ if (page != null && page instanceof IBpmn2DetailsPage) {
+ ((IBpmn2DetailsPage)page).selectionChanged(part, bootstrapSelection);
+ bootstrapSelection = null;
+ }
+ }
+ }
+
+ public ISelection getSelection() {
+ return getSelectionProvider().getSelection();
+ }
+
+ protected boolean isImportant(IWorkbenchPart part) {
+ return (part instanceof IEditorPart);
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ partActivated(part);
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ getSelectionProvider().removeSelectionChangedListener(listener);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ getSelectionProvider().selectionChanged(event);
+ }
+
+ public void setSelection(ISelection selection) {
+ getSelectionProvider().setSelection(selection);
+ }
+
+ protected void showPageRec(PageRec pageRec) {
+ IPageSite pageSite = getPageSite(pageRec.page);
+ ISelectionProvider provider = pageSite.getSelectionProvider();
+ if (provider == null && (pageRec.page instanceof IBpmn2DetailsPage)) {
+ pageSite.setSelectionProvider((IBpmn2DetailsPage) pageRec.page);
+ }
+ super.showPageRec(pageRec);
+ }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,368 @@
+package org.jboss.tools.bpmn2.view;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.CommandParameter;
+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.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.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2DetailsPageImpl extends Page implements IBpmn2DetailsPage {
+
+ class RootFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement != selectedEditorObject.eContainer() && (element instanceof
FlowElement || element instanceof Artifact)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class SelectedElementObserver extends EContentAdapter {
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ handleSelectedElementChanged(notification);
+ }
+ }
+
+ private EObject selectedEditorObject = null;
+ private EObject selectedTreeObject = null;
+ private Bpmn2DiagramEditor editor;
+ private TreeViewer treeViewer;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+ private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+
+ public Bpmn2DetailsPageImpl(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ public void init(IPageSite site) {
+ site.getPage().addSelectionListener(this);
+ super.init(site);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Tree eventTree = editor.getFormToolkit().createTree(
+ parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ popupMenu = createPopupMenu(eventTree);
+ eventTree.setMenu(popupMenu);
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+ treeViewer.setAutoExpandLevel(2);
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTreeViewerSelectionChanged(event);
+ }
+ });
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private Menu createPopupMenu(Composite composite) {
+ Menu popupMenu = new Menu(composite);
+ composite.setMenu(popupMenu);
+ popupMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ depopulatePopupMenu();
+ populatePopupMenu();
+ }
+ });
+ return popupMenu;
+ }
+
+ private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(event.getSelection());
+ }
+ EObject object = unwrapTreeViewerSelection(event.getSelection());
+ if (object != selectedTreeObject) {
+ selectedTreeObject = object;
+ }
+ }
+
+ private EObject unwrapTreeViewerSelection(ISelection selection) {
+ EObject result = null;
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ result = (EObject)object;
+ }
+ }
+ return result;
+ }
+
+ private void populatePopupMenu() {
+ createAddChildSubmenu();
+ createAddSiblingSubmenu();
+ }
+
+ private void createAddChildSubmenu() {
+ MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addChildMenuItem.setText("&New Child");
+ addChildSubmenu = new Menu(addChildMenuItem);
+ addChildMenuItem.setMenu(addChildSubmenu);
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addChildMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+
+ private void createAddSiblingSubmenu() {
+ MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addSiblingMenuItem.setText("N&ew Sibling");
+ addSiblingSubmenu = new Menu(addSiblingMenuItem);
+ addSiblingMenuItem.setMenu(addSiblingSubmenu);
+ if (!canEnableAddSibling()) {
+ addSiblingMenuItem.setEnabled(false);
+ } else {
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addSiblingMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+ }
+
+ private boolean canEnableAddSibling() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ return ((EObject)object).eContainer() != treeViewer.getInput();
+ }
+ }
+ return false;
+ }
+
+ private Object getTreeViewerSelectionUnwrapped() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+ private void depopulatePopupMenu() {
+ disposePopupMenuItems(popupMenu);
+ }
+
+ private void disposePopupMenuItems(Menu menu) {
+ for (MenuItem menuItem : menu.getItems()) {
+ Menu nestedMenu = menuItem.getMenu();
+ if (nestedMenu != null) {
+ disposePopupMenuItems(nestedMenu);
+ }
+ menuItem.dispose();
+ }
+ }
+
+ @Override
+ public Control getControl() {
+ return treeViewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ // Nothing to do
+
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ popupMenu.dispose();
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (part == editor) {
+ EObject object = unwrapEditorSelection(selection);
+ if (selectedEditorObject == null || object != selectedEditorObject) {
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().remove(selectedElementObserver);
+ }
+ selectedEditorObject = object;
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().add(selectedElementObserver);
+ treeViewer.setInput(selectedEditorObject.eContainer());
+ treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
+ } else {
+ treeViewer.setInput(null);
+ treeViewer.setSelection(null);
+ }
+
+ }
+ }
+ }
+
+ private EObject unwrapEditorSelection(ISelection selection) {
+ if (!(selection instanceof StructuredSelection)) {
+ return null;
+ }
+ Object object = ((StructuredSelection)selection).getFirstElement();
+ if (object == null || !(object instanceof EditPart)) {
+ return null;
+ }
+ object = ((EditPart)object).getModel();
+ if (object == null || !(object instanceof View)) {
+ return null;
+ }
+ return ((View)object).getElement();
+ }
+
+ private void handleSelectedElementChanged(Notification notification) {
+ int eventType = notification.getEventType();
+ if (eventType == Notification.ADD || eventType == Notification.SET) {
+ Object object = notification.getNewValue();
+ if (object instanceof EObject) {
+ setIdIfNotSet((EObject)object);
+ updateTreeSelection(object);
+ }
+ }
+ }
+
+ private void updateTreeSelection(final Object object) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ treeViewer.setSelection(new StructuredSelection(object));
+ }
+ });
+ }
+
+ protected void setIdIfNotSet(EObject obj) {
+ if (obj.eClass() != null) {
+ EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+ if (idAttr != null && !obj.eIsSet(idAttr)) {
+ CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+ Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
+ editor.getEditingDomain().getCommandStack().execute(command);
+ }
+ }
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ treeViewer.addSelectionChangedListener(listener);
+ }
+
+ @Override
+ public ISelection getSelection() {
+ return treeViewer.getSelection();
+ }
+
+ @Override
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ treeViewer.removeSelectionChangedListener(listener);
+
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ // ignore
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,7 @@
+package org.jboss.tools.bpmn2.view;
+
+
+
+public interface IBpmn2DefinitionsPage extends IBpmn2DetailsPage {
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java 2010-12-13
13:09:26 UTC (rev 27408)
@@ -0,0 +1,9 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.part.IPage;
+
+public interface IBpmn2DetailsPage extends IPage, ISelectionListener, ISelectionProvider
{
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain