Author: mes
Date: 2010-12-07 14:28:17 -0800 (Tue, 07 Dec 2010)
New Revision: 23116
Removed:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddEdgeTask.java
Modified:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddNestedNetworkTask.java
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNetworkViewTask.java
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNodeViewTaskFactoryImpl.java
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/gui/BasicCytoShapeEntity.java
core3/editor-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/editor-impl/trunk/src/main/resources/images/edge.png
Log:
cleaned up handling of edge dropping
Deleted:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddEdgeTask.java
===================================================================
---
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddEdgeTask.java
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddEdgeTask.java
2010-12-07 22:28:17 UTC (rev 23116)
@@ -1,33 +0,0 @@
-package org.cytoscape.editor.internal;
-
-import org.cytoscape.task.AbstractNodeViewTask;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.View;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.work.TaskMonitor;
-
-
-public class AddEdgeTask extends AbstractNodeViewTask {
-
- private static CyNode sourceNode = null;
-
-
- public AddEdgeTask(View<CyNode> nv, CyNetworkView view) {
- super(nv,view);
- }
-
- @Override
- public void run(TaskMonitor tm) throws Exception {
- System.out.println("Running add edge - sourceNode: " +
sourceNode);
- if ( sourceNode == null ) {
- sourceNode = nodeView.getModel();
- } else {
- CyNetwork net = netView.getModel();
- CyNode targetNode = nodeView.getModel();
- net.addEdge(sourceNode,targetNode,true);
- netView.updateView();
- sourceNode = null;
- }
- }
-}
Modified:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddNestedNetworkTask.java
===================================================================
---
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddNestedNetworkTask.java
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/AddNestedNetworkTask.java
2010-12-07 22:28:17 UTC (rev 23116)
@@ -17,20 +17,35 @@
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
import org.cytoscape.work.util.ListSingleSelection;
+import org.cytoscape.dnd.DropUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class AddNestedNetworkTask extends AbstractNodeViewTask {
+ private static final Logger logger =
LoggerFactory.getLogger(AddNestedNetworkTask.class);
+
@Tunable(description="Select a Network")
public ListSingleSelection<CyNetwork> nestedNetwork;
- public AddNestedNetworkTask(View<CyNode> nv, CyNetworkView view,
CyNetworkManager mgr) {
+ private final Transferable t;
+
+ public AddNestedNetworkTask(View<CyNode> nv, CyNetworkView view,
CyNetworkManager mgr,
+ Transferable t) {
super(nv,view);
+ this.t = t;
nestedNetwork = new ListSingleSelection<CyNetwork>(new
ArrayList<CyNetwork>(mgr.getNetworkSet()));
}
@Override
public void run(TaskMonitor tm) throws Exception {
+ if ( !DropUtil.transferableMatches(t,"Network") ) {
+ logger.warn("Transferable object does not match
expected type (Network) for task.");
+ return;
+ }
+
CyNode n = nodeView.getModel();
n.setNestedNetwork( nestedNetwork.getSelectedValue() );
netView.updateView();
Modified:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNetworkViewTask.java
===================================================================
---
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNetworkViewTask.java
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNetworkViewTask.java
2010-12-07 22:28:17 UTC (rev 23116)
@@ -14,13 +14,17 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
-import org.cytoscape.editor.internal.gui.BasicCytoShapeEntity;
+import org.cytoscape.dnd.DropUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DropNetworkViewTask extends AbstractNetworkViewTask {
private final Transferable t;
private final Point2D xformPt;
+
+ private static final Logger logger =
LoggerFactory.getLogger(DropNetworkViewTask.class);
public DropNetworkViewTask(CyNetworkView view, Transferable t, Point2D
xformPt) {
super(view);
@@ -30,25 +34,11 @@
@Override
public void run(TaskMonitor tm) throws Exception {
- if ( t==null)
+ if ( !DropUtil.transferableMatches(t,"Node") ) {
+ logger.warn("Transferable object does not match
expected type (Node) for task.");
return;
-
- DataFlavor[] dfl = t.getTransferDataFlavors();
-
- if ( dfl==null)
- return;
-
- for (DataFlavor d : dfl) {
- if ( d.getRepresentationClass() ==
BasicCytoShapeEntity.class ) {
- String myShape =
t.getTransferData(d).toString();
- if ( myShape.equals("Node") ) {
- addNode();
- }
- }
}
- }
- private void addNode() {
CyNetwork net = view.getModel();
CyNode n = net.addNode();
View<CyNode> nv = view.getNodeView(n);
Modified:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNodeViewTaskFactoryImpl.java
===================================================================
---
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNodeViewTaskFactoryImpl.java
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/DropNodeViewTaskFactoryImpl.java
2010-12-07 22:28:17 UTC (rev 23116)
@@ -14,7 +14,7 @@
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.AbstractTask;
-import org.cytoscape.editor.internal.gui.BasicCytoShapeEntity;
+import org.cytoscape.dnd.GraphicalEntity;
public class DropNodeViewTaskFactoryImpl implements DropNodeViewTaskFactory {
@@ -42,39 +42,6 @@
}
public TaskIterator getTaskIterator() {
-
- if ( t==null)
- return null;
-
- try {
-
- DataFlavor[] dfl = t.getTransferDataFlavors();
-
- if ( dfl==null)
- return null;
-
- for (DataFlavor d : dfl) {
- if ( d.getRepresentationClass() == BasicCytoShapeEntity.class ) {
- String myShape = t.getTransferData(d).toString();
- System.out.println("got shape drop: " +
myShape);
- if ( myShape.equals("Edge") ) {
- return new TaskIterator(new
AddEdgeTask(nv, view));
- } else if ( myShape.equals("Network") ) {
- return new TaskIterator(new
AddNestedNetworkTask(nv, view, netMgr));
- }
- }
- }
-
- } catch (Exception e) {
- return new TaskIterator(new ExceptionTask(e));
- }
-
- return null;
+ return new TaskIterator(new AddNestedNetworkTask(nv, view,
netMgr, t));
}
-
- private static class ExceptionTask extends AbstractTask {
- private final Exception e;
- ExceptionTask(Exception e) { this.e = e; }
- public void run(TaskMonitor tm) throws Exception { throw e; }
- }
}
Modified:
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/gui/BasicCytoShapeEntity.java
===================================================================
---
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/gui/BasicCytoShapeEntity.java
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/java/org/cytoscape/editor/internal/gui/BasicCytoShapeEntity.java
2010-12-07 22:28:17 UTC (rev 23116)
@@ -83,6 +83,7 @@
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.application.swing.CySwingApplication;
+import org.cytoscape.dnd.GraphicalEntity;
/**
@@ -96,7 +97,7 @@
* @version 1.0
*
*/
-public class BasicCytoShapeEntity extends JComponent implements
DragGestureListener {
+public class BasicCytoShapeEntity extends JComponent implements
DragGestureListener, GraphicalEntity {
// MLC 07/27/06:
private static final long serialVersionUID = -5229827235046946347L;
@@ -210,21 +211,6 @@
myDragSource.createDefaultDragGestureRecognizer(_cytoShape,
DnDConstants.ACTION_COPY, this);
handler = (new BasicCytoShapeTransferHandler(this, null));
this.setTransferHandler(handler);
-/*
- Dimension mySize = new Dimension(((JPanel)
Cytoscape.getDesktop()
-
.getCytoPanel(SwingConstants.WEST))
-
.getSize().width
- - 5,
-
Math.max(_image.getIconHeight(),
-
CytoShapeIcon.DEFAULT_HEIGHT)
- +
CytoShapeIcon.DEFAULT_HEIGHT);
-
- this.setMaximumSize(mySize);
- this.setMinimumSize(mySize);
- this.setPreferredSize(mySize);
- */
-
-
}
/**
@@ -238,7 +224,7 @@
* @param title The title to set.
*
*/
- public void setTitle(String title) {
+ private void setTitle(String title) {
this.title = title;
}
@@ -252,7 +238,7 @@
/**
* @param myDragSource The DragSource to set.
*/
- public void setMyDragSource(DragSource myDragSource) {
+ private void setMyDragSource(DragSource myDragSource) {
this.myDragSource = myDragSource;
}
@@ -267,21 +253,21 @@
* @param _image the icon to set for the shape
*
*/
- public void setIcon(Icon _image) {
+ private void setIcon(Icon _image) {
this._image = _image;
}
/**
* @return Returns the image associated with the shape's icon
*/
- public Image get_image() {
+ public Image getImage() {
return _img;
}
/**
* @param _img The _img to set.
*/
- public void set_image(Image _img) {
+ private void setImage(Image _img) {
this._img = _img;
}
@@ -295,7 +281,7 @@
/**
* @param attributeName The attributeName to set.
*/
- public void setAttributeName(String attributeName) {
+ private void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}
@@ -309,7 +295,7 @@
/**
* @param attributeValue The attributeValue to set.
*/
- public void setAttributeValue(String attributeValue) {
+ private void setAttributeValue(String attributeValue) {
this.attributeValue = attributeValue;
}
Modified:
core3/editor-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/editor-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-12-07 22:27:59 UTC (rev 23115)
+++
core3/editor-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-12-07 22:28:17 UTC (rev 23116)
@@ -26,14 +26,16 @@
<osgi:service id="dropNetworkViewTaskFactoryService"
ref="dropNetworkViewTaskFactory"
interface="org.cytoscape.dnd.DropNetworkViewTaskFactory">
<osgi:service-properties>
- <entry key="title" value="Drop NetworkView TaskFactory Service" />
+ <entry key="title" value="Create Node" />
+ <entry key="preferredAction" value="Node" />
</osgi:service-properties>
</osgi:service>
<osgi:service id="dropNodeViewTaskFactoryService"
ref="dropNodeViewTaskFactory"
interface="org.cytoscape.dnd.DropNodeViewTaskFactory">
<osgi:service-properties>
- <entry key="title" value="Drop NodeView TaskFactory Service" />
+ <entry key="title" value="Create Nested Network" />
+ <entry key="preferredAction" value="Network" />
</osgi:service-properties>
</osgi:service>
</beans>
Modified: core3/editor-impl/trunk/src/main/resources/images/edge.png
===================================================================
(Binary files differ)
--
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.