cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r421091 [1/2] - in /incubator/cayenne/soc/trunk/cayenne-rop/rop-browser: ./ META-INF/ dist/ lib/ src/org/apache/cayenne/ropbrowser/ src/org/apache/cayenne/ropbrowser/commands/ src/org/apache/cayenne/ropbrowser/figures/ src/org/apache/cayenn...
Date Wed, 12 Jul 2006 02:53:16 GMT
Author: aadamchik
Date: Tue Jul 11 19:53:14 2006
New Revision: 421091

URL: http://svn.apache.org/viewvc?rev=421091&view=rev
Log:
CAY-593 rop-browser patch - it works!

Added:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/smack-2.2.1.jar   (with props)
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/smackx-2.2.1.jar   (with props)
    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/commands/ElementSetConstraintCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipLabel.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/parts/ElementDiagramEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPartFactory.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java
Removed:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ModelTest.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ObjectSetConstraintCommand.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/NullFigure.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/IObject.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/NullModelElement.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ObjectDiagram.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/NullEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ObjectDiagramEditPart.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ObjectEditPartFactory.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/dist/build.properties
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.xml
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/log4j.properties
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/web.xml
    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/ObjectEditorInput.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ROPBrowserPlugin.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/CompartmentFigure.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/Artist.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/Gallery.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/Painting.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/auto/_Artist.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/auto/_Gallery.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/auto/_Painting.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/ElementEditPart.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/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=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath Tue Jul 11 19:53:14 2006
@@ -9,5 +9,7 @@
 	<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="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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -5,10 +5,10 @@
 Bundle-Version: 1.0.0
 Bundle-Activator: org.apache.cayenne.ropbrowser.ROPBrowserPlugin
 Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.ui.forms,
- org.eclipse.ui.views,
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.forms,
+ org.eclipse.ui.views,
  org.eclipse.gef
 Eclipse-AutoStart: true
 Bundle-ClassPath: lib/hessian-3.0.13.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=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/build.properties Tue Jul 11 19:53:14 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
+               lib/cayenne-client-nodeps-1.2RC1.jar
\ No newline at end of file

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.properties
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.properties?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.properties (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.properties Tue Jul 11 19:53:14 2006
@@ -1,5 +1,5 @@
 # This can be overriden from command line to point to Eclipse location
-eclipse.home = g:/eclipse
+eclipse.home = g:/eclipse
 
 server.src = ../src/org/apache/cayenne/ropbrowser/server
 client.src = ../src/org/apache/cayenne/ropbrowser/model
@@ -12,4 +12,4 @@
 build.cayenneNode.xml = classes/${_cayenneNode.xml}
 _cayenne.xml = cayenne.xml
 _cayenneMap.xml = ropbrowserMap.map.xml
-_cayenneNode.xml = ropbrowserNode.driver.xml
+_cayenneNode.xml = ropbrowserNode.driver.xml
\ No newline at end of file

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.xml?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.xml (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/build.xml Tue Jul 11 19:53:14 2006
@@ -1,15 +1,12 @@
 <?xml version="1.0"?>
 
-<!-- ================================================= -->
-<!--    Provides a class generator for the client classes.     -->
-<!-- ================================================= -->
 <project name="cws" default="package">
 	
-	<property file="build.properties"/>
-	
-	<path id="classpath">
-		<fileset dir="${eclipse.home}/plugins" includes="org.eclipse.ui.views_*.jar,org.eclipse.draw2d_*.jar"/>
-		<fileset dir="../lib" includes="**/*.jar"/>
+	<property file="build.properties"/>
+	
+	<path id="classpath">
+		<fileset dir="${eclipse.home}/plugins" includes="org.eclipse.ui.views_*.jar,org.eclipse.draw2d_*.jar"/>
+		<fileset dir="../lib" includes="**/*.jar"/>
 	</path>
 		
 	<target name="compile"
@@ -23,7 +20,7 @@
 	    	classpathref="classpath"/>
 	</target>
 	
-	<target name="compile-server" description="compile the server classes">
+	<target name="compile-server" description="compile the server classes">
 		<mkdir dir="build/server"/>
 	  <javac srcdir="${server.src}" destdir="build/server" classpathref="classpath" />
 	</target>
@@ -32,7 +29,7 @@
 	  <copy file="${cayenne.xml}" todir="classes"/>
 	  <copy file="${cayenneMap.xml}" todir="classes"/>
 	  <copy file="${cayenneNode.xml}" todir="classes"/>
-	  <war destfile="build/cayenne.war" webxml="${webxml}">
+	  <war destfile="build/rop-browser.war" webxml="${webxml}">
 	    <lib dir="../lib/server"/>
 	    <lib dir="${eclipse.home}/plugins" includes="org.eclipse.ui.views_*.jar"/>
 	    <classes dir="build/client/"/>

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/log4j.properties?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/log4j.properties (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/log4j.properties Tue Jul 11 19:53:14 2006
@@ -18,5 +18,3 @@
 # (change to DEBUG to see the progress of Cayenne XML files loading)
 log4j.logger.org.objectstyle.cayenne.conf = INFO
 
-# Custom Loggers....
-log4j.logger.cayenne3t = DEBUG

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/web.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/web.xml?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/web.xml (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/dist/web.xml Tue Jul 11 19:53:14 2006
@@ -3,11 +3,6 @@
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
 <web-app>
-	<!-- tracks client sesssions .. used for session debugging -->
-	<listener>
-		<listener-class>cayenne3t.example.util.SessionTracker</listener-class>
-	</listener>
-	
 	<!-- on session timeout server-side DataContext will be deallocated
 	     shared DataChannels will be deallocated when no sessions are using them 
 	-->
@@ -17,11 +12,10 @@
 	
 	<!-- Deploying Cayenne distributed service using Hessian OPP transport -->
 	<servlet>
-		<servlet-name>cayenne</servlet-name>
+		<servlet-name>rop-browser</servlet-name>
 		<servlet-class>org.objectstyle.cayenne.remote.hessian.service.HessianServlet</servlet-class>
 		
-		<!-- client-server events setup -->
-		<!-- 
+		<!--
 		<init-param>
 			<param-name>cayenne.RemoteService.EventBridge.factory</param-name>
 			<param-value>org.objectstyle.cayenne.event.XMPPBridgeFactory</param-value>
@@ -37,25 +31,11 @@
 		<init-param>
 			<param-name>cayenne.XMPPBridge.xmppChatService</param-name>
 			<param-value>conference</param-value>
-		</init-param> -->
+		</init-param>
+		-->
 	</servlet>
 	<servlet-mapping>
-		<servlet-name>cayenne</servlet-name>
-		<url-pattern>/cayenne</url-pattern>
+		<servlet-name>rop-browser</servlet-name>
+		<url-pattern>/rop-browser</url-pattern>
 	</servlet-mapping>
-	
-	<!-- helper filter that sets up logging and debugs requests. This is optional -->
-	<filter>
-		<filter-name>cayenne-web-service-filter</filter-name>
-		<filter-class>cayenne3t.example.util.RequestFilter</filter-class>
-		<init-param>
-			<param-name>log4j-config</param-name>
-			<param-value>/WEB-INF/log4j.properties</param-value>
-		</init-param>
-	</filter>
-	
-	<filter-mapping>
-		<filter-name>cayenne-web-service-filter</filter-name>
-		<servlet-name>cayenne</servlet-name>
-	</filter-mapping>
 </web-app>

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

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

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

Propchange: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/lib/smackx-2.2.1.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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,34 +1,41 @@
 /*
- * Created on 1/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
+
 package org.apache.cayenne.ropbrowser;
 
-import java.util.ArrayList;
 import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
 
-import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 import org.objectstyle.cayenne.CayenneContext;
 import org.objectstyle.cayenne.DataChannel;
 import org.objectstyle.cayenne.ObjectContext;
-import org.objectstyle.cayenne.map.EntityResolver;
-import org.objectstyle.cayenne.map.ObjAttribute;
-import org.objectstyle.cayenne.map.ObjEntity;
-import org.objectstyle.cayenne.query.Query;
 import org.objectstyle.cayenne.remote.ClientChannel;
 import org.objectstyle.cayenne.remote.ClientConnection;
 import org.objectstyle.cayenne.remote.hessian.HessianConnection;
 
+/**
+ * Singleton class which manages connections to the Cayenne web service,
+ * mapping host strings to ObjectContexts.
+ * 
+ * @author Marcel Gordon
+ */
 public class ConnectionManager {
 	
 	private static ConnectionManager _ref;
+	/** All connections made by the application */
 	private Hashtable<String, ObjectContext> connections;
 	
 	private ConnectionManager() {
@@ -42,9 +49,18 @@
 		return _ref;
 	}
 	
-	public ObjectContext connect(String address) {
+	/**
+	 * Get an object context for the given host, creating and storing the context if none exists.
+	 * @param address full address of the Cayenne web service (eg http://localhost:8080/rop-browser/rop-browser)
+	 * @return ObjectContext connected to the given address
+	 */
+	public ObjectContext getObjectContext(String address) {
+		
+		if (connections.containsKey(address)) {
+			return connections.get(address);
+		}
 		
-		ClientConnection connection = new HessianConnection(address);
+		ClientConnection connection = new HessianConnection(address, null, null, "shared-session");
 		DataChannel channel = new ClientChannel(connection);
 		ObjectContext context = new CayenneContext(channel);
 		

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,15 +1,25 @@
 /*
- * Created on 8/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser;
 
 import java.util.EventObject;
 
-import org.apache.cayenne.ropbrowser.model.ObjectDiagram;
-import org.apache.cayenne.ropbrowser.parts.ObjectEditPartFactory;
+import org.apache.cayenne.ropbrowser.model.ElementDiagram;
+import org.apache.cayenne.ropbrowser.parts.ElementEditPartFactory;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.gef.ContextMenuProvider;
 import org.eclipse.gef.DefaultEditDomain;
@@ -21,10 +31,21 @@
 import org.eclipse.ui.IEditorPart;
 import org.objectstyle.cayenne.ObjectContext;
 
+/**
+ * Editor class allowing visual editing of database data via
+ * Cayenne's object model.
+ * <p>Despite the dire warnings in the GEF API, clients (even those
+ * in official GEF examples) customarily extend GraphicalEditor.
+ * 
+ * @author Marcel Gordon
+ */
 public class ObjectEditor extends GraphicalEditor {
 
+	/** ID of the Editor */
 	public static final String ID = "org.apache.cayenne.ropbrowser.ObjectEditor";
-	private ObjectDiagram objectDiagram;
+	/** Root component of the data model */
+	private ElementDiagram objectDiagram;
+	/** ObjectContext for all the objects in the editor */
 	private ObjectContext context;
 	
 	public ObjectEditor() {
@@ -39,17 +60,13 @@
 	
 	/**
 	 * Configure the graphical viewer before it receives contents.
-	 * <p>This is the place to choose an appropriate RootEditPart and EditPartFactory
-	 * for your editor. The RootEditPart determines the behavior of the editor's "work-area".
-	 * For example, GEF includes zoomable and scrollable root edit parts. The EditPartFactory
-	 * maps model elements to edit parts (controllers).</p>
 	 * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
 	 */
 	protected void configureGraphicalViewer() {
 		super.configureGraphicalViewer();
 		
 		GraphicalViewer viewer = getGraphicalViewer();
-		viewer.setEditPartFactory(new ObjectEditPartFactory());
+		viewer.setEditPartFactory(new ElementEditPartFactory());
 		viewer.setRootEditPart(new ScalableFreeformRootEditPart());
 		viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
 
@@ -59,7 +76,8 @@
 		getSite().registerContextMenu(cmProvider, viewer);
 	}
 	
-	/* (non-Javadoc)
+	/**
+	 * Fires a property change event to inform the workbench that the editor has been modified.
 	 * @see org.eclipse.gef.ui.parts.GraphicalEditor#commandStackChanged(java.util.EventObject)
 	 */
 	public void commandStackChanged(EventObject event) {
@@ -67,23 +85,32 @@
 		super.commandStackChanged(event);
 	}
 
-	@Override
+	/**
+	 * Saves changes made in the editor back to the database.
+	 */
 	public void doSave(IProgressMonitor monitor) {
 		context.commitChanges();
 	}
 
-	@Override
+	/**
+	 * Does nothing - no save as in this application.
+	 */
 	public void doSaveAs() {
 	}
 
-	@Override
+	/**
+	 * Save as not allowed in this application.
+	 */
 	public boolean isSaveAsAllowed() {
 		return false;
 	}
 	
+	/**
+	 * Initialises the editor for a given context and query.
+	 */
 	protected void setInput(IEditorInput input) {
 		super.setInput(input);
 		this.context = ((ObjectEditorInput) input).getContext();
-		objectDiagram = new ObjectDiagram(this.context, ((ObjectEditorInput) input).getQuery());		
+		objectDiagram = new ElementDiagram(this.context, ((ObjectEditorInput) input).getQuery());		
 	}
 }

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,28 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 Elias Volanakis 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:
- *    Elias Volanakis - initial API and implementation
- *******************************************************************************/
+/*
+ *  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;
 
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.actions.ActionFactory;
-
 import org.eclipse.gef.ContextMenuProvider;
 import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.ui.actions.ActionRegistry;
 import org.eclipse.gef.ui.actions.GEFActionConstants;
-
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionFactory;
 
 /**
- * Provides context menu actions for the ShapesEditor.
- * @author Elias Volanakis
+ * Provides context menu items for the ObjectEditor.
+ * 
+ * @author Marcel Gordon
  */
 class ObjectEditorContextMenuProvider extends ContextMenuProvider {
 
@@ -30,8 +35,6 @@
 	private ActionRegistry actionRegistry;
 		
 	/**
-	 * Instantiate a new menu context provider for the specified EditPartViewer 
-	 * and ActionRegistry.
 	 * @param viewer	the editor's graphical viewer
 	 * @param registry	the editor's action registry
 	 * @throws IllegalArgumentException if registry is <tt>null</tt>. 
@@ -45,8 +48,7 @@
 	}
 	
 	/**
-	 * Called when the context menu is about to show. Actions, 
-	 * whose state is enabled, will appear in the context menu.
+	 * Creates context menu items for the editor.
 	 * @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
 	 */
 	public void buildContextMenu(IMenuManager menu) {
@@ -68,5 +70,4 @@
 	private IAction getAction(String actionId) {
 		return actionRegistry.getAction(actionId);
 	}
-
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorInput.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorInput.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorInput.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ObjectEditorInput.java Tue Jul 11 19:53:14 2006
@@ -1,8 +1,18 @@
 /*
- * Created on 8/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser;
 
@@ -11,9 +21,17 @@
 import org.eclipse.ui.IPersistableElement;
 import org.objectstyle.cayenne.ObjectContext;
 
+/**
+ * Input for the ObjectEditor class, providing the context and
+ * query needed to initialise the editor.
+ * 
+ * @author Marcel Gordon
+ */
 public class ObjectEditorInput implements IEditorInput {
 
+	/** name of the query stored in the Cayenne data map */
 	protected String query;
+	/** context in which the query exists */
 	protected ObjectContext context;
 	
 	public ObjectEditorInput(ObjectContext context, String query) {
@@ -29,6 +47,9 @@
 		return ImageDescriptor.getMissingImageDescriptor();
 	}
 
+	/**
+	 * The name of the query contained in the Cayenne data map.
+	 */
 	public String getName() {
 		return query;
 	}
@@ -49,10 +70,16 @@
 		return query;
 	}
 
+	/**
+	 * @return the context in which the query is found
+	 */
 	public ObjectContext getContext() {
 		return context;
 	}
 	
+	/**
+	 * Used to determine whether to open a new editor.
+	 */
 	public boolean equals(Object o) {
 		if (o instanceof ObjectEditorInput) {
 			ObjectEditorInput input = (ObjectEditorInput) o;

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ROPBrowserPlugin.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ROPBrowserPlugin.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ROPBrowserPlugin.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/ROPBrowserPlugin.java Tue Jul 11 19:53:14 2006
@@ -1,7 +1,23 @@
+/*
+ *  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;
 
-import org.eclipse.ui.plugin.*;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
 /**

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementDeleteCommand.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementDeleteCommand.java?rev=421091&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementDeleteCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementDeleteCommand.java Tue Jul 11 19:53:14 2006
@@ -0,0 +1,121 @@
+/*
+ *  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.ElementDiagram;
+import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * Command for deleting an element from the ObjectDiagram.
+ * 
+ * @author Marcel Gordon
+ */
+public class ElementDeleteCommand extends Command {
+	
+	/** ModelElement to remove. */
+	private final ModelElement child;
+	
+	/** ElementDiagram to remove from. */
+	private final ElementDiagram parent;
+	/** Copy of the incoming connections of child. */
+	private List targetConnections;
+	/** Copy of the outgoing connections */
+	private List sourceConnections;
+	/** True if child was successfully removed from its parent. */
+	private boolean wasRemoved;
+	
+	/**
+	 * 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 ElementDeleteCommand(ElementDiagram parent, ModelElement child) {
+		if (parent == null || child == null) {
+			throw new IllegalArgumentException();
+		}
+		setLabel("element deletion");
+		this.parent = parent;
+		this.child = child;
+	}
+	
+	/**
+	 * Reconnects the given List of Connections with their sources and targets.
+	 */
+	private void addConnections(List connections) {
+		for (Iterator iter = connections.iterator(); iter.hasNext();) {
+			Connection conn = (Connection) iter.next();
+			conn.connect();
+		}
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#canUndo()
+	 */
+	public boolean canUndo() {
+		return wasRemoved;
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		// store a copy of incoming & outgoing connections before proceeding 
+		targetConnections = child.getTargetConnections();
+		sourceConnections = child.getSourceConnections();
+		redo();
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#redo()
+	 */
+	public void redo() {
+		// remove the child and disconnect its connections
+		wasRemoved = parent.removeChild(child);
+		if (wasRemoved) {
+			removeConnections(targetConnections);
+			removeConnections(sourceConnections);
+		}
+	}
+	
+	/**
+	 * Removes all the connections in the supplied list from both source and target.
+	 */
+	private void removeConnections(List connections) {
+		for (Iterator iter = connections.iterator(); iter.hasNext();) {
+			Connection conn = (Connection) iter.next();
+			conn.disconnect();
+		}
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#undo()
+	 */
+	public void undo() {
+		// add the child and reconnect its connections
+		if (parent.addElement(child)) {
+			// TODO haven't maintained all the lost child ModelElements; therefore can't do complete undo
+			// need to find a way of storing and reconstructing all of the children
+			addConnections(targetConnections);
+		}
+	}
+}
\ No newline at end of file

Added: 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=421091&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/ElementSetConstraintCommand.java Tue Jul 11 19:53:14 2006
@@ -0,0 +1,93 @@
+/*
+ *  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.ModelElement;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+
+/**
+ * Command for moving or resizing an element in the editor.
+ * 
+ * @author Marcel Gordon
+ */
+public class ElementSetConstraintCommand extends Command {
+	
+	/** Stores the new size and location. */
+	private final Rectangle newBounds;
+	/** Stores the old size and location. */
+	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();
+		}
+		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));
+	}
+	
+	/**
+	 * @see org.eclipse.gef.commands.Command#execute()
+	 */
+	public void execute() {
+		oldBounds = new Rectangle(element.getX(), element.getY(), element.getWidth(), element.getHeight());
+		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);
+	}
+	
+	/**
+	 * @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);
+	}
+}

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,8 +1,18 @@
 /*
- * Created on 14/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser.figures;
 
@@ -15,59 +25,114 @@
 import org.eclipse.draw2d.Label;
 import org.eclipse.draw2d.LineBorder;
 import org.eclipse.draw2d.ToolbarLayout;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.swt.graphics.Color;
 import org.objectstyle.cayenne.map.Attribute;
 import org.objectstyle.cayenne.map.Relationship;
 
+/**
+ * A Figure representing a CollectionEditPart in the editor. Contains two compartments,
+ * for relationships and attributes, and a name to describe the object.
+ * 
+ * @author Marcel Gordon
+ */
 public class CollectionFigure extends Figure {
 	
-	public static Color classColor = new Color(null,255,255,100);
+	/** sub-figure for displaying the object's attributes */ 
 	private CompartmentFigure attributeFigure = new CompartmentFigure();
+	/** sub-figure for displaying the object's relationships */
 	private CompartmentFigure relationshipFigure = new CompartmentFigure();
+	/** name of the object, or MSG_NULL_RESULT if none can be obtained */
+	private Label name;
+	/** name to be used where no name can be located */
+	public static final String MSG_NULL_RESULT = "NULL";
 	
 	public CollectionFigure(CollectionModelElement model) {
 		ToolbarLayout layout = new ToolbarLayout();
 		setLayoutManager(layout);	
 		setBorder(new LineBorder(ColorConstants.black,1));
-		setBackgroundColor(classColor);
+		
+		// root figure should be a different colour
+		if (model.getCreatedFrom() == null) {
+			setBackgroundColor(ColorConstants.lightBlue);
+		}
+		else {
+			setBackgroundColor(ColorConstants.yellow);
+		}
 		setOpaque(true);
 		
-		add(new Label(model.getName()));
+		String objectName = model.getName();
+		if (objectName == null) {
+			name = new Label(MSG_NULL_RESULT);
+		}
+		else {
+			name = new Label(objectName);
+		}
+		add(name);
+		
 		add(attributeFigure);
-		setAttributes(model.getCurrent());
 		add(relationshipFigure);
-		setRelationships(model.getCurrent());
+		
+		setContents(model.getCurrent());
 	}
 	
+	/**
+	 * Set or change the data which is being displayed in this figure's
+	 * relationship and attribute sub-figures
+	 */
+	private void setContents(AbstractObject model) {
+		setAttributes(model);
+		setRelationships(model);
+	}
+	
+	/**
+	 * @return the sub-figure which contains the displayed object's relationships
+	 */
 	public CompartmentFigure getRelationshipCompartment() {
 		return relationshipFigure;
 	}
 	
+	/**
+	 * @return the sub-figure which contains the displayed object's attributes
+	 */
 	public CompartmentFigure getAttributeCompartment() {
 		return attributeFigure;
 	}
 
-	public void setAttributes(AbstractObject model) {
+	protected void setAttributes(AbstractObject model) {
 		getAttributeCompartment().removeAll();
 		
-		Iterator i = model.getAttributes().iterator();
-		while (i.hasNext()) {
-			Attribute a = (Attribute) i.next();
-			Label l = new Label(a.getName() + " : " + model.getPropertyValue(a.getName()));
-			getAttributeCompartment().add(l);
+		if (model != null) {
+			Iterator i = model.getAttributes().iterator();
+			while (i.hasNext()) {
+				Attribute a = (Attribute) i.next();
+				Label l = new Label(a.getName() + " : " + model.getPropertyValue(a.getName()));
+				getAttributeCompartment().add(l);
+			}
 		}
 	}
 
-	public void setRelationships(AbstractObject model) {
+	protected void setRelationships(AbstractObject model) {
 		getRelationshipCompartment().removeAll();
 		
-		Iterator i = model.getRelationships().iterator();
-		while (i.hasNext()) {
-			Relationship r = (Relationship) i.next();
-			String toManyString = (r.isToMany() ? "1-n" : "1-1");
-			Label l = new Label(r.getName() + " -> " + r.getTargetEntityName() + " (" + toManyString + ")");
-			getRelationshipCompartment().add(l);
-		}		
+		if (model != null) {
+			Iterator i = model.getRelationships().iterator();
+			while (i.hasNext()) {
+				Relationship r = (Relationship) i.next();
+				Label l = new RelationshipLabel(r);
+				getRelationshipCompartment().add(l);
+			}
+		}
+	}
+
+	/**
+	 * Refresh the entire figure - name and contents
+	 */
+	public void refresh(AbstractObject current) {
+		if (current != null) {
+			name.setText(current.getName());
+		}
+		else {
+			name.setText(MSG_NULL_RESULT);
+		}
+		setContents(current);
 	}
 }

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CompartmentFigure.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CompartmentFigure.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CompartmentFigure.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/CompartmentFigure.java Tue Jul 11 19:53:14 2006
@@ -1,8 +1,18 @@
 /*
- * Created on 14/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser.figures;
 
@@ -13,6 +23,11 @@
 import org.eclipse.draw2d.ToolbarLayout;
 import org.eclipse.draw2d.geometry.Insets;
 
+/**
+ * A sub-figure for use in other figures as a container.
+ *  
+ * @author Marcel Gordon
+ */
 public class CompartmentFigure extends Figure {
 	
 	public CompartmentFigure() {

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipLabel.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipLabel.java?rev=421091&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipLabel.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/figures/RelationshipLabel.java Tue Jul 11 19:53:14 2006
@@ -0,0 +1,43 @@
+/*
+ *  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.figures;
+
+import org.eclipse.draw2d.Label;
+import org.objectstyle.cayenne.map.Relationship;
+
+// TODO could be a figure for a sub-edit part similar to a table column
+
+/**
+ * A Label which stores and displays information on a relationship
+ * between objects.
+ * 
+ * @author Marcel Gordon
+ */
+public class RelationshipLabel extends Label {
+	
+	private Relationship relationship;
+	
+	public RelationshipLabel(Relationship relationship) {
+		this.relationship = relationship;
+		String toManyString = (relationship.isToMany() ? "1-n" : "1-1");
+		setText(relationship.getName() + " -> " + relationship.getTargetEntityName() + " (" + toManyString + ")");
+	}
+	
+	public Relationship getRelationship() {
+		return relationship;
+	}
+}

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,8 +1,18 @@
 /*
- * Created on 16/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser.model;
 
@@ -10,21 +20,21 @@
 import java.beans.PropertyChangeSupport;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-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.IPropertySource;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 import org.objectstyle.cayenne.PersistentObject;
 import org.objectstyle.cayenne.map.EntityResolver;
 import org.objectstyle.cayenne.map.ObjAttribute;
-import org.objectstyle.cayenne.map.ObjEntity;
 import org.objectstyle.cayenne.map.Relationship;
 import org.objectstyle.cayenne.property.ClassDescriptor;
 
+/**
+ * Base class for all persistent objects, allowing generic access
+ * to properties and relationships and handling property change
+ * notification.
+ * 
+ * @author Marcel Gordon
+ */
 public class AbstractObject extends PersistentObject {
 
 	protected static SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
@@ -35,19 +45,28 @@
 		return this.getClass().getSimpleName();
 	}
 	
+	/**
+	 * @return a collection of {@link Relationship} objects.
+	 */
 	public Collection getRelationships() {
 		return objectContext.getEntityResolver().getObjEntity(getName()).getRelationships();
 	}
 
+	/**
+	 * @return a collection of {@link org.objectstyle.cayenne.map.Attribute} objects.
+	 */
 	public Collection getAttributes() {
 		return objectContext.getEntityResolver().getObjEntity(getName()).getAttributes();
 	}
 	
+	/**
+	 * Accesses the given relationship for this object, returning the result.
+	 * @param rel the relationship to follow
+	 * @return a List of PersistentObjects for a to-many relationship;
+	 * a PersistentObject or null for a to-one relationship.
+	 */
 	public Object followRelationship(Relationship rel) {
 		
-		// TODO when creating a new object, need to deal with foreign keys - allow
-		// the new object to be linked to another object
-		
 		EntityResolver resolver = objectContext.getEntityResolver();
 		ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
 		
@@ -56,6 +75,11 @@
 		return value;
 	}
 
+	/**
+	 * Accesses a property of the object.
+	 * @param id the name of the property
+	 * @return the value of the property
+	 */
 	public Object getPropertyValue(Object id) {
 		if(objectContext != null) {
             objectContext.prepareForAccess(this, id.toString());
@@ -82,13 +106,27 @@
 		return value;
 	}
 
+	/**
+	 * Determines if a given property is set for this object.
+	 * @param id the name of the property
+	 * @return true if the property is set; false otherwise.
+	 */
 	public boolean isPropertySet(Object id) {
 		return getPropertyValue(id) != null;
 	}
 
+	/**
+	 * Resets the value of the given property. Does nothing.
+	 * @param id the name of the property
+	 */
 	public void resetPropertyValue(Object id) {
 	}
 
+	/**
+	 * Sets the value of a property of the object
+	 * @param id the name of the property
+	 * @param value the value to set the property to
+	 */
 	public void setPropertyValue(Object id, Object value) {
 		
 		if(objectContext != null) {

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Artist.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Artist.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Artist.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Artist.java Tue Jul 11 19:53:14 2006
@@ -1,109 +1,25 @@
+/*
+ *  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.model;
 
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.cayenne.ropbrowser.model.auto._Artist;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.apache.cayenne.ropbrowser.model.auto._Artist;
 
 /**
  * A persistent class mapped as "Artist" Cayenne entity.
  */
-public class Artist extends _Artist {
-	
-	/** 
-	 * A static array of property descriptors.
-	 * There is one IPropertyDescriptor entry per editable property.
-	 * @see #getPropertyDescriptors()
-	 * @see #getPropertyValue(Object)
-	 * @see #setPropertyValue(Object, Object)
-	 */
-	/*
-	private static IPropertyDescriptor[] descriptors;
-	
-	protected static final DateFormat dateFormatter;
-	
-	static {
-		descriptors = new IPropertyDescriptor[] { 
-				new TextPropertyDescriptor(_Artist.ARTIST_NAME_PROPERTY, "Name"), // id and description pair
-				new TextPropertyDescriptor(_Artist.DATE_OF_BIRTH_PROPERTY, "DOB")
-		};
-		
-		dateFormatter = new SimpleDateFormat("dd/MM/yy");
-	}
-	
-	public Object getPropertyValue(Object id) {
-
-		// treat it as a String - if not a String, no property anyway
-		String propertyName = id.toString();
-		
-		if (propertyName.equals(_Artist.ARTIST_NAME_PROPERTY)) {
-			return getArtistName();
-		}
-		else if (propertyName.equals(_Artist.DATE_OF_BIRTH_PROPERTY)) {
-			return dateFormatter.format(getDateOfBirth());
-		}
-		
-		return null;
-	}
-	
-	public void resetPropertyValue(Object id) {
-		// treat it as a String - if not a String, no property anyway
-		String propertyName = id.toString();
-		
-		if (propertyName.equals(_Artist.ARTIST_NAME_PROPERTY)) {
-			setArtistName("");
-		}
-		else if (propertyName.equals(_Artist.DATE_OF_BIRTH_PROPERTY)) {
-			setDateOfBirth(null);
-		}
-	}
-	
-	public void setPropertyValue(Object id, Object value) {
-		// treat it as a String - if not a String, no property anyway
-		String propertyName = id.toString();
-		
-		if (propertyName.equals(_Artist.ARTIST_NAME_PROPERTY)) {
-			setArtistName(value.toString());
-		}
-		else if (propertyName.equals(_Artist.DATE_OF_BIRTH_PROPERTY)) {
-			try {
-				setDateOfBirth(dateFormatter.parse(value.toString()));
-			}
-			catch (Exception e) {
-				// TODO logging
-				System.out.println(e.getMessage());
-			}
-		}
-	}
-	
-	public boolean isPropertySet(Object id) {
-		// treat it as a String - if not a String, no property anyway
-		String propertyName = id.toString();
-		
-		if (propertyName.equals(_Artist.ARTIST_NAME_PROPERTY)) {
-			return this.getArtistName() != null;
-		}
-		else if (propertyName.equals(_Artist.DATE_OF_BIRTH_PROPERTY)) {
-			return this.getDateOfBirth() != null;
-		}
-		
-		return false;
-	}
-	
-	/**
-	 * Returns an array of IPropertyDescriptors for this shape.
-	 * <p>The returned array is used to fill the property view, when the edit-part corresponding
-	 * to this model element is selected.</p>
-	 * @see #descriptors
-	 * @see #getPropertyValue(Object)
-	 * @see #setPropertyValue(Object, Object)
-	 */
-	/*
-	public IPropertyDescriptor[] getPropertyDescriptors() {
-		return descriptors;
-	}
-	*/
+public class Artist extends _Artist {
 }

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,17 +1,28 @@
 /*
- * Created on 7/06/2006
+ *  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.
  *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 package org.apache.cayenne.ropbrowser.model;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.util.Arrays;
+import java.util.ArrayList;
 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;
@@ -20,22 +31,48 @@
 import org.objectstyle.cayenne.map.ObjEntity;
 
 /**
- * Class representing a collection of ObjectModelElements.
+ * Class representing a collection of AbstractObjects.
  * Used to display a number of records as one element on the
  * canvas with the ability to scroll through them.
  * 
- * @author marcel
+ * @author Marcel Gordon
  *
  */
-public class CollectionModelElement extends ModelElement implements IObject, PropertyChangeListener {
-
-	public static final String PROP_RECORDS = "Collection.TotalRecords";
+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;
+	
+	/**
+	 * List of AbstractObjects displayed by this element.
+	 */
 	protected List<AbstractObject> objects;
+	/**
+	 * The AbstractObject currently being displayed.
+	 */
 	protected AbstractObject current;
+	/**
+	 * The index of the AbstractObject currently being displayed.
+	 */
 	protected int currentRecord;
-	protected AbstractObject createdFrom;
+	/**
+	 * The ModelElement which initiated the creation of this element. Used to
+	 * prevent duplication of elements.
+	 */
+	protected ModelElement createdFrom;
+	/**
+	 * Property for the currently displayed AbstractObject.
+	 */
 	public static String PROP_CURRENT_RECORD = "Collection.RecordNo";
+	/**
+	 * Property for the total number of records stored.
+	 */
 	public static String PROP_TOTAL_RECORDS = "Collection.TotalRecords";
 	
 	protected IPropertyDescriptor[] properties = null;
@@ -47,19 +84,60 @@
 		};
 	}
 	
-	public CollectionModelElement(AbstractObject createdFrom) {
+	/**
+	 * @param createdFrom the ModelElement which initiated this element's creation.
+	 */
+	public CollectionModelElement(ModelElement createdFrom) {
 		this.createdFrom = createdFrom;
 	}
 	
+	/**
+	 * Gets the name of the CollectionModelElement.
+	 * 
+	 * @return the name as a String, or null if it cannot be determined.
+	 */
 	public String getName() {
-		return current.getName();
+		if (current != null) {
+			return current.getName();
+		}
+		List targets = getTargetConnections();
+		if (!targets.isEmpty()) {
+			Connection conn = (Connection) targets.get(0);
+			return conn.getRelationship().getTargetEntityName();
+		}
+		return null;
 	}
 	
-	public void setObjects(List<AbstractObject> list) {
+	/**
+	 * Set the records to be displayed. Adds itself as a listener
+	 * to all the AbstractObjects in the list in order to fire its
+	 * 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 setObjects(Object value) {
+		
 		List oldObjects = this.objects;
-		this.objects = list;
 		this.currentRecord = 0;
-		this.current = list.get(currentRecord);
+		
+		if (value instanceof List) {
+			this.objects = (List) value;
+			if (this.objects.isEmpty()) {
+				this.current = null;
+			}
+			else {
+				this.current = this.objects.get(currentRecord);
+			}
+		}
+		else {
+			this.objects = new ArrayList<AbstractObject>();
+			if (value != null) {
+				objects.add((AbstractObject) value);
+				this.current = this.objects.get(currentRecord);
+			}
+			else {
+				this.current = null;
+			}
+		}
 		
 		for (AbstractObject object : objects) {
 			object.addPropertyChangeListener(this);
@@ -68,14 +146,22 @@
 		firePropertyChange(PROP_RECORDS, oldObjects, objects);
 	}
 	
-	@Override
+	/**
+	 * Get the IPropertyDescriptors for use in the Eclipse Properties view.
+	 * Creates the property descriptor array once on demand.
+	 * @return property descriptors for the current AbstractObject and the
+	 * CollectionModelElement, or just the latter if the former is null.
+	 */
 	public IPropertyDescriptor[] getPropertyDescriptors() {
+		if (current == null) {
+			return CollectionModelElement.descriptors;
+		}
 		if (properties == null) {
-			EntityResolver entityResolver = getCurrent().getObjectContext().getEntityResolver();
+			int i = 0;
+			EntityResolver entityResolver = current.getObjectContext().getEntityResolver();
 			ObjEntity entity = entityResolver.getObjEntity(getName());
 			Iterator attributes = entity.getAttributes().iterator();
 			properties = new IPropertyDescriptor[entity.getAttributes().size() + CollectionModelElement.descriptors.length];
-			int i = 0;
 			while (attributes.hasNext()) {
 				ObjAttribute attribute = (ObjAttribute) attributes.next();
 				properties[i++] = new TextPropertyDescriptor(attribute.getName(), attribute.getName());
@@ -84,12 +170,18 @@
 				properties[i] = CollectionModelElement.descriptors[j];
 			}
 		}
-		
-		return properties; 
+		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() {
-		return current.getRelationships();
+		if (current != null) {
+			return current.getRelationships();
+		}
+		return null;
 	}
 
 	@Override
@@ -97,10 +189,13 @@
 		if (id.toString().equals(PROP_CURRENT_RECORD)) {
 			return Integer.toString(currentRecord);
 		}
-		else if (id.toString().equals(PROP_TOTAL_RECORDS)) {
+		if (id.toString().equals(PROP_TOTAL_RECORDS)) {
 			return Integer.toString(objects.size());
 		}
-		return current.getPropertyValue(id);
+		if (current != null) {
+			return current.getPropertyValue(id);
+		}
+		return null;
 	}
 
 	@Override
@@ -108,10 +203,13 @@
 		if (id.toString().equals(PROP_CURRENT_RECORD)) {
 			return true;
 		}
-		else if (id.toString().equals(PROP_TOTAL_RECORDS)) {
+		if (id.toString().equals(PROP_TOTAL_RECORDS)) {
 			return true;
 		}
-		return current.isPropertySet(id);
+		if (current != null) { 
+			return current.isPropertySet(id);
+		}
+		return false;
 	}
 
 	@Override
@@ -120,7 +218,7 @@
 			currentRecord = 0;
 			this.current = this.objects.get(currentRecord);
 		}
-		else {
+		else if (current != null) {
 			current.resetPropertyValue(id);
 		}
 	}
@@ -133,11 +231,15 @@
 			this.current = this.objects.get(currentRecord);
 			firePropertyChange(id.toString(), new Integer(oldCurrent), new Integer(currentRecord));
 		}
-		else {
+		else if (current != null) {
 			current.setPropertyValue(id, value);
 		}
 	}
 	
+	/**
+	 * Scrolls through the AbstractObject list, cycling back to the start once the
+	 * end is reached.
+	 */
 	public void next() {
 		int oldCurrent = currentRecord;
 		
@@ -151,14 +253,28 @@
 		firePropertyChange(PROP_CURRENT_RECORD, new Integer(oldCurrent), new Integer(currentRecord));
 	}
 
+	/**
+	 * @return the AbstractObject currently being displayed.
+	 */
 	public AbstractObject getCurrent() {
 		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() {
-		return current.getObjectContext().getEntityResolver().getObjEntity(current.getName()).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;
 		
@@ -172,6 +288,10 @@
 		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())
@@ -182,37 +302,43 @@
 		return false;
 	}
 
-	public AbstractObject getCreatedFrom() {
+	/**
+	 * @return the ModelElement which initiated the creation of this element.
+	 */
+	public ModelElement getCreatedFrom() {
 		return createdFrom;
 	}
 
-	public List<AbstractObject> getObjects() {
+	/**
+	 * @return the list of AbstractObjects being displayed.
+	 */
+	List<AbstractObject> getObjects() {
 		return this.objects;
 	}
 
-	public void updateConnections() {
+	public void updateConnectedElements() {
 		for (Object o : getSourceConnections()) {
 			Connection conn = (Connection) o;
 			ModelElement element = conn.getTarget();
 			if (element instanceof CollectionModelElement) {
+				
 				CollectionModelElement collection = (CollectionModelElement) element;
-				Object object = getCurrent().followRelationship(conn.getRelationship());
-				if (object == null) {
-					// replace this node and everything coming from it with NullModelElements
-				}
-				else {
-					if (conn.getRelationship().isToMany()) {
-						collection.setObjects((List) object);
-					}
-					else {
-						collection.setObjects(Arrays.asList(new AbstractObject[] {(AbstractObject) object}));
-					}
+				
+				Object object = null;
+				if (current != null) {
+					object = current.followRelationship(conn.getRelationship());
 				}
+				
+				collection.setObjects(object);
 			}
-			element.updateConnections();
+			element.updateConnectedElements();
 		}
 	}
 
+	/**
+	 * Listens for property changes in the underlying AbstractObjects
+	 * and fires property change notifications of its own.
+	 */
 	public void propertyChange(PropertyChangeEvent evt) {
 		firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
 	}

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=421091&r1=421090&r2=421091&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 Tue Jul 11 19:53:14 2006
@@ -1,24 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 Elias Volanakis 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:
- *    Elias Volanakis - initial API and implementation
- *******************************************************************************/
+/*
+ *  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.model;
 
-import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-import org.eclipse.draw2d.Graphics;
 import org.objectstyle.cayenne.map.Relationship;
 
 /**
- * A connection between two distinct shapes.
- * @author Elias Volanakis
+ * A connection between two {@link ModelElement} objects.
+ * 
+ * @author Marcel Gordon
  */
 public class Connection {
 	
@@ -26,15 +29,14 @@
 	private ModelElement source;
 	/** Connection's target endpoint. */
 	private ModelElement target;
-	
+	/** The relationship that this connection represents */
 	private Relationship relationship;
 
 	/** 
-	 * Create a (solid) connection between two distinct shapes.
+	 * Create a (solid) connection between two elements.
 	 * @param source a source endpoint for this connection (non null)
 	 * @param target a target endpoint for this connection (non null)
-	 * @throws IllegalArgumentException if any of the parameters are null or source == target
-	 * @see #setLineStyle(int) 
+	 * @throws IllegalArgumentException if any of the parameters are null or source == target 
 	 */
 	public Connection(ModelElement source, ModelElement target, Relationship relationship) {
 		this.source = source;
@@ -53,7 +55,7 @@
 	
 	/**
 	 * Returns the source endpoint of this connection.
-	 * @return a non-null Shape instance
+	 * @return a non-null element
 	 */
 	public ModelElement getSource() {
 		return source;
@@ -61,7 +63,7 @@
 	
 	/**
 	 * Returns the target endpoint of this connection.
-	 * @return a non-null Shape instance
+	 * @return a non-null element
 	 */
 	public ModelElement getTarget() {
 		return target;
@@ -75,7 +77,18 @@
 		target.addConnection(this);
 	}
 
+	/**
+	 * @return the relationship this connection represents
+	 */
 	public Relationship getRelationship() {
 		return relationship;
+	}
+
+	/**
+	 * Removes the connection from its source and target elements.
+	 */
+	public void disconnect() {
+		source.removeConnection(this);
+		target.removeConnection(this);
 	}
 }

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java?rev=421091&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java Tue Jul 11 19:53:14 2006
@@ -0,0 +1,138 @@
+/*
+ *  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.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.objectstyle.cayenne.ObjectContext;
+import org.objectstyle.cayenne.query.NamedQuery;
+
+/**
+ * The root component in the model - a diagram of ModelElements 
+ * representing objects.
+ * 
+ * @author Marcel Gordon
+ */
+public class ElementDiagram {
+	
+	/** property indicating a node (element) has been added */
+	public static final String PROP_NODE_ADDED = "ObjectDiagram.NodeAdded";
+	/** property indicating that a node (element) has been removed */
+	public static final String PROP_NODE_REMOVED = "ObjectDiagram.NodeRemoved";
+	/** the ModelElements contained in the diagram */
+	protected List<ModelElement> objects = new ArrayList<ModelElement>();
+	/** the Cayenne context in which the objects represented by the ModelElements exist */
+	protected ObjectContext context;
+	
+	/** Delegate used to implemenent property-change-support. */
+	private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport(this);
+	
+	/**
+	 * @param context the Cayenne context in which the objects in the diagram are found
+	 * @param query the name of the query contained in the Cayenne data map from which
+	 * this diagram is initialised
+	 */
+	public ElementDiagram(ObjectContext context, String query) {
+		this.context = context;
+		
+		NamedQuery select = new NamedQuery(query);
+		List matches = this.context.performQuery(select);
+		CollectionModelElement coll = new CollectionModelElement(null);
+		coll.setObjects(matches);
+		addElement(coll);
+	}
+
+	/**
+	 * Add a ModelElement to the diagram
+	 * @param element the element to add
+	 * @return true if the element was added; false otherwise
+	 */
+	public boolean addElement(ModelElement element) {
+		if (element != null) {
+			if (!objects.contains(element)) {
+				objects.add(element);
+				firePropertyChange(PROP_NODE_ADDED, null, element);
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	/**
+	 * Remove an element from the diagram
+	 * @param element the element to remove
+	 * @return true if removed; false otherwise
+	 */
+	public boolean removeChild(ModelElement element) {
+		if (element != null) {
+			Iterator i = element.getSourceConnections().iterator();
+			while (i.hasNext()) {
+				Connection conn  = (Connection) i.next();
+				removeChild(conn.getTarget());
+			}
+			objects.remove(element);
+			firePropertyChange(PROP_NODE_REMOVED, null, element);
+			return true;
+		}
+		return false;
+	}
+	
+	/** Return a List of Objects in this diagram.  The returned List should not be modified. */
+	public List getObjects() {
+		return objects;
+	}
+	
+	/** 
+	 * Remove a PropertyChangeListener from this component.
+	 * @param l a PropertyChangeListener instance
+	 */
+	public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
+		if (l != null) {
+			pcsDelegate.removePropertyChangeListener(l);
+		}
+	}
+	
+	/** 
+	 * Attach a non-null PropertyChangeListener to this object.
+	 * @param l a non-null PropertyChangeListener instance
+	 * @throws IllegalArgumentException if the parameter is null
+	 */
+	public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
+		if (l == null) {
+			throw new IllegalArgumentException();
+		}
+		pcsDelegate.addPropertyChangeListener(l);
+	}
+	
+	/** 
+	 * Report a property change to registered listeners (for example edit parts).
+	 * @param property the programmatic name of the property that changed
+	 * @param oldValue the old value of this property
+	 * @param newValue the new value of this property
+	 */
+	protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+		if (pcsDelegate.hasListeners(property)) {
+			pcsDelegate.firePropertyChange(property, oldValue, newValue);
+		}
+	}
+}

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Gallery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Gallery.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Gallery.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/Gallery.java Tue Jul 11 19:53:14 2006
@@ -1,6 +1,22 @@
+/*
+ *  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.model;
 
-import org.apache.cayenne.ropbrowser.model.auto._Gallery;
+import org.apache.cayenne.ropbrowser.model.auto._Gallery;
 
 /**
  * A persistent class mapped as "Gallery" Cayenne entity.

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElement.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElement.java?rev=421091&r1=421090&r2=421091&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElement.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ModelElement.java Tue Jul 11 19:53:14 2006
@@ -1,13 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 Elias Volanakis 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:
- *    Elias Volanakis - initial API and implementation
- *******************************************************************************/
+/*
+ *  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.model;
 
 import java.beans.PropertyChangeListener;
@@ -17,22 +23,23 @@
 
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource;
-import org.objectstyle.cayenne.PersistentObject;
 
 /**
- * Adapted from org.eclipse.gef.examples.shapes
- * Abstract prototype of a model element.
- * <p>This class provides features necessary for all model elements, like:</p>
- * <ul>
- * <li>property-change support (used to notify edit parts of model changes),</li> 
- * <li>property-source support (used to display property values in the Property View) and</li>
- * </ul>
+ * Abstract prototype of a model element. Handles display information
+ * such as dimensions, location and connections. Also handles property
+ * change notification for descendents.
+ * 
+ * @author Marcel Gordon
  */
 public abstract class ModelElement implements IPropertySource {
 	
+	/** Property indicating a transient visual property has changed */
 	public static final String PROP_TRANSIENT = "ModelElement.transient";
+	/** Property indicating that a source connection has been added or removed */
 	public static final String PROP_SOURCE_CONN = "ModelElement.sourceConnection";
+	/** Property indicating that a target connection has been added or removed */
 	public static final String PROP_TARGET_CONN = "ModelElement.targetConnection";
+	
 	protected int x = 0;
 	protected int y = 0;
 	protected int height;
@@ -44,14 +51,26 @@
 	/** Delegate used to implemenent property-change-support. */
 	private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport(this);
 	
+	/** 
+	 * @return copy of the List of Connections originating at the ModelElement.
+	 */
 	public List getSourceConnections() {
 		return new ArrayList<Connection>(sourceConnections);
 	}
 
+	/** 
+	 * @return copy of the List of Connections terminating at the ModelElement.
+	 */
 	public List getTargetConnections() {
 		return new ArrayList<Connection>(targetConnections);
 	}
 	
+	/**
+	 * Add a connection to the ModelElement. The connection will
+	 * be added to the source or target list depending upon its
+	 * role in the connection supplied.
+	 * @throws IllegalArgumentException if connection is null or source == target
+	 */
 	public void addConnection(Connection conn) {
 		if (conn == null || conn.getSource() == conn.getTarget()) {
 			throw new IllegalArgumentException();
@@ -111,25 +130,29 @@
 	
 	/**
 	 * Returns a value for this property source that can be edited in a property sheet.
-	 * <p>My personal rule of thumb:</p>
-	 * <ul>
-	 * <li>model elements should return themselves and</li> 
-	 * <li>custom IPropertySource implementations (like DimensionPropertySource in the GEF-logic
-	 * example) should return an editable value.</li>
-	 * </ul>
-	 * <p>Override only if necessary.</p>
 	 * @return this instance
 	 */
 	public Object getEditableValue() {
 		return this;
 	}
 	
+	/**
+	 * Property descriptors for editing via the Eclipse Properties view.
+	 * <p>Default implementation returns an array of size 0. Extending classes
+	 * should override to allow properties to be edited.
+	 */
 	public IPropertyDescriptor[] getPropertyDescriptors() {
 		return new IPropertyDescriptor[0];
 	}
 	
+	/**
+	 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) 
+	 */
 	public abstract Object getPropertyValue(Object id);
 	
+	/**
+	 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object) 
+	 */
 	public abstract boolean isPropertySet(Object id);
 	
 	/** 
@@ -142,8 +165,14 @@
 		}
 	}
 	
+	/**
+	 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
+	 */
 	public abstract void resetPropertyValue(Object id);
 	
+	/**
+	 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+	 */
 	public abstract void setPropertyValue(Object id, Object value);
 
 	public void setSize(int width, int height) {
@@ -158,5 +187,26 @@
 		firePropertyChange(PROP_TRANSIENT, null, null);
 	}
 	
-	public abstract void updateConnections();
+	/**
+	 * Update elements which are targets of connections from this ModelElement after a data change.
+	 */
+	public abstract void updateConnectedElements();
+
+	/**
+	 * Remove a connection from the ModelElement. The connection
+	 * will be removed from the source or target list depending
+	 * upon its role in the connection.
+	 */
+	public void removeConnection(Connection conn) {
+		if (conn == null) {
+			throw new IllegalArgumentException();
+		}
+		if (conn.getSource() == this) {
+			sourceConnections.remove(conn);
+			firePropertyChange(PROP_SOURCE_CONN, null, conn);
+		} else if (conn.getTarget() == this) {
+			targetConnections.remove(conn);
+			firePropertyChange(PROP_TARGET_CONN, null, conn);
+		}
+	}
 }



Mime
View raw message