incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ange...@apache.org
Subject svn commit: r821409 - in /incubator/ace/trunk: core/ webui/ webui/lib/ webui/src/org/apache/ace/ webui/src/org/apache/ace/client/
Date Sat, 03 Oct 2009 20:47:51 GMT
Author: angelos
Date: Sat Oct  3 20:47:50 2009
New Revision: 821409

URL: http://svn.apache.org/viewvc?rev=821409&view=rev
Log:
ACE-41 Added an initial version of using drag-and-drop for creating associations. This also
means the checkboxes and the '<->' buttons are gone.

Added:
    incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5-javadoc.jar   (with props)
    incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5.jar   (with props)
Modified:
    incubator/ace/trunk/core/build.xml
    incubator/ace/trunk/webui/.classpath
    incubator/ace/trunk/webui/build.xml
    incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java
    incubator/ace/trunk/webui/src/org/apache/ace/webui.gwt.xml

Modified: incubator/ace/trunk/core/build.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/core/build.xml?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/core/build.xml (original)
+++ incubator/ace/trunk/core/build.xml Sat Oct  3 20:47:50 2009
@@ -521,7 +521,7 @@
     <target name="package-webui" unless="webui.uptodate">
     	<!-- TODO add an activator to bridge between OSGi and GWT -->
         <copy file="../webui/webui.war" tofile="deploy/bundle/org.apache.ace.webui-1.0.0.jar"/>
-    	<echo file="org.apache.ace.webui-1.0.0.bnd">Import-Package: org.apache.ace.log,org.apache.ace.client.repository,org.apache.ace.client.repository.object,org.apache.ace.client.repository.repository,org.apache.ace.client.repository.stateful,org.apache.ace.client.repository.helper,org.apache.ace.client.repository.helper.bundle,org.xml.sax,
javax.xml.parsers, junit.framework;resolution:=optional, com.google.gwt.benchmarks;resolution:=optional,
*
+    	<echo file="org.apache.ace.webui-1.0.0.bnd">Import-Package: org.apache.ace.log,org.apache.ace.client.repository,org.apache.ace.client.repository.object,org.apache.ace.client.repository.repository,org.apache.ace.client.repository.stateful,org.apache.ace.client.repository.helper,org.apache.ace.client.repository.helper.bundle,org.xml.sax,
javax.xml.parsers, junit.framework;resolution:=optional, com.google.gwt.benchmarks;resolution:=optional,
com.allen_sauer.gwt.dnd.client;resolution:=optional, com.allen_sauer.gwt.dnd.client.drop;resolution:=optional,
*
 Dynamic-ImportPackage: *
 Bundle-Name: Apache ACE Client Web UI
 Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar
@@ -532,7 +532,7 @@
         <bnd-wrap jars="deploy/bundle/org.apache.ace.webui-1.0.0.jar" output="deploy/bundle/org.apache.ace.webui-1.0.0.jar"/>
     	<jar file="deploy/bundle/org.apache.ace.webui-1.0.0.jar" update="true">
     	<manifest>
-            <attribute name="Bundle-ClassPath" value="WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar,
WEB-INF/lib/felix.jar, ."/>
+            <attribute name="Bundle-ClassPath" value="WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar,
."/>
     	</manifest>
     	</jar>
     	<delete file="org.apache.ace.webui-1.0.0.bnd"/>

Modified: incubator/ace/trunk/webui/.classpath
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/.classpath?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/.classpath (original)
+++ incubator/ace/trunk/webui/.classpath Sat Oct  3 20:47:50 2009
@@ -7,5 +7,10 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/core"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/server"/>
 	<classpathentry kind="lib" path="lib/gwt/gwt-user.jar"/>
+	<classpathentry kind="lib" path="lib/gwt-dnd-2.6.5.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:platform:/resource/webui/lib/gwt-dnd-2.6.5-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="output" path="war/WEB-INF/classes"/>
 </classpath>

