cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r424641 [1/2] - in /incubator/cayenne/soc/trunk/cayenne-rop/rop-browser: ./ META-INF/ lib/ lib/server/ src/org/apache/cayenne/ropbrowser/ src/org/apache/cayenne/ropbrowser/actions/ src/org/apache/cayenne/ropbrowser/commands/ src/org/apache/...
Date Sat, 22 Jul 2006 22:44:41 GMT
Author: aadamchik
Date: Sat Jul 22 15:44:39 2006
New Revision: 424641

URL: http://svn.apache.org/viewvc?rev=424641&view=rev
Log:
CAY-604

Added:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/cayenne-client-nodeps-1.2.jar   (with props)
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/server/cayenne-1.2.jar   (with props)
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/HideAction.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/InsertAction.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ToggleLayoutAction.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ContractRelationshipCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ExpandRelationshipCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/HideElementCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/NextObjectCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectInsertCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/SelectionHandlesEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/SingleDirectEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/SingleSelectionPolicy.java
Removed:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/cayenne-client-nodeps-1.2RC1.jar
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/server/cayenne-1.2RC1.jar
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementDeleteCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/AbstractButton.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/PopOutButton.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipButton.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElementFactory.java
Modified:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/META-INF/MANIFEST.MF
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ConnectionManager.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditor.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorContextMenuProvider.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CollectionFigure.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/ElementFigure.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/SingleFigure.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DelegatingLayoutManager.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DirectedGraphLayoutVisitor.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/GraphLayoutManager.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/AbstractObject.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/CollectionModelElement.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Connection.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElement.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/SingleModelElement.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/CollectionEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ConnectionEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementDiagramEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/SingleEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/CollectionDirectEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/CollectionSelectionPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementXYLayoutEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath Sat Jul 22 15:44:39 2006
@@ -8,8 +8,8 @@
 	<classpathentry kind="lib" path="lib/commons-lang-2.1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-logging.jar"/>
 	<classpathentry kind="lib" path="lib/hessian-3.0.13.jar"/>
-	<classpathentry kind="lib" path="lib/cayenne-client-nodeps-1.2RC1.jar"/>
 	<classpathentry kind="lib" path="lib/smack-2.2.1.jar"/>
 	<classpathentry kind="lib" path="lib/smackx-2.2.1.jar"/>
+	<classpathentry kind="lib" path="lib/cayenne-client-nodeps-1.2.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/META-INF/MANIFEST.MF?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/META-INF/MANIFEST.MF (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/META-INF/MANIFEST.MF Sat Jul 22 15:44:39 2006
@@ -15,4 +15,4 @@
  lib/commons-logging.jar,
  lib/commons-lang-2.1.jar,
  lib/commons-collections-3.1.jar,
- lib/cayenne-client-nodeps-1.2RC1.jar
+ lib/cayenne-client-nodeps-1.2.jar

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties Sat Jul 22 15:44:39 2006
@@ -5,4 +5,4 @@
                lib/commons-logging.jar,\
                lib/commons-lang-2.1.jar,\
                lib/commons-collections-3.1.jar,\
-               lib/cayenne-client-nodeps-1.2RC1.jar
\ No newline at end of file
+               lib/cayenne-client-nodeps-1.2.jar
\ No newline at end of file

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/cayenne-client-nodeps-1.2.jar
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/cayenne-client-nodeps-1.2.jar?rev=424641&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/cayenne-client-nodeps-1.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/server/cayenne-1.2.jar
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/server/cayenne-1.2.jar?rev=424641&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/server/cayenne-1.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ConnectionManager.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ConnectionManager.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ConnectionManager.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ConnectionManager.java Sat Jul 22 15:44:39 2006
@@ -60,8 +60,9 @@
 			return connections.get(address);
 		}
 		
-		ClientConnection connection = new HessianConnection(address, null, null, "shared-session");
+		ClientConnection connection = new HessianConnection(address); //, null, null, "shared-session");
 		DataChannel channel = new ClientChannel(connection);
+		// TODO configure query caching
 		ObjectContext context = new CayenneContext(channel);
 		
 		connections.put(address, context);

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditor.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditor.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditor.java Sat Jul 22 15:44:39 2006
@@ -18,6 +18,10 @@
 
 import java.util.EventObject;
 
+import org.apache.cayenne.ropbrowser.actions.DeleteAction;
+import org.apache.cayenne.ropbrowser.actions.HideAction;
+import org.apache.cayenne.ropbrowser.actions.InsertAction;
+import org.apache.cayenne.ropbrowser.actions.ToggleLayoutAction;
 import org.apache.cayenne.ropbrowser.model.ElementDiagram;
 import org.apache.cayenne.ropbrowser.parts.ElementEditPartFactory;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -27,6 +31,7 @@
 import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
 import org.eclipse.gef.ui.parts.GraphicalEditor;
 import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jface.action.IAction;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.objectstyle.cayenne.ObjectContext;
@@ -44,18 +49,21 @@
 	/** ID of the Editor */
 	public static final String ID = "org.apache.cayenne.ropbrowser.ObjectEditor";
 	/** Root component of the data model */
-	private ElementDiagram objectDiagram;
+	private ElementDiagram elementDiagram;
 	/** ObjectContext for all the objects in the editor */
 	private ObjectContext context;
 	
+	private boolean dirty;
+	
 	public ObjectEditor() {
 		setEditDomain(new DefaultEditDomain(this));
+		dirty = false;
 	}
 	
 	@Override
 	protected void initializeGraphicalViewer() {
 		GraphicalViewer viewer = getGraphicalViewer();
-		viewer.setContents(objectDiagram);
+		viewer.setContents(elementDiagram);
 	}
 	
 	/**
@@ -81,6 +89,7 @@
 	 * @see org.eclipse.gef.ui.parts.GraphicalEditor#commandStackChanged(java.util.EventObject)
 	 */
 	public void commandStackChanged(EventObject event) {
+		dirty = true;
 		firePropertyChange(IEditorPart.PROP_DIRTY);
 		super.commandStackChanged(event);
 	}
@@ -90,6 +99,12 @@
 	 */
 	public void doSave(IProgressMonitor monitor) {
 		context.commitChanges();
+		dirty = false;
+		firePropertyChange(IEditorPart.PROP_DIRTY);
+	}
+	
+	public boolean isDirty() {
+		return dirty;
 	}
 
 	/**
@@ -111,6 +126,29 @@
 	protected void setInput(IEditorInput input) {
 		super.setInput(input);
 		this.context = ((ObjectEditorInput) input).getContext();
-		objectDiagram = new ElementDiagram(this.context, ((ObjectEditorInput) input).getQuery());		
+		elementDiagram = new ElementDiagram(this.context, ((ObjectEditorInput) input).getQuery());		
+	}
+	
+	protected void createActions() {
+		super.createActions();
+		
+		IAction action = new HideAction(this);
+		getActionRegistry().registerAction(action);
+		getSelectionActions().add(action.getId());
+		
+		action = new DeleteAction(this);
+		getActionRegistry().registerAction(action);
+		getSelectionActions().add(action.getId());
+		
+		action = new InsertAction(this);
+		getActionRegistry().registerAction(action);
+		getSelectionActions().add(action.getId());
+		
+		action = new ToggleLayoutAction(this);
+		getActionRegistry().registerAction(action);
+	}
+
+	public ElementDiagram getDiagram() {
+		return elementDiagram;
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorContextMenuProvider.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorContextMenuProvider.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorContextMenuProvider.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorContextMenuProvider.java Sat Jul 22 15:44:39 2006
@@ -16,6 +16,10 @@
  */
 package org.apache.cayenne.ropbrowser;
 
