cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r429528 - in /incubator/cayenne/soc/trunk/cayenne-rop/rop-browser: ./ src/org/apache/cayenne/ropbrowser/ src/org/apache/cayenne/ropbrowser/actions/ src/org/apache/cayenne/ropbrowser/commands/ src/org/apache/cayenne/ropbrowser/figures/ src/o...
Date Tue, 08 Aug 2006 00:43:44 GMT
Author: aadamchik
Date: Mon Aug  7 17:43:43 2006
New Revision: 429528

URL: http://svn.apache.org/viewvc?rev=429528&view=rev
Log:
CAY-622 - client patch

Added:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/TypeConverter.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ROPActionBarContributor.java
Modified:
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/plugin.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/actions/DeleteAction.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/SetNameAction.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/PopOutCommand.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/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/ElementDiagram.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/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/ElementEditPolicy.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java
    incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/wizards/SelectParametersPage.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=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/.classpath Mon Aug  7 17:43:43 2006
@@ -6,9 +6,9 @@
 	<classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
 	<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/smackx-2.2.1.jar"/>
 	<classpathentry sourcepath="G:/soc/smack-dev-2.2.1/source" kind="lib" path="lib/smack-2.2.1.jar"/>
 	<classpathentry sourcepath="/cayenne-java/src/cayenne/java" kind="lib" path="lib/cayenne-client-nodeps-1.2.jar"/>
+	<classpathentry kind="lib" path="lib/hessian-3.0.13.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/plugin.xml?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/plugin.xml (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/plugin.xml Mon Aug  7 17:43:43 2006
@@ -17,6 +17,7 @@
          point="org.eclipse.ui.editors">
       <editor
             class="org.apache.cayenne.ropbrowser.ObjectEditor"
+            contributorClass="org.apache.cayenne.ropbrowser.actions.ROPActionBarContributor"
             default="false"
             icon="icons/sample.gif"
             id="org.apache.cayenne.ropbrowser.ObjectEditor"

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -59,37 +59,33 @@
 	
 	/**
 	 * 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)
+	 * @param address full address of the Cayenne web service (eg http://localhost:8080/rop-browser)
+	 * @param sharedSession 
 	 * @return ObjectContext connected to the given address
 	 */
