package org.cytoscape.editor.internal;


import java.awt.geom.Point2D;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;

import java.util.List;
import java.util.ArrayList;

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.model.CyNetworkManager;
import org.cytoscape.work.ProvidesTitle;
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="Network")
	public ListSingleSelection<CyNetwork> nestedNetwork;

	private final Transferable t;

	@ProvidesTitle
	public String getTitle() {
		return "Choose Network for Node";
	}
	
	public AddNestedNetworkTask(View<CyNode> nv, CyNetworkView view, CyNetworkManager mgr,
	                            Transferable t) {
		super(nv,view);
		this.t = t;
		
		ArrayList<CyNetwork> networkSet = new ArrayList<CyNetwork>(mgr.getNetworkSet());

		// Remove self from the network list
		for (int i=0; i<networkSet.size(); i++ ){
			if (view.getModel() == networkSet.get(i)){
				networkSet.remove(i);
				break;
			}			
		}
		
		nestedNetwork = new ListSingleSelection<CyNetwork>(networkSet);
	}

	@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.setNetworkPointer( nestedNetwork.getSelectedValue() );
		netView.updateView();
	}
}

@@ -1294,326 +1294,72 @@
 %0D%0A%09%09
-%0D%0A%09%09ArrayList%3CCyNetwork%3E networkSet = new ArrayList%3CCyNetwork%3E(mgr.getNetworkSet());%0D%0A%0D%0A%09%09// Remove self from the network list%0D%0A%09%09for (int i=0; i%3CnetworkSet.size(); i++ )%7B%0D%0A%09%09%09if (view.getModel() == networkSet.get(i))%7B%0D%0A%09%09%09%09networkSet.remove(i);%0D%0A%09%09%09%09break;%0D%0A%09%09%09%7D%09%09%09%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09nested
+nestedNetwork = new ListSingleSelection%3CCy
 Network
- = 
+%3E(
 new 
-ListSingleSelection
+ArrayList
 %3CCyN
@@ -1366,17 +1366,24 @@
 etwork%3E(
-n
+mgr.getN
 etworkSe
@@ -1383,16 +1383,19 @@
 tworkSet
+())
 );%0D%0A%09%7D%0D%0A

Revert the change