+import org.apache.cayenne.ropbrowser.actions.DeleteAction;
+import org.apache.cayenne.ropbrowser.actions.HideAction;
+import org.apache.cayenne.ropbrowser.actions.InsertAction;
+import org.apache.cayenne.ropbrowser.actions.ToggleLayoutAction;
 import org.eclipse.gef.ContextMenuProvider;
 import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.ui.actions.ActionRegistry;
@@ -62,9 +66,26 @@
 		menu.appendToGroup(
 				GEFActionConstants.GROUP_UNDO, 
 				getAction(ActionFactory.REDO.getId()));
-		menu.appendToGroup(
-				GEFActionConstants.GROUP_EDIT,
-				getAction(ActionFactory.DELETE.getId()));
+		
+		IAction action = getAction(HideAction.ID);
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+		}
+		
+		action = getAction(DeleteAction.ID);
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+		}
+		
+		action = getAction(InsertAction.ID);
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+		}
+		
+		action = getAction(ToggleLayoutAction.ID);
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
+		}
 	}
 	
 	private IAction getAction(String actionId) {

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,72 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.actions;
+
+import java.util.List;
+
+import org.apache.cayenne.ropbrowser.parts.SingleEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.ui.actions.SelectionAction;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class DeleteAction extends SelectionAction {
+	
+	private Request request;
+	
+	public static final String ID = "org.apache.cayenne.ropbrowser.actions.ExpungeAction";
+	public static final String DELETE_REQUEST = "Delete";
+	
+	public DeleteAction(IWorkbenchPart part) {
+		super(part);
+		setId(ID);
+		setText("Delete");
+		request = new Request(DELETE_REQUEST);
+	}
+
+	protected boolean calculateEnabled() {
+		return canPerformAction();
+	}
+	
+	public void run() {
+		execute(getCommand());
+	}
+	
+	private boolean canPerformAction() {
+		if (getSelectedObjects().isEmpty())
+			return false;
+		List parts = getSelectedObjects();
+		for (int i=0; i<parts.size(); i++){
+			Object o = parts.get(i);
+			if (!(o instanceof SingleEditPart)) {
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	private Command getCommand() {
+		List editparts = getSelectedObjects();
+		CompoundCommand cc = new CompoundCommand();
+		for (int i=0; i < editparts.size(); i++) {
+			EditPart part = (EditPart)editparts.get(i);
+			cc.add(part.getCommand(request));
+		}
+		return cc;
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/HideAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/HideAction.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/HideAction.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/HideAction.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,77 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.actions;
+
+import java.util.List;
+
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.parts.ElementEditPart;
+import org.apache.cayenne.ropbrowser.parts.SingleEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.ui.actions.SelectionAction;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class HideAction extends SelectionAction {
+	
+	private Request request;
+	
+	public static final String ID = "org.apache.cayenne.ropbrowser.actions.HideAction";
+	public static final String HIDE_REQUEST = "Hide";
+	
+	public HideAction(IWorkbenchPart part) {
+		super(part);
+		setId(ID);
+		setText("Hide");
+		request = new Request(HIDE_REQUEST);
+	}
+
+	protected boolean calculateEnabled() {
+		return canPerformAction();
+	}
+	
+	public void run() {
+		execute(getCommand());
+	}
+	
+	private boolean canPerformAction() {
+		if (getSelectedObjects().isEmpty())
+			return false;
+		List parts = getSelectedObjects();
+		for (int i=0; i<parts.size(); i++){
+			Object o = parts.get(i);
+			if (!(o instanceof ElementEditPart)) {
+				return false;
+			}
+			if (((ElementEditPart) o).isRoot()) {
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	private Command getCommand() {
+		List editparts = getSelectedObjects();
+		CompoundCommand cc = new CompoundCommand();
+		for (int i=0; i < editparts.size(); i++) {
+			EditPart part = (EditPart)editparts.get(i);
+			cc.add(part.getCommand(request));
+		}
+		return cc;
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/InsertAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/InsertAction.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/InsertAction.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/InsertAction.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,77 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.actions;
+
+import java.util.List;
+
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.apache.cayenne.ropbrowser.parts.CollectionEditPart;
+import org.apache.cayenne.ropbrowser.parts.SingleEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.ui.actions.SelectionAction;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class InsertAction extends SelectionAction {
+	
+	private Request request;
+	
+	public static final String ID = "org.apache.cayenne.ropbrowser.actions.InsertAction";
+	public static final String INSERT_REQUEST = "Insert";
+	
+	public InsertAction(IWorkbenchPart part) {
+		super(part);
+		setId(ID);
+		setText("Insert");
+		request = new Request(INSERT_REQUEST);
+	}
+
+	protected boolean calculateEnabled() {
+		return canPerformAction();
+	}
+	
+	public void run() {
+		execute(getCommand());
+	}
+	
+	private boolean canPerformAction() {
+		if (getSelectedObjects().isEmpty())
+			return false;
+		List parts = getSelectedObjects();
+		for (int i=0; i<parts.size(); i++){
+			Object o = parts.get(i);
+			if (o instanceof CollectionEditPart) {
+				return true;
+			}
+			if ((o instanceof SingleEditPart) && (((SingleModelElement) ((SingleEditPart) o).getModel()).getCurrentObject() == null)) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private Command getCommand() {
+		List editparts = getSelectedObjects();
+		CompoundCommand cc = new CompoundCommand();
+		for (int i=0; i < editparts.size(); i++) {
+			EditPart part = (EditPart)editparts.get(i);
+			cc.add(part.getCommand(request));
+		}
+		return cc;
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ToggleLayoutAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ToggleLayoutAction.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ToggleLayoutAction.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ToggleLayoutAction.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,37 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.actions;
+
+import org.apache.cayenne.ropbrowser.ObjectEditor;
+import org.eclipse.jface.action.Action;
+
+
+public class ToggleLayoutAction  extends Action {
+	
+	private ObjectEditor editor;
+	
+	public static final String ID = "org.apache.cayenne.ropbrowser.actions.ToggleLayoutAction";
+	
+	public ToggleLayoutAction(ObjectEditor editor) {
+		this.editor = editor;
+		setId(ID);
+		setText("Toggle Layout");
+	}
+	
+	public void run() {
+		editor.getDiagram().toggleAutoLayout();
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ContractRelationshipCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ContractRelationshipCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ContractRelationshipCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ContractRelationshipCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,72 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.MemberConnection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.model.RelationshipConnection;
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.eclipse.gef.commands.Command;
+import org.objectstyle.cayenne.map.Relationship;
+
+public class ContractRelationshipCommand extends Command {
+
+	protected SingleModelElement source;
+	protected RelationshipConnection conn;
+	protected Command deleteCommand;
+	
+	public ContractRelationshipCommand(RelationshipConnection conn) {
+		this.conn = conn;
+		this.deleteCommand = null;
+		setLabel("contract relationship");
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return true;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		redo();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		conn.disconnect();
+		if (!conn.getTarget().isConnectedToRoot()) {
+			deleteCommand = new HideElementCommand(conn.getTarget());
+			deleteCommand.execute();
+		}
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		conn.connect();
+		if (deleteCommand != null) {
+			deleteCommand.undo();
+		}
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,58 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cayenne.ropbrowser.model.Connection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.eclipse.gef.commands.Command;
+
+public class DeleteObjectCommand extends Command {
+	
+	/** ModelElement to remove. */
+	private final ModelElement element;
+	
+	/**
+	 * Create a command that will remove the ModelElement from its parent ElementDiagram.
+	 * @param parent the ElementDiagram containing the child
+	 * @param child    the ModelElement to remove
+	 * @throws IllegalArgumentException if any parameter is null
+	 */
+	public DeleteObjectCommand(ModelElement element) {
+		if (element == null) {
+			throw new IllegalArgumentException();
+		}
+		setLabel("element expunction");
+		this.element = element;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return false;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		element.getDiagram().removeObject(element.getCurrentObject());
+		element.deleteCurrentObject();
+	}
+}

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java Sat Jul 22 15:44:39 2006
@@ -29,65 +29,30 @@
  */
 public class ElementSetConstraintCommand extends Command {
 	
-	/** Stores the new size and location. */
-	private final Rectangle newBounds;
-	/** Stores the old size and location. */
+	private ModelElement element;
 	private Rectangle oldBounds;
-	/** A request to move/resize an edit part. */
-	private final ChangeBoundsRequest request;
-	
-	/** Element to manipulate. */
-	private final ModelElement element;
-		
-	/** @param element	the element to manipulate
-	 * @param req		the move and resize request
-	 * @param newBounds the new size and location
-	 * @throws IllegalArgumentException if any of the parameters is null
-	 */
-	public ElementSetConstraintCommand(ModelElement element, ChangeBoundsRequest req, 
-			Rectangle newBounds) {
-		if (element == null || req == null || newBounds == null) {
-			throw new IllegalArgumentException();
-		}
+	private Rectangle newBounds;
+
+	public ElementSetConstraintCommand(ModelElement element, Rectangle oldBounds, Rectangle newBounds)
+	{
+		super();
 		this.element = element;
-		this.request = req;
-		this.newBounds = newBounds.getCopy();
-		setLabel("move / resize");
-	}
-	
-	/**
-	 * @see org.eclipse.gef.commands.Command#canExecute()
-	 */
-	public boolean canExecute() {
-		Object type = request.getType();
-		// make sure the Request is of a type we support:
-		return (RequestConstants.REQ_MOVE.equals(type)
-				|| RequestConstants.REQ_MOVE_CHILDREN.equals(type) 
-				|| RequestConstants.REQ_RESIZE.equals(type)
-				|| RequestConstants.REQ_RESIZE_CHILDREN.equals(type));
+		this.oldBounds = oldBounds;
+		this.newBounds = newBounds;
+		setLabel("move");
 	}
-	
-	/**
-	 * @see org.eclipse.gef.commands.Command#execute()
-	 */
-	public void execute() {
-		oldBounds = new Rectangle(element.getX(), element.getY(), element.getWidth(), element.getHeight());
+
+	public void execute()
+	{
 		redo();
 	}
 	
-	/**
-	 * @see org.eclipse.gef.commands.Command#redo()
-	 */
 	public void redo() {
-		element.setSize(newBounds.getSize().width, newBounds.getSize().height);
-		element.setLocation(newBounds.getLocation().x, newBounds.getLocation().y);
+		element.modifyBounds(newBounds);
 	}
-	
-	/**
-	 * @see org.eclipse.gef.commands.Command#undo()
-	 */
-	public void undo() {
-		element.setSize(oldBounds.getSize().width, oldBounds.getSize().height);
-		element.setLocation(oldBounds.getLocation().x, oldBounds.getLocation().y);
+
+	public void undo()
+	{
+		element.modifyBounds(oldBounds);
 	}
 }

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ExpandRelationshipCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ExpandRelationshipCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ExpandRelationshipCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ExpandRelationshipCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,88 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.MemberConnection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.model.RelationshipConnection;
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.eclipse.gef.commands.Command;
+import org.objectstyle.cayenne.map.Relationship;
+
+public class ExpandRelationshipCommand extends Command {
+
+	protected Relationship relationship;
+	protected SingleModelElement source;
+	protected RelationshipConnection conn;
+	
+	public ExpandRelationshipCommand(SingleModelElement source, Relationship relationship) {
+		this.relationship = relationship;
+		this.source = source;
+		setLabel("expand relationship");
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return true;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		redo();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		Object value = source.getCurrentObject().followRelationship(relationship);
+		
+		ModelElement newElement;
+		
+		if (relationship.isToMany()) {
+			newElement = new CollectionModelElement(source.getDiagram(), relationship.getTargetEntityName());
+		}
+		else {
+			newElement = new SingleModelElement(source.getDiagram(), relationship.getTargetEntityName());
+		}
+		
+		newElement.setObject(value);
+		 
+		if (source.getDiagram().addElement(newElement)) {
+			// add the element as a new element; check for member connections
+			conn = new RelationshipConnection(source, newElement, relationship);
+			source.getDiagram().createMemberConnections(newElement);
+		}
+		else {
+			// the element exists; just connect it in a relationship to this one
+			conn = new RelationshipConnection(source, source.getDiagram().getElement(newElement), relationship);
+		} 
+		conn.connect();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		Command contractCommand = new ContractRelationshipCommand(conn);
+		contractCommand.execute();
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/HideElementCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/HideElementCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/HideElementCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/HideElementCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,111 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.Connection;
+import org.apache.cayenne.ropbrowser.model.MemberConnection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.model.RelationshipConnection;
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * Command for deleting an element from the ObjectDiagram.
+ * 
+ * @author Marcel Gordon
+ */
+public class HideElementCommand extends Command {
+	
+	/** ModelElement to remove. */
+	private final ModelElement element;
+	
+	private ArrayList<Command> subcommands;
+	
+	private List<Connection> sourceConnections;
+	private List<Connection> targetConnections;
+	
+	/**
+	 * Create a command that will remove the ModelElement from its parent ElementDiagram.
+	 * @param parent the ElementDiagram containing the child
+	 * @param child    the ModelElement to remove
+	 * @throws IllegalArgumentException if any parameter is null
+	 */
+	public HideElementCommand(ModelElement element) {
+		if (element == null) {
+			throw new IllegalArgumentException();
+		}
+		setLabel("hide element");
+		this.element = element;
+		subcommands = new ArrayList<Command>();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return true;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		sourceConnections = element.getSourceConnections();
+		targetConnections = element.getTargetConnections();
+		redo();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		for (Connection conn : element.getTargetConnections()) {
+			conn.disconnect(); 
+		}
+		for (Connection conn : element.getSourceConnections()) {
+			conn.disconnect();
+			if (!conn.getTarget().isConnectedToRoot()) {
+				Command recCommand = new HideElementCommand(conn.getTarget());
+				subcommands.add(recCommand);
+				recCommand.execute();
+			}
+		}
+		element.getDiagram().removeElement(element);
+		
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		for (Command command : subcommands) {
+			command.undo();
+		}		
+		for (Connection conn : sourceConnections) {
+			conn.connect();
+		}
+		for (Connection conn : targetConnections) {
+			conn.connect();
+		}
+		element.getDiagram().addElement(element);
+	}
+}
\ No newline at end of file

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/NextObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/NextObjectCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/NextObjectCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/NextObjectCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,57 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.eclipse.gef.commands.Command;
+
+public class NextObjectCommand extends Command {
+	
+	private CollectionModelElement element;
+	
+	public NextObjectCommand(CollectionModelElement element) {
+		this.element = element;
+		setLabel("next object");
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return true;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		redo();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		element.next();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		element.previous();
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectInsertCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectInsertCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectInsertCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectInsertCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,62 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import org.apache.cayenne.ropbrowser.model.AbstractObject;
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.Connection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.model.RelationshipConnection;
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.eclipse.gef.commands.Command;
+import org.objectstyle.cayenne.map.ObjEntity;
+
+public class ObjectInsertCommand extends Command {
+	
+	/** ModelElement to insert a record into. */
+	private final ModelElement element;
+	
+	/**
+	 * Create a command that will remove the ModelElement from its parent ElementDiagram.
+	 * @param parent the ElementDiagram containing the child
+	 * @param child    the ModelElement to remove
+	 * @throws IllegalArgumentException if any parameter is null
+	 */
+	public ObjectInsertCommand(ModelElement element) {
+		if (element == null) {
+			throw new IllegalArgumentException();
+		}
+		setLabel("insert object");
+		this.element = element;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return false;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		ObjEntity entity = element.getDiagram().getObjectContext().getEntityResolver().getObjEntity(element.getName());
+		Class entityClass = entity.getJavaClass();
+		AbstractObject object = (AbstractObject) element.getDiagram().getObjectContext().newObject(entityClass);
+		element.addObject(object);
+	}
+}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java?rev=424641&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java Sat Jul 22 15:44:39 2006
@@ -0,0 +1,68 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.ropbrowser.commands;
+
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.MemberConnection;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.eclipse.gef.commands.Command;
+
+public class PopOutCommand extends Command {
+
+	private CollectionModelElement element;
+	private SingleModelElement newElement;
+	
+	public PopOutCommand(CollectionModelElement element) {
+		this.element = element;
+		setLabel("pop out");
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return true;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		if (element.getCurrentObject() != null) {
+			redo();
+		}
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		newElement = new SingleModelElement(element.getDiagram(), element.getName());
+		newElement.setObject(element.getCurrentObject());
+		if (element.getDiagram().addElement(newElement)) {
+			element.getDiagram().createMemberConnections(newElement);
+		}
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		Command deleteCommand = new HideElementCommand(newElement);
+		deleteCommand.execute();
+	}
+}

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CollectionFigure.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CollectionFigure.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CollectionFigure.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CollectionFigure.java Sat Jul 22 15:44:39 2006
@@ -16,20 +16,19 @@
 package org.apache.cayenne.ropbrowser.figures;
 
 import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.parts.CollectionEditPart;
 import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.Label;
 
 public class CollectionFigure extends ElementFigure {
 	
-	private PopOutButton popOutButton;
-	private CompartmentFigure commandFigure;
+	public CollectionFigure(CollectionEditPart part) {
+		super(part);
+	}
 	
-	public CollectionFigure(CollectionModelElement element) {
-		super(element);
-		
+	protected void setBackgroundColour() {
 		// root figure should be a different colour
-		if (model.getCreatedFrom() == null) {
+		if (getElementCast().isRoot()) {
 			setBackgroundColor(ColorConstants.lightBlue);
 		}
 		else {
@@ -37,28 +36,18 @@
 		}
 	}
 
-	protected void addComponents() {
-		super.addComponents();
-		
-		popOutButton = new PopOutButton();
-		commandFigure = new CompartmentFigure();
-		
-		add(commandFigure);
-		commandFigure.add(popOutButton);
+	private CollectionModelElement getElementCast() {
+		return (CollectionModelElement) part.getModel();
 	}
 	
-	@Override
 	protected void setName() {
-		String modelName = model.getName();
+		CollectionModelElement element = getElementCast();
+		String modelName = element.getName();
 		if (modelName != null) {
-			name.setText(modelName + " (" + model.getPropertyValue(CollectionModelElement.PROP_TOTAL_RECORDS) + ")");
+			name.setText(modelName + " (" + element.getPropertyValue(CollectionModelElement.PROP_TOTAL_RECORDS) + ")");
 		}
 		else {
 			name.setText(MSG_NULL_RESULT);
 		}
-	}
-	
-	public Figure getCommandCompartment() {
-		return commandFigure;
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/ElementFigure.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/ElementFigure.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/ElementFigure.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/ElementFigure.java Sat Jul 22 15:44:39 2006
@@ -19,17 +19,14 @@
 import java.util.Iterator;
 
 import org.apache.cayenne.ropbrowser.model.AbstractObject;
-import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
 import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.parts.ElementEditPart;
 import org.eclipse.draw2d.ColorConstants;
 import org.eclipse.draw2d.Figure;
 import org.eclipse.draw2d.Label;
 import org.eclipse.draw2d.LineBorder;
 import org.eclipse.draw2d.ToolbarLayout;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.requests.DirectEditRequest;
 import org.objectstyle.cayenne.map.Attribute;
-import org.objectstyle.cayenne.map.Relationship;
 
 /**
  * A Figure representing a CollectionEditPart in the editor. Contains two compartments,
@@ -46,11 +43,11 @@
 	/** name to be used where no name can be located */
 	public static final String MSG_NULL_RESULT = "NULL";
 	
-	protected ModelElement model;
+	protected ElementEditPart part;
 	
-	public ElementFigure(ModelElement model) {
+	public ElementFigure(ElementEditPart part) {
 		
-		this.model = model;
+		this.part = part;
 		
 		ToolbarLayout layout = new ToolbarLayout();
 		setLayoutManager(layout);	
@@ -69,6 +66,8 @@
 		add(attributeFigure);
 	}
 	
+	protected abstract void setBackgroundColour();
+	
 	protected abstract void setName();
 	
 	/**
@@ -76,7 +75,7 @@
 	 * relationship and attribute sub-figures
 	 */
 	protected void setContents() {
-		setAttributes(model.getCurrent());
+		setAttributes(((ModelElement) part.getModel()).getCurrentObject());
 	}
 	
 	/**
@@ -103,17 +102,8 @@
 	 * Refresh the entire figure - name and contents
 	 */
 	public void refresh() {
+		setBackgroundColour();
 		setName();
 		setContents();
-	}
-
-	public void doButtonAtPoint(Point loc, ModelElement element) {
-		
-		translateToRelative(loc);
-		
-		if (containsPoint(loc) && findFigureAt(loc) instanceof AbstractButton) {
-			AbstractButton button = (AbstractButton) findFigureAt(loc);
-			button.doButton(element);
-		}
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/SingleFigure.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/SingleFigure.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/SingleFigure.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/SingleFigure.java Sat Jul 22 15:44:39 2006
@@ -15,12 +15,16 @@
  */
 package org.apache.cayenne.ropbrowser.figures;
 
-import java.util.Iterator;
-
 import org.apache.cayenne.ropbrowser.model.AbstractObject;
+import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
 import org.apache.cayenne.ropbrowser.model.SingleModelElement;
+import org.apache.cayenne.ropbrowser.parts.SingleEditPart;
+import org.eclipse.draw2d.ActionEvent;
+import org.eclipse.draw2d.ActionListener;
+import org.eclipse.draw2d.Button;
+import org.eclipse.draw2d.Clickable;
 import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Label;
+import org.objectstyle.cayenne.PersistenceState;
 import org.objectstyle.cayenne.map.Relationship;
 
 public class SingleFigure extends ElementFigure {
@@ -28,10 +32,18 @@
 	/** sub-figure for displaying the object's relationships */
 	protected CompartmentFigure relationshipFigure;
 	
-	public SingleFigure(SingleModelElement element) {
-		super(element);
-		
-		setBackgroundColor(ColorConstants.lightGray);
+	public SingleFigure(SingleEditPart part) {
+		super(part);
+	}
+	
+	protected void setBackgroundColour() {
+		if (getElementCast().getCurrentObject() != null &&
+				getElementCast().getCurrentObject().getPersistenceState() == PersistenceState.DELETED) {
+			setBackgroundColor(ColorConstants.red);
+		}
+		else {
+			setBackgroundColor(ColorConstants.lightGray);
+		}
 	}
 
 	protected void addComponents() {
@@ -48,22 +60,31 @@
 		return relationshipFigure;
 	}
 	
-	protected void setRelationships(AbstractObject model) {
-		getRelationshipCompartment().removeAll();
+	protected void setRelationships() {
+		relationshipFigure.removeAll();
+		
+		if (getElementCast().getCurrentObject() == null) return;
 		
-		if (model != null) {
-			Iterator i = model.getRelationships().iterator();
-			while (i.hasNext()) {
-				Relationship r = (Relationship) i.next();
-				Label l = new RelationshipButton(r);
-				getRelationshipCompartment().add(l);
-			}
+		Button relButton;
+		String buttonLabel;
+		for (Object o : getElementCast().getCurrentObject().getRelationships()) {
+			Relationship relationship = (Relationship) o;
+			relButton = new Button(relationship.getName() + " -> " + relationship.getTargetEntityName() + (relationship.isToMany() ? " (1-n)" : " (1-1)"));
+			relButton.setStyle(Clickable.STYLE_TOGGLE);
+			relButton.getModel().setUserData(relationship);
+			relButton.addActionListener((SingleEditPart) part);
+			relButton.setSelected(((SingleEditPart) part).isRelationshipExpanded(relationship));
+			relationshipFigure.add(relButton);
 		}
 	}
 	
+	private SingleModelElement getElementCast() {
+		return (SingleModelElement) part.getModel();
+	}
+	
 	@Override
 	protected void setName() {
-		name.setText(model.getCurrent().getName());
+		name.setText(getElementCast().getName());
 	}
 	
 	/**
@@ -72,7 +93,6 @@
 	 */
 	protected void setContents() {
 		super.setContents();
-		setRelationships(model.getCurrent());
+		setRelationships();
 	}
-	
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DelegatingLayoutManager.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DelegatingLayoutManager.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DelegatingLayoutManager.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DelegatingLayoutManager.java Sat Jul 22 15:44:39 2006
@@ -7,17 +7,13 @@
 
 import org.apache.cayenne.ropbrowser.parts.ElementDiagramEditPart;
 import org.apache.cayenne.ropbrowser.policies.ElementXYLayoutEditPolicy;
-import org.apache.cayenne.ropbrowser.policies.CollectionSelectionPolicy;
-import org.apache.cayenne.ropbrowser.model.ElementDiagram;
+import org.apache.cayenne.ropbrowser.policies.SelectionHandlesEditPolicy;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.LayoutManager;
 import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.gef.EditPolicy;
 
-import com.caucho.hessian.io.CollectionSerializer;
-
-// TODO add an on/off command for auto layout
 
 /**
  * Used to delegate between the GraphyLayoutManager and the GraphXYLayout classes
@@ -27,8 +23,6 @@
 {
 
 	private ElementDiagramEditPart diagram;
-	private Map figureToBoundsMap;
-	private Map partsToNodeMap;
 
 	private LayoutManager activeLayoutManager;
 	private GraphLayoutManager graphLayoutManager;
@@ -49,32 +43,11 @@
 
 	public void layout(IFigure container)
 	{
-		if (diagram.isLayoutManualDesired())
+		if (!diagram.isAutoLayoutDesired())
 		{
-
-			if (activeLayoutManager != xyLayoutManager)
-			{
-
-				if (diagram.isLayoutManualAllowed())
-				{
-
-					//	yes we are okay to start populating the table bounds
-					setLayoutManager(container, xyLayoutManager);
-					activeLayoutManager.layout(container);
-
-				}
-				else
-				{
-					setLayoutManager(container, xyLayoutManager);
-					activeLayoutManager.layout(container);
-				}
-
-			}
-			else
-			{
-				setLayoutManager(container, xyLayoutManager);
-				activeLayoutManager.layout(container);
-			}
+			diagram.setTableFigureBounds(true);
+			setLayoutManager(container, xyLayoutManager);
+			activeLayoutManager.layout(container);
 		}
 		else
 		{
@@ -135,8 +108,7 @@
 		}
 		else
 		{
-			// TODO find a way to get selection feedback / handles
-			diagram.installEditPolicy(EditPolicy.LAYOUT_ROLE, null);
+			diagram.installEditPolicy(EditPolicy.LAYOUT_ROLE, new SelectionHandlesEditPolicy());
 		}
 	}
 	

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DirectedGraphLayoutVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DirectedGraphLayoutVisitor.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DirectedGraphLayoutVisitor.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/DirectedGraphLayoutVisitor.java Sat Jul 22 15:44:39 2006
@@ -9,14 +9,13 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cayenne.ropbrowser.parts.ElementDiagramEditPart;
-import org.apache.cayenne.ropbrowser.parts.ConnectionEditPart;
 import org.apache.cayenne.ropbrowser.figures.ElementFigure;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.parts.ConnectionEditPart;
+import org.apache.cayenne.ropbrowser.parts.ElementDiagramEditPart;
 import org.apache.cayenne.ropbrowser.parts.ElementEditPart;
 import org.eclipse.draw2d.AbsoluteBendpoint;
-import org.eclipse.draw2d.Connection;
 import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PolygonDecoration;
 import org.eclipse.draw2d.PolylineConnection;
 import org.eclipse.draw2d.geometry.Insets;
 import org.eclipse.draw2d.geometry.Rectangle;
@@ -144,27 +143,25 @@
 		Node n = (Node) partToNodesMap.get(element);
 		ElementFigure tableFigure = (ElementFigure) element.getFigure();
 
-		Rectangle bounds = new Rectangle(n.x, n.y, tableFigure.getPreferredSize().width,
-				tableFigure.getPreferredSize().height);
-
+		Rectangle bounds = new Rectangle(n.x, n.y, tableFigure.getPreferredSize().width, tableFigure.getPreferredSize().height);
+		
 		tableFigure.setBounds(bounds);
 
 		for (int i = 0; i < element.getSourceConnections().size(); i++)
 		{
-			ConnectionEditPart relationship = (ConnectionEditPart) element.getSourceConnections().get(i);
-			applyResults(relationship);
+			ConnectionEditPart connection = (ConnectionEditPart) element.getSourceConnections().get(i);
+			applyResults(connection);
 		}
 	}
 
 	//******************* RelationshipPart apply methods **********/
 
-	protected void applyResults(ConnectionEditPart relationshipPart)
+	protected void applyResults(ConnectionEditPart connection)
 	{
-
-		Edge e = (Edge) partToNodesMap.get(relationshipPart);
+		Edge e = (Edge) partToNodesMap.get(connection);
 		NodeList nodes = e.vNodes;
 
-		PolylineConnection conn = (PolylineConnection) relationshipPart.getConnectionFigure();
+		PolylineConnection conn = (PolylineConnection) connection.getConnectionFigure();
 		if (nodes != null)
 		{
 			List bends = new ArrayList();
@@ -191,7 +188,6 @@
 		{
 			conn.setRoutingConstraint(Collections.EMPTY_LIST);
 		}
-
 	}
 
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/GraphLayoutManager.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/GraphLayoutManager.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/GraphLayoutManager.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/layout/GraphLayoutManager.java Sat Jul 22 15:44:39 2006
@@ -21,8 +21,6 @@
 {
 
 	private ElementDiagramEditPart diagram;
-	private Map figureToBoundsMap;
-	private Map partsToNodeMap;
 
 	public GraphLayoutManager(ElementDiagramEditPart diagram)
 	{
@@ -50,6 +48,6 @@
 			return;
 		*/
 		new DirectedGraphLayoutVisitor().layoutDiagram(diagram);
+		diagram.setTableModelBounds();
 	}
-	
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/AbstractObject.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/AbstractObject.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/AbstractObject.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/AbstractObject.java Sat Jul 22 15:44:39 2006
@@ -21,6 +21,7 @@
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -53,14 +54,20 @@
 	 * @return a collection of {@link Relationship} objects.
 	 */
 	public Collection getRelationships() {
-		return objectContext.getEntityResolver().getObjEntity(getName()).getRelationships();
+		if(objectContext != null) {
+			return objectContext.getEntityResolver().getObjEntity(getName()).getRelationships();
+		}
+		return Collections.EMPTY_LIST;
 	}
 
 	/**
 	 * @return a collection of {@link org.objectstyle.cayenne.map.Attribute} objects.
 	 */
 	public Collection getAttributes() {
-		return objectContext.getEntityResolver().getObjEntity(getName()).getAttributes();
+		if (objectContext != null) {
+			return objectContext.getEntityResolver().getObjEntity(getName()).getAttributes();
+		}
+		return Collections.EMPTY_LIST;
 	}
 	
 	/**
@@ -70,13 +77,30 @@
 	 * a PersistentObject or null for a to-one relationship.
 	 */
 	public Object followRelationship(Relationship rel) {
-		
-		EntityResolver resolver = objectContext.getEntityResolver();
-		ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
-		
-		Object value = descriptor.getProperty(rel.getName()).readProperty(this);
-		
-		return value;
+		if (objectContext != null) {
+			EntityResolver resolver = objectContext.getEntityResolver();
+			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
+			
+			Object value = descriptor.getProperty(rel.getName()).readProperty(this);
+			
+			return value;
+		}
+		return null;
+	}
+	
+	public void setRelationship(Relationship rel, AbstractObject oldValue, AbstractObject newValue) {
+		if (objectContext != null) {
+			
+			EntityResolver resolver = objectContext.getEntityResolver();
+			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
+			
+			descriptor.getProperty(rel.getName()).writeProperty(this, oldValue, newValue);
+			
+			// notify objectContext about simple property change
+	        objectContext.propertyChanged(this, rel.getName(), oldValue, newValue);
+	        
+	        firePropertyChange(rel.getName(), oldValue, newValue);
+		}
 	}
 
 	/**
@@ -87,27 +111,28 @@
 	public Object getPropertyValue(Object id) {
 		if(objectContext != null) {
             objectContext.prepareForAccess(this, id.toString());
-        }
-		
-		EntityResolver resolver = objectContext.getEntityResolver();
-		ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
-		ObjAttribute attribute = (ObjAttribute) resolver.getObjEntity(getName()).getAttribute(id.toString());
 		
-		Object value = null;
-		if (attribute.getType().equals("java.util.Date")) {
-			value = dateFormatter.format(descriptor.getProperty(id.toString()).readProperty(this));
-		}
-		else {
-			value = descriptor.getProperty(id.toString()).readProperty(this);
-			if (value == null) {
-				value = new String("");
+			EntityResolver resolver = objectContext.getEntityResolver();
+			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
+			ObjAttribute attribute = (ObjAttribute) resolver.getObjEntity(getName()).getAttribute(id.toString());
+			
+			Object value = null;
+			if (attribute.getType().equals("java.util.Date")) {
+				value = dateFormatter.format(descriptor.getProperty(id.toString()).readProperty(this));
 			}
 			else {
-				value = value.toString(); 
-			}
-		} 
-		
-		return value;
+				value = descriptor.getProperty(id.toString()).readProperty(this);
+				if (value == null) {
+					value = new String("");
+				}
+				else {
+					value = value.toString(); 
+				}
+			} 
+			
+			return value;
+		}
+		return null;
 	}
 
 	/**
@@ -133,46 +158,44 @@
 	 */
 	public void setPropertyValue(Object id, Object value) {
 		
-		if(objectContext != null) {
-            objectContext.prepareForAccess(this, id.toString());
-        }
-		EntityResolver resolver = objectContext.getEntityResolver();
-		ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
-		ObjAttribute attribute = (ObjAttribute) resolver.getObjEntity(getName()).getAttribute(id.toString());
-		
-		Object newValue = null;
-		if (attribute.getType().equals("java.util.Date")) {
-			try {
-				newValue = dateFormatter.parse(value.toString());
-			}
-			catch(ParseException e) {
-				// TODO logging etc
-				System.out.println("Invalid date format");
-			}
-		}
-		else {
-			// try to use a constructor from a String
-			try {
-				Class newClass = Class.forName(attribute.getType());
-				newValue = newClass.getConstructor(Class.forName("java.lang.String")).newInstance(value.toString());
-			}
-			catch(Exception e) {
-				// TODO log
-				System.out.println("No String constructor available; implement a custom IPropertyDescriptor or type convertor");
-				newValue = value;
+		if(objectContext != null) {            
+			EntityResolver resolver = objectContext.getEntityResolver();
+			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
+			ObjAttribute attribute = (ObjAttribute) resolver.getObjEntity(getName()).getAttribute(id.toString());
+			
+			Object newValue = null;
+			if (attribute.getType().equals("java.util.Date")) {
+				try {
+					newValue = dateFormatter.parse(value.toString());
+				}
+				catch(ParseException e) {
+					// TODO logging etc
+					System.out.println("Invalid date format");
+				}
 			}
+			else {
+				// try to use a constructor from a String
+				try {
+					Class newClass = Class.forName(attribute.getType());
+					newValue = newClass.getConstructor(Class.forName("java.lang.String")).newInstance(value.toString());
+				}
+				catch(Exception e) {
+					// TODO log
+					System.out.println("No String constructor available; implement a custom IPropertyDescriptor or type convertor");
+					newValue = value;
+				}
+			}
+			
+			objectContext.prepareForAccess(this, id.toString());
+	        Object oldValue = descriptor.getProperty(id.toString()).readProperty(this);
+	        
+	        descriptor.getProperty(id.toString()).writeProperty(this, oldValue, newValue);
+	        
+	        // notify objectContext about simple property change
+	        objectContext.propertyChanged(this, id.toString(), oldValue, newValue);
+	        
+	        firePropertyChange(id.toString(), oldValue, newValue);
 		}
-		
-        Object oldValue = descriptor.getProperty(id.toString()).readProperty(this);
-        
-        descriptor.getProperty(id.toString()).writeProperty(this, oldValue, newValue);
-        
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, id.toString(), oldValue, newValue);
-        }
-        
-        firePropertyChange(id.toString(), oldValue, newValue);
 	}
 	
 	/** 
@@ -215,15 +238,18 @@
 	 * @return array of IPropertyDescriptors for the objects attributes
 	 */
 	public IPropertyDescriptor[] getPropertyDescriptors() {
-		EntityResolver entityResolver = getObjectContext().getEntityResolver();
-		ObjEntity entity = entityResolver.getObjEntity(getName());
-		Iterator attributes = entity.getAttributes().iterator();
-		IPropertyDescriptor[] properties = new IPropertyDescriptor[entity.getAttributes().size()];
-		int i = 0;
-		while (attributes.hasNext()) {
-			ObjAttribute attribute = (ObjAttribute) attributes.next();
-			properties[i++] = new TextPropertyDescriptor(attribute.getName(), attribute.getName());
+		if (objectContext != null) {
+			EntityResolver entityResolver = getObjectContext().getEntityResolver();
+			ObjEntity entity = entityResolver.getObjEntity(getName());
+			Iterator attributes = entity.getAttributes().iterator();
+			IPropertyDescriptor[] properties = new IPropertyDescriptor[entity.getAttributes().size()];
+			int i = 0;
+			while (attributes.hasNext()) {
+				ObjAttribute attribute = (ObjAttribute) attributes.next();
+				properties[i++] = new TextPropertyDescriptor(attribute.getName(), attribute.getName());
+			}
+			return properties;
 		}
-		return properties;
+		return new IPropertyDescriptor[0];
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/CollectionModelElement.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/CollectionModelElement.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/CollectionModelElement.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/CollectionModelElement.java Sat Jul 22 15:44:39 2006
@@ -19,17 +19,14 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.PropertyDescriptor;
 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.objectstyle.cayenne.map.EntityResolver;
-import org.objectstyle.cayenne.map.ObjAttribute;
-import org.objectstyle.cayenne.map.ObjEntity;
+import org.objectstyle.cayenne.Persistent;
+import org.objectstyle.cayenne.util.PersistentObjectList;
+
 
 /**
  * Class representing a collection of AbstractObjects.
@@ -42,10 +39,6 @@
 public class CollectionModelElement extends ModelElement implements PropertyChangeListener {
 	
 	/**
-	 * Property for changes to the records being displayed by this element.
-	 */
-	public static final String PROP_RECORDS = "Collection.Records";
-	/**
 	 * Property descriptors for total records and current record for use with the Eclipse Properties view.
 	 */
 	protected static IPropertyDescriptor [] descriptors;
@@ -84,8 +77,8 @@
 	/**
 	 * @param createdFrom the ModelElement which initiated this element's creation.
 	 */
-	public CollectionModelElement(ModelElement createdFrom) {
-		super(createdFrom);
+	public CollectionModelElement(ElementDiagram diagram, String name) {
+		super(diagram, name);
 	}
 	
 	/**
@@ -94,12 +87,17 @@
 	 * own property change events when the underlying data is changed.
 	 * @param value may be null, an empty list or a list of AbstractObjects.
 	 */
-	public void setData(Object value) {
+	public void setObject(Object value) {
 		
 		List oldObjects = this.objects;
 		this.currentRecord = 0;
 		
-		if (value instanceof List) {
+		if (value instanceof AbstractObject) {
+			this.objects = new ArrayList<AbstractObject>();
+			this.objects.add((AbstractObject) value);
+			this.current = (AbstractObject) value;
+		}
+		else if (value instanceof List) {
 			this.objects = (List) value;
 			if (this.objects.isEmpty()) {
 				this.current = null;
@@ -109,7 +107,6 @@
 			}
 		}
 		else {
-			// TODO create NullModelElement
 			this.objects = new ArrayList<AbstractObject>();
 			this.current = null;
 		}
@@ -118,6 +115,10 @@
 			object.addPropertyChangeListener(this);
 		}
 		
+		if (getCurrentObject() != null) {
+			name = getCurrentObject().getName();
+		}
+		
 		firePropertyChange(PROP_RECORDS, oldObjects, objects);
 	}
 	
@@ -144,17 +145,6 @@
 		}
 		return properties;
 	}
-	
-	/**
-	 * @return all the {@link org.objectstyle.cayenne.map.Relationship} of the currently displayed AbstractObject,
-	 * or null if no object is being displayed.
-	 */
-	public Collection getRelationships() {
-		if (current != null) {
-			return current.getRelationships();
-		}
-		return null;
-	}
 
 	@Override
 	public Object getPropertyValue(Object id) {
@@ -213,94 +203,43 @@
 	 * end is reached.
 	 */
 	public void next() {
-		int oldCurrent = currentRecord;
-		
-		if (currentRecord == objects.size() - 1) {
-			currentRecord = 0;
-		}
-		else {
-			currentRecord++;
+		if (objects != null && !objects.isEmpty()) {
+			int oldCurrent = currentRecord;
+			
+			if (currentRecord == objects.size() - 1) {
+				currentRecord = 0;
+			}
+			else {
+				currentRecord++;
+			}
+			current = objects.get(currentRecord);
+			firePropertyChange(PROP_CURRENT_RECORD, new Integer(oldCurrent), new Integer(currentRecord));
 		}
-		current = objects.get(currentRecord);
-		firePropertyChange(PROP_CURRENT_RECORD, new Integer(oldCurrent), new Integer(currentRecord));
 	}
 
 	/**
 	 * @return the AbstractObject currently being displayed.
 	 */
-	public AbstractObject getCurrent() {
+	public AbstractObject getCurrentObject() {
 		return current;
 	}
 
 	/**
-	 * @return all the {@link org.objectstyle.cayenne.map.Attribute} of the currently displayed AbstractObject,
-	 * or null if no object is being displayed.
-	 */
-	public Collection getAttributes() {
-		if (current != null) {
-			return current.getObjectContext().getEntityResolver().getObjEntity(current.getName()).getAttributes();
-		}
-		return null;
-	}
-
-	/**
 	 * Scrolls backwards through the AbstractObject list, cycling to the end once the
 	 * start is reached.
 	 */
 	public void previous() {
-		int oldCurrent = currentRecord;
+		if (objects != null && !objects.isEmpty()) {
+			int oldCurrent = currentRecord;
 		
-		if (currentRecord == 0) {
-			currentRecord = objects.size() - 1;
-		}
-		else {
-			currentRecord--;
-		}
-		current = objects.get(currentRecord);
-		firePropertyChange(PROP_CURRENT_RECORD, new Integer(oldCurrent), new Integer(currentRecord));
-	}
-	
-	/**
-	 * Used to compare two CollectionModelElements to determine if one is
-	 * already in the {@link org.apache.cayenne.ropbrowser.model.ElementDiagram} and hence should not be created.
-	 */
-	public boolean equals(Object o) {
-		if (o instanceof CollectionModelElement) {
-			if (objects.equals(((CollectionModelElement) o).getObjects())
-					&& createdFrom == ((CollectionModelElement) o).getCreatedFrom()) {
-				return true;
+			if (currentRecord == 0) {
+				currentRecord = objects.size() - 1;
 			}
-		}
-		return false;
-	}
-
-
-
-	/**
-	 * @return the list of AbstractObjects being displayed.
-	 */
-	List<AbstractObject> getObjects() {
-		return this.objects;
-	}
-
-	public void updateConnectedElements() {
-		for (Object o : getSourceConnections()) {
-			if (o instanceof RelationshipConnection) {
-				RelationshipConnection conn = (RelationshipConnection) o;
-				ModelElement element = conn.getTarget();
-				if (element instanceof CollectionModelElement) {
-					
-					CollectionModelElement collection = (CollectionModelElement) element;
-					
-					Object object = null;
-					if (current != null) {
-						object = current.followRelationship(conn.getRelationship());
-					}
-					
-					collection.setData(object);
-					collection.updateConnectedElements();
-				}
+			else {
+				currentRecord--;
 			}
+			current = objects.get(currentRecord);
+			firePropertyChange(PROP_CURRENT_RECORD, new Integer(oldCurrent), new Integer(currentRecord));
 		}
 	}
 
@@ -313,11 +252,38 @@
 	}
 
 	public boolean contains(AbstractObject object) {
-		for (AbstractObject record : objects) {
-			if (object == record) {
-				return true;
+		if (objects == null) {
+			return false;
+		}
+		return objects.contains(object);
+	}
+
+	public void removeObject(AbstractObject object) {
+		if (objects.remove(object)) {
+			validateCurrent();
+			firePropertyChange(PROP_RECORDS, null, objects);
+			firePropertyChange(PROP_TOTAL_RECORDS, objects.size() + 1, objects.size());
+		}
+	}
+	
+	protected void validateCurrent() {
+		if (currentRecord > objects.size() - 1 || !objects.contains(current)) {
+			currentRecord = 0;
+			if (!objects.isEmpty()) {
+				current = objects.get(currentRecord);
+			}
+			else {
+				current = null;
 			}
+			firePropertyChange(PROP_CURRENT_RECORD, null, objects);
 		}
-		return false;
+	}
+
+	public void addObject(AbstractObject object) {
+		objects.add(object);
+		object.addPropertyChangeListener(this);
+		firePropertyChange(PROP_TOTAL_RECORDS, null, objects);
+		firePropertyChange(PROP_RECORDS, null, objects);
+		validateCurrent();
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Connection.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Connection.java?rev=424641&r1=424640&r2=424641&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Connection.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Connection.java Sat Jul 22 15:44:39 2006
@@ -27,6 +27,8 @@
 	private ModelElement source;
 	/** Connection's target endpoint. */
 	private ModelElement target;
+	
+	private boolean connected;
 
 	/** 
 	 * Create a (solid) connection between two elements.
@@ -37,6 +39,7 @@
 	public Connection(ModelElement source, ModelElement target) {
 		this.source = source;
 		this.target = target;
+		this.connected = false;
 	}
 	
 	/**
@@ -67,15 +70,21 @@
 	 * Connect this connection.
 	 */  
 	public void connect() {
-		source.addConnection(this);
-		target.addConnection(this);
+		if (!connected) {
+			source.addConnection(this);
+			target.addConnection(this);
+			connected = true;
+		}
 	}
 
 	/**
 	 * Removes the connection from its source and target elements.
 	 */
 	public void disconnect() {
-		source.removeConnection(this);
-		target.removeConnection(this);
+		if (connected) {
+			source.removeConnection(this);
+			target.removeConnection(this);
+			connected = false;
+		}
 	}
 }



Mime
View raw message