JBoss Tools SVN: r27408 - in trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram: src/org/jboss/tools/bpmn2/process/diagram/part and 4 other directories.
by jbosstools-commits@lists.jboss.org
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
14 years
JBoss Tools SVN: r27407 - trunk/documentation/jboss-tools-docs.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2010-12-13 07:30:48 -0500 (Mon, 13 Dec 2010)
New Revision: 27407
Modified:
trunk/documentation/jboss-tools-docs/all-guides.xml
trunk/documentation/jboss-tools-docs/pom.xml
Log:
TOOLSDOC-132 trying to update hudson doc builds
Modified: trunk/documentation/jboss-tools-docs/all-guides.xml
===================================================================
--- trunk/documentation/jboss-tools-docs/all-guides.xml 2010-12-13 12:19:18 UTC (rev 27406)
+++ trunk/documentation/jboss-tools-docs/all-guides.xml 2010-12-13 12:30:48 UTC (rev 27407)
@@ -98,7 +98,7 @@
<fileMode>0644</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
- <!-- <fileSet>
+ <fileSet>
<directory>../../deltacloud/docs/Cloud_Tools_Reference_Guide/target/docbook/publish/en-US</directory>
<outputDirectory>/cloud</outputDirectory>
<filtered>false</filtered>
@@ -110,7 +110,7 @@
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>0644</fileMode>
<directoryMode>0755</directoryMode>
- </fileSet> -->
+ </fileSet>
<fileSet>
<directory>../../hibernatetools/docs/reference/target/docbook/publish/en-US</directory>
<outputDirectory>/hibernatetools</outputDirectory>
@@ -357,7 +357,7 @@
<fileMode>0644</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
- <!-- <fileSet>
+ <fileSet>
<directory>../../modeshape/docs/ModeShape_Tools_Reference_Guide/target/docbook/publish/en-US</directory>
<outputDirectory>/modeshape</outputDirectory>
<filtered>false</filtered>
@@ -369,7 +369,7 @@
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>0644</fileMode>
<directoryMode>0755</directoryMode>
- </fileSet> -->
+ </fileSet>
</fileSets>
</assembly>
Modified: trunk/documentation/jboss-tools-docs/pom.xml
===================================================================
--- trunk/documentation/jboss-tools-docs/pom.xml 2010-12-13 12:19:18 UTC (rev 27406)
+++ trunk/documentation/jboss-tools-docs/pom.xml 2010-12-13 12:30:48 UTC (rev 27407)
@@ -15,7 +15,7 @@
<module>../guides/GettingStartedGuide</module>
<module>../guides/Beginners_Guide</module>
<module>../../as/docs/reference</module>
- <!-- <module>../../deltacloud/docs/Cloud_Tools_Reference_Guide</module> -->
+ <module>../../deltacloud/docs/Cloud_Tools_Reference_Guide</module>
<module>../../hibernatetools/docs/reference</module>
<module>../../jbpm/docs/reference</module>
<module>../../jsf/docs/userguide</module>
@@ -34,7 +34,7 @@
<module>../../jbpm/docs/converter_ref</module>
<module>../../jmx/docs/reference</module>
<module>../../bpel/docs/reference</module>
- <!-- <module>../../modeshape/docs/ModeShape_Tools_Reference_Guide</module> -->
+ <module>../../modeshape/docs/ModeShape_Tools_Reference_Guide</module>
<module>index</module>
</modules>
14 years
JBoss Tools SVN: r27406 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: src/org/jboss/tools/deltacloud/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 07:19:18 -0500 (Mon, 13 Dec 2010)
New Revision: 27406
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
Log:
[JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-13 12:18:42 UTC (rev 27405)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-13 12:19:18 UTC (rev 27406)
@@ -4,6 +4,13 @@
(PROP_INSTANCES_ADDED):
(createInstance):
[JBIDE-7877] added notification for instances being added
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (IInstanceStateMatcher.matchesState):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (State):
+ (Action):
+ (getState):
+ (performInstanceAction):
+ [JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
2010-12-10 André Dietisheim <adietish(a)redhat.com>
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-13 12:18:42 UTC (rev 27405)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-13 12:19:18 UTC (rev 27406)
@@ -69,7 +69,7 @@
private SecurePasswordStore passwordStore;
public static interface IInstanceStateMatcher {
- public boolean matchesState(DeltaCloudInstance instance, String instanceState);
+ public boolean matchesState(DeltaCloudInstance instance, DeltaCloudInstance.State instanceState);
}
public DeltaCloud(String name, String url, String username, String passwd) throws DeltaCloudException {
@@ -314,20 +314,20 @@
IInstanceStateMatcher differsFromPending = new IInstanceStateMatcher() {
@Override
- public boolean matchesState(DeltaCloudInstance instance, String instanceState) {
- return !DeltaCloudInstance.PENDING.equals(instanceState);
+ public boolean matchesState(DeltaCloudInstance instance, DeltaCloudInstance.State instanceState) {
+ return !DeltaCloudInstance.State.PENDING.equals(instanceState);
}
};
return waitForState(instanceId, differsFromPending, pm);
}
- public DeltaCloudInstance waitForState(String instanceId, final String expectedState, IProgressMonitor pm)
+ public DeltaCloudInstance waitForState(String instanceId, final DeltaCloudInstance.State expectedState, IProgressMonitor pm)
throws InterruptedException, DeltaCloudException {
IInstanceStateMatcher stateMatcher = new IInstanceStateMatcher() {
@Override
- public boolean matchesState(DeltaCloudInstance instance, String instanceState) {
- return expectedState != null && expectedState.equals(instanceState);
+ public boolean matchesState(DeltaCloudInstance instance, DeltaCloudInstance.State instanceState) {
+ return expectedState != null && expectedState.equals(instanceState.getName());
}
};
return waitForState(instanceId, stateMatcher, pm);
@@ -339,7 +339,7 @@
if (instance != null) {
while (!pm.isCanceled()) {
if (stateMatcher.matchesState(instance, instance.getState())
- || instance.getState().equals(DeltaCloudInstance.TERMINATED)) {
+ || instance.getState().equals(DeltaCloudInstance.State.TERMINATED)) {
return instance;
}
Thread.sleep(400);
@@ -488,9 +488,9 @@
Instance instance = client.listInstances(instanceId);
deltaCloudInstance = new DeltaCloudInstance(this, instance);
DeltaCloudInstance currentInstance = instanceRepo.getById(instanceId);
- // FIXME: remove BOGUS state when server fixes state
+ // FIXME: remove STATE_BOGUS state when server fixes state
// problems
- if (!(deltaCloudInstance.getState().equals(DeltaCloudInstance.BOGUS))
+ if (!(deltaCloudInstance.getState().equals(DeltaCloudInstance.State.BOGUS))
&& !(currentInstance.getState().equals(deltaCloudInstance.getState()))) {
replaceInstance(deltaCloudInstance, currentInstance);
}
@@ -512,19 +512,23 @@
firePropertyChange(PROP_INSTANCES, instances, repo.get());
}
- public boolean performInstanceAction(String instanceId, String actionId) throws DeltaCloudException {
- return performInstanceAction(instanceRepo.getById(instanceId), actionId);
+ public boolean performInstanceAction(String instanceId, DeltaCloudInstance.Action action) throws DeltaCloudException {
+ return performInstanceAction(instanceRepo.getById(instanceId), action);
}
- protected boolean performInstanceAction(DeltaCloudInstance instance, String actionId) throws DeltaCloudException {
+ protected boolean performInstanceAction(DeltaCloudInstance instance, DeltaCloudInstance.Action action) throws DeltaCloudException {
try {
if (instance == null) {
return false;
}
DeltaCloudInstancesRepository repo = getInstancesRepository();
DeltaCloudInstance[] instances = repo.get();
- boolean result = instance.performInstanceAction(actionId, client);
+ boolean result = instance.performInstanceAction(action, client);
if (result) {
+ if (DeltaCloudInstance.Action.DESTROY.equals(action)) {
+ repo.remove(instance);
+ firePropertyChange(PROP_INSTANCES_REMOVED, null, instance);
+ }
// TODO: remove notification with all instanceRepo, replace by
// notifying the changed instance
firePropertyChange(PROP_INSTANCES, instances, repo.get());
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java 2010-12-13 12:18:42 UTC (rev 27405)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java 2010-12-13 12:19:18 UTC (rev 27406)
@@ -19,7 +19,8 @@
import org.jboss.tools.deltacloud.core.client.InternalDeltaCloudClient;
/**
- * An instance that may be reached on a DeltaCloud instance. Wraps Instance from upper layers.
+ * An instance that may be reached on a DeltaCloud instance. Wraps Instance from
+ * upper layers.
*
* @see Instance
* @see DeltaCloud
@@ -29,17 +30,47 @@
*/
public class DeltaCloudInstance extends AbstractDeltaCloudElement {
- public final static String PENDING = Instance.InstanceState.PENDING.toString();
- public final static String RUNNING = Instance.InstanceState.RUNNING.toString();
- public final static String STOPPED = Instance.InstanceState.STOPPED.toString();
- public final static String TERMINATED = Instance.InstanceState.TERMINATED.toString();
- public final static String BOGUS = Instance.InstanceState.BOGUS.toString();
+ public enum State {
- public final static String START = InstanceAction.START;
- public final static String STOP = InstanceAction.STOP;
- public final static String REBOOT = InstanceAction.REBOOT;
- public final static String DESTROY = InstanceAction.DESTROY;
+ PENDING(Instance.InstanceState.PENDING.name()),
+ RUNNING(Instance.InstanceState.RUNNING.name()),
+ STOPPED(Instance.InstanceState.STOPPED.name()),
+ TERMINATED(Instance.InstanceState.TERMINATED.name()),
+ BOGUS(Instance.InstanceState.BOGUS.name());
+ private String name;
+
+ private State(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean equals(String state) {
+ return name.equals(state);
+ }
+ }
+
+ public enum Action {
+
+ START(InstanceAction.START),
+ STOP(InstanceAction.STOP),
+ REBOOT(InstanceAction.REBOOT),
+ DESTROY(InstanceAction.DESTROY);
+
+ private String name;
+
+ private Action(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
private Instance instance;
private String givenName;
@@ -68,8 +99,8 @@
return instance.getOwnerId();
}
- public String getState() {
- return instance.getState().toString();
+ public State getState() {
+ return State.valueOf(instance.getState().name());
}
public String getKey() {
@@ -99,7 +130,7 @@
public boolean isStopped() {
return instance.getState() == InstanceState.STOPPED;
}
-
+
public boolean canStart() {
return instance.canStart();
}
@@ -116,7 +147,6 @@
return instance.canDestroy();
}
-
public boolean isRunning() {
return instance.isRunning();
}
@@ -127,13 +157,13 @@
return hostNames.get(0);
return null;
}
-
- protected boolean performInstanceAction(String actionId, InternalDeltaCloudClient client)
+
+ protected boolean performInstanceAction(Action action, InternalDeltaCloudClient client)
throws DeltaCloudClientException {
- InstanceAction action = instance.getAction(actionId);
- if (action == null) {
+ InstanceAction instanceAction = instance.getAction(action.getName());
+ if (instanceAction == null) {
return false;
}
- return client.performInstanceAction(action);
+ return client.performInstanceAction(instanceAction);
}
}
14 years
JBoss Tools SVN: r27405 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools: internal/deltacloud/ui/utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 07:18:42 -0500 (Mon, 13 Dec 2010)
New Revision: 27405
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
Log:
[JBIDE-7864] added hasImages property tester, rename CreateInstanceHandler2 to CreateInstanceFromAnyImage, renamed CreateInstanceHandler to CreateInstanceFromSpecificImage
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-13 11:37:47 UTC (rev 27404)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-13 12:18:42 UTC (rev 27405)
@@ -136,7 +136,7 @@
try {
key = instance.getKey();
if (!cloud.getType().equals(DeltaCloud.MOCK_TYPE)) {
- if (instance.getState().equals(DeltaCloudInstance.RUNNING) && (key == null || key.length() == 0)) {
+ if (instance.getState().equals(DeltaCloudInstance.State.RUNNING) && (key == null || key.length() == 0)) {
instance = cloud.refreshInstance(instance.getId());
if (instance != null) {
key = instance.getKey();
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-13 11:37:47 UTC (rev 27404)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-13 12:18:42 UTC (rev 27405)
@@ -26,13 +26,12 @@
* @see DeltaCloud
* @see DeltaCloudViewItem
*/
- public static DeltaCloud getCloud(DeltaCloudViewItem element) {
- CloudItem cvCloud = getCVCloudElement(element);
- if (cvCloud == null) {
+ public static DeltaCloud getCloud(DeltaCloudViewItem<?> element) {
+ CloudItem cloudItem = getCloudItem(element);
+ if (cloudItem == null) {
return null;
}
- DeltaCloud cloud = (DeltaCloud) cvCloud.getModel();
- return cloud;
+ return cloudItem.getModel();
}
/**
@@ -45,12 +44,11 @@
* @see DeltaCloudViewItem
* @see CloudItem
*/
- public static CloudItem getCVCloudElement(DeltaCloudViewItem element) {
+ public static CloudItem getCloudItem(DeltaCloudViewItem<?> element) {
while (!(element instanceof CloudItem)
&& element != null) {
- element = (DeltaCloudViewItem) element.getParent();
+ element = (DeltaCloudViewItem<?>) element.getParent();
}
return (CloudItem) element;
}
-
}
14 years
JBoss Tools SVN: r27404 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/commands and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 06:37:47 -0500 (Mon, 13 Dec 2010)
New Revision: 27404
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
Log:
[JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-13 11:37:47 UTC (rev 27404)
@@ -1,5 +1,15 @@
2010-12-13 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java (performFinish):
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java (getStatusIcon):
+ * src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java (run):
+ * src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java (PerformInstanceActionJob):
+ (run):
+ * src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java (stopInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java (startInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java (rebootInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java (executeInstanceAction):
+ [JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
* plugin.xml:
[JBIDE-7864] added hasImages property tester, rename CreateInstanceHandler2 to CreateInstanceFromAnyImage,
renamed CreateInstanceHandler to CreateInstanceFromSpecificImage
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -15,7 +15,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionThread;
+import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionJob;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils.IElementFormatter;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -27,13 +27,13 @@
*/
public abstract class AbstractInstanceHandler extends AbstractHandler implements IHandler {
- protected void executeInstanceAction(DeltaCloudInstance instance, String actionId, String expectedState,
+ protected void executeInstanceAction(DeltaCloudInstance instance, DeltaCloudInstance.Action action, DeltaCloudInstance.State expectedState,
String title, String message) {
if (instance != null) {
- PerformInstanceActionThread t = new PerformInstanceActionThread(
+ PerformInstanceActionJob t = new PerformInstanceActionJob(
instance.getDeltaCloud(),
instance,
- actionId,
+ action,
title,
message,
expectedState);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -81,8 +81,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.REBOOT
- , DeltaCloudInstance.RUNNING
+ , DeltaCloudInstance.Action.REBOOT
+ , DeltaCloudInstance.State.RUNNING
, CVMessages.getString(REBOOTING_INSTANCE_TITLE)
, CVMessages.getFormattedString(REBOOTING_INSTANCE_MSG, new String[] { instance.getName() }));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -83,8 +83,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.START
- , DeltaCloudInstance.RUNNING
+ , DeltaCloudInstance.Action.START
+ , DeltaCloudInstance.State.RUNNING
, CVMessages.getString(STARTING_INSTANCE_TITLE)
, CVMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] { instance.getName() }));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -81,8 +81,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.STOP
- , DeltaCloudInstance.STOPPED
+ , DeltaCloudInstance.Action.STOP
+ , DeltaCloudInstance.State.STOPPED
, CVMessages.getString(STOPPING_INSTANCE_TITLE)
, CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] { instance.getName() }));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -48,7 +48,7 @@
@Override
public void run() {
try {
- cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.DESTROY);
+ cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.Action.DESTROY);
} catch (DeltaCloudException e) {
// TODO internationalize strings
ErrorUtils.handleError("Error",
Copied: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java (from rev 27367, trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java)
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.common.log.StatusFactory;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+
+public class PerformInstanceActionJob extends Job {
+
+ private static final String INSTANCEACTION_ERROR_TITLE = "InstanceActionError.title"; //$NON-NLS-1$
+ private static final String INSTANCEACTION_ERROR_MESSAGE = "InstanceActionError.msg"; //$NON-NLS-1$
+
+ private DeltaCloud cloud;
+ private DeltaCloudInstance instance;
+ private DeltaCloudInstance.Action action;
+ private String taskName;
+ private DeltaCloudInstance.State expectedState;
+
+ public PerformInstanceActionJob(DeltaCloud cloud, DeltaCloudInstance instance,
+ DeltaCloudInstance.Action action, String title, String taskName, DeltaCloudInstance.State expectedState) {
+ super(title);
+ this.cloud = cloud;
+ this.instance = instance;
+ this.action = action;
+ this.taskName = taskName;
+ this.expectedState = expectedState;
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor pm) {
+ String id = instance.getId();
+ try {
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.worked(1);
+ // To handle the user starting a new action when we haven't
+ // confirmed the last one yet,
+ // cancel the previous job and then go on performing this action
+ cancelPreviousJob(id);
+ cloud.performInstanceAction(id, action);
+ cloud.waitForState(id, expectedState, pm);
+ } catch (Exception e) {
+ final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog.openError(
+ UIUtils.getActiveShell(),
+ CVMessages.getString(INSTANCEACTION_ERROR_TITLE),
+ CVMessages.getFormattedString(INSTANCEACTION_ERROR_MESSAGE, action.getName(), instance.getName()),
+ status);
+ }
+ });
+
+ } finally {
+ cloud.removeInstanceJob(id, this);
+ pm.done();
+ }
+ return Status.OK_STATUS;
+ }
+
+ private void cancelPreviousJob(String id) {
+ Job job = cloud.getInstanceJob(id);
+ if (job != null) {
+ job.cancel();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // do nothing, this is ok
+ }
+ }
+ }
+}
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.jboss.tools.common.log.StatusFactory;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
-
-public class PerformInstanceActionThread extends Job {
-
- private static final String INSTANCEACTION_ERROR_TITLE = "InstanceActionError.title"; //$NON-NLS-1$
- private static final String INSTANCEACTION_ERROR_MESSAGE = "InstanceActionError.msg"; //$NON-NLS-1$
-
- private DeltaCloud cloud;
- private DeltaCloudInstance instance;
- private String action;
- private String taskName;
- private String expectedState;
-
- public PerformInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance,
- String action, String title, String taskName, String expectedState) {
- super(title);
- this.cloud = cloud;
- this.instance = instance;
- this.action = action;
- this.taskName = taskName;
- this.expectedState = expectedState;
- }
-
- @Override
- public IStatus run(IProgressMonitor pm) {
- String id = instance.getId();
- try {
- pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
- pm.worked(1);
- // To handle the user starting a new action when we haven't
- // confirmed the last one yet,
- // cancel the previous job and then go on performing this action
- cancelPreviousJob(id);
- cloud.performInstanceAction(id, action);
- cloud.waitForState(id, expectedState, pm);
- } catch (Exception e) {
- final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(
- UIUtils.getActiveShell(),
- CVMessages.getString(INSTANCEACTION_ERROR_TITLE),
- CVMessages.getFormattedString(INSTANCEACTION_ERROR_MESSAGE, action, instance.getName()),
- status);
- }
- });
-
- } finally {
- cloud.removeInstanceJob(id, this);
- pm.done();
- }
- return Status.OK_STATUS;
- }
-
- private void cancelPreviousJob(String id) {
- Job job = cloud.getInstanceJob(id);
- if (job != null) {
- job.cancel();
- try {
- job.join();
- } catch (InterruptedException e) {
- // do nothing, this is ok
- }
- }
- }
-}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -86,12 +86,12 @@
}
}
- private Image getStatusIcon(String status) {
- if (DeltaCloudInstance.STOPPED.equals(status)) {
+ private Image getStatusIcon(DeltaCloudInstance.State status) {
+ if (DeltaCloudInstance.State.STOPPED.equals(status)) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_STOPPED);
- } else if (DeltaCloudInstance.RUNNING.equals(status)) {
+ } else if (DeltaCloudInstance.State.RUNNING.equals(status)) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_RUNNING);
- } else if (DeltaCloudInstance.BOGUS.equals(status)) {
+ } else if (DeltaCloudInstance.State.BOGUS.equals(status)) {
return PlatformUI.getWorkbench().getSharedImages().
getImage(ISharedImages.IMG_DEC_FIELD_WARNING);
} else {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-13 10:43:38 UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-13 11:37:47 UTC (rev 27404)
@@ -175,7 +175,7 @@
if (instance != null) {
result = true;
}
- if (instance != null && instance.getState().equals(DeltaCloudInstance.PENDING)) {
+ if (instance != null && instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
final String instanceId = instance.getId();
final String instanceName = name;
Job job = new WatchCreateJob(WizardMessages.getString(STARTING_INSTANCE_TITLE),
14 years
JBoss Tools SVN: r27403 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: src/org/jboss/tools/deltacloud/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 05:43:38 -0500 (Mon, 13 Dec 2010)
New Revision: 27403
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Log:
[JBIDE-7877] notifying about instances that were added
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-13 10:41:42 UTC (rev 27402)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-13 10:43:38 UTC (rev 27403)
@@ -1,3 +1,10 @@
+2010-12-13 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (PROP_INSTANCES_ADDED):
+ (createInstance):
+ [JBIDE-7877] added notification for instances being added
+
2010-12-10 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (loadImages):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-13 10:41:42 UTC (rev 27402)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-13 10:43:38 UTC (rev 27403)
@@ -41,7 +41,9 @@
public final static String MOCK_TYPE = "MOCK"; //$NON-NLS-1$
public final static String EC2_TYPE = "EC2"; //$NON-NLS-1$
- public static final String PROP_INSTANCES = "instanceRepo";
+ public static final String PROP_INSTANCES = "instances";
+ public static final String PROP_INSTANCES_ADDED = "instancesAdded";
+ public static final String PROP_INSTANCES_REMOVED = "instancesRemoved";
public static final String PROP_IMAGES = "images";
public static final String PROP_NAME = "name";
@@ -619,6 +621,7 @@
// TODO: remove notification with all instanceRepo, replace by
// notifying the changed instance
firePropertyChange(PROP_INSTANCES, instances, repo.get());
+ firePropertyChange(PROP_INSTANCES_ADDED, null, deltaCloudInstance);
return deltaCloudInstance;
}
} catch (DeltaCloudClientException e) {
14 years
JBoss Tools SVN: r27402 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 05:41:42 -0500 (Mon, 13 Dec 2010)
New Revision: 27402
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
Log:
[JBIDE-7877] fixed what action to execute when destroying instances
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 10:38:59 UTC (rev 27401)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 10:41:42 UTC (rev 27402)
@@ -48,7 +48,7 @@
@Override
public void run() {
try {
- cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.START);
+ cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.DESTROY);
} catch (DeltaCloudException e) {
// TODO internationalize strings
ErrorUtils.handleError("Error",
14 years
JBoss Tools SVN: r27401 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks: gef/tree/command and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2010-12-13 05:38:59 -0500 (Mon, 13 Dec 2010)
New Revision: 27401
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerTemplateConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerXMLNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateConnection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateNodeGraphicalModel.java
Log:
JBIDE-7833
Fixed
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -3229,7 +3229,9 @@
if (Collection.class.isAssignableFrom(clazz)) {
return true;
}
+ if(clazz.isArray()) return true;
} catch (Throwable t) {
+ t.printStackTrace();
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -20,7 +20,7 @@
*/
public class DeleteConnectionCommand extends Command {
- private TreeNodeConnection connection;
+ protected TreeNodeConnection connection;
public DeleteConnectionCommand(TreeNodeConnection connection) {
Assert.isNotNull(connection);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -90,4 +90,14 @@
public void setTarget(AbstractSmooksGraphicalModel target) {
this.target = target;
}
+
+ public TreeNodeConnection getTempConnectionHandle() {
+ return tempConnectionHandle;
+ }
+
+ public void setTempConnectionHandle(TreeNodeConnection tempConnectionHandle) {
+ this.tempConnectionHandle = tempConnectionHandle;
+ }
+
+
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -29,11 +29,11 @@
protected int severity = IFieldMarker.TYPE_NONE;
- private Object data;
+ protected Object data;
- private AbstractSmooksGraphicalModel sourceNode;
+ protected AbstractSmooksGraphicalModel sourceNode;
- private AbstractSmooksGraphicalModel targetNode;
+ protected AbstractSmooksGraphicalModel targetNode;
protected List<String> markerMessages = null;
@@ -81,7 +81,11 @@
}
public void connectTarget() {
+// if(data instanceof RemoveResult) {
+// ((TreeNodeModel)targetNode.getModelRootNode()).reAddMappingConnections(((RemoveResult)data).getRemoveMappings());
+// }
targetNode.addTargetConnection(this, sourceNode);
+
}
public void disconnectSource() {
@@ -90,9 +94,9 @@
public void disconnectTarget() {
targetNode.removeTargetConnection(this);
- if(data instanceof RemoveResult) {
- ((TreeNodeModel)targetNode.getModelRootNode()).removeMappingConnections(((RemoveResult)data).getRemoveMappings());
- }
+// if(data instanceof RemoveResult) {
+// ((TreeNodeModel)targetNode.getModelRootNode()).removeMappingConnections(((RemoveResult)data).getRemoveMappings());
+// }
}
public AbstractSmooksGraphicalModel getSourceNode() {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -12,7 +12,6 @@
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagPropertyObject;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
-import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateNodeGraphicalModel;
import org.jboss.tools.smooks.templating.template.CollectionMapping;
import org.jboss.tools.smooks.templating.template.Mapping;
@@ -201,35 +200,69 @@
return parentNode.getParentCollectionConnection();
}
+
+// public void reAddMappingConnections(List<Mapping> removeMappings){
+// if(removeMappings == null || removeMappings.isEmpty()) {
+// return;
+// }
+//
+// // Remove from all the children first...
+// for(AbstractSmooksGraphicalModel child : children) {
+// if(child instanceof TreeNodeModel) {
+// ((TreeNodeModel)child).reAddMappingConnections(removeMappings);
+// }
+// }
+// for (Mapping mapping : removeMappings) {
+// Object mappingObj = mapping.getMappingNode();
+// if(this.data == mappingObj){
+//
+// }
+// }
+// // Now remove from this node...
+// if(targetConnections != null && !targetConnections.isEmpty()) {
+// List<TreeNodeConnection> connectionsToAdd = new ArrayList<TreeNodeConnection>();
+// for(TreeNodeConnection connection : targetConnections) {
+// Object connectionData = connection.getData();
+// if(connectionData instanceof Mapping) {
+// if(removeMappings.contains(connectionData)) {
+// connectionsToAdd.add(connection);
+// }
+// }
+// }
+// for(TreeNodeConnection connection : connectionsToAdd) {
+// connection.connect();
+// }
+// }
+// }
- public void removeMappingConnections(List<Mapping> removeMappings) {
- if(removeMappings == null || removeMappings.isEmpty()) {
- return;
- }
-
- // Remove from all the children first...
- for(AbstractSmooksGraphicalModel child : children) {
- if(child instanceof TreeNodeModel) {
- ((TreeNodeModel)child).removeMappingConnections(removeMappings);
- }
- }
-
- // Now remove from this node...
- if(targetConnections != null && !targetConnections.isEmpty()) {
- List<TreeNodeConnection> connectionsToRemove = new ArrayList<TreeNodeConnection>();
- for(TreeNodeConnection connection : targetConnections) {
- Object connectionData = connection.getData();
- if(connectionData instanceof Mapping) {
- if(removeMappings.contains(connectionData)) {
- connectionsToRemove.add(connection);
- }
- }
- }
- for(TreeNodeConnection connection : connectionsToRemove) {
- connection.disconnect();
- }
- }
- }
+// public void removeMappingConnections(List<Mapping> removeMappings) {
+// if(removeMappings == null || removeMappings.isEmpty()) {
+// return;
+// }
+//
+// // Remove from all the children first...
+// for(AbstractSmooksGraphicalModel child : children) {
+// if(child instanceof TreeNodeModel) {
+// ((TreeNodeModel)child).removeMappingConnections(removeMappings);
+// }
+// }
+//
+// // Now remove from this node...
+// if(targetConnections != null && !targetConnections.isEmpty()) {
+// List<TreeNodeConnection> connectionsToRemove = new ArrayList<TreeNodeConnection>();
+// for(TreeNodeConnection connection : targetConnections) {
+// Object connectionData = connection.getData();
+// if(connectionData instanceof Mapping) {
+// if(removeMappings.contains(connectionData)) {
+// connectionsToRemove.add(connection);
+// }
+// }
+// }
+// for(TreeNodeConnection connection : connectionsToRemove) {
+// connection.disconnect();
+// }
+// }
+// }
public void setText(String text) {
// if (text != null && !text.equals(this.text)) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerTemplateConnectionEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerTemplateConnectionEditPart.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerTemplateConnectionEditPart.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -10,24 +10,50 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.editparts.freemarker;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
+import org.jboss.tools.smooks.gef.tree.command.DeleteConnectionCommand;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeConnectionEditPart;
+import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeConnectionEditPolicy;
+import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeEndpointEditPolicy;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerModelAnalyzer;
+import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateNodeGraphicalModel;
+import org.jboss.tools.smooks.templating.template.Mapping;
+import org.jboss.tools.smooks.templating.template.TemplateBuilder;
+import org.jboss.tools.smooks.templating.template.result.RemoveResult;
/**
* @author Dart
*
*/
-public class FreemarkerTemplateConnectionEditPart extends TreeNodeConnectionEditPart {
+public class FreemarkerTemplateConnectionEditPart extends
+ TreeNodeConnectionEditPart {
public FreemarkerTemplateConnectionEditPart() {
super();
}
+ @Override
+ protected void createEditPolicies() {
+ this.installEditPolicy(EditPolicy.CONNECTION_ROLE,
+ new FreemarkerTemplateConnectionEditPolicy());
+ this.installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
+ new TreeNodeEndpointEditPolicy());
+ }
+
/*
* (non-Javadoc)
*
@@ -39,11 +65,120 @@
AbstractSmooksGraphicalModel target = connection.getTargetNode();
Object data = target.getData();
if (data instanceof TagObject) {
- if (FreemarkerModelAnalyzer.isChoiceElement(((TagObject) data).getReferenceElement())) {
- this.setMarkerImage(SmooksConfigurationActivator.getDefault().getImageRegistry().get(
- GraphicsConstants.IMAGE_XSL_CHOICE));
+ if (FreemarkerModelAnalyzer.isChoiceElement(((TagObject) data)
+ .getReferenceElement())) {
+ this.setMarkerImage(SmooksConfigurationActivator.getDefault()
+ .getImageRegistry()
+ .get(GraphicsConstants.IMAGE_XSL_CHOICE));
}
}
super.refreshVisuals();
}
+
+ public class FreemarkerTemplateConnectionEditPolicy extends
+ ConnectionEditPolicy {
+
+ @Override
+ protected Command getDeleteCommand(GroupRequest request) {
+ Object connection = getHost().getModel();
+ EditPart host = getHost();
+ if (connection != null && connection instanceof TreeNodeConnection) {
+ if (host instanceof TreeNodeConnectionEditPart) {
+ if (!((TreeNodeConnectionEditPart) host).isCanDelete()) {
+ return null;
+ }
+ }
+ DeleteFreeMarkerConnectionCommand command = new DeleteFreeMarkerConnectionCommand(
+ (TreeNodeConnection) connection);
+ return command;
+ }
+ return null;
+ }
+
+ }
+
+ public class DeleteFreeMarkerConnectionCommand extends
+ DeleteConnectionCommand {
+
+ private List<TreeNodeConnection> relatedConnections = new ArrayList<TreeNodeConnection>();
+
+ public DeleteFreeMarkerConnectionCommand(TreeNodeConnection connection) {
+ super(connection);
+ }
+
+ @Override
+ public void execute() {
+ Object target = connection.getTargetNode();
+ if (target instanceof FreemarkerTemplateNodeGraphicalModel) {
+ RemoveResult removeResult;
+ try {
+ TemplateBuilder builder = ((FreemarkerTemplateNodeGraphicalModel) target)
+ .getTemplateBuilder();
+ Object mapping = connection.getData();
+ if (builder == null || mapping == null)
+ return;
+ if (mapping instanceof Mapping) {
+ relatedConnections.clear();
+ removeResult = builder.removeMapping((Mapping) mapping);
+ relatedConnections.addAll(removeMappingConnections(
+ removeResult.getRemoveMappings(),
+ (FreemarkerTemplateNodeGraphicalModel) target));
+ }
+ for (TreeNodeConnection con : relatedConnections) {
+ con.disconnect();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ super.execute();
+ }
+
+ @Override
+ public void redo() {
+ super.redo();
+ }
+
+ @Override
+ public void undo() {
+ super.undo();
+ for (TreeNodeConnection c : relatedConnections) {
+ c.connect();
+ }
+ }
+
+ public List<TreeNodeConnection> removeMappingConnections(
+ List<Mapping> removeMappings, AbstractSmooksGraphicalModel node) {
+ if (removeMappings == null || removeMappings.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ // Remove from all the children first...
+ for (AbstractSmooksGraphicalModel child : node.getChildren()) {
+ if (child instanceof TreeNodeModel) {
+ relatedConnections.addAll(removeMappingConnections(
+ removeMappings, (TreeNodeModel) child));
+ }
+ }
+
+ // Now remove from this node...
+ if (node.getTargetConnections() != null && !node.getTargetConnections().isEmpty()) {
+ List<TreeNodeConnection> connectionsToRemove = new ArrayList<TreeNodeConnection>();
+ for (TreeNodeConnection connection : node
+ .getTargetConnections()) {
+ Object connectionData = connection.getData();
+ if (connectionData instanceof Mapping) {
+ for (Mapping mapping : removeMappings) {
+ if(mapping.getMappingNode() == ((Mapping)connectionData).getMappingNode() &&
+ mapping.getSrcPath().equals(((Mapping)connectionData).getSrcPath())){
+ connectionsToRemove.add(connection);
+ }
+ }
+ }
+ }
+ return connectionsToRemove;
+ }
+ return Collections.emptyList();
+ }
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerXMLNodeEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerXMLNodeEditPart.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerXMLNodeEditPart.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -11,6 +11,8 @@
package org.jboss.tools.smooks.graphical.editors.editparts.freemarker;
import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -21,11 +23,16 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
+import org.jboss.tools.smooks.gef.tree.editparts.CreateConnectionCommand;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
import org.jboss.tools.smooks.gef.tree.figures.TreeNodeFigure;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateConnection;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateGraphicalModel;
+import org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateNodeGraphicalModel;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.IFreemarkerTemplateModel;
+import org.jboss.tools.smooks.templating.template.Mapping;
import org.jboss.tools.smooks.templating.template.TemplateBuilder;
/**
@@ -165,4 +172,72 @@
refreshAllChildren(abstractSmooksGraphicalModel.getChildrenWithoutDynamic());
}
}
+
+ public class CreateFreemarkerXMLConnectionCommand extends CreateConnectionCommand{
+ private List<TreeNodeConnection> relatedConnections = new ArrayList<TreeNodeConnection>();
+
+ public List<TreeNodeConnection> removeMappingConnections(
+ List<Mapping> removeMappings, AbstractSmooksGraphicalModel node) {
+ if (removeMappings == null || removeMappings.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ // Remove from all the children first...
+ for (AbstractSmooksGraphicalModel child : node.getChildren()) {
+ if (child instanceof TreeNodeModel) {
+ relatedConnections.addAll(removeMappingConnections(
+ removeMappings, (TreeNodeModel) child));
+ }
+ }
+
+ // Now remove from this node...
+ if (node.getTargetConnections() != null && !node.getTargetConnections().isEmpty()) {
+ List<TreeNodeConnection> connectionsToRemove = new ArrayList<TreeNodeConnection>();
+ for (TreeNodeConnection connection : node
+ .getTargetConnections()) {
+ Object connectionData = connection.getData();
+ if (connectionData instanceof Mapping) {
+ for (Mapping mapping : removeMappings) {
+ if(mapping.getMappingNode() == ((Mapping)connectionData).getMappingNode() &&
+ mapping.getSrcPath().equals(((Mapping)connectionData).getSrcPath())){
+ connectionsToRemove.add(connection);
+ }
+ }
+ }
+ }
+ return connectionsToRemove;
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void execute() {
+ super.execute();
+ Object target = getTempConnectionHandle().getTargetNode();
+ if (target instanceof FreemarkerTemplateNodeGraphicalModel) {
+ FreemarkerTemplateConnection connection = (FreemarkerTemplateConnection)this.getTempConnectionHandle();
+ List<Mapping> removeMappings = connection.getRemoveMappings();
+ if(removeMappings!=null){
+ relatedConnections.clear();
+ relatedConnections.addAll(removeMappingConnections(removeMappings, (FreemarkerTemplateNodeGraphicalModel)target));
+ for (TreeNodeConnection con : relatedConnections) {
+ con.disconnect();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void undo() {
+ super.undo();
+ for (TreeNodeConnection c : relatedConnections) {
+ c.connect();
+ }
+ }
+
+ }
+
+ public CreateConnectionCommand createCreateConnectionCommand() {
+ return new CreateFreemarkerXMLConnectionCommand();
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateConnection.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateConnection.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateConnection.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -10,12 +10,23 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.model.freemarker;
+import java.util.List;
+
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+import org.jboss.tools.smooks.templating.template.Mapping;
/**
* @author Dart
*
*/
public class FreemarkerTemplateConnection extends TreeNodeConnection {
+ protected List<Mapping> removeMappings;
+ public void setRemoveMappingConnections(List<Mapping> removeMappings) {
+ this.removeMappings = removeMappings;
+ }
+
+ public List<Mapping> getRemoveMappings() {
+ return removeMappings;
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateNodeGraphicalModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateNodeGraphicalModel.java 2010-12-13 10:36:29 UTC (rev 27400)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateNodeGraphicalModel.java 2010-12-13 10:38:59 UTC (rev 27401)
@@ -58,7 +58,7 @@
this.domainProvider = domainProvider;
}
- protected TemplateBuilder getTemplateBuilder() {
+ public TemplateBuilder getTemplateBuilder() {
AbstractSmooksGraphicalModel parent = this;
while (parent != null
&& !(parent instanceof FreemarkerTemplateGraphicalModel)) {
@@ -181,7 +181,10 @@
}
connection.setData(mappingResult.getMapping());
- ((TreeNodeModel)getModelRootNode()).removeMappingConnections(mappingResult.getRemoveMappings());
+ if(connection instanceof FreemarkerTemplateConnection){
+ ((FreemarkerTemplateConnection)connection).setRemoveMappingConnections(mappingResult.getRemoveMappings());
+ }
+// ((TreeNodeModel)getModelRootNode()).removeMappingConnections(mappingResult.getRemoveMappings());
} else if (isMappingValueConnection(connection)) {
String mappingString = null;
@@ -349,7 +352,8 @@
public void removeTargetConnection(TreeNodeConnection connection) {
((TreeNodeModel)connection.getSourceNode()).getConnections().remove(connection);
getConnections().remove(connection);
-
+// changeFreemarkerContents();
+// super.removeTargetConnection(connection);
RemoveResult removeResult;
try {
TemplateBuilder builder = getTemplateBuilder();
@@ -358,9 +362,10 @@
return;
if (mapping instanceof Mapping) {
removeResult = builder.removeMapping((Mapping) mapping);
- changeFreemarkerContents();
+
connection.setData(removeResult);
}
+ changeFreemarkerContents();
super.removeTargetConnection(connection);
} catch (Exception e) {
e.printStackTrace();
14 years
JBoss Tools SVN: r27400 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 05:36:29 -0500 (Mon, 13 Dec 2010)
New Revision: 27400
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
Log:
cleanup
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 10:01:47 UTC (rev 27399)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13 10:36:29 UTC (rev 27400)
@@ -50,6 +50,7 @@
try {
cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.START);
} catch (DeltaCloudException e) {
+ // TODO internationalize strings
ErrorUtils.handleError("Error",
MessageFormat.format("Could not destroy instance {0}", instance.getName()), e,
Display.getDefault().getActiveShell());
14 years
JBoss Tools SVN: r27399 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-13 05:01:47 -0500 (Mon, 13 Dec 2010)
New Revision: 27399
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
Log:
cleanup
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java 2010-12-13 09:30:23 UTC (rev 27398)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java 2010-12-13 10:01:47 UTC (rev 27399)
@@ -34,6 +34,9 @@
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+/**
+ * @author André Dietisheim
+ */
public class RSEUtils {
private static final String VIEW_REMOTESYSEXPLORER_ID = "org.eclipse.rse.ui.view.systemView";
@@ -152,47 +155,4 @@
}
});
}
-
- // private static void test() {
- // ISystemRegistry registry = SystemStartHere.getSystemRegistry();
- // RSECorePlugin rsep = RSECorePlugin.getDefault();
- // IRSECoreRegistry coreRegistry = rsep.getCoreRegistry();
- // IRSESystemType[] sysTypes = coreRegistry.getSystemTypes();
- // IRSESystemType sshType = null;
- // for (IRSESystemType sysType : sysTypes) {
- // if (sysType.getId().equals(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID))
- // sshType = sysType;
- // }
- // String connectionName = instance.getName() + " [" + instance.getId() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- // try {
- // IHost host = registry.createHost(sshType, connectionName, hostname,
- // null);
- // if (host != null) {
- // host.setDefaultUserId("root"); //$NON-NLS-1$
- // IConnectorService[] services = host.getConnectorServices();
- // if (services.length > 0) {
- // final IConnectorService service = services[0];
- // Job connect = new Job(CVMessages.getFormattedString(RSE_CONNECTING_MSG,
- // connectionName)) {
- // @Override
- // protected IStatus run(IProgressMonitor monitor) {
- // try {
- // service.connect(monitor);
- // return Status.OK_STATUS;
- // } catch (Exception e) {
- // return Status.CANCEL_STATUS;
- // }
- // }
- // };
- // connect.setUser(true);
- // connect.schedule();
- // }
- // }
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // Activator.log(e);
- // }
- //
- // }
-
}
14 years