Author: mes
Date: 2010-11-20 15:19:40 -0800 (Sat, 20 Nov 2010)
New Revision: 22963
Modified:
core3/ding-presentation-impl/trunk/pom.xml
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphView.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
core3/ding-presentation-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
Log:
added support for DnD and removed Phoebe refs
Modified: core3/ding-presentation-impl/trunk/pom.xml
===================================================================
--- core3/ding-presentation-impl/trunk/pom.xml 2010-11-20 23:19:07 UTC (rev
22962)
+++ core3/ding-presentation-impl/trunk/pom.xml 2010-11-20 23:19:40 UTC (rev
22963)
@@ -164,8 +164,8 @@
<version>7.3</version>
</dependency>
<dependency>
- <groupId>phoebe</groupId>
- <artifactId>phoebe.dnd</artifactId>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>dnd-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphView.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphView.java
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphView.java
2010-11-20 23:19:40 UTC (rev 22963)
@@ -7,7 +7,6 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.CyNetworkView;
-import phoebe.PhoebeCanvasDropListener;
import javax.swing.*;
import java.awt.*;
@@ -523,7 +522,7 @@
public GraphLOD getGraphLOD();
public void fitSelected();
- public void addTransferComponent(JComponent comp);
+// public void addTransferComponent(JComponent comp);
// for printing
public void setBounds(int x, int y, int width, int height) ;
@@ -558,8 +557,6 @@
public void removeMouseMotionListener(MouseMotionListener m);
public void removeKeyListener(KeyListener k);
- public void addPhoebeCanvasDropListener(PhoebeCanvasDropListener l);
- public void removePhoebeCanvasDropListener(PhoebeCanvasDropListener l);
public CyNetworkView getViewModel();
}
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2010-11-20 23:19:40 UTC (rev 22963)
@@ -85,6 +85,8 @@
import org.cytoscape.task.EdgeViewTaskFactory;
import org.cytoscape.task.NetworkViewTaskFactory;
import org.cytoscape.task.NodeViewTaskFactory;
+import org.cytoscape.dnd.DropNetworkViewTaskFactory;
+import org.cytoscape.dnd.DropNodeViewTaskFactory;
import org.cytoscape.util.intr.IntBTree;
import org.cytoscape.util.intr.IntEnumerator;
import org.cytoscape.util.intr.IntHash;
@@ -108,9 +110,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import phoebe.PhoebeCanvasDropListener;
-import phoebe.PhoebeCanvasDroppable;
-
/**
* DING implementation of the GINY view.
*
@@ -124,7 +123,7 @@
* @author Nerius Landys
*/
public class DGraphView implements RenderingEngine<CyNetwork>, GraphView,
- Printable, PhoebeCanvasDroppable,
NetworkViewChangeMicroListener,
+ Printable, NetworkViewChangeMicroListener,
NodeViewChangeMicroListener, EdgeViewChangeMicroListener,
FitContentEventListener, FitSelectedEventListener {
@@ -363,6 +362,8 @@
Map<NodeViewTaskFactory, Map> nodeViewTFs;
Map<EdgeViewTaskFactory, Map> edgeViewTFs;
Map<NetworkViewTaskFactory, Map> emptySpaceTFs;
+ Map<DropNodeViewTaskFactory, Map> dropNodeViewTFs;
+ Map<DropNetworkViewTaskFactory, Map> dropEmptySpaceTFs;
TunableInterceptor interceptor;
TaskManager manager;
@@ -387,6 +388,8 @@
Map<NodeViewTaskFactory, Map> nodeViewTFs,
Map<EdgeViewTaskFactory, Map> edgeViewTFs,
Map<NetworkViewTaskFactory, Map> emptySpaceTFs,
+ Map<DropNodeViewTaskFactory, Map> dropNodeViewTFs,
+ Map<DropNetworkViewTaskFactory, Map> dropEmptySpaceTFs,
TaskManager manager, CyEventHelper eventHelper,
CyTableManager tableMgr) {
@@ -412,6 +415,8 @@
this.nodeViewTFs = nodeViewTFs;
this.edgeViewTFs = edgeViewTFs;
this.emptySpaceTFs = emptySpaceTFs;
+ this.dropNodeViewTFs = dropNodeViewTFs;
+ this.dropEmptySpaceTFs = dropEmptySpaceTFs;
this.manager = manager;
@@ -2652,10 +2657,6 @@
return list;
}
- public void addTransferComponent(JComponent comp) {
- m_networkCanvas.addTransferComponent(comp);
- }
-
/**
* This method is used by freehep lib to export network as graphics.
*/
@@ -2727,14 +2728,6 @@
m_networkCanvas.removeKeyListener(k);
}
- public void addPhoebeCanvasDropListener(PhoebeCanvasDropListener l) {
- m_networkCanvas.addPhoebeCanvasDropListener(l);
- }
-
- public void removePhoebeCanvasDropListener(PhoebeCanvasDropListener l) {
- m_networkCanvas.removePhoebeCanvasDropListener(l);
- }
-
static <X> List<X> makeList(X nodeOrEdge) {
List<X> nl = new ArrayList<X>(1);
nl.add(nodeOrEdge);
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
2010-11-20 23:19:40 UTC (rev 22963)
@@ -18,6 +18,8 @@
import org.cytoscape.task.EdgeViewTaskFactory;
import org.cytoscape.task.NetworkViewTaskFactory;
import org.cytoscape.task.NodeViewTaskFactory;
+import org.cytoscape.dnd.DropNetworkViewTaskFactory;
+import org.cytoscape.dnd.DropNodeViewTaskFactory;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.VisualLexicon;
@@ -51,6 +53,8 @@
private Map<NodeViewTaskFactory, Map> nodeViewTFs;
private Map<EdgeViewTaskFactory, Map> edgeViewTFs;
private Map<NetworkViewTaskFactory, Map> emptySpaceTFs;
+ private Map<DropNodeViewTaskFactory, Map> dropNodeViewTFs;
+ private Map<DropNetworkViewTaskFactory, Map> dropEmptySpaceTFs;
private TaskManager tm;
private final CyTableManager tableMgr;
@@ -77,6 +81,8 @@
nodeViewTFs = new HashMap<NodeViewTaskFactory, Map>();
edgeViewTFs = new HashMap<EdgeViewTaskFactory, Map>();
emptySpaceTFs = new HashMap<NetworkViewTaskFactory, Map>();
+ dropNodeViewTFs = new HashMap<DropNodeViewTaskFactory, Map>();
+ dropEmptySpaceTFs = new HashMap<DropNetworkViewTaskFactory,
Map>();
}
/**
@@ -102,7 +108,8 @@
+ targetView.getSUID());
dgv = new DGraphView(targetView, dataTableFactory,
rootNetworkFactory, undo,
spacialFactory, dingLexicon,
- nodeViewTFs, edgeViewTFs,
emptySpaceTFs, tm, eventHelper,
+ nodeViewTFs, edgeViewTFs,
emptySpaceTFs, dropNodeViewTFs,
+ dropEmptySpaceTFs, tm, eventHelper,
tableMgr);
logger.info("DGraphView created as a presentation for
view model: "
+ targetView.getSUID());
@@ -113,9 +120,8 @@
JDesktopPane desktopPane =
inFrame.getDesktopPane();
// TODO - not sure this layered pane bit is
optimal
- inFrame.setContentPane(dgv.getContainer(inFrame
- .getLayeredPane()));
- dgv.addTransferComponent(desktopPane);
+
inFrame.setContentPane(dgv.getContainer(inFrame.getLayeredPane()));
+ // dgv.addTransferComponent(desktopPane);
} else {
JComponent component = (JComponent)
presentationContainer;
component.add(dgv.getComponent());
@@ -189,11 +195,38 @@
emptySpaceTFs.put(evtf, props);
}
- public void removeNetworkViewTaskFactory(NetworkViewTaskFactory evtf,
- Map props) {
+ public void removeNetworkViewTaskFactory(NetworkViewTaskFactory evtf,
Map props) {
if (evtf == null)
return;
emptySpaceTFs.remove(evtf);
}
+
+ public void addDropNetworkViewTaskFactory(DropNetworkViewTaskFactory
evtf, Map props) {
+ if (evtf == null)
+ return;
+
+ dropEmptySpaceTFs.put(evtf, props);
+ }
+
+ public void removeDropNetworkViewTaskFactory(DropNetworkViewTaskFactory
evtf, Map props) {
+ if (evtf == null)
+ return;
+
+ dropEmptySpaceTFs.remove(evtf);
+ }
+
+ public void addDropNodeViewTaskFactory(DropNodeViewTaskFactory nvtf,
Map props) {
+ if (nvtf == null)
+ return;
+
+ dropNodeViewTFs.put(nvtf, props);
+ }
+
+ public void removeDropNodeViewTaskFactory(DropNodeViewTaskFactory nvtf,
Map props) {
+ if (nvtf == null)
+ return;
+
+ dropNodeViewTFs.remove(nvtf);
+ }
}
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2010-11-20 23:19:40 UTC (rev 22963)
@@ -38,6 +38,10 @@
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetListener;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
@@ -74,17 +78,12 @@
import org.cytoscape.util.intr.IntStack;
import org.cytoscape.work.undo.UndoSupport;
-import phoebe.PhoebeCanvasDropEvent;
-import phoebe.PhoebeCanvasDropListener;
-import phoebe.PhoebeCanvasDroppable;
-
-
/**
*
*/
public class InnerCanvas extends DingCanvas implements MouseListener,
MouseMotionListener,
-
java.awt.dnd.DropTargetListener,
- PhoebeCanvasDroppable,
KeyListener,
+ DropTargetListener,
+ KeyListener,
MouseWheelListener {
private final static long serialVersionUID = 1202416511420671L;
@@ -136,20 +135,6 @@
// AJK: 1/14/2007 END
- /**
- * DOCUMENT ME!
- */
- public Vector<PhoebeCanvasDropListener> listeners = new
Vector<PhoebeCanvasDropListener>();
-
- /**
- * AJK: 01/12/07
- * Transfer handler components -- contain transfer handlers
- * N.B. -- don't use this code -- just a quick fix that will be
replaced in
- * Cytosape 2.5.
- */
- private Vector<JComponent> transferComponents = new
Vector<JComponent>();
-
-
private UndoSupport m_undo;
InnerCanvas(Object lock, DGraphView view, UndoSupport undo) {
@@ -170,9 +155,7 @@
addMouseWheelListener(this);
addKeyListener(this);
setFocusable(true);
- dropTarget = new DropTarget(this, // component
- DnDConstants.ACTION_COPY, // actions
- this); // DropTargetListener
+ dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY,
this);
popup = new PopupMenuHelper(m_view, this);
}
@@ -1253,7 +1236,7 @@
* @param dte the DropTargetDragEvent
*
*/
- public void dragEnter(java.awt.dnd.DropTargetDragEvent dte) {
+ public void dragEnter(DropTargetDragEvent dte) {
dte.acceptDrag(DnDConstants.ACTION_COPY);
}
@@ -1262,115 +1245,42 @@
* @param dte the DropTargetDragEvent
*
*/
- public void dragExit(java.awt.dnd.DropTargetEvent dte) {
- }
+ public void dragExit(DropTargetEvent dte) { }
/**
* default dropActionChanged handler. Does nothing, can be overridden.
* @param dte the DropTargetDragEvent
*
*/
- public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dte) {
- }
+ public void dropActionChanged(DropTargetDragEvent dte) { }
/**
* default dragOver handler. Does nothing, can be overridden.
* @param dte the DropTargetDragEvent
*
*/
- public void dragOver(java.awt.dnd.DropTargetDragEvent dte) {
- }
+ public void dragOver(DropTargetDragEvent dte) { }
/**
- * default drop handler. Accepts drop, builds a transferable, creates
and
- * fires a PhoebeCanvasDropEvent, then calls dropComplete().
- * @param dte the DropTargetDragEvent
- *
+ * default drop handler.
*/
- public void drop(java.awt.dnd.DropTargetDropEvent dte) {
+ public void drop(DropTargetDropEvent dte) {
dte.acceptDrop(DnDConstants.ACTION_COPY);
Transferable t = dte.getTransferable();
Point pt = dte.getLocation();
- PhoebeCanvasDropEvent event = new PhoebeCanvasDropEvent(m_view,
// the view should be the event source
- t, //
item dropped
- pt //
location
- );
- processPhoebeCanvasDropEvent(event);
+ NodeView nview = m_view.getPickedNodeView(pt);
+ if ( nview != null )
+ popup.createDropNodeViewMenu(nview,pt,t);
+ else
+ popup.createDropEmptySpaceMenu(pt,t);
dte.dropComplete(true);
}
- /**
- * adds a listener to the store of PhoebeCanvasDropTargetListeners
- * @param l the PhoebeCanvasDropTargetListener
- *
- */
- public void addPhoebeCanvasDropListener(PhoebeCanvasDropListener l) {
- listeners.addElement(l);
- }
- /**
- * removes a listener from the store of PhoebeCanvasDropTargetListeners
- * @param l the PhoebeCanvasDropTargetListener
- *
- */
- public void removePhoebeCanvasDropListener(PhoebeCanvasDropListener l) {
- listeners.removeElement(l);
- }
-
- /**
- * handles a PhoebeCanvasDropEvent. For each listerner, calls its
itemDropped() method
- * @param event the PhoebeCanvasDropEvent
- *
- */
- protected synchronized void
processPhoebeCanvasDropEvent(PhoebeCanvasDropEvent event) {
- Enumeration e = listeners.elements();
-
- Transferable t = event.getTransferable();
- TransferHandler th;
- JComponent jComp;
- Iterator<JComponent> it = transferComponents.iterator();
-
- while (it.hasNext()) {
- jComp = it.next();
- th = jComp.getTransferHandler();
-
- if (th != null) {
- // th.importData(jComp, t);
- }
- }
-
- while (e.hasMoreElements()) {
- PhoebeCanvasDropListener l = (PhoebeCanvasDropListener)
e.nextElement();
- l.itemDropped(event);
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param comp DOCUMENT ME!
- */
- public void addTransferComponent(JComponent comp) {
- if (!transferComponents.contains(comp)) {
- transferComponents.addElement(comp);
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param comp DOCUMENT ME!
- */
- public void removeTransferComponent(JComponent comp) {
- transferComponents.removeElement(comp);
- }
-
- // AJK: 01/12/07 END
-
public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
double factor = 1.0;
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
2010-11-20 23:19:40 UTC (rev 22963)
@@ -33,6 +33,8 @@
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.event.ActionEvent;
+import java.awt.Point;
+import java.awt.datatransfer.Transferable;
import java.util.Map;
import java.util.Collection;
import java.util.List;
@@ -49,6 +51,9 @@
import org.cytoscape.task.NetworkViewTaskFactory;
import org.cytoscape.task.NodeViewTaskFactory;
import org.cytoscape.task.EdgeViewTaskFactory;
+import org.cytoscape.dnd.DropNetworkViewTaskFactory;
+import org.cytoscape.dnd.DropNodeViewTaskFactory;
+
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.model.CyNode;
@@ -106,6 +111,38 @@
}
/**
+ * Creates a menu based on a drop event on a NodeView.
+ */
+ void createDropNodeViewMenu(NodeView nview, Point p, Transferable t) {
+ if (nview != null ) {
+ Collection<DropNodeViewTaskFactory> usableTFs =
getPreferredActions(m_view.dropNodeViewTFs,null);
+ View<CyNode> nv = nview.getNodeViewModel();
+
+ // build a menu of actions if more than factory exists
+ if ( usableTFs.size() > 1) {
+ String nodeLabel =
nv.getModel().getCyRow().get("name",String.class);
+ JPopupMenu menu = new JPopupMenu(nodeLabel);
+ JMenuTracker tracker = new JMenuTracker(menu);
+
+ for ( DropNodeViewTaskFactory nvtf : usableTFs
) {
+
nvtf.setNodeView(nv,m_view.cyNetworkView);
+ nvtf.setDropInformation(t,p);
+ createMenuItem(menu, nvtf, tracker,
m_view.dropNodeViewTFs.get( nvtf ));
+ }
+
+ menu.show(invoker, new
Double(p.getX()).intValue(), new Double(p.getY()).intValue());
+
+ // execute the task directly if only one factory exists
+ } else if ( usableTFs.size() == 1) {
+ DropNodeViewTaskFactory tf =
usableTFs.iterator().next();
+ tf.setNodeView(nv,m_view.cyNetworkView);
+ tf.setDropInformation(t,p);
+ executeTask(tf);
+ }
+ }
+ }
+
+ /**
* Creates a menu based on the NodeView.
*/
void createNodeViewMenu(NodeView nview, int x, int y , String action) {
@@ -138,6 +175,29 @@
/**
* Creates a menu based on the NetworkView.
*/
+ void createDropEmptySpaceMenu(Point p, Transferable t) {
+ // build a menu of actions if more than factory exists
+ Collection<DropNetworkViewTaskFactory> usableTFs =
getPreferredActions(m_view.dropEmptySpaceTFs,null);
+ if ( usableTFs.size() > 1 ) {
+ JPopupMenu menu = new JPopupMenu("Double Click Menu:
empty");
+ JMenuTracker tracker = new JMenuTracker(menu);
+ for ( DropNetworkViewTaskFactory nvtf : usableTFs ) {
+ nvtf.setNetworkView(m_view.cyNetworkView);
+ nvtf.setDropInformation(t,p);
+ createMenuItem(menu, nvtf, tracker,
m_view.dropEmptySpaceTFs.get( nvtf ) );
+ }
+ menu.show(invoker, new Double(p.getX()).intValue(), new
Double(p.getY()).intValue());
+ // execute the task directly if only one factory exists
+ } else if ( usableTFs.size() == 1) {
+ DropNetworkViewTaskFactory tf =
usableTFs.iterator().next();
+ tf.setNetworkView(m_view.cyNetworkView);
+ tf.setDropInformation(t,p);
+ executeTask(tf);
+ }
+ }
+ /**
+ * Creates a menu based on the NetworkView.
+ */
void createEmptySpaceMenu(int x, int y, String action) {
// build a menu of actions if more than factory exists
Collection<NetworkViewTaskFactory> usableTFs =
getPreferredActions(m_view.emptySpaceTFs,action);
Modified:
core3/ding-presentation-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-11-20 23:19:07 UTC (rev 22962)
+++
core3/ding-presentation-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-11-20 23:19:40 UTC (rev 22963)
@@ -91,4 +91,16 @@
unbind-method="removeNetworkViewTaskFactory"
ref="dingRenderingEngineFactory" />
</osgi:set>
+ <osgi:set id="dropNodeViewTaskFactorySet"
interface="org.cytoscape.dnd.DropNodeViewTaskFactory"
+ cardinality="0..N">
+ <osgi:listener bind-method="addDropNodeViewTaskFactory"
+ unbind-method="removeDropNodeViewTaskFactory"
ref="dingRenderingEngineFactory" />
+ </osgi:set>
+
+ <osgi:set id="dropEmptySpaceTaskFactorySet"
interface="org.cytoscape.dnd.DropNetworkViewTaskFactory"
+ cardinality="0..N">
+ <osgi:listener bind-method="addDropNetworkViewTaskFactory"
+ unbind-method="removeDropNetworkViewTaskFactory"
ref="dingRenderingEngineFactory" />
+ </osgi:set>
+
</beans>
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.