Modified: incubator/ace/trunk/webui/build.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/build.xml?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/build.xml (original)
+++ incubator/ace/trunk/webui/build.xml Sat Oct  3 20:47:50 2009
@@ -10,6 +10,7 @@
     <path refid="bnd.classpath" />
     <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
     <!-- Add any additional non-server libs (such as JUnit) -->
+    <fileset dir="../webui/lib" includes="gwt-dnd-2.6.5.jar"/>
     <fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
   </path>
 

Added: incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5-javadoc.jar
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5-javadoc.jar?rev=821409&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5-javadoc.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5.jar
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5.jar?rev=821409&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/ace/trunk/webui/lib/gwt-dnd-2.6.5.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java Sat Oct  3 20:47:50
2009
@@ -19,10 +19,15 @@
 package org.apache.ace.client;
 
 import org.apache.ace.client.Main.StatusHandler;
+import org.apache.ace.client.services.AssociationService;
+import org.apache.ace.client.services.AssociationServiceAsync;
 import org.apache.ace.client.services.BundleDescriptor;
 import org.apache.ace.client.services.BundleService;
 import org.apache.ace.client.services.BundleServiceAsync;
+import org.apache.ace.client.services.Descriptor;
+import org.apache.ace.client.services.GroupDescriptor;
 
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
@@ -31,9 +36,10 @@
  */
 public class BundleTable extends ObjectTable<BundleDescriptor> {
     private BundleServiceAsync m_bundleService = GWT.create(BundleService.class);
+    private AssociationServiceAsync m_associationService = GWT.create(AssociationService.class);
 
-    BundleTable(StatusHandler handler, Main main) {
-        super(handler, main);
+    BundleTable(StatusHandler handler, PickupDragController dragController, Main main) {
+        super(handler, dragController, main);
     }
 
     @Override
@@ -55,4 +61,11 @@
     protected void remove(BundleDescriptor object, AsyncCallback<Void> callback) {
         m_bundleService.remove(object, callback);
     }
+
+    @Override
+    protected void link(BundleDescriptor object, Descriptor other, AsyncCallback<Void>
callback) {
+        if (other instanceof GroupDescriptor) {
+            m_associationService.link(object, (GroupDescriptor) other, callback);
+        }
+    }
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java Sat Oct  3 20:47:50
2009
@@ -19,10 +19,16 @@
 package org.apache.ace.client;
 
 import org.apache.ace.client.Main.StatusHandler;
+import org.apache.ace.client.services.AssociationService;
+import org.apache.ace.client.services.AssociationServiceAsync;
+import org.apache.ace.client.services.BundleDescriptor;
+import org.apache.ace.client.services.Descriptor;
 import org.apache.ace.client.services.GroupDescriptor;
 import org.apache.ace.client.services.GroupService;
 import org.apache.ace.client.services.GroupServiceAsync;
+import org.apache.ace.client.services.LicenseDescriptor;
 
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -32,9 +38,10 @@
  */
 public class GroupTable extends ObjectTable<GroupDescriptor> {
     private GroupServiceAsync m_groupService = GWT.create(GroupService.class);
+    private AssociationServiceAsync m_associationService = GWT.create(AssociationService.class);
 
-    GroupTable(StatusHandler handler, Main main) {
-        super(handler, main);
+    GroupTable(StatusHandler handler, PickupDragController dragController, Main main) {
+        super(handler, dragController, main);
     }
 
     @Override
@@ -71,4 +78,14 @@
         m_groupService.remove(object, callback);
     }
 
+    @Override
+    protected void link(GroupDescriptor object, Descriptor other, AsyncCallback<Void>
callback) {
+        if (other instanceof BundleDescriptor) {
+            m_associationService.link((BundleDescriptor) other, object, callback);
+        }
+        else if (other instanceof LicenseDescriptor) {
+            m_associationService.link(object, (LicenseDescriptor) other, callback);
+        }
+    }
+
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java Sat Oct  3 20:47:50
2009
@@ -19,10 +19,16 @@
 package org.apache.ace.client;
 
 import org.apache.ace.client.Main.StatusHandler;
+import org.apache.ace.client.services.AssociationService;
+import org.apache.ace.client.services.AssociationServiceAsync;
+import org.apache.ace.client.services.Descriptor;
+import org.apache.ace.client.services.GroupDescriptor;
 import org.apache.ace.client.services.LicenseDescriptor;
 import org.apache.ace.client.services.LicenseService;
 import org.apache.ace.client.services.LicenseServiceAsync;
+import org.apache.ace.client.services.TargetDescriptor;
 
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -32,9 +38,10 @@
  */
 public class LicenseTable extends ObjectTable<LicenseDescriptor> {
     private LicenseServiceAsync m_licenseService = GWT.create(LicenseService.class);
+    private AssociationServiceAsync m_associationService = GWT.create(AssociationService.class);
 
-    LicenseTable(StatusHandler handler, Main main) {
-        super(handler, main);
+    LicenseTable(StatusHandler handler, PickupDragController dragController, Main main) {
+        super(handler, dragController, main);
     }
 
     @Override
@@ -70,4 +77,14 @@
     protected void remove(LicenseDescriptor object, AsyncCallback<Void> callback) {
         m_licenseService.remove(object, callback);
     }
-}
+
+    @Override
+    protected void link(LicenseDescriptor object, Descriptor other, AsyncCallback<Void>
callback) {
+        if (other instanceof GroupDescriptor) {
+            m_associationService.link((GroupDescriptor) other, object, callback);
+        }
+        else if (other instanceof TargetDescriptor) {
+            m_associationService.link(object, (TargetDescriptor) other, callback);
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java Sat Oct  3 20:47:50 2009
@@ -26,12 +26,11 @@
 import org.apache.ace.client.services.AssociationService;
 import org.apache.ace.client.services.AssociationServiceAsync;
 import org.apache.ace.client.services.Descriptor;
-import org.apache.ace.client.services.GroupDescriptor;
-import org.apache.ace.client.services.LicenseDescriptor;
 import org.apache.ace.client.services.TargetDescriptor;
 import org.apache.ace.client.services.TargetService;
 import org.apache.ace.client.services.TargetServiceAsync;
 
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.impl.StringBuilderImpl;
@@ -53,13 +52,15 @@
 public class Main implements EntryPoint {
     private static final int REFRESH_INTERVAL = 2000;
     private StatusLabel m_statusLabel = new StatusLabel();
-    private BundleTable m_bundleTable = new BundleTable(m_statusLabel, this);
-    private GroupTable m_groupTable = new GroupTable(m_statusLabel, this);
-    private LicenseTable m_licenseTable = new LicenseTable(m_statusLabel, this);
-    private TargetTable m_targetTable = new TargetTable(m_statusLabel, this);
+    private PickupDragController m_dragController = new PickupDragController(RootPanel.get(),
false);
+    private BundleTable m_bundleTable = new BundleTable(m_statusLabel, m_dragController,
this);
+    private GroupTable m_groupTable = new GroupTable(m_statusLabel, m_dragController, this);
+    private LicenseTable m_licenseTable = new LicenseTable(m_statusLabel, m_dragController,
this);
+    private TargetTable m_targetTable = new TargetTable(m_statusLabel, m_dragController,
this);
     
     AssociationServiceAsync m_assocationService = GWT.create(AssociationService.class);
     
+    
     /**
      * Interface for the columns, that they can use to indicate their status of
      * communication with the server.
@@ -139,50 +140,6 @@
 //        targetScrollPanel.setHeight("30em");
         targetScrollPanel.setStyleName("objectTable");
         
-        // Create the association buttons
-        Button b2g = new Button("<->");
-        b2g.addClickHandler(new ClickHandler() {
-            public void onClick(ClickEvent event) {
-                m_assocationService.link(m_bundleTable.getCheckedObject(), m_groupTable.getCheckedObject(),
new AsyncCallback<Void>() {
-                    public void onFailure(Throwable caught) {
-                        Window.alert("Error creating association: " + caught);
-                    }
-                    public void onSuccess(Void result) {
-                        updateHighlight();
-                    }
-                });
-            }
-        });
-        
-        Button g2l = new Button("<->");
-        g2l.addClickHandler(new ClickHandler() {
-            public void onClick(ClickEvent event) {
-                GroupDescriptor group = m_groupTable.getCheckedObject();
-                LicenseDescriptor license = m_licenseTable.getCheckedObject();
-                m_assocationService.link(group, license, new AsyncCallback<Void>()
{
-                    public void onFailure(Throwable caught) {
-                        Window.alert("Error creating association: " + caught);
-                    }
-                    public void onSuccess(Void result) {
-                        updateHighlight();
-                    }
-                });
-            }
-        });
-        Button l2t = new Button("<->");
-        l2t.addClickHandler(new ClickHandler() {
-            public void onClick(ClickEvent event) {
-                m_assocationService.link(m_licenseTable.getCheckedObject(), m_targetTable.getCheckedObject(),
new AsyncCallback<Void>() {
-                    public void onFailure(Throwable caught) {
-                        Window.alert("Error creating association: " + caught);
-                    }
-                    public void onSuccess(Void result) {
-                        updateHighlight();
-                    }
-                });
-            }
-        });
-        
         FlexTable rootPanel = new FlexTable();
         FlexCellFormatter formatter = rootPanel.getFlexCellFormatter();
         rootPanel.setWidth("100%");
@@ -190,30 +147,27 @@
         rootPanel.setHTML(1, 0, "Bundle");
         formatter.setWidth(1, 0, "25%");
         rootPanel.setWidget(2, 0, addBundleButton);
-        rootPanel.setWidget(2, 1, b2g);
-        formatter.setStyleName(2, 1, "fixedColumn");
         rootPanel.setWidget(3, 0, bundleScrollPanel);
         formatter.setHeight(3, 0, "90%");
-        rootPanel.setHTML(1, 2, "Group");
+        rootPanel.setHTML(1, 1, "Group");
+        formatter.setWidth(1, 1, "25%");
+        rootPanel.setWidget(2, 1, addGroupButton);
+        rootPanel.setWidget(3, 1, groupScrollPanel);
+        rootPanel.setHTML(1, 2, "License");
         formatter.setWidth(1, 2, "25%");
-        rootPanel.setWidget(2, 2, addGroupButton);
-        rootPanel.setWidget(2, 3, g2l);
-        formatter.setStyleName(2, 3, "fixedColumn");
-        rootPanel.setWidget(3, 2, groupScrollPanel);
-        rootPanel.setHTML(1, 4, "License");
-        formatter.setWidth(1, 4, "25%");
-        rootPanel.setWidget(2, 4, addLicenseButton);
-        rootPanel.setWidget(2, 5, l2t);
-        formatter.setStyleName(2, 5, "fixedColumn");
-        rootPanel.setWidget(3, 4, licenseScrollPanel);
-        rootPanel.setHTML(1, 6, "Target");
-        formatter.setWidth(1, 6, "25%");
-        rootPanel.setWidget(3, 6, targetScrollPanel);
+        rootPanel.setWidget(2, 2, addLicenseButton);
+        rootPanel.setWidget(3, 2, licenseScrollPanel);
+        rootPanel.setHTML(1, 3, "Target");
+        formatter.setWidth(1, 3, "25%");
+        rootPanel.setWidget(3, 3, targetScrollPanel);
         rootPanel.setWidget(0, 0, new CheckoutPanel(this));
-        formatter.setColSpan(0, 0, 7);
+        formatter.setColSpan(0, 0, 4);
         rootPanel.setWidget(4, 0, m_statusLabel);
-        formatter.setColSpan(4, 0, 7);
+        formatter.setColSpan(4, 0, 4);
         RootPanel.get("body").add(rootPanel);
+        
+        m_dragController.setBehaviorDragProxy(true);
+        m_dragController.setBehaviorDragStartSensitivity(4);
     }
     
     /**

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java Sat Oct  3 20:47:50
2009
@@ -27,22 +27,27 @@
 import org.apache.ace.client.services.AssociationServiceAsync;
 import org.apache.ace.client.services.Descriptor;
 
+import com.allen_sauer.gwt.dnd.client.DragContext;
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
+import com.allen_sauer.gwt.dnd.client.drop.DropController;
+import com.allen_sauer.gwt.dnd.client.drop.SimpleDropController;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.CheckBox;
 import com.google.gwt.user.client.ui.DockPanel;
 import com.google.gwt.user.client.ui.FlexTable;
 import com.google.gwt.user.client.ui.FocusPanel;
+import com.google.gwt.user.client.ui.Label;
 
 /**
  * Basic table for using a valueobject per row.
  */
 public abstract class ObjectTable<T extends Descriptor> extends FlexTable {
     private final StatusHandler m_handler;
+    private final PickupDragController m_dragController;
     private final Main m_main;
     
     private final Map<T, ObjectPanel> m_panels = new HashMap<T, ObjectPanel>();
@@ -64,7 +69,6 @@
                 ObjectPanel panel = m_panels.get(t);
                 if (panel == null) {
                     panel = new ObjectPanel(t);
-                    panel.addToGroup(m_buttonGroup);
                     m_panels.put(t, panel);
                 }
                 panel.setText(getText(t));
@@ -82,24 +86,11 @@
     };
     
     /**
-     * Deselects all other checkboxes in the same group when one gets clicked;
-     * this way, we end up with a single selected button.
-     */
-    private final ClickHandler m_buttonGroup = new ClickHandler() {
-        public void onClick(ClickEvent event) {
-            for (ObjectPanel w : m_panels.values()) {
-                if (!w.owns(event.getSource())) {
-                    w.setChecked(false);
-                }
-            }
-        }
-    };
-
-    /**
      * Sole constructor for this class; all subclasses must delegate to this one.
      */
-    public ObjectTable(StatusHandler handler, Main main) {
+    public ObjectTable(StatusHandler handler, PickupDragController dragController, Main main)
{
         m_handler = handler;
+        m_dragController = dragController;
         m_main = main;
     }
     
@@ -127,23 +118,15 @@
     protected abstract void remove(T object, AsyncCallback<Void> callback);
     
     /**
-     * States whether removal of this object is allowed.
+     * Links an object of ours with some other, that has been dropped onto our object.
      */
-    protected boolean canDelete() {
-        return true;
-    }
+    protected abstract void link(T object, Descriptor other, AsyncCallback<Void> callback);
     
-
     /**
-     * Finds the currently checked object, or <code>null</code> if none is found.
+     * States whether removal of this object is allowed.
      */
-    public T getCheckedObject() {
-        for (Map.Entry<T, ObjectPanel> entry : m_panels.entrySet()) {
-            if (entry.getValue().isChecked()) {
-                return entry.getKey();
-            }
-        }
-        return null;
+    protected boolean canDelete() {
+        return true;
     }
     
     /**
@@ -195,15 +178,17 @@
      * unlink and delete the related object.
      */
     private class ObjectPanel extends FocusPanel {
-        private final CheckBox m_checkbox;
+        private final Label m_label;
         private boolean m_selected;
+        private final T m_object;
 
         public ObjectPanel(final T object) {
+            m_object = object;
             DockPanel mainPanel = new DockPanel();
 
-            m_checkbox = new CheckBox(getText(object));
-            m_checkbox.setStylePrimaryName("objectpaneltext");
-            mainPanel.add(m_checkbox, DockPanel.WEST);
+            m_label = new Label(getText(object));
+            m_label.setStylePrimaryName("objectpaneltext");
+            mainPanel.add(m_label, DockPanel.WEST);
 
             if (canDelete()) {
                 Button delete = new Button("x");
@@ -235,7 +220,6 @@
                         public void onSuccess(Void result) {
                             m_main.updateHighlight();
                         }
-                        
                     });
                     event.stopPropagation(); // we don't want the panel to get the click
                 }
@@ -252,14 +236,30 @@
                     m_main.updateHighlight();
                 }
             });
+            
+            m_dragController.makeDraggable(this);
+            DropController dropController = new SimpleDropController(this) {
+                @Override
+                public void onDrop(DragContext context) {
+                    Object other = ((ObjectPanel) context.draggable).getObject();
+                    if (other instanceof Descriptor) {
+                        link(object, (Descriptor) other, new AsyncCallback<Void>()
{
+                            public void onFailure(Throwable caught) {
+                                Window.alert("Error linking objects.");
+                            }
+                            public void onSuccess(Void result) {
+                                // Hurrah!
+                                m_main.updateHighlight();
+                            }
+                        });
+                    }
+                }
+            };
+            m_dragController.registerDropController(dropController);
         }
         
-        public boolean isChecked() {
-            return m_checkbox.getValue();
-        }
-        
-        public void setChecked(boolean b) {
-            m_checkbox.setValue(b);
+        public T getObject() {
+            return m_object;
         }
         
         public boolean isSelected() {
@@ -270,40 +270,16 @@
             m_selected = selected;
             if (selected) {
                 addStyleDependentName("selected");
-                m_checkbox.addStyleDependentName("selected");
+                m_label.addStyleDependentName("selected");
             }
             else {
                 removeStyleDependentName("selected");
-                m_checkbox.removeStyleDependentName("selected");
+                m_label.removeStyleDependentName("selected");
             }
         }
         
-        public void setRelated(boolean related) {
-            if (related) {
-                addStyleDependentName("related");
-            }
-            else {
-                removeStyleDependentName("related");
-            }
-        }
-
         public void setText(String text) {
-            m_checkbox.setText(text);
-        }
-        
-        /**
-         * Returns whether the given object is 'owned' by this panel.
-         */
-        public boolean owns(Object object) {
-            return object.equals(m_checkbox);
-        }
-        
-        /**
-         * Registers a clickhandler with the checkbox; this is used to make sure that at
most one
-         * checkbox in a column is checked.
-         */
-        public void addToGroup(ClickHandler handler) {
-            m_checkbox.addClickHandler(handler);
+            m_label.setText(text);
         }
     }
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java Sat Oct  3 20:47:50
2009
@@ -19,10 +19,15 @@
 package org.apache.ace.client;
 
 import org.apache.ace.client.Main.StatusHandler;
+import org.apache.ace.client.services.AssociationService;
+import org.apache.ace.client.services.AssociationServiceAsync;
+import org.apache.ace.client.services.Descriptor;
+import org.apache.ace.client.services.LicenseDescriptor;
 import org.apache.ace.client.services.TargetDescriptor;
 import org.apache.ace.client.services.TargetService;
 import org.apache.ace.client.services.TargetServiceAsync;
 
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
@@ -31,9 +36,10 @@
  */
 public class TargetTable extends ObjectTable<TargetDescriptor> {
     private TargetServiceAsync m_targetService = GWT.create(TargetService.class);
+    private AssociationServiceAsync m_associationService = GWT.create(AssociationService.class);
 
-    TargetTable(StatusHandler handler, Main main) {
-        super(handler, main);
+    TargetTable(StatusHandler handler, PickupDragController dragController, Main main) {
+        super(handler, dragController, main);
     }
 
     @Override
@@ -60,4 +66,11 @@
     protected boolean canDelete() {
         return false;
     }
+
+    @Override
+    protected void link(TargetDescriptor object, Descriptor other, AsyncCallback<Void>
callback) {
+        if (other instanceof LicenseDescriptor) {
+            m_associationService.link((LicenseDescriptor) other, object, callback);
+        }
+    }
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/webui.gwt.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/webui.gwt.xml?rev=821409&r1=821408&r2=821409&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/webui.gwt.xml (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/webui.gwt.xml Sat Oct  3 20:47:50 2009
@@ -12,7 +12,8 @@
   <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->
 
   <!-- Other module inherits                                      -->
-
+  <inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
+  
   <!-- Specify the app entry point class.                         -->
   <entry-point class='org.apache.ace.client.Main'/>
 </module>



Mime
View raw message