http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
deleted file mode 100644
index cd87e58..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workbench.iterationstrategy.contextview;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-import 
net.sf.taverna.t2.workbench.iterationstrategy.editor.IterationStrategyEditorControl;
-import org.apache.taverna.workflowmodel.Edit;
-import org.apache.taverna.workflowmodel.EditException;
-import org.apache.taverna.workflowmodel.Edits;
-import org.apache.taverna.workflowmodel.Processor;
-import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
-import 
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author alanrw
- *
- */
-@SuppressWarnings("serial")
-public class IterationStrategyConfigurationDialog extends HelpEnabledDialog {
-
-       private static Logger logger = Logger
-       .getLogger(IterationStrategyConfigurationDialog.class);
-
-       private final EditManager editManager;
-       private final FileManager fileManager;
-
-
-       private final Frame owner;
-       private final Processor processor;
-       private final IterationStrategyStack originalStack;
-
-       private IterationStrategyStack workingStack;
-
-       public IterationStrategyConfigurationDialog(Frame owner, Processor 
processor, IterationStrategyStack iStack, EditManager editManager, FileManager 
fileManager) {
-               super (owner, "List handling for " + processor.getLocalName(), 
true, null);
-               this.owner = owner;
-               this.processor = processor;
-               this.originalStack = iStack;
-               this.editManager = editManager;
-               this.fileManager = fileManager;
-               this.workingStack = 
IterationStrategyContextualView.copyIterationStrategyStack(originalStack);
-               IterationStrategy iterationStrategy = 
IterationStrategyContextualView.getIterationStrategy(workingStack);
-               IterationStrategyEditorControl iterationStrategyEditorControl = 
new IterationStrategyEditorControl(
-                               iterationStrategy);
-               this.add(iterationStrategyEditorControl, BorderLayout.CENTER);
-
-               JPanel buttonPanel = new JPanel();
-               buttonPanel.setLayout(new FlowLayout());
-
-               JButton okButton = new JButton(new OKAction(this));
-               buttonPanel.add(okButton);
-
-               JButton resetButton = new JButton(new ResetAction(
-                               iterationStrategyEditorControl));
-               buttonPanel.add(resetButton);
-
-               JButton cancelButton = new JButton(new CancelAction(this));
-               buttonPanel.add(cancelButton);
-
-               this.add(buttonPanel, BorderLayout.SOUTH);
-               this.pack();
-               this.setSize(new Dimension(getPreferredSize().width, 
getPreferredSize().height > 400 ? 400 : getPreferredSize().height));
-       }
-
-       private final class OKAction extends AbstractAction {
-               private final JDialog dialog;
-
-               private OKAction(JDialog dialog) {
-                       super("OK");
-                       this.dialog = dialog;
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       Edits edits = editManager.getEdits();
-                       try {
-                               Edit<?> edit = 
edits.getSetIterationStrategyStackEdit(
-                                               processor,
-                                               
IterationStrategyContextualView.copyIterationStrategyStack(workingStack));
-                               editManager.doDataflowEdit(
-                                               
fileManager.getCurrentDataflow(), edit);
-                               dialog.setVisible(false);
-                       } catch (RuntimeException ex) {
-                               logger.warn("Could not set list handling", ex);
-                               JOptionPane.showMessageDialog(owner,
-                                               "Can't set list handling",
-                                               "An error occured when setting 
list handling: "
-                                                               + 
ex.getMessage(),
-                                               JOptionPane.ERROR_MESSAGE);
-                       } catch (EditException ex) {
-                               logger.warn("Could not set list handling", ex);
-                               JOptionPane.showMessageDialog(owner,
-                                               "Can't set list handling",
-                                               "An error occured when setting 
list handling: "
-                                                               + 
ex.getMessage(),
-                                               JOptionPane.ERROR_MESSAGE);
-                       }
-               }
-       }
-
-       private final class ResetAction extends AbstractAction {
-               private final IterationStrategyEditorControl 
strategyEditorControl;
-
-               private ResetAction(
-                               IterationStrategyEditorControl 
strategyEditorControl) {
-                       super("Reset");
-                       this.strategyEditorControl = strategyEditorControl;
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       workingStack = 
IterationStrategyContextualView.copyIterationStrategyStack(originalStack);
-                       strategyEditorControl
-                                       
.setIterationStrategy(IterationStrategyContextualView.getIterationStrategy(workingStack));
-               }
-
-       }
-
-       private final class CancelAction extends AbstractAction {
-               private final JDialog dialog;
-
-               private CancelAction(JDialog dialog) {
-                       super("Cancel");
-                       this.dialog = dialog;
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       dialog.setVisible(false);
-               }
-
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
deleted file mode 100644
index 4b0b602..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-/**
- *
- */
-package net.sf.taverna.t2.workbench.iterationstrategy.contextview;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-import 
net.sf.taverna.t2.workbench.iterationstrategy.editor.IterationStrategyTree;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import org.apache.taverna.workflowmodel.Processor;
-import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
-import 
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
-import 
org.apache.taverna.workflowmodel.processor.iteration.impl.IterationStrategyImpl;
-import 
org.apache.taverna.workflowmodel.processor.iteration.impl.IterationStrategyStackImpl;
-
-import org.apache.log4j.Logger;
-import org.jdom.Content;
-import org.jdom.Element;
-import org.jdom.filter.ElementFilter;
-
-/**
- * Contextual view of an {@link IterationStrategyStack}.
- *
- * @author Stian Soiland-Reyes
- *
- */
-public class IterationStrategyContextualView extends ContextualView {
-
-       private static Logger logger = Logger
-                       .getLogger(IterationStrategyContextualView.class);
-
-       private EditManager editManager;
-
-       private FileManager fileManager;
-
-       private IterationStrategyStack iterationStack;
-
-       private final Processor processor;
-
-       private IterationStrategyTree strategyTree = new 
IterationStrategyTree();
-
-       static {
-
-// This should be enabled and modified for T2-822
-/*             editManager.addObserver(new Observer<EditManagerEvent> () {
-
-                       private void examineEdit(Edit edit) {
-                               if (edit instanceof ConnectDatalinkEdit) {
-                                       
processConnectDatalinkEdit((ConnectDatalinkEdit) edit);
-                               }
-                               if (edit instanceof CompoundEdit) {
-                                       processCompoundEdit((CompoundEdit) 
edit);
-                               }
-                       }
-
-                       private void 
processConnectDatalinkEdit(ConnectDatalinkEdit edit) {
-                               Datalink d = ((ConnectDatalinkEdit) 
edit).getSubject();
-                               EventHandlingInputPort sink = d.getSink();
-                               if (sink instanceof ProcessorInputPort) {
-                                       ProcessorInputPort pip = 
(ProcessorInputPort) sink;
-                                       Processor p = pip.getProcessor();
-                                       final HelpEnabledDialog dialog = new 
IterationStrategyConfigurationDialog(null, p, 
copyIterationStrategyStack(p.getIterationStrategy()));
-                                       dialog.setVisible(true);
-                               }
-                       }
-
-                       private void processCompoundEdit(CompoundEdit edit) {
-                               for (Edit e : edit.getChildEdits()) {
-                                       examineEdit(e);
-                               }
-                       }
-
-                       @Override
-                       public void notify(Observable<EditManagerEvent> sender,
-                                       EditManagerEvent message) throws 
Exception {
-                               if (!(message instanceof DataflowEditEvent)) {
-                                       return;
-                               }
-                               examineEdit(message.getEdit());
-                       }});*/
-       }
-
-       public IterationStrategyContextualView(Processor processor, EditManager 
editManager, FileManager fileManager) {
-               if (processor == null || processor.getIterationStrategy() == 
null) {
-                       throw new NullPointerException(
-                                       "Iteration strategy stack can't be 
null");
-               }
-               this.processor = processor;
-               this.editManager = editManager;
-               this.fileManager = fileManager;
-               refreshIterationStrategyStack();
-               initView();
-       }
-
-       @Override
-       public Action getConfigureAction(final Frame owner) {
-               return new ConfigureIterationStrategyAction(owner);
-       }
-
-       public Processor getProcessor() {
-               return processor;
-       }
-
-       @Override
-       public void refreshView() {
-               refreshIterationStrategyStack();
-               
strategyTree.setIterationStrategy(getIterationStrategy(iterationStack));
-       }
-
-       public static IterationStrategyStack copyIterationStrategyStack(
-                       IterationStrategyStack stack) {
-               Element asXML = ((IterationStrategyStackImpl)stack).asXML();
-               stripEmptyElements(asXML);
-               IterationStrategyStackImpl copyStack = new 
IterationStrategyStackImpl();
-               copyStack.configureFromElement(asXML);
-               if (copyStack.getStrategies().isEmpty()) {
-                       copyStack.addStrategy(new IterationStrategyImpl());
-               }
-               return copyStack;
-       }
-
-       private static void stripEmptyElements(Element asXML) {
-               int childCount = asXML.getContent().size();
-               int index = 0;
-               while (index < childCount) {
-                       Content child = asXML.getContent(index);
-                       if (child instanceof Element) {
-                               Element childElement = (Element) child;
-                               if (childElement.getName().equals("port")) {
-                                       index++;
-                               }
-                               else if (childElement.getDescendants(new 
ElementFilter("port")).hasNext()) {
-                                       stripEmptyElements(childElement);
-                                       index++;
-                               } else {
-                                       asXML.removeContent(childElement);
-                                       childCount--;
-                               }
-                       }
-               }
-       }
-
-       public static IterationStrategy 
getIterationStrategy(IterationStrategyStack iStack) {
-               List<? extends IterationStrategy> strategies = iStack
-                               .getStrategies();
-               if (strategies.isEmpty()) {
-                       throw new IllegalStateException("Empty iteration 
stack");
-               }
-               IterationStrategy strategy = strategies.get(0);
-               if (!(strategy instanceof IterationStrategyImpl)) {
-                       throw new IllegalStateException(
-                                       "Can't edit unknown iteration strategy 
implementation "
-                                                       + strategy);
-               }
-               return (IterationStrategyImpl) strategy;
-       }
-
-       private void refreshIterationStrategyStack() {
-               IterationStrategyStack originalIterationStrategy = processor
-                               .getIterationStrategy();
-               if (!(originalIterationStrategy instanceof 
IterationStrategyStackImpl)) {
-                       throw new IllegalStateException(
-                                       "Unknown iteration strategy 
implementation "
-                                                       + 
originalIterationStrategy);
-               }
-               this.iterationStack = 
copyIterationStrategyStack((IterationStrategyStackImpl) 
originalIterationStrategy);
-       }
-
-       @Override
-       public JComponent getMainFrame() {
-               refreshView();
-               return strategyTree;
-       }
-
-       @Override
-       public String getViewTitle() {
-               return "List handling";
-       }
-
-       private final class ConfigureIterationStrategyAction extends 
AbstractAction {
-               private final Frame owner;
-
-               private ConfigureIterationStrategyAction(Frame owner) {
-                       super("Configure");
-                       this.owner = owner;
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       final HelpEnabledDialog dialog = new 
IterationStrategyConfigurationDialog(owner, processor, iterationStack, 
editManager, fileManager);
-                       dialog.setVisible(true);
-                       refreshView();
-               }
-
-
-
-       }
-
-       @Override
-       public int getPreferredPosition() {
-               return 200;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
deleted file mode 100644
index c722983..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-package net.sf.taverna.t2.workbench.iterationstrategy.contextview;
-
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import 
net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import org.apache.taverna.workflowmodel.Processor;
-
-public class IterationStrategyContextualViewFactory implements
-               ContextualViewFactory<Processor> {
-
-       private EditManager editManager;
-       private FileManager fileManager;
-
-       public boolean canHandle(Object selection) {
-               return selection instanceof Processor;
-       }
-
-       public List<ContextualView> getViews(Processor p) {
-               return Arrays.asList(new ContextualView[] {new 
IterationStrategyContextualView(p, editManager, fileManager)});
-       }
-
-       public void setEditManager(EditManager editManager) {
-               this.editManager = editManager;
-       }
-
-       public void setFileManager(FileManager fileManager) {
-               this.fileManager = fileManager;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
deleted file mode 100644
index 5124c0d..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *    
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *    
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-/**
- * 
- */
-package net.sf.taverna.t2.workbench.iterationstrategy.editor;
-
-import java.awt.Component;
-
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
-import net.sf.taverna.t2.workbench.iterationstrategy.IterationStrategyIcons;
-import org.apache.taverna.workflowmodel.processor.iteration.CrossProduct;
-import org.apache.taverna.workflowmodel.processor.iteration.DotProduct;
-import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
-
-import org.apache.log4j.Logger;
-
-@SuppressWarnings("serial")
-final class IterationStrategyCellRenderer extends DefaultTreeCellRenderer {
-
-       @SuppressWarnings("unused")
-       private static Logger logger = Logger
-                       .getLogger(IterationStrategyCellRenderer.class);
-
-       @Override
-       public Component getTreeCellRendererComponent(JTree tree, Object value,
-                       boolean selected, boolean expanded, boolean leaf, int 
row,
-                       boolean hasFocus) {
-               super.getTreeCellRendererComponent(tree, value, selected, 
expanded,
-                               leaf, row, hasFocus);
-               if (value instanceof CrossProduct) {
-                       setIcon(IterationStrategyIcons.joinIteratorIcon);
-                       setText("Cross product");
-               } else if (value instanceof DotProduct) {
-                       setIcon(IterationStrategyIcons.lockStepIteratorIcon);
-                       setText("Dot product");
-               } else if (value instanceof NamedInputPortNode) {
-                       setIcon(IterationStrategyIcons.leafnodeicon);
-                       NamedInputPortNode namedInput = (NamedInputPortNode) 
value;
-                       setText(namedInput.getPortName());
-               } else {
-                       setText("List handling");
-                       if (!leaf){
-                               if (expanded) {
-                                       setIcon(WorkbenchIcons.folderOpenIcon);
-                               } else {
-                                       
setIcon(WorkbenchIcons.folderClosedIcon);
-                               }
-                       }
-               }
-               return this;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditor.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditor.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditor.java
deleted file mode 100644
index 3dce138..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditor.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *    
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *    
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-package net.sf.taverna.t2.workbench.iterationstrategy.editor;
-
-import java.awt.GraphicsEnvironment;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.UnsupportedFlavorException;
-//import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import javax.swing.DropMode;
-import javax.swing.JComponent;
-import javax.swing.JTree;
-import javax.swing.TransferHandler;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
-
-import net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI;
-import 
org.apache.taverna.workflowmodel.processor.iteration.AbstractIterationStrategyNode;
-import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
-import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
-import org.apache.taverna.workflowmodel.processor.iteration.TerminalNode;
-
-import org.apache.log4j.Logger;
-
-@SuppressWarnings("serial")
-public class IterationStrategyEditor extends IterationStrategyTree implements
-               UIComponentSPI {
-
-       private static Logger logger = Logger
-                       .getLogger(IterationStrategyEditor.class);
-
-       //private BufferedImage imgGhost; // The 'drag image'
-
-       // mouse was clicked
-
-       public IterationStrategyEditor() {
-               super();
-               // Make this a drag source
-               if (!GraphicsEnvironment.isHeadless()) {
-                       this.setDragEnabled(true);  
-               this.setDropMode(DropMode.ON_OR_INSERT);  
-               this.setTransferHandler(new TreeTransferHandler());  
-               this.getSelectionModel().setSelectionMode(  
-                       TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);  
-               expandTree();
-               }
-
-               //
-       }
-
-       public IterationStrategyEditor(IterationStrategy theStrategy) {
-               this();
-               setIterationStrategy(theStrategy);
-       }
-
-    /**
-     * 
-     * This code is freely adapted from code derived 
-     *
-     */
-    class TreeTransferHandler extends TransferHandler {  
-        DataFlavor nodesFlavor;
-        DataFlavor[] flavors = new DataFlavor[1];  
-       
-        public TreeTransferHandler() {
-               getNodesFlavor();
-          }
-        
-        private DataFlavor getNodesFlavor() {
-               if (nodesFlavor == null) {
-                try {  
-                     nodesFlavor = new 
DataFlavor(DataFlavor.javaJVMLocalObjectMimeType +
-                             ";class=" + 
AbstractIterationStrategyNode.class.getName(),
-                             "AbstractIterationStrategyNode",
-                             this.getClass().getClassLoader());  
-                    flavors[0] = nodesFlavor;  
-                } catch(Exception e) {  
-                    logger.error("Problem creating nodesFlavor:" + e);
-                }                      
-               }
-               return nodesFlavor;
-        }
-       
-        public boolean canImport(TransferHandler.TransferSupport support) {  
-            if(!support.isDrop()) {
-               logger.error("isDrop not supported");
-                return false;  
-            }  
-
-            if(!support.isDataFlavorSupported(getNodesFlavor())) {
-               logger.info("Not correct flavor");
-                return false;  
-            }  
-            // Do not allow a drop on the drag source selections.  
-            JTree.DropLocation dl =  
-                    (JTree.DropLocation)support.getDropLocation();  
-            TreePath dest = dl.getPath();  
-            AbstractIterationStrategyNode destination =  
-                (AbstractIterationStrategyNode)dest.getLastPathComponent();
-            Transferable t = support.getTransferable();
-            if (destination instanceof TerminalNode) {
-               return false;
-            }
-            try {
-                               AbstractIterationStrategyNode node = 
(AbstractIterationStrategyNode) t.getTransferData(getNodesFlavor());
-                               if (node.isNodeDescendant(destination)) {
-                                       return false;
-                               }
-                       } catch (UnsupportedFlavorException e) {
-                               return false;
-                       } catch (IOException e) {
-                               return false;
-                       }  
-//                     JTree tree = (JTree) support.getComponent();
-//                     int dropRow = tree.getRowForPath(dl.getPath());
-//                     int selRow = tree.getLeadSelectionRow();
-//                     if (selRow == dropRow) {
-//                             logger.info("Dragging to source");
-//                             return false;
-//
-//                     }
-                       support.setShowDropLocation(true);  
-            return true;  
-        }  
-       
-         protected Transferable createTransferable(JComponent c) {  
-            JTree tree = (JTree)c;  
-            TreePath[] paths = tree.getSelectionPaths();  
-            if(paths != null) {  
-                AbstractIterationStrategyNode node =  
-                    
(AbstractIterationStrategyNode)paths[0].getLastPathComponent();  
-                 return new NodeTransferable(node);  
-            }  
-            return null;  
-        }  
-              
-        protected void exportDone(JComponent source, Transferable data, int 
action) {  
-        }  
-       
-        public int getSourceActions(JComponent c) {  
-            return MOVE;  
-        }  
-       
-        public boolean importData(TransferHandler.TransferSupport support) { 
-            if(!canImport(support)) {
-               logger.info("Cannot import");
-                return false;  
-            }  
-            // Extract transfer data.  
-            AbstractIterationStrategyNode node = null;  
-            try {  
-                Transferable t = support.getTransferable();  
-                node = (AbstractIterationStrategyNode) 
t.getTransferData(getNodesFlavor());  
-            } catch(UnsupportedFlavorException ufe) {  
-                logger.error("UnsupportedFlavor", ufe);  
-            } catch (Exception e) {
-               logger.error("Problem getting transfer data", e);
-            }
-
-           // Get drop location info.  
-            JTree.DropLocation dl =  
-                    (JTree.DropLocation)support.getDropLocation();  
-            int childIndex = dl.getChildIndex();  
-            TreePath dest = dl.getPath();  
-            AbstractIterationStrategyNode parent =  
-                (AbstractIterationStrategyNode)dest.getLastPathComponent();
-            int index = childIndex;
-            logger.info ("parent is a " + parent.getClass().getName());
-            if (parent instanceof NamedInputPortNode) {
-               AbstractIterationStrategyNode sibling = parent;
-               parent = (AbstractIterationStrategyNode) sibling.getParent();
-               index = parent.getIndex(sibling);
-            } else if (index == -1) {
-               index = parent.getChildCount();
-            }
-            if (parent instanceof TerminalNode) {
-               if (parent.getChildCount() > 0) {
-                       parent = (AbstractIterationStrategyNode) 
parent.getChildAt(0);
-                       index = parent.getChildCount();
-               }
-               
-            }
-            logger.info("parent is a " + parent.getClass().getName());
-
-                       try {
-                               // The parent insert removes from the oldParent
-                               parent.insert(node, index++);
-                               DefaultTreeModel model = 
IterationStrategyEditor.this
-                                               .getModel();
-                               refreshModel();
-                       } catch (IllegalStateException e) {
-                               logger.error(e);
-                       } catch (IllegalArgumentException e) {
-                               logger.error(e);
-                       }
-          return true;  
-        }  
-       
-        public String toString() {  
-            return getClass().getName();  
-        }  
-       
-        public class NodeTransferable implements Transferable {  
-            AbstractIterationStrategyNode node;  
-       
-            public NodeTransferable(AbstractIterationStrategyNode node) {  
-                this.node = node;  
-             }  
-       
-            public AbstractIterationStrategyNode getTransferData(DataFlavor 
flavor)  
-                                     throws UnsupportedFlavorException {  
-                if(!isDataFlavorSupported(flavor))  
-                    throw new UnsupportedFlavorException(flavor);  
-                return node;  
-            }  
-       
-            public DataFlavor[] getTransferDataFlavors() {  
-                return flavors;  
-            }  
-       
-            public boolean isDataFlavorSupported(DataFlavor flavor) {
-                return getNodesFlavor().equals(flavor);  
-            }  
-        }  
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditorControl.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditorControl.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditorControl.java
deleted file mode 100644
index 6d80004..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyEditorControl.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *    
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *    
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-/**
- * This file is a component of the Taverna project,
- * and is licensed under the GNU LGPL.
- * Copyright Tom Oinn, EMBL-EBI
- */
-package net.sf.taverna.t2.workbench.iterationstrategy.editor;
-
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.BoxLayout;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JToolBar;
-import javax.swing.SwingConstants;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
-import net.sf.taverna.t2.workbench.iterationstrategy.IterationStrategyIcons;
-import org.apache.taverna.workflowmodel.processor.iteration.CrossProduct;
-import org.apache.taverna.workflowmodel.processor.iteration.DotProduct;
-import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
-import 
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyNode;
-import org.apache.taverna.workflowmodel.processor.iteration.TerminalNode;
-
-import org.apache.log4j.Logger;
-
-/**
- * A control panel for the iteration tree editor allowing the user to 
manipulate
- * the tree, removing and adding nodes into the tree based on the context.
- * 
- * @author Tom Oinn
- * @author Stian Soiland-Reyes
- * 
- */
-@SuppressWarnings("serial")
-public class IterationStrategyEditorControl extends JPanel {
-
-       protected static Set<IterationStrategyNode> descendentsOfNode(
-                       IterationStrategyNode node) {
-               Set<IterationStrategyNode> descendants = new 
HashSet<IterationStrategyNode>();
-               Set<IterationStrategyNode> nodesToVisit = new 
HashSet<IterationStrategyNode>();
-               Set<IterationStrategyNode> visitedNodes = new 
HashSet<IterationStrategyNode>();
-
-               // Note: Not added to descendants
-               nodesToVisit.add(node);
-               while (!nodesToVisit.isEmpty()) {
-                       // pick the first one
-                       IterationStrategyNode visiting = 
nodesToVisit.iterator().next();
-                       visitedNodes.add(visiting);
-                       nodesToVisit.remove(visiting);
-
-                       // Find new and interesting children
-                       List<IterationStrategyNode> children = 
visiting.getChildren();
-                       Set<IterationStrategyNode> newNodes = new 
HashSet<IterationStrategyNode>(
-                                       children);
-                       newNodes.removeAll(visitedNodes);
-
-                       descendants.addAll(newNodes);
-                       nodesToVisit.addAll(newNodes);
-               }
-               return descendants;
-       }
-
-       private static Logger logger = Logger
-                       .getLogger(IterationStrategyEditorControl.class);
-
-       private IterationStrategyNode selectedNode = null;
-
-       private IterationStrategyTree tree;
-
-       protected AddCrossAction addCross = new AddCrossAction();
-       protected AddDotAction addDot = new AddDotAction();
-       protected ChangeAction change = new ChangeAction();
-       protected NormalizeAction normalize = new NormalizeAction();
-       protected RemoveAction remove = new RemoveAction();
-       protected MoveUpAction moveUp = new MoveUpAction();
-
-       //private static final int ICON_SIZE = 15;
-
-       protected ImageIcon arrowUpIcon = WorkbenchIcons.upArrowIcon;
-       protected ImageIcon arrowDownIcon = WorkbenchIcons.downArrowIcon;
-       //protected ImageIcon arrowLeft = WorkbenchIcons.leftArrowIcon;
-       //protected ImageIcon arrowRight = WorkbenchIcons.rightArrowIcon;
-       protected ImageIcon normalizeIcon = WorkbenchIcons.normalizeIcon;
-
-       private final IterationStrategy strategy;
-
-       /**
-        * Create a new panel from the supplied iteration strategy
-        */
-       public IterationStrategyEditorControl(IterationStrategy strategy) {
-
-               this.strategy = strategy;
-               setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
-
-               // Create the components
-               tree = new IterationStrategyEditor(strategy);
-
-               JButton addCrossButton = new JButton(addCross);
-               addCrossButton.setHorizontalAlignment(SwingConstants.LEFT);
-               JButton addDotButton = new JButton(addDot);
-               addDotButton.setHorizontalAlignment(SwingConstants.LEFT);
-               JButton normalizeButton = new JButton(normalize);
-               normalizeButton.setHorizontalAlignment(SwingConstants.LEFT);
-               normalizeButton.setIcon(normalizeIcon);
-               JButton removeButton = new JButton(remove);
-               removeButton.setHorizontalAlignment(SwingConstants.LEFT);
-               JButton changeButton = new JButton(change);
-               changeButton.setHorizontalAlignment(SwingConstants.LEFT);
-
-               JButton moveUpButton = new JButton(moveUp);
-               moveUpButton.setIcon(arrowUpIcon);
-               moveUpButton.setHorizontalAlignment(SwingConstants.LEFT);
-
-               // Set the default enabled state to off on all buttons other 
than the
-               // normalizeButton
-               // one.
-               disableButtons();
-
-               // Create a layout with the tree on the right and the buttons 
in a grid
-               // layout on the left
-               JToolBar toolbar = new JToolBar();
-               toolbar.setFloatable(false);
-               toolbar.setRollover(true);
-               // toolbar.setLayout(new GridLayout(2,2));
-               toolbar.add(normalizeButton);
-               toolbar.add(addCrossButton);
-               toolbar.add(addDotButton);
-               toolbar.add(removeButton);
-               toolbar.add(changeButton);
-               toolbar.add(moveUpButton);
-
-               toolbar.setAlignmentX(LEFT_ALIGNMENT);
-
-               // Listen to tree selection events and enable buttons 
appropriately
-               tree.addTreeSelectionListener(new ButtonEnabler());
-
-               // Add components to the control panel
-               add(toolbar);
-               JScrollPane treePane = new JScrollPane(tree);
-               //treePane.setPreferredSize(new Dimension(0, 0));
-               add(treePane);
-       }
-
-       public void setIterationStrategy(IterationStrategy iterationStrategy) {
-               tree.setIterationStrategy(iterationStrategy);
-               disableButtons();
-               selectNode(null);
-       }
-
-       private void disableButtons() {
-               remove.setEnabled(false);
-               addCross.setEnabled(false);
-               addDot.setEnabled(false);
-               change.setEnabled(false);
-       }
-
-       private IterationStrategyNode findRoot() {
-               IterationStrategyNode root = (IterationStrategyNode) 
tree.getModel()
-                               .getRoot();
-               if (root.getChildCount() > 0) {
-                       return root.getChildAt(0);
-               }
-               return root;
-       }
-
-       protected void selectNode(TreeNode newNode) {
-               DefaultTreeModel model = tree.getModel();
-               if (newNode == null) {
-                       newNode = (TreeNode) model.getRoot();
-               }
-               TreeNode[] pathToRoot = model.getPathToRoot(newNode);
-               tree.setSelectionPath(new TreePath(pathToRoot));
-       }
-
-       /**
-        * Add a cross product node as a child of the selected node
-        */
-       protected class AddCrossAction extends AbstractAction {
-
-               public AddCrossAction() {
-                       super("Add Cross", 
IterationStrategyIcons.joinIteratorIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       CrossProduct newNode = new CrossProduct();
-                       newNode.setParent(selectedNode);
-                       tree.refreshModel();
-               }
-       }
-
-       /**
-        * Add a dot product node as a child of the selected node
-        * 
-        * @author Stian Soiland-Reyes
-        * 
-        */
-       protected class AddDotAction extends AbstractAction {
-
-               public AddDotAction() {
-                       super("Add Dot", 
IterationStrategyIcons.lockStepIteratorIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       DotProduct newNode = new DotProduct();
-                       newNode.setParent(selectedNode);
-                       tree.refreshModel();
-               }
-       }
-
-       protected class ButtonEnabler implements TreeSelectionListener {
-               public void valueChanged(TreeSelectionEvent e) {
-                       TreePath selectedPath = e.getPath();
-                       IterationStrategyNode selectedObject = 
(IterationStrategyNode) selectedPath
-                                       .getLastPathComponent();
-                       selectedNode = selectedObject;
-                       if (selectedObject instanceof CrossProduct
-                                       || selectedObject instanceof 
DotProduct) {
-                               if ((selectedObject.getParent() == null) || 
(selectedObject.getParent() instanceof TerminalNode)) {
-                                       remove.setEnabled(false);
-                               } else {
-                                       remove.setEnabled(true);
-                               }
-                               if (selectedObject instanceof CrossProduct) {
-                                       change.putValue(Action.NAME, "Change to 
Dot Product");
-                                       change.putValue(Action.SMALL_ICON,
-                                                       
IterationStrategyIcons.lockStepIteratorIcon);
-                               } else {
-                                       change.putValue(Action.NAME, "Change to 
Cross Product");
-                                       change.putValue(Action.SMALL_ICON,
-                                                       
IterationStrategyIcons.joinIteratorIcon);
-                               }
-                               addCross.setEnabled(true);
-                               addDot.setEnabled(true);
-                               change.setEnabled(true);
-                       } else {
-                               // Top- or leaf node
-                               remove.setEnabled(false);
-                               addCross.setEnabled(false);
-                               addDot.setEnabled(false);
-                               change.setEnabled(false);
-                       }
-               }
-       }
-
-       /**
-        * Add a cross product node as a child of the selected node
-        */
-       protected class ChangeAction extends AbstractAction {
-
-               public ChangeAction() {
-                       super("Switch to...", 
IterationStrategyIcons.joinIteratorIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       IterationStrategyNode newNode;
-                       if (selectedNode instanceof CrossProduct) {
-                               newNode = new DotProduct();
-                       } else {
-                               newNode = new CrossProduct();
-                       }
-
-                       List<IterationStrategyNode> children = new 
ArrayList<IterationStrategyNode>(
-                                       selectedNode.getChildren());
-                       for (IterationStrategyNode child : children) {
-                               child.setParent(newNode);
-                       }
-
-                       DefaultTreeModel model = tree.getModel();
-                       if (selectedNode.getParent() == null) {
-                               model.setRoot(newNode);
-                               tree.refreshModel();
-                               newNode.setParent(null);
-                       } else {
-                               IterationStrategyNode parent = 
selectedNode.getParent();
-                               int index = parent.getIndex(selectedNode);
-                               selectedNode.setParent(null);
-                               parent.insert(newNode, index);
-                               tree.refreshModel();
-                       }
-
-                       selectNode(newNode);
-               }
-
-       }
-
-       /**
-        * Normalize the tree when the button is pressed
-        * 
-        */
-       protected class NormalizeAction extends AbstractAction {
-               public NormalizeAction() {
-                       super("Normalize", normalizeIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       strategy.normalize();
-                       // Expand all the nodes in the tree
-                       //DefaultTreeModel model = tree.getModel();
-                       tree.refreshModel();
-               }
-       }
-
-       /**
-        * Remove the selected node, moving any descendant leaf nodes to the 
parent
-        * to prevent them getting lost
-        */
-       protected class RemoveAction extends AbstractAction {
-               public RemoveAction() {
-                       super("Remove node", WorkbenchIcons.deleteIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       IterationStrategyNode nodeToBeRemoved = selectedNode;
-
-                       //DefaultTreeModel model = tree.getModel();
-
-                       // Now removeButton the candidate nodes from their 
parents and
-                       // put them back into the root node
-                       IterationStrategyNode root = findRoot();
-                       if (root == selectedNode) {
-                               return;
-                       }
-                       IterationStrategyNode oldParent = 
nodeToBeRemoved.getParent();
-
-                       for (IterationStrategyNode nodeToMove : 
descendentsOfNode(nodeToBeRemoved)) {
-                               nodeToMove.setParent(oldParent);
-                       }
-                       nodeToBeRemoved.setParent(null);
-                       tree.refreshModel();
-                       // Disable the various buttons, as the current selection
-                       // is now invalid.
-                       remove.setEnabled(false);
-                       addCross.setEnabled(false);
-                       addDot.setEnabled(false);
-                       change.setEnabled(false);
-                       selectNode(oldParent);
-               }
-       }
-
-       protected class MoveUpAction extends AbstractAction {
-
-               public MoveUpAction() {
-                       super("Move up", arrowUpIcon);
-               }
-
-               public void actionPerformed(ActionEvent e) {
-                       //DefaultTreeModel model = tree.getModel();
-
-                       IterationStrategyNode aboveNode = aboveSelectedNode();
-                       if ((aboveNode == null) || ((aboveNode instanceof 
TerminalNode) && (aboveNode.getChildCount() > 0))) {
-                               logger.warn("Can't move above top");
-                               return;
-                       }
-                       IterationStrategyNode selectedParent = 
selectedNode.getParent();
-                       IterationStrategyNode aboveParent = 
aboveNode.getParent();
-                       if (selectedParent != null && 
selectedParent.equals(aboveParent)) {
-                               // Siblings
-                               int aboveChildIndex = 
selectedParent.getIndex(aboveNode);
-                               selectedParent.insert(selectedNode, 
aboveChildIndex);
-                               tree.refreshModel();
-                               selectNode(selectedNode);
-                       } else if (aboveNode.equals(selectedParent)) {
-                               if (aboveParent instanceof TerminalNode
-                                               && 
selectedNode.getAllowsChildren()) {
-                                       aboveNode.setParent(selectedNode);
-                                       selectedNode.setParent(aboveParent);
-                                       tree.refreshModel();
-                                       selectNode(selectedNode);
-                               } else if (!(aboveParent instanceof 
TerminalNode)){
-                                       int aboveChildIndex = 
aboveParent.getIndex(aboveNode);
-                                       aboveParent.insert(selectedNode, 
aboveChildIndex);
-                                       tree.refreshModel();
-                                       selectNode(selectedNode);
-                               }
-                       } else {
-
-                       }
-
-               }
-
-       }
-
-       protected IterationStrategyNode belowSelectedNode() {
-               return offsetFromSelectedNode(1);
-       }
-
-       protected IterationStrategyNode offsetFromSelectedNode(int offset) {
-               int currentRow = tree.getRowForPath(tree.getSelectionPath());
-               int offsetRow = currentRow + offset;
-               TreePath offsetPath = tree.getPathForRow(offsetRow);
-               if (offsetPath == null) {
-                       return null;
-               }
-               IterationStrategyNode offsetNode = (IterationStrategyNode) 
offsetPath
-                               .getLastPathComponent();
-               if (offsetNode == tree.getModel().getRoot()) {
-                       return null;
-               }
-               return offsetNode;
-       }
-
-       protected IterationStrategyNode aboveSelectedNode() {
-               return offsetFromSelectedNode(-1);
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyTree.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyTree.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyTree.java
deleted file mode 100644
index 5230f87..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/editor/IterationStrategyTree.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *    
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *    
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- 
******************************************************************************/
-package net.sf.taverna.t2.workbench.iterationstrategy.editor;
-
-import java.util.Enumeration;
-
-import javax.swing.ImageIcon;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
-
-import net.sf.taverna.t2.workbench.iterationstrategy.IterationStrategyIcons;
-import net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI;
-import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
-
-@SuppressWarnings("serial")
-public class IterationStrategyTree extends JTree implements UIComponentSPI {
-
-       private IterationStrategy strategy = null;
-
-       public IterationStrategyTree() {
-               super();
-               setCellRenderer(new IterationStrategyCellRenderer());
-       }
-
-       public ImageIcon getIcon() {
-               return IterationStrategyIcons.leafnodeicon;
-       }
-
-       public void onDisplay() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void onDispose() {
-               this.strategy = null;
-               setModel(null);
-       }
-
-       public synchronized void setIterationStrategy(
-                       IterationStrategy theStrategy) {
-               if (theStrategy != this.strategy) {
-                       this.strategy = theStrategy;
-                       TreeNode terminal = theStrategy.getTerminalNode();
-                       setModel(new DefaultTreeModel(terminal));
-                       
this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
-                       expandTree();
-                       revalidate();
-               }
-       }
-       
-       protected synchronized void refreshModel() {
-               
this.getModel().nodeStructureChanged(strategy.getTerminalNode());
-               expandTree();
-       }
-
-       @Override
-       public DefaultTreeModel getModel() {
-               return (DefaultTreeModel) super.getModel();
-       }
-
-       @Override
-       public void setModel(TreeModel newModel) {
-               if (newModel != null && !(newModel instanceof 
DefaultTreeModel)) {
-                       throw new IllegalArgumentException(
-                                       "Model must be a DefaultTreeModel");
-               }
-               super.setModel(newModel);
-       }
-
-       protected void expandTree() {  
-               DefaultMutableTreeNode root =  
-               (DefaultMutableTreeNode)this.getModel().getRoot();  
-           Enumeration e = root.breadthFirstEnumeration();  
-           while(e.hasMoreElements()) {  
-               DefaultMutableTreeNode node =  
-                   (DefaultMutableTreeNode)e.nextElement();  
-               if(node.isLeaf()) continue;  
-               int row = this.getRowForPath(new TreePath(node.getPath()));  
-               this.expandRow(row);  
-           }  
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/menu/IterationStrategyConfigureMenuAction.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/menu/IterationStrategyConfigureMenuAction.java
 
b/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/menu/IterationStrategyConfigureMenuAction.java
deleted file mode 100644
index cb1c9cb..0000000
--- 
a/taverna-iteration-strategy-ui/src/main/java/net/sf/taverna/t2/workbench/iterationstrategy/menu/IterationStrategyConfigureMenuAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester   
- * 
- *  Modifications to the initial code base are copyright of their
- *  respective authors, or their employers as appropriate.
- * 
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public License
- *  as published by the Free Software Foundation; either version 2.1 of
- *  the License, or (at your option) any later version.
- *    
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *    
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.workbench.iterationstrategy.menu;
-
-import java.awt.event.ActionEvent;
-import java.net.URI;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-import 
net.sf.taverna.t2.workbench.iterationstrategy.contextview.IterationStrategyConfigurationDialog;
-import 
net.sf.taverna.t2.workbench.iterationstrategy.contextview.IterationStrategyContextualView;
-import org.apache.taverna.workflowmodel.Processor;
-
-public class IterationStrategyConfigureMenuAction extends 
AbstractContextualMenuAction {
-       
-       
-       
-       public static final URI configureRunningSection = URI
-       .create("http://taverna.sf.net/2009/contextMenu/configureRunning";);
-       
-       private static final URI ITERATION_STRATEGY_CONFIGURE_URI = URI
-       
.create("http://taverna.sf.net/2008/t2workbench/iterationStrategyConfigure";);
-
-       public IterationStrategyConfigureMenuAction() {
-               super(configureRunningSection, 40, 
ITERATION_STRATEGY_CONFIGURE_URI);
-       }
-
-       @SuppressWarnings("serial")
-       @Override
-       protected Action createAction() {
-               return new AbstractAction("List handling...") {
-                       public void actionPerformed(ActionEvent e) {
-                               Processor p = (Processor) 
getContextualSelection().getSelection();
-                               final HelpEnabledDialog dialog = new 
IterationStrategyConfigurationDialog(null, p, 
IterationStrategyContextualView.copyIterationStrategyStack(p.getIterationStrategy()));
               
-                               dialog.setVisible(true);
-                       }
-               };
-       }
-       
-       public boolean isEnabled() {
-               return super.isEnabled() && 
(getContextualSelection().getSelection() instanceof Processor);
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/IterationStrategyIcons.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/IterationStrategyIcons.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/IterationStrategyIcons.java
new file mode 100644
index 0000000..bdfe724
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/IterationStrategyIcons.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ 
******************************************************************************/
+package org.apache.taverna.workbench.iterationstrategy;
+
+import javax.swing.ImageIcon;
+
+import org.apache.log4j.Logger;
+
+public class IterationStrategyIcons {
+
+       private static Logger logger = Logger
+                       .getLogger(IterationStrategyIcons.class);
+
+       public static ImageIcon joinIteratorIcon, lockStepIteratorIcon,
+                       leafnodeicon;
+
+       static {
+               try {
+                       Class<?> c = IterationStrategyIcons.class;
+                       joinIteratorIcon = new ImageIcon(c
+                                       
.getResource("icons/crossproducticon.png"));
+                       lockStepIteratorIcon = new ImageIcon(c
+                                       
.getResource("icons/dotproducticon.png"));
+                       leafnodeicon = new ImageIcon(c
+                                       .getResource("icons/leafnodeicon.png"));
+               } catch (Exception ex) {
+                       logger.warn("Could not find icon", ex);
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
new file mode 100644
index 0000000..ef45ec3
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyConfigurationDialog.java
@@ -0,0 +1,148 @@
+/**
+ *
+ */
+package org.apache.taverna.workbench.iterationstrategy.contextview;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+
+import org.apache.taverna.workbench.edits.EditManager;
+import org.apache.taverna.workbench.file.FileManager;
+import org.apache.taverna.workbench.helper.HelpEnabledDialog;
+import 
org.apache.taverna.workbench.iterationstrategy.editor.IterationStrategyEditorControl;
+import org.apache.taverna.workflowmodel.Edit;
+import org.apache.taverna.workflowmodel.EditException;
+import org.apache.taverna.workflowmodel.Edits;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+import 
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author alanrw
+ *
+ */
+@SuppressWarnings("serial")
+public class IterationStrategyConfigurationDialog extends HelpEnabledDialog {
+
+       private static Logger logger = Logger
+       .getLogger(IterationStrategyConfigurationDialog.class);
+
+       private final EditManager editManager;
+       private final FileManager fileManager;
+
+
+       private final Frame owner;
+       private final Processor processor;
+       private final IterationStrategyStack originalStack;
+
+       private IterationStrategyStack workingStack;
+
+       public IterationStrategyConfigurationDialog(Frame owner, Processor 
processor, IterationStrategyStack iStack, EditManager editManager, FileManager 
fileManager) {
+               super (owner, "List handling for " + processor.getLocalName(), 
true, null);
+               this.owner = owner;
+               this.processor = processor;
+               this.originalStack = iStack;
+               this.editManager = editManager;
+               this.fileManager = fileManager;
+               this.workingStack = 
IterationStrategyContextualView.copyIterationStrategyStack(originalStack);
+               IterationStrategy iterationStrategy = 
IterationStrategyContextualView.getIterationStrategy(workingStack);
+               IterationStrategyEditorControl iterationStrategyEditorControl = 
new IterationStrategyEditorControl(
+                               iterationStrategy);
+               this.add(iterationStrategyEditorControl, BorderLayout.CENTER);
+
+               JPanel buttonPanel = new JPanel();
+               buttonPanel.setLayout(new FlowLayout());
+
+               JButton okButton = new JButton(new OKAction(this));
+               buttonPanel.add(okButton);
+
+               JButton resetButton = new JButton(new ResetAction(
+                               iterationStrategyEditorControl));
+               buttonPanel.add(resetButton);
+
+               JButton cancelButton = new JButton(new CancelAction(this));
+               buttonPanel.add(cancelButton);
+
+               this.add(buttonPanel, BorderLayout.SOUTH);
+               this.pack();
+               this.setSize(new Dimension(getPreferredSize().width, 
getPreferredSize().height > 400 ? 400 : getPreferredSize().height));
+       }
+
+       private final class OKAction extends AbstractAction {
+               private final JDialog dialog;
+
+               private OKAction(JDialog dialog) {
+                       super("OK");
+                       this.dialog = dialog;
+               }
+
+               public void actionPerformed(ActionEvent e) {
+                       Edits edits = editManager.getEdits();
+                       try {
+                               Edit<?> edit = 
edits.getSetIterationStrategyStackEdit(
+                                               processor,
+                                               
IterationStrategyContextualView.copyIterationStrategyStack(workingStack));
+                               editManager.doDataflowEdit(
+                                               
fileManager.getCurrentDataflow(), edit);
+                               dialog.setVisible(false);
+                       } catch (RuntimeException ex) {
+                               logger.warn("Could not set list handling", ex);
+                               JOptionPane.showMessageDialog(owner,
+                                               "Can't set list handling",
+                                               "An error occured when setting 
list handling: "
+                                                               + 
ex.getMessage(),
+                                               JOptionPane.ERROR_MESSAGE);
+                       } catch (EditException ex) {
+                               logger.warn("Could not set list handling", ex);
+                               JOptionPane.showMessageDialog(owner,
+                                               "Can't set list handling",
+                                               "An error occured when setting 
list handling: "
+                                                               + 
ex.getMessage(),
+                                               JOptionPane.ERROR_MESSAGE);
+                       }
+               }
+       }
+
+       private final class ResetAction extends AbstractAction {
+               private final IterationStrategyEditorControl 
strategyEditorControl;
+
+               private ResetAction(
+                               IterationStrategyEditorControl 
strategyEditorControl) {
+                       super("Reset");
+                       this.strategyEditorControl = strategyEditorControl;
+               }
+
+               public void actionPerformed(ActionEvent e) {
+                       workingStack = 
IterationStrategyContextualView.copyIterationStrategyStack(originalStack);
+                       strategyEditorControl
+                                       
.setIterationStrategy(IterationStrategyContextualView.getIterationStrategy(workingStack));
+               }
+
+       }
+
+       private final class CancelAction extends AbstractAction {
+               private final JDialog dialog;
+
+               private CancelAction(JDialog dialog) {
+                       super("Cancel");
+                       this.dialog = dialog;
+               }
+
+               public void actionPerformed(ActionEvent e) {
+                       dialog.setVisible(false);
+               }
+
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
new file mode 100644
index 0000000..2f516ef
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualView.java
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ 
******************************************************************************/
+/**
+ *
+ */
+package org.apache.taverna.workbench.iterationstrategy.contextview;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JComponent;
+
+import org.apache.taverna.workbench.edits.EditManager;
+import org.apache.taverna.workbench.file.FileManager;
+import org.apache.taverna.workbench.helper.HelpEnabledDialog;
+import 
org.apache.taverna.workbench.iterationstrategy.editor.IterationStrategyTree;
+import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView;
+import org.apache.taverna.workflowmodel.Processor;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+import 
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack;
+import 
org.apache.taverna.workflowmodel.processor.iteration.impl.IterationStrategyImpl;
+import 
org.apache.taverna.workflowmodel.processor.iteration.impl.IterationStrategyStackImpl;
+
+import org.apache.log4j.Logger;
+import org.jdom.Content;
+import org.jdom.Element;
+import org.jdom.filter.ElementFilter;
+
+/**
+ * Contextual view of an {@link IterationStrategyStack}.
+ *
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class IterationStrategyContextualView extends ContextualView {
+
+       private static Logger logger = Logger
+                       .getLogger(IterationStrategyContextualView.class);
+
+       private EditManager editManager;
+
+       private FileManager fileManager;
+
+       private IterationStrategyStack iterationStack;
+
+       private final Processor processor;
+
+       private IterationStrategyTree strategyTree = new 
IterationStrategyTree();
+
+       static {
+
+// This should be enabled and modified for T2-822
+/*             editManager.addObserver(new Observer<EditManagerEvent> () {
+
+                       private void examineEdit(Edit edit) {
+                               if (edit instanceof ConnectDatalinkEdit) {
+                                       
processConnectDatalinkEdit((ConnectDatalinkEdit) edit);
+                               }
+                               if (edit instanceof CompoundEdit) {
+                                       processCompoundEdit((CompoundEdit) 
edit);
+                               }
+                       }
+
+                       private void 
processConnectDatalinkEdit(ConnectDatalinkEdit edit) {
+                               Datalink d = ((ConnectDatalinkEdit) 
edit).getSubject();
+                               EventHandlingInputPort sink = d.getSink();
+                               if (sink instanceof ProcessorInputPort) {
+                                       ProcessorInputPort pip = 
(ProcessorInputPort) sink;
+                                       Processor p = pip.getProcessor();
+                                       final HelpEnabledDialog dialog = new 
IterationStrategyConfigurationDialog(null, p, 
copyIterationStrategyStack(p.getIterationStrategy()));
+                                       dialog.setVisible(true);
+                               }
+                       }
+
+                       private void processCompoundEdit(CompoundEdit edit) {
+                               for (Edit e : edit.getChildEdits()) {
+                                       examineEdit(e);
+                               }
+                       }
+
+                       @Override
+                       public void notify(Observable<EditManagerEvent> sender,
+                                       EditManagerEvent message) throws 
Exception {
+                               if (!(message instanceof DataflowEditEvent)) {
+                                       return;
+                               }
+                               examineEdit(message.getEdit());
+                       }});*/
+       }
+
+       public IterationStrategyContextualView(Processor processor, EditManager 
editManager, FileManager fileManager) {
+               if (processor == null || processor.getIterationStrategy() == 
null) {
+                       throw new NullPointerException(
+                                       "Iteration strategy stack can't be 
null");
+               }
+               this.processor = processor;
+               this.editManager = editManager;
+               this.fileManager = fileManager;
+               refreshIterationStrategyStack();
+               initView();
+       }
+
+       @Override
+       public Action getConfigureAction(final Frame owner) {
+               return new ConfigureIterationStrategyAction(owner);
+       }
+
+       public Processor getProcessor() {
+               return processor;
+       }
+
+       @Override
+       public void refreshView() {
+               refreshIterationStrategyStack();
+               
strategyTree.setIterationStrategy(getIterationStrategy(iterationStack));
+       }
+
+       public static IterationStrategyStack copyIterationStrategyStack(
+                       IterationStrategyStack stack) {
+               Element asXML = ((IterationStrategyStackImpl)stack).asXML();
+               stripEmptyElements(asXML);
+               IterationStrategyStackImpl copyStack = new 
IterationStrategyStackImpl();
+               copyStack.configureFromElement(asXML);
+               if (copyStack.getStrategies().isEmpty()) {
+                       copyStack.addStrategy(new IterationStrategyImpl());
+               }
+               return copyStack;
+       }
+
+       private static void stripEmptyElements(Element asXML) {
+               int childCount = asXML.getContent().size();
+               int index = 0;
+               while (index < childCount) {
+                       Content child = asXML.getContent(index);
+                       if (child instanceof Element) {
+                               Element childElement = (Element) child;
+                               if (childElement.getName().equals("port")) {
+                                       index++;
+                               }
+                               else if (childElement.getDescendants(new 
ElementFilter("port")).hasNext()) {
+                                       stripEmptyElements(childElement);
+                                       index++;
+                               } else {
+                                       asXML.removeContent(childElement);
+                                       childCount--;
+                               }
+                       }
+               }
+       }
+
+       public static IterationStrategy 
getIterationStrategy(IterationStrategyStack iStack) {
+               List<? extends IterationStrategy> strategies = iStack
+                               .getStrategies();
+               if (strategies.isEmpty()) {
+                       throw new IllegalStateException("Empty iteration 
stack");
+               }
+               IterationStrategy strategy = strategies.get(0);
+               if (!(strategy instanceof IterationStrategyImpl)) {
+                       throw new IllegalStateException(
+                                       "Can't edit unknown iteration strategy 
implementation "
+                                                       + strategy);
+               }
+               return (IterationStrategyImpl) strategy;
+       }
+
+       private void refreshIterationStrategyStack() {
+               IterationStrategyStack originalIterationStrategy = processor
+                               .getIterationStrategy();
+               if (!(originalIterationStrategy instanceof 
IterationStrategyStackImpl)) {
+                       throw new IllegalStateException(
+                                       "Unknown iteration strategy 
implementation "
+                                                       + 
originalIterationStrategy);
+               }
+               this.iterationStack = 
copyIterationStrategyStack((IterationStrategyStackImpl) 
originalIterationStrategy);
+       }
+
+       @Override
+       public JComponent getMainFrame() {
+               refreshView();
+               return strategyTree;
+       }
+
+       @Override
+       public String getViewTitle() {
+               return "List handling";
+       }
+
+       private final class ConfigureIterationStrategyAction extends 
AbstractAction {
+               private final Frame owner;
+
+               private ConfigureIterationStrategyAction(Frame owner) {
+                       super("Configure");
+                       this.owner = owner;
+               }
+
+               public void actionPerformed(ActionEvent e) {
+                       final HelpEnabledDialog dialog = new 
IterationStrategyConfigurationDialog(owner, processor, iterationStack, 
editManager, fileManager);
+                       dialog.setVisible(true);
+                       refreshView();
+               }
+
+
+
+       }
+
+       @Override
+       public int getPreferredPosition() {
+               return 200;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
new file mode 100644
index 0000000..412e081
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/contextview/IterationStrategyContextualViewFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester
+ *
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ 
******************************************************************************/
+package org.apache.taverna.workbench.iterationstrategy.contextview;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.taverna.workbench.edits.EditManager;
+import org.apache.taverna.workbench.file.FileManager;
+import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView;
+import 
org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
+import org.apache.taverna.workflowmodel.Processor;
+
+public class IterationStrategyContextualViewFactory implements
+               ContextualViewFactory<Processor> {
+
+       private EditManager editManager;
+       private FileManager fileManager;
+
+       public boolean canHandle(Object selection) {
+               return selection instanceof Processor;
+       }
+
+       public List<ContextualView> getViews(Processor p) {
+               return Arrays.asList(new ContextualView[] {new 
IterationStrategyContextualView(p, editManager, fileManager)});
+       }
+
+       public void setEditManager(EditManager editManager) {
+               this.editManager = editManager;
+       }
+
+       public void setFileManager(FileManager fileManager) {
+               this.fileManager = fileManager;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
new file mode 100644
index 0000000..4be3997
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyCellRenderer.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ 
******************************************************************************/
+/**
+ * 
+ */
+package org.apache.taverna.workbench.iterationstrategy.editor;
+
+import java.awt.Component;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import org.apache.taverna.workbench.icons.WorkbenchIcons;
+import org.apache.taverna.workbench.iterationstrategy.IterationStrategyIcons;
+import org.apache.taverna.workflowmodel.processor.iteration.CrossProduct;
+import org.apache.taverna.workflowmodel.processor.iteration.DotProduct;
+import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
+
+import org.apache.log4j.Logger;
+
+@SuppressWarnings("serial")
+final class IterationStrategyCellRenderer extends DefaultTreeCellRenderer {
+
+       @SuppressWarnings("unused")
+       private static Logger logger = Logger
+                       .getLogger(IterationStrategyCellRenderer.class);
+
+       @Override
+       public Component getTreeCellRendererComponent(JTree tree, Object value,
+                       boolean selected, boolean expanded, boolean leaf, int 
row,
+                       boolean hasFocus) {
+               super.getTreeCellRendererComponent(tree, value, selected, 
expanded,
+                               leaf, row, hasFocus);
+               if (value instanceof CrossProduct) {
+                       setIcon(IterationStrategyIcons.joinIteratorIcon);
+                       setText("Cross product");
+               } else if (value instanceof DotProduct) {
+                       setIcon(IterationStrategyIcons.lockStepIteratorIcon);
+                       setText("Dot product");
+               } else if (value instanceof NamedInputPortNode) {
+                       setIcon(IterationStrategyIcons.leafnodeicon);
+                       NamedInputPortNode namedInput = (NamedInputPortNode) 
value;
+                       setText(namedInput.getPortName());
+               } else {
+                       setText("List handling");
+                       if (!leaf){
+                               if (expanded) {
+                                       setIcon(WorkbenchIcons.folderOpenIcon);
+                               } else {
+                                       
setIcon(WorkbenchIcons.folderClosedIcon);
+                               }
+                       }
+               }
+               return this;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyEditor.java
----------------------------------------------------------------------
diff --git 
a/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyEditor.java
 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyEditor.java
new file mode 100644
index 0000000..695fd0b
--- /dev/null
+++ 
b/taverna-iteration-strategy-ui/src/main/java/org/apache/taverna/workbench/iterationstrategy/editor/IterationStrategyEditor.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ 
******************************************************************************/
+package org.apache.taverna.workbench.iterationstrategy.editor;
+
+import java.awt.GraphicsEnvironment;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+//import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+import javax.swing.DropMode;
+import javax.swing.JComponent;
+import javax.swing.JTree;
+import javax.swing.TransferHandler;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.apache.taverna.workbench.ui.zaria.UIComponentSPI;
+import 
org.apache.taverna.workflowmodel.processor.iteration.AbstractIterationStrategyNode;
+import org.apache.taverna.workflowmodel.processor.iteration.IterationStrategy;
+import org.apache.taverna.workflowmodel.processor.iteration.NamedInputPortNode;
+import org.apache.taverna.workflowmodel.processor.iteration.TerminalNode;
+
+import org.apache.log4j.Logger;
+
+@SuppressWarnings("serial")
+public class IterationStrategyEditor extends IterationStrategyTree implements
+               UIComponentSPI {
+
+       private static Logger logger = Logger
+                       .getLogger(IterationStrategyEditor.class);
+
+       //private BufferedImage imgGhost; // The 'drag image'
+
+       // mouse was clicked
+
+       public IterationStrategyEditor() {
+               super();
+               // Make this a drag source
+               if (!GraphicsEnvironment.isHeadless()) {
+                       this.setDragEnabled(true);  
+               this.setDropMode(DropMode.ON_OR_INSERT);  
+               this.setTransferHandler(new TreeTransferHandler());  
+               this.getSelectionModel().setSelectionMode(  
+                       TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);  
+               expandTree();
+               }
+
+               //
+       }
+
+       public IterationStrategyEditor(IterationStrategy theStrategy) {
+               this();
+               setIterationStrategy(theStrategy);
+       }
+
+    /**
+     * 
+     * This code is freely adapted from code derived 
+     *
+     */
+    class TreeTransferHandler extends TransferHandler {  
+        DataFlavor nodesFlavor;
+        DataFlavor[] flavors = new DataFlavor[1];  
+       
+        public TreeTransferHandler() {
+               getNodesFlavor();
+          }
+        
+        private DataFlavor getNodesFlavor() {
+               if (nodesFlavor == null) {
+                try {  
+                     nodesFlavor = new 
DataFlavor(DataFlavor.javaJVMLocalObjectMimeType +
+                             ";class=" + 
AbstractIterationStrategyNode.class.getName(),
+                             "AbstractIterationStrategyNode",
+                             this.getClass().getClassLoader());  
+                    flavors[0] = nodesFlavor;  
+                } catch(Exception e) {  
+                    logger.error("Problem creating nodesFlavor:" + e);
+                }                      
+               }
+               return nodesFlavor;
+        }
+       
+        public boolean canImport(TransferHandler.TransferSupport support) {  
+            if(!support.isDrop()) {
+               logger.error("isDrop not supported");
+                return false;  
+            }  
+
+            if(!support.isDataFlavorSupported(getNodesFlavor())) {
+               logger.info("Not correct flavor");
+                return false;  
+            }  
+            // Do not allow a drop on the drag source selections.  
+            JTree.DropLocation dl =  
+                    (JTree.DropLocation)support.getDropLocation();  
+            TreePath dest = dl.getPath();  
+            AbstractIterationStrategyNode destination =  
+                (AbstractIterationStrategyNode)dest.getLastPathComponent();
+            Transferable t = support.getTransferable();
+            if (destination instanceof TerminalNode) {
+               return false;
+            }
+            try {
+                               AbstractIterationStrategyNode node = 
(AbstractIterationStrategyNode) t.getTransferData(getNodesFlavor());
+                               if (node.isNodeDescendant(destination)) {
+                                       return false;
+                               }
+                       } catch (UnsupportedFlavorException e) {
+                               return false;
+                       } catch (IOException e) {
+                               return false;
+                       }  
+//                     JTree tree = (JTree) support.getComponent();
+//                     int dropRow = tree.getRowForPath(dl.getPath());
+//                     int selRow = tree.getLeadSelectionRow();
+//                     if (selRow == dropRow) {
+//                             logger.info("Dragging to source");
+//                             return false;
+//
+//                     }
+                       support.setShowDropLocation(true);  
+            return true;  
+        }  
+       
+         protected Transferable createTransferable(JComponent c) {  
+            JTree tree = (JTree)c;  
+            TreePath[] paths = tree.getSelectionPaths();  
+            if(paths != null) {  
+                AbstractIterationStrategyNode node =  
+                    
(AbstractIterationStrategyNode)paths[0].getLastPathComponent();  
+                 return new NodeTransferable(node);  
+            }  
+            return null;  
+        }  
+              
+        protected void exportDone(JComponent source, Transferable data, int 
action) {  
+        }  
+       
+        public int getSourceActions(JComponent c) {  
+            return MOVE;  
+        }  
+       
+        public boolean importData(TransferHandler.TransferSupport support) { 
+            if(!canImport(support)) {
+               logger.info("Cannot import");
+                return false;  
+            }  
+            // Extract transfer data.  
+            AbstractIterationStrategyNode node = null;  
+            try {  
+                Transferable t = support.getTransferable();  
+                node = (AbstractIterationStrategyNode) 
t.getTransferData(getNodesFlavor());  
+            } catch(UnsupportedFlavorException ufe) {  
+                logger.error("UnsupportedFlavor", ufe);  
+            } catch (Exception e) {
+               logger.error("Problem getting transfer data", e);
+            }
+
+           // Get drop location info.  
+            JTree.DropLocation dl =  
+                    (JTree.DropLocation)support.getDropLocation();  
+            int childIndex = dl.getChildIndex();  
+            TreePath dest = dl.getPath();  
+            AbstractIterationStrategyNode parent =  
+                (AbstractIterationStrategyNode)dest.getLastPathComponent();
+            int index = childIndex;
+            logger.info ("parent is a " + parent.getClass().getName());
+            if (parent instanceof NamedInputPortNode) {
+               AbstractIterationStrategyNode sibling = parent;
+               parent = (AbstractIterationStrategyNode) sibling.getParent();
+               index = parent.getIndex(sibling);
+            } else if (index == -1) {
+               index = parent.getChildCount();
+            }
+            if (parent instanceof TerminalNode) {
+               if (parent.getChildCount() > 0) {
+                       parent = (AbstractIterationStrategyNode) 
parent.getChildAt(0);
+                       index = parent.getChildCount();
+               }
+               
+            }
+            logger.info("parent is a " + parent.getClass().getName());
+
+                       try {
+                               // The parent insert removes from the oldParent
+                               parent.insert(node, index++);
+                               DefaultTreeModel model = 
IterationStrategyEditor.this
+                                               .getModel();
+                               refreshModel();
+                       } catch (IllegalStateException e) {
+                               logger.error(e);
+                       } catch (IllegalArgumentException e) {
+                               logger.error(e);
+                       }
+          return true;  
+        }  
+       
+        public String toString() {  
+            return getClass().getName();  
+        }  
+       
+        public class NodeTransferable implements Transferable {  
+            AbstractIterationStrategyNode node;  
+       
+            public NodeTransferable(AbstractIterationStrategyNode node) {  
+                this.node = node;  
+             }  
+       
+            public AbstractIterationStrategyNode getTransferData(DataFlavor 
flavor)  
+                                     throws UnsupportedFlavorException {  
+                if(!isDataFlavorSupported(flavor))  
+                    throw new UnsupportedFlavorException(flavor);  
+                return node;  
+            }  
+       
+            public DataFlavor[] getTransferDataFlavors() {  
+                return flavors;  
+            }  
+       
+            public boolean isDataFlavorSupported(DataFlavor flavor) {
+                return getNodesFlavor().equals(flavor);  
+            }  
+        }  
+    }
+}

Reply via email to