[jbosstools-commits] JBoss Tools SVN: r17412 - trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Sep 2 04:45:14 EDT 2009


Author: Grid.Qian
Date: 2009-09-02 04:45:13 -0400 (Wed, 02 Sep 2009)
New Revision: 17412

Modified:
   trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEditPart.java
   trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEntryEditPart.java
Log:
JBIDE-4633: commit the changes

Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEditPart.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEditPart.java	2009-09-02 08:42:39 UTC (rev 17411)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEditPart.java	2009-09-02 08:45:13 UTC (rev 17412)
@@ -1,18 +1,32 @@
 package org.eclipse.bpel.ui.editparts;
 
 import org.eclipse.bpel.common.ui.tray.TrayCategoryEditPart;
-import org.eclipse.bpel.model.Scope;
 import org.eclipse.bpel.ui.BPELEditor;
 import org.eclipse.bpel.ui.editparts.policies.TrayContainerEditPolicy;
 import org.eclipse.bpel.ui.util.ModelHelper;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.gef.AccessibleEditPart;
 import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.RootEditPart;
 import org.eclipse.jface.viewers.StructuredSelection;
 
 public abstract class BPELTrayCategoryEditPart extends TrayCategoryEditPart{
 	
+	// added by Grid.Qian
+	// use the variable to hold the root of the editpart
+	// because when we delete a correlationSets from scope
+	// the editpart parent will be null
+	private RootEditPart holdRoot;
+	
+	// added by Grid.Qian
+	// use the variable to hold the parent's of the model
+	// that will be a scope or a process
+	// because when we delete a correlationSets from scope
+	// the eContainer will be null
+	private EObject eObj;
+	
 	@Override
 	protected void createEditPolicies() {
 		super.createEditPolicies();
@@ -40,13 +54,54 @@
 			selectEditPart(getModelChildren().get(0));
 		} else {
 			// if we are executing this method we are dealing with scoped variables
-			Scope scope = (Scope)((EObject)getModel()).eContainer();
-			BPELEditor editor = ModelHelper.getBPELEditor(scope);
-			EditPart editPart = (EditPart)editor.getGraphicalViewer().getEditPartRegistry().get(scope);
+			
+			// delete the line by Grid.Qian because the econtainer maybe null
+			// when the model is deleted from the scope
+			// Scope scope = (Scope)((EObject)getModel()).eContainer();
+			BPELEditor editor = ModelHelper.getBPELEditor(eObj);
+			EditPart editPart = (EditPart)editor.getGraphicalViewer().getEditPartRegistry().get(eObj);
 			if (editPart != null) {
 				getViewer().setSelection(new StructuredSelection(editPart));
 			}
 		}
 	}
+	
+	/**
+	 * Overwrite the method by Grid.Qian to get the viewer 
+	 * when the editpart's parent == null
+	 */
+	public EditPartViewer getViewer() {
+		try {
+			return super.getViewer();
+		} catch (Exception e) {
+			return holdRoot.getViewer();
+		}
 
+	}
+
+	/**
+	 * Overwrite the method by Grid.Qian
+	 * Hold the editpart's root editpart
+	 */
+	public void setParent(EditPart parent) {
+		if (this.getParent() == parent)
+			return;
+		if (parent != null) {
+			holdRoot = parent.getRoot();
+		}
+		super.setParent(parent);
+	}
+	
+
+	/**
+	 * Overwrite the method by Grid.Qian
+	 * Hold the scope or process that the model belong to
+	 */
+	public void setModel(Object model) {
+		if (getModel() == model)
+			return;
+		eObj = ((EObject) model).eContainer();
+		super.setModel(model);
+	}
+
 }

Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEntryEditPart.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEntryEditPart.java	2009-09-02 08:42:39 UTC (rev 17411)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/editparts/BPELTrayCategoryEntryEditPart.java	2009-09-02 08:45:13 UTC (rev 17412)
@@ -23,7 +23,9 @@
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.gef.AccessibleEditPart;
 import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.RootEditPart;
 
 /**
  * Tray category edit part.
@@ -38,6 +40,12 @@
 	
 	protected MouseMotionListener mouseMotionListener;
 	
+	// added by Grid.Qian
+	// use the variable to hold the root of the editpart
+	// because when we delete a correlationSet from scope
+	// the editpart parent will be null
+	private RootEditPart holdRoot;
+
 	@Override
 	protected AccessibleEditPart createAccessible() {
 		return new BPELTrayAccessibleEditPart(this);
@@ -134,7 +142,11 @@
 	@Override
 	public void removeNotify() {
 		// we only do the following hack if we are dealing with scoped variables
-		if (!(((EObject)getParent().getModel()).eContainer() instanceof Scope)) {
+		
+		// when we delete a variable from scope, the variables parent will
+		// be null, so we need to filter this
+		EObject eObj = ((EObject) getParent().getModel()).eContainer();
+		if (eObj != null && !(eObj instanceof Scope)) {
 			super.removeNotify();
 			return;
 		}
@@ -152,4 +164,30 @@
 			children.get(i).removeNotify();
 		unregister();
 	}
+
+	/**
+	 * Overwrite the method by Grid.Qian to get the viewer 
+	 * when the editpart's parent == null
+	 */
+	public EditPartViewer getViewer() {
+		try {
+			return super.getViewer();
+		} catch (Exception e) {
+			return holdRoot.getViewer();
+		}
+
+	}
+
+	/**
+	 * Overwrite the method by Grid.Qian
+	 * Hold the editpart's root editpart
+	 */
+	public void setParent(EditPart parent) {
+		if (this.getParent() == parent)
+			return;
+		if (parent != null) {
+			holdRoot = parent.getRoot();
+		}
+		super.setParent(parent);
+	}
 }



More information about the jbosstools-commits mailing list