-	public ObjectContext getNewObjectContext(String address) {
+	public ObjectContext getNewObjectContext(String address, boolean sharedSession) {
 		
 		DataChannel channel = null;
 		
-		if (connections.containsKey(address)) {
+		if (sharedSession && connections.containsKey(address)) {
 			channel = connections.get(address);
 		}
 		else {
-			HessianConnection connection = new HessianConnection(address, null, null, "conference");
-			channel = new ClientChannel(connection);
-			connections.put(address, channel);
+			if (sharedSession) {
+				HessianConnection connection = new HessianConnection(address, null, null, "conference");
+				channel = new ClientChannel(connection);
+				connections.put(address, channel);
+			}
+			else {
+				HessianConnection connection = new HessianConnection(address);
+				channel = new ClientChannel(connection);
+			}
 		}
 		
 		if (channel != null) {
-			// TODO XMPP notification of graph changes; DataChannel.* ?
-			channel.getEventManager().addListener(this, "handleXMPP", GraphEvent.class, DataChannel.GRAPH_CHANGED_SUBJECT);
-			channel.getEventManager().addListener(this, "handleXMPP", GraphEvent.class, DataChannel.GRAPH_FLUSHED_SUBJECT);
-					
 			ObjectContext context = new CayenneContext(channel, true, false);
 			return context;
 		}
 		return null;
-	}
-	
-	/**
-	 * Deal with XMPP events
-	 */
-	public void handleXMPP(GraphEvent event) {
-		System.out.println("XMPP : " + event.toString());
 	}
 }

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -38,6 +38,9 @@
 import org.eclipse.jface.action.IAction;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
+import org.objectstyle.cayenne.DataChannel;
+import org.objectstyle.cayenne.ObjectContext;
+import org.objectstyle.cayenne.graph.GraphEvent;
 
 /**
  * Editor class allowing visual editing of database data via
@@ -48,8 +51,6 @@
  * @author Marcel Gordon
  */
 public class ObjectEditor extends GraphicalEditor {
-
-	// TODO move to Derby 
 	
 	/** ID of the Editor */
 	public static final String ID = "org.apache.cayenne.ropbrowser.ObjectEditor";
@@ -141,7 +142,8 @@
 	protected void setInput(IEditorInput input) {
 		super.setInput(input);
 		// create the diagram using the context from the input
-		elementDiagram = new ElementDiagram(((ObjectEditorInput) input).getContext());
+		ObjectContext inputContext = ((ObjectEditorInput) input).getContext();
+		elementDiagram = new ElementDiagram(inputContext);
 	}
 	
 	/**
@@ -150,8 +152,6 @@
 	@Override
 	protected void createActions() {
 		super.createActions();
-		
-		// TODO enable menu and Ctrl + Z/Y undo/redo
 		
 		IAction action = new HideAction(this);
 		getActionRegistry().registerAction(action);

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/TypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/TypeConverter.java?rev=429528&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/TypeConverter.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/TypeConverter.java Mon Aug  7 17:43:43 2006
@@ -0,0 +1,84 @@
+/*
+ *  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 java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Class for the conversion of values to and from Strings.
+ * 
+ * @author Marcel Gordon
+ */
+public class TypeConverter {
+	/**
+	 * Formatter for displaying {@link Date} objects as {@link String}s.
+	 */
+	protected static final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
+	
+	public static String getStringValue(Object value, String typeName) {
+		String stringValue = null;
+		if (typeName.equals("java.util.Date")) {
+			try {
+				stringValue = dateFormatter.format(value);
+			}
+			catch (Exception e) {
+				stringValue = new String("");
+			}
+		}
+		else {
+			if (value == null) {
+				stringValue = new String("");
+			}
+			else {
+				stringValue = value.toString(); 
+			}
+		}
+		
+		return stringValue;
+	}
+	
+	public static Object getValueFromString(Object value, String typeName) throws Exception {
+		if (!(value instanceof String)) {
+			return value;
+		}
+		
+		String stringValue = (String) value;
+		
+		//	convert from a String to the correct object type
+		Object newValue = null;
+		if (typeName.equals("java.util.Date")) {
+			newValue = dateFormatter.parse(stringValue);
+		}
+		else if (typeName.equals("java.sql.Date")) {
+			newValue = java.sql.Date.valueOf(stringValue); 
+		}
+		else if (typeName.equals("java.sql.Time")) {
+			newValue = java.sql.Time.valueOf(stringValue);
+		}
+		else if (typeName.equals("java.sql.Timestamp")) {
+			newValue = java.sql.Timestamp.valueOf(stringValue);
+		}
+		else {
+			// try to use a constructor from a String
+			Class newClass = Class.forName(typeName);
+			newValue = newClass.getConstructor(Class.forName("java.lang.String")).newInstance(stringValue);
+		}
+		
+		return newValue;
+	}
+}

Modified: 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=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/DeleteAction.java Mon Aug  7 17:43:43 2006
@@ -18,6 +18,8 @@
 import java.util.List;
 
 import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.apache.cayenne.ropbrowser.parts.CollectionEditPart;
+import org.apache.cayenne.ropbrowser.parts.ElementEditPart;
 import org.apache.cayenne.ropbrowser.parts.SingleEditPart;
 import org.eclipse.gef.EditPart;
 import org.eclipse.gef.Request;
@@ -58,7 +60,7 @@
 
 	/**
 	 * Test whether the action can be performed.
-	 * @return true if the selection includes only {@link SingleEditPart} objects
+	 * @return true if the selection includes only {@link ElementEditPart} objects
 	 * which are not storing null values.
 	 */
 	@Override
@@ -68,10 +70,10 @@
 		List parts = getSelectedObjects();
 		for (int i=0; i<parts.size(); i++){
 			Object o = parts.get(i);
-			if (!(o instanceof SingleEditPart)) {
+			if (!(o instanceof SingleEditPart || o instanceof CollectionEditPart)) {
 				return false;
 			}
-			if (((ModelElement) ((SingleEditPart) o).getModel()).isNull()) {
+			if (((ModelElement) ((ElementEditPart) o).getModel()).isNull()) {
 				return false;
 			}
 		}

Added: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ROPActionBarContributor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ROPActionBarContributor.java?rev=429528&view=auto
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ROPActionBarContributor.java (added)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/ROPActionBarContributor.java Mon Aug  7 17:43:43 2006
@@ -0,0 +1,39 @@
+/*
+ *  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.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.RetargetAction;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+
+public class ROPActionBarContributor extends ActionBarContributor {
+
+	@Override
+
+	protected void buildActions() {
+		IWorkbenchAction undo=ActionFactory.UNDO.create(getPage().getWorkbenchWindow());
+		addRetargetAction((RetargetAction) undo);
+	
+		IWorkbenchAction redo=ActionFactory.REDO.create(getPage().getWorkbenchWindow());
+		addRetargetAction((RetargetAction) redo);
+	}
+
+	@Override
+	protected void declareGlobalActionKeys() {
+	}
+
+}

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/SetNameAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/SetNameAction.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/SetNameAction.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/actions/SetNameAction.java Mon Aug  7 17:43:43 2006
@@ -48,7 +48,7 @@
 	public SetNameAction(IWorkbenchPart part) {
 		super(part);
 		setId(ID);
-		setText("Set Name");
+		setText("Set name");
 		request = new SetNameElementRequest();
 	}
 

Modified: 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=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/DeleteObjectCommand.java Mon Aug  7 17:43:43 2006
@@ -50,7 +50,7 @@
 	
 	@Override
 	public boolean canExecute() {
-		return element.isNull();
+		return !element.isNull();
 	}
 	
 	@Override

Modified: 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=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/commands/PopOutCommand.java Mon Aug  7 17:43:43 2006
@@ -61,14 +61,16 @@
 	
 	@Override
 	public void redo() {
-		newElement = new SingleModelElement(element.getName());
-		newElement.setObject(element.getCurrentObject());
+		if (newElement == null) {
+			newElement = new SingleModelElement(element.getName());
+			newElement.setObject(element.getCurrentObject());
+		}
 		element.getDiagram().addElement(newElement);
 	}
 	
 	@Override
 	public void undo() {
-		Command deleteCommand = new HideElementCommand(newElement);
-		deleteCommand.execute();
+		Command hideCommand = new HideElementCommand(newElement);
+		hideCommand.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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -25,6 +25,7 @@
 import org.eclipse.draw2d.ActionListener;
 import org.eclipse.draw2d.Button;
 import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.MarginBorder;
 import org.eclipse.draw2d.ToolbarLayout;
 import org.objectstyle.cayenne.map.Attribute;
@@ -38,8 +39,6 @@
  */
 public class CollectionFigure extends ElementFigure implements ActionListener {
 	
-	// TODO neaten up class separation
-	
 	/**
 	 * Figure to act as a dropdown box to allow quick navigation through objects.
 	 */
@@ -120,12 +119,19 @@
 			while (i.hasNext()) {
 				Attribute a = (Attribute) i.next();
 				Button b;
+				
+				String attributeValue = model.getPropertyValue(a.getName());
+				if (attributeValue.length() > MAX_ATTRIBUTE_LENGTH) {
+					attributeValue = attributeValue.substring(0, MAX_ATTRIBUTE_LENGTH - 3);
+					attributeValue += "...";
+				}
+				
 				// if expanded, use open icon, else closed
 				if (lastNavAttribute != null && a.getName().equals(lastNavAttribute)) {
-					b = new Button(a.getName() + " : " + model.getPropertyValue(a.getName()) + " ", ROPBrowserPlugin.getDefault().getImageRegistry().get(ROPBrowserPlugin.IMG_DROP_OPEN));
+					b = new Button(a.getName() + " : " + attributeValue + " ", ROPBrowserPlugin.getDefault().getImageRegistry().get(ROPBrowserPlugin.IMG_DROP_OPEN));
 				}
 				else {
-					b = new Button(a.getName() + " : " + model.getPropertyValue(a.getName()) + " ", ROPBrowserPlugin.getDefault().getImageRegistry().get(ROPBrowserPlugin.IMG_DROP_CLOSED));
+					b = new Button(a.getName() + " : " + attributeValue + " ", ROPBrowserPlugin.getDefault().getImageRegistry().get(ROPBrowserPlugin.IMG_DROP_CLOSED));
 				}
 				if (model.isDeleted()) {
 					b.setForegroundColor(ColorConstants.gray);
@@ -173,6 +179,8 @@
 
 class DropdownFigure extends CompartmentFigure {
 	
+	private static final String LABEL_NULL = "null";
+
 	public void populateDropdown(String attributeName, ActionListener actionListener, Iterator<AbstractObject> iterator) {
 		// remove any existing buttons from the navFigure
 		for (Object child : getChildren()) {
@@ -186,7 +194,19 @@
 		while (iterator.hasNext()) {
 			AbstractObject o = iterator.next();
 			// label the button with the attribute's value for this object
-			Button b = new Button(o.getPropertyValue(attributeName).toString());
+			String attributeValue = o.getPropertyValue(attributeName);
+			Button b;
+			if (attributeValue != null) {
+				if (attributeValue.length() > ElementFigure.MAX_ATTRIBUTE_LENGTH) {
+					attributeValue = attributeValue.substring(0, ElementFigure.MAX_ATTRIBUTE_LENGTH - 3);
+					attributeValue += "...";
+				}
+				b = new Button(attributeValue);
+			}
+			else {
+				b = new Button(LABEL_NULL);
+			}
+				
 			b.setBorder(new MarginBorder(0, 10, 0, 0));
 			b.setOpaque(false);
 			// set the user data to the object for use by the action listener

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -27,6 +27,7 @@
 import org.eclipse.draw2d.Label;
 import org.eclipse.draw2d.LineBorder;
 import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.swt.widgets.Display;
 import org.objectstyle.cayenne.map.Attribute;
 
 /**
@@ -42,7 +43,8 @@
 	/** name of the object */
 	protected Label name;
 	/** name to be used where no name can be located */
-	public static final String MSG_NULL_RESULT = "NULL"; 
+	public static final String MSG_NULL_RESULT = "NULL";
+	protected static final int MAX_ATTRIBUTE_LENGTH = 16; 
 	
 	/** the part which the figure represents */
 	protected ElementEditPart part;
@@ -58,7 +60,9 @@
 		
 		addComponents();
 		
-		refresh();
+		setBackgroundColour();
+		setName();
+		setAttributes(((ModelElement) part.getModel()).getCurrentObject());
 	}
 	
 	/**
@@ -85,14 +89,6 @@
 	protected abstract void setName();
 	
 	/**
-	 * Set or change the data which is being displayed in this figure's
-	 * relationship and attribute sub-figures
-	 */
-	protected void setContents() {
-		setAttributes(((ModelElement) part.getModel()).getCurrentObject());
-	}
-	
-	/**
 	 * @return the sub-figure which contains the displayed object's attributes
 	 */
 	public CompartmentFigure getAttributeCompartment() {
@@ -110,7 +106,12 @@
 			Iterator i = model.getAttributes().iterator();
 			while (i.hasNext()) {
 				Attribute a = (Attribute) i.next();
-				Label l = new Label(a.getName() + " : " + model.getPropertyValue(a.getName()));
+				String attributeValue = model.getPropertyValue(a.getName());
+				if (attributeValue.length() > MAX_ATTRIBUTE_LENGTH) {
+					attributeValue = attributeValue.substring(0, MAX_ATTRIBUTE_LENGTH - 3);
+					attributeValue += "...";
+				}
+				Label l = new Label(a.getName() + " : " + attributeValue);
 				if (model.isDeleted()) {
 					l.setForegroundColor(ColorConstants.gray);
 				}
@@ -120,11 +121,10 @@
 	}
 
 	/**
-	 * Refresh the entire figure - name and contents
+	 * Refresh the entire figure
 	 */
 	public void refresh() {
-		setBackgroundColour();
 		setName();
-		setContents();
+		setAttributes(((ModelElement) part.getModel()).getCurrentObject());
 	}
 }

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -22,6 +22,7 @@
 import org.eclipse.draw2d.ColorConstants;
 import org.eclipse.draw2d.CompoundBorder;
 import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.swt.widgets.Display;
 import org.objectstyle.cayenne.map.Relationship;
 
 /**
@@ -38,6 +39,8 @@
 	
 	public SingleFigure(SingleEditPart part) {
 		super(part);
+		
+		setRelationships();
 	}
 	
 	@Override
@@ -111,8 +114,9 @@
 	}
 	
 	@Override
-	protected void setContents() {
-		super.setContents();
+	public void refresh() {
+		super.refresh();
+		setBackgroundColour();
 		setRelationships();
 	}
 }

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -25,6 +25,7 @@
 import java.util.Date;
 import java.util.Iterator;
 
+import org.apache.cayenne.ropbrowser.TypeConverter;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 import org.objectstyle.cayenne.PersistenceState;
@@ -44,10 +45,7 @@
  * @author Marcel Gordon
  */
 public class AbstractObject extends PersistentObject {	
-	/**
-	 * Formatter for displaying {@link Date} objects as {@link String}s.
-	 */
-	protected static SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy ");
+	
 	/** Property indicating that the object has been deleted */
 	public static final String PROP_DELETED = "AbstractObject.Deleted";
 	/** Property indicating that the object has been modified */
@@ -96,6 +94,8 @@
 			EntityResolver resolver = objectContext.getEntityResolver();
 			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
 			
+			objectContext.prepareForAccess(this, rel.getName());
+			
 			Object value = descriptor.getProperty(rel.getName()).readProperty(this);
 			
 			return value;
@@ -162,23 +162,8 @@
 			// convert the value of the property to a String for display
 			// in a TextPropertyDescriptor
 			Object value = descriptor.getProperty(id.toString()).readProperty(this);
-			String stringValue = null;
-			if (attribute.getType().equals("java.util.Date")) {
-				try {
-					stringValue = dateFormatter.format(value);
-				}
-				catch (Exception e) {
-					stringValue = new String("");
-				}
-			}
-			else {
-				if (value == null) {
-					stringValue = new String("");
-				}
-				else {
-					stringValue = value.toString(); 
-				}
-			} 
+			
+			String stringValue = TypeConverter.getStringValue(value, attribute.getType());
 			
 			return stringValue;
 		}
@@ -261,38 +246,16 @@
 			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
 			ObjAttribute attribute = (ObjAttribute) resolver.getObjEntity(getName()).getAttribute(id.toString());
 			
-			// convert from a String to the correct object type
-			Object newValue = null;
-			if (attribute.getType().equals("java.util.Date")) {
-				try {
-					newValue = dateFormatter.parse(value.toString());
-				}
-				catch(ParseException e) {
-					newValue = value;
-				}
-			}
-			else if (attribute.getType().equals("java.sql.Date")) {
-				newValue = java.sql.Date.valueOf(value.toString()); 
-			}
-			else if (attribute.getType().equals("java.sql.Time")) {
-				newValue = java.sql.Time.valueOf(value.toString());
-			}
-			else if (attribute.getType().equals("java.sql.Timestamp")) {
-				newValue = java.sql.Timestamp.valueOf(value.toString());
-			}
-			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) {
-					newValue = value;
-				}
-			}
-			
 			objectContext.prepareForAccess(this, id.toString());
 	        Object oldValue = descriptor.getProperty(id.toString()).readProperty(this);
+	        Object newValue = null;
+	        
+	        try {
+	        	newValue = TypeConverter.getValueFromString(value, attribute.getType());
+	        }
+	        catch (Exception e) {
+	        	newValue = value;
+	        }
 	        
 	        descriptor.getProperty(id.toString()).writeProperty(this, oldValue, newValue);
 	        
@@ -309,11 +272,13 @@
 	 * @param oldValue the old target of the relationship
 	 * @param newValue the new target of the relationship
 	 */
-	public void setRelationship(Relationship rel, AbstractObject oldValue, AbstractObject newValue) {
+	public void setRelationship(Relationship rel, Object oldValue, Object newValue) {
 		if (objectContext != null) {
 			
 			EntityResolver resolver = objectContext.getEntityResolver();
 			ClassDescriptor descriptor = resolver.getClassDescriptor(getName());
+			
+			objectContext.prepareForAccess(this, rel.getName());
 			
 			descriptor.getProperty(rel.getName()).writeProperty(this, oldValue, newValue);
 			

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=429528&r1=429527&r2=429528&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 Mon Aug  7 17:43:43 2006
@@ -22,6 +22,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.objectstyle.cayenne.util.PersistentObjectList;
+
 
 /**
  * Class representing a collection of AbstractObjects.
@@ -50,10 +52,23 @@
 		}
 				
 		public int compare(AbstractObject arg0, AbstractObject arg1) {
+			if (arg0 == null) {
+				return -1;
+			}
+			if (arg1 == null) {
+				return 1;
+			}
 			
 			Object value0 = arg0.getPropertyValueRaw(sortName);
 			Object value1 = arg1.getPropertyValueRaw(sortName);
 			
+			if (value0 == null) {
+				return -1;
+			}
+			if (value1 == null) {
+				return 1;
+			}
+			
 			if (!arg0.getClass().equals(arg1.getClass())) {
 				return value0.toString().compareTo(value1.toString()); 
 			}
@@ -100,6 +115,13 @@
 	public void addObject(AbstractObject object) {
 		if (!objects.contains(object)) {
 			objects.add(object);
+			for (Connection conn : getTargetConnections()) {
+				if (conn instanceof RelationshipConnection) {
+					RelationshipConnection relConn = (RelationshipConnection) conn;
+					// notify objectContext about simple property change
+					relConn.getSource().getCurrentObject().getObjectContext().propertyChanged(relConn.getSource().getCurrentObject(), relConn.getRelationship().getName(), null, objects);
+				}
+			}
 			object.addPropertyChangeListener(this);
 			getDiagram().createMemberConnections(this, object);
 			firePropertyChange(PROP_TOTAL_RECORDS, null, objects);
@@ -232,6 +254,11 @@
 				for (Connection conn : getSourceConnections()) {
 					if (conn instanceof MemberConnection && conn.getTarget().contains(object)) { // should always be true
 						conn.disconnect();
+					}
+					if (conn instanceof RelationshipConnection) {
+						RelationshipConnection relConn = (RelationshipConnection) conn;
+						// notify objectContext about simple property change
+						relConn.getSource().getCurrentObject().getObjectContext().propertyChanged(relConn.getSource().getCurrentObject(), relConn.getRelationship().getName(), null, objects);
 					}
 				}
 				validateCurrent();

Modified: 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=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/model/ElementDiagram.java Mon Aug  7 17:43:43 2006
@@ -19,9 +19,13 @@
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.util.ArrayList;
+import java.util.EventObject;
 import java.util.List;
 
+import org.objectstyle.cayenne.DataChannel;
 import org.objectstyle.cayenne.ObjectContext;
+import org.objectstyle.cayenne.event.EventSubject;
+import org.objectstyle.cayenne.graph.GraphEvent;
 
 /**
  * The root component in the model - a diagram of {@link ModelElement}s and 
@@ -32,15 +36,17 @@
 public class ElementDiagram {
 	
 	/** property indicating that changes have been committed to the database */
-	public static final String PROP_COMMIT = "ObjectDiagram.GraphCommitted";
+	public static final String PROP_COMMIT = "ElementDiagram.GraphCommitted";
 	/** property indicating that the layout has changed between automatic and manual */
-	public static final String PROP_LAYOUT = "ObjectDiagram.LayoutChanged";
+	public static final String PROP_LAYOUT = "ElementDiagram.LayoutChanged";
 	/** property indicating a node (element) has been added */
-	public static final String PROP_NODE_ADDED = "ObjectDiagram.NodeAdded";
+	public static final String PROP_NODE_ADDED = "ElementDiagram.NodeAdded";
 	/** property indicating that a node (element) has been removed */
-	public static final String PROP_NODE_REMOVED = "ObjectDiagram.NodeRemoved";
+	public static final String PROP_NODE_REMOVED = "ElementDiagram.NodeRemoved";
 	/** property indicating that changes have been rolled back */
-	public static final String PROP_ROLLBACK = "ObjectDiagram.GraphRollback";
+	public static final String PROP_ROLLBACK = "ElementDiagram.GraphRollback";
+	/** property indicating that there has been an external change to the model */
+	public static final String PROP_EXT_CHANGE = "ElementDiagram.ExternalChange";
 	/** whether automatic layout is being used (rather than manual) */
 	private boolean autoLayout;
 	/** the Cayenne context in which the objects represented by the ModelElements exist */

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/CollectionEditPart.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/CollectionEditPart.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/CollectionEditPart.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/CollectionEditPart.java Mon Aug  7 17:43:43 2006
@@ -66,15 +66,6 @@
 	private CollectionModelElement getModelCast() {
 		return (CollectionModelElement) getModel();
 	}
-	
-	@Override
-	public Command getCommand(Request request) {
-		if (request.getType().equals(SetNameElementRequest.SET_NAME_REQUEST)) {
-			return new SetNameElementCommand(this.getModelCast(), ((SetNameElementRequest) request).getName());
-		}
-		// handle requests not in policies; pass the rest along
-		return super.getCommand(request); 
-	}
 
 	/**
 	 * Handle action events from dropdown buttons in the figure,

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementDiagramEditPart.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementDiagramEditPart.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementDiagramEditPart.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementDiagramEditPart.java Mon Aug  7 17:43:43 2006
@@ -152,6 +152,9 @@
 			}
 			hideNullObjects();
 		}
+		else if (ElementDiagram.PROP_EXT_CHANGE.equals(prop)) {
+			refreshChildren();
+		}
 	}
 
 	/**

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPart.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPart.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPart.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/ElementEditPart.java Mon Aug  7 17:43:43 2006
@@ -20,14 +20,18 @@
 import java.beans.PropertyChangeListener;
 import java.util.List;
 
+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.RemoveAction;
+import org.apache.cayenne.ropbrowser.commands.DeleteObjectCommand;
 import org.apache.cayenne.ropbrowser.commands.ExistingObjectCommand;
 import org.apache.cayenne.ropbrowser.commands.ExistingObjectRequest;
 import org.apache.cayenne.ropbrowser.commands.HideElementCommand;
 import org.apache.cayenne.ropbrowser.commands.ObjectInsertCommand;
 import org.apache.cayenne.ropbrowser.commands.RemoveObjectCommand;
+import org.apache.cayenne.ropbrowser.commands.SetNameElementCommand;
+import org.apache.cayenne.ropbrowser.commands.SetNameElementRequest;
 import org.apache.cayenne.ropbrowser.figures.ElementFigure;
 import org.apache.cayenne.ropbrowser.model.ModelElement;
 import org.apache.cayenne.ropbrowser.policies.ElementEditPolicy;
@@ -44,6 +48,7 @@
 import org.eclipse.gef.RequestConstants;
 import org.eclipse.gef.commands.Command;
 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.swt.widgets.Display;
 
 /**
  * Base abstract EditPart class corresponding to {@link ModelElement}.
@@ -111,7 +116,9 @@
 		}
 		else {
 			// for any other kind of property change, refresh the figure
-			((ElementFigure) getFigure()).refresh();
+			if (Display.getCurrent() != null) {
+				((ElementFigure) getFigure()).refresh();
+			}
 		}
 	}
 	
@@ -214,6 +221,12 @@
 		}
 		if (request.getType().equals(ExistingObjectRequest.EXISTING_REQUEST)) {
 			return new ExistingObjectCommand(this.getModelCast(), ((ExistingObjectRequest) request).getSelectedObject());
+		}
+		if (request.getType().equals(DeleteAction.DELETE_REQUEST)) {
+			return new DeleteObjectCommand(this.getModelCast());
+		}
+		if (request.getType().equals(SetNameElementRequest.SET_NAME_REQUEST)) {
+			return new SetNameElementCommand(this.getModelCast(), ((SetNameElementRequest) request).getName());
 		}
 		return super.getCommand(request); 
 	}

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/SingleEditPart.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/SingleEditPart.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/SingleEditPart.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/parts/SingleEditPart.java Mon Aug  7 17:43:43 2006
@@ -55,14 +55,6 @@
 		return (SingleModelElement) getModel();
 	}
 
-	@Override
-	public Command getCommand(Request request) {
-		if (request.getType().equals(DeleteAction.DELETE_REQUEST)) {
-			return new DeleteObjectCommand(this.getModelCast());
-		}
-		return super.getCommand(request); 
-	}
-
 	/**
 	 * Handles action events from its figure's relationship buttons,
 	 * expanding or contracting a relationship.

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/policies/ElementEditPolicy.java Mon Aug  7 17:43:43 2006
@@ -20,6 +20,7 @@
 import org.apache.cayenne.ropbrowser.model.CollectionModelElement;
 import org.apache.cayenne.ropbrowser.model.ElementDiagram;
 import org.apache.cayenne.ropbrowser.model.ModelElement;
+import org.eclipse.gef.Request;
 import org.eclipse.gef.commands.Command;
 import org.eclipse.gef.editpolicies.ComponentEditPolicy;
 import org.eclipse.gef.requests.GroupRequest;

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/views/ControlPanelView.java Mon Aug  7 17:43:43 2006
@@ -106,7 +106,10 @@
 	private SelectQueryWizard selectWizard;
 
 	/** server to connect to */
-	private Combo serverCombo; 
+	private Combo serverCombo;
+	
+	/** whether to use shared session mode */
+	private Button sharedSessionButton;
 	
 	public ControlPanelView() {
 		connectionManager = ConnectionManager.getInstance();
@@ -126,7 +129,7 @@
 		ObjectContext currentContext = null;
 		
 		try {
-			currentContext = connectionManager.getNewObjectContext(serverCombo.getText());
+			currentContext = connectionManager.getNewObjectContext(serverCombo.getText(), sharedSessionButton.getSelection());
 		}
 		catch (Exception ex) {
 			ROPBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, ROPBrowserPlugin.ID, Status.OK, ex.getMessage(), ex));
@@ -214,6 +217,10 @@
 		newDiagramButton.setText("Display in new editor");
 		newDiagramButton.setSelection(true);
 		
+		sharedSessionButton = new Button(miscGroup, SWT.CHECK);
+		sharedSessionButton.setText("Shared session");
+		sharedSessionButton.setSelection(true);
+		
 		parent.pack();
 	}
 
@@ -278,12 +285,12 @@
 	private ObjectContext getObjectContext(String address) {
 		ObjectContext context;
 		if (newDiagramButton.getSelection()) {
-			context = this.connectionManager.getNewObjectContext(address);
+			context = this.connectionManager.getNewObjectContext(address, sharedSessionButton.getSelection());
 		}
 		else {
 			ObjectEditor existingEditor = getExistingEditor(address);
 			if (existingEditor == null) {
-				context = this.connectionManager.getNewObjectContext(address);
+				context = this.connectionManager.getNewObjectContext(address, sharedSessionButton.getSelection());
 			}
 			else {
 				context = existingEditor.getDiagram().getObjectContext();
@@ -292,11 +299,12 @@
 		return context;
 	}
 
-	private void openParametersWizard() {
-		selectWizard = new SelectQueryWizard(connectionManager.getNewObjectContext((String) selectQueryCombo.getData()), selectQueryCombo.getText(), SelectQueryWizard.RETURN_PARAMS);
+	private boolean openParametersWizard() {
+		selectWizard = new SelectQueryWizard(connectionManager.getNewObjectContext((String) selectQueryCombo.getData(), sharedSessionButton.getSelection()), selectQueryCombo.getText(), SelectQueryWizard.RETURN_PARAMS);
 		WizardDialog dialog = new WizardDialog(getViewSite().getShell(), selectWizard);
 		dialog.create();
 		dialog.open();
+		return (dialog.getReturnCode() == WizardDialog.OK);
 	}
 
 	private void runNamedQuery() {
@@ -359,8 +367,9 @@
 			runNamedQuery();
 		}
 		else if (e.getSource() == parametersButton && selectQueryCombo.indexOf(selectQueryCombo.getText()) != -1) {
-			openParametersWizard();
-			runSelectQuery();
+			if (openParametersWizard()) {
+				runSelectQuery();
+			}
 		}
 		else if (e.getSource() == runSelectQueryButton) {
 			runSelectQuery();

Modified: incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/wizards/SelectParametersPage.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/wizards/SelectParametersPage.java?rev=429528&r1=429527&r2=429528&view=diff
==============================================================================
--- incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/wizards/SelectParametersPage.java (original)
+++ incubator/cayenne/soc/trunk/cayenne-rop/rop-browser/src/org/apache/cayenne/ropbrowser/wizards/SelectParametersPage.java Mon Aug  7 17:43:43 2006
@@ -19,6 +19,7 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 
+import org.apache.cayenne.ropbrowser.TypeConverter;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ColumnWeightData;
 import org.eclipse.jface.viewers.ComboBoxCellEditor;
@@ -116,7 +117,12 @@
 		GREATER_THAN (Expression.GREATER_THAN),
 		GREATER_THAN_EQUAL_TO (Expression.GREATER_THAN_EQUAL_TO),
 		LESS_THAN (Expression.LESS_THAN),
-		LESS_THAN_EQUAL_TO (Expression.LESS_THAN_EQUAL_TO);
+		LESS_THAN_EQUAL_TO (Expression.LESS_THAN_EQUAL_TO),
+		LIKE (Expression.LIKE),
+		LIKE_IGNORE_CASE (Expression.LIKE_IGNORE_CASE),
+		NOT_EQUAL_TO (Expression.NOT_EQUAL_TO),
+		NOT_LIKE (Expression.NOT_LIKE),
+		NOT_LIKE_IGNORE_CASE (Expression.NOT_LIKE_IGNORE_CASE);
 		
 		private final int cayenneValue;
 		
@@ -253,8 +259,6 @@
 			attributeTable.refresh();
 		}
 	}
-		
-		// TODO make a util class for converting to and from Strings, use here and AO
 
 	/**
 	 * @return the names and values of the parameters which have been set.
@@ -300,7 +304,7 @@
 					case 2 : Operator operator = operatorMap.get(attribute.getName());
 							 return (operator == null ? new String("") : operator.toString());
 					case 3 : Object paramValue = paramMap.get(attribute.getName());
-							 return (paramValue == null ? new String("") : paramValue.toString());
+							 return (paramValue == null ? new String("") : TypeConverter.getStringValue(paramValue, paramValue.getClass().getCanonicalName()));
 				}
 			}
 			return new String("");
@@ -340,7 +344,7 @@
 				}
 				if (property.equals(COLUMN_NAMES[3])) {
 					Object paramValue = paramMap.get(((ObjAttribute) element).getName());
-					return (paramValue == null ? new String("") : paramValue.toString());
+					return (paramValue == null ? new String("") : TypeConverter.getStringValue(paramValue, paramValue.getClass().getCanonicalName()));
 				}
 			}
 			return null;
@@ -360,9 +364,7 @@
 					}
 					else {
 						try {
-							// try to use a constructor with a String parameter to translate to the correct type
-							Class typeClass = Class.forName(attribute.getText(1));
-							Object typedValue = typeClass.getConstructor(Class.forName("java.lang.String")).newInstance(value.toString());
+							Object typedValue = TypeConverter.getValueFromString(value, attribute.getText(1));
 							paramMap.put(attribute.getText(0), typedValue);
 						}
 						catch (Exception ex) {



Mime
View raw message