You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 12:45:48 UTC
[24/52] [abbrv] incubator-taverna-workbench git commit:
taverna-ui-impl/
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java
deleted file mode 100644
index 8bac354..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java
+++ /dev/null
@@ -1,75 +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
- ******************************************************************************/
-
-/**
- * @author Alan R Williams
- */
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry;
-
-/**
- * An SPI registry for discovering ActivityViewFactories for a given object,
- * like an {@link net.sf.taverna.t2.workflowmodel.processor.activity.Activity}.
- * <p>
- * For {@link ContextualViewFactory factories} to be found, its full qualified
- * name needs to be defined as a resource file
- * <code>/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualViewFactory</code>
- *
- * @author Stuart Owen
- * @author Ian Dunlop
- * @author Stian Soiland-Reyes
- *
- * @see ContextualViewFactory
- */
-public class ContextualViewFactoryRegistryImpl implements
- ContextualViewFactoryRegistry {
- private List<ContextualViewFactory<?>> contextualViewFactories;
-
- /**
- * Discover and return the ContextualViewFactory associated to the provided
- * object. This is accomplished by returning the discovered
- * {@link ContextualViewFactory#canHandle(Object)} that returns true for
- * that Object.
- *
- * @param object
- * @return
- * @see ContextualViewFactory#canHandle(Object)
- */
- @Override
- public List<ContextualViewFactory<?>> getViewFactoriesForObject(
- Object object) {
- List<ContextualViewFactory<?>> result = new ArrayList<>();
- for (ContextualViewFactory<?> factory : contextualViewFactories)
- if (factory.canHandle(object))
- result.add(factory);
- return result;
- }
-
- public void setContextualViewFactories(
- List<ContextualViewFactory<?>> contextualViewFactories) {
- this.contextualViewFactories = contextualViewFactories;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualView.java
deleted file mode 100644
index 018a121..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualView.java
+++ /dev/null
@@ -1,263 +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.ui.views.contextualviews.annotated;
-
-import static javax.swing.BoxLayout.Y_AXIS;
-
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-import java.util.regex.Pattern;
-
-import javax.swing.BoxLayout;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.TitledBorder;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.lang.ui.DialogTextArea;
-import net.sf.taverna.t2.workbench.edits.CompoundEdit;
-import net.sf.taverna.t2.workbench.edits.Edit;
-import net.sf.taverna.t2.workbench.edits.EditException;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.impl.ContextualViewComponent;
-
-import org.apache.log4j.Logger;
-
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * This is a ContextualView that should be able to display and allow editing of
- * Annotation information for any Annotated. At the moment it is only used for
- * Dataflow.
- *
- * @author Alan R Williams
- */
-@SuppressWarnings("serial")
-class AnnotatedContextualView extends ContextualView {
- private static final int WORKFLOW_NAME_LENGTH = 20;
- public static final String VIEW_TITLE = "Annotations";
- private final static String MISSING_VALUE = "Type here to give details";
- private final static int DEFAULT_AREA_WIDTH = 60;
- private final static int DEFAULT_AREA_ROWS = 8;
-
- private static Logger logger = Logger
- .getLogger(AnnotatedContextualView.class);
- private static PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle
- .getBundle("annotatedcontextualview");
-
- // TODO convert to scufl2
- // private static AnnotationTools annotationTools = new AnnotationTools();
-
- /**
- * The object to which the Annotations apply
- */
- private Annotated<?> annotated;
- private SelectionManager selectionManager;
- private EditManager editManager;
- private boolean isStandalone = false;
- private JPanel panel;
- @SuppressWarnings("unused")
- private final List<AnnotationBeanSPI> annotationBeans;
-
- public AnnotatedContextualView(Annotated<?> annotated,
- EditManager editManager, SelectionManager selectionManager,
- List<AnnotationBeanSPI> annotationBeans) {
- super();
- this.editManager = editManager;
- this.selectionManager = selectionManager;
- this.annotationBeans = annotationBeans;
- this.annotated = annotated;
-
- initialise();
- initView();
- }
-
- @Override
- public void refreshView() {
- initialise();
- }
-
- private void initialise() {
- if (panel == null) {
- panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, Y_AXIS));
- } else
- panel.removeAll();
- populatePanel();
- revalidate();
- }
-
- @Override
- public JComponent getMainFrame() {
- return panel;
- }
-
- @Override
- public String getViewTitle() {
- return VIEW_TITLE;
- }
-
- private Map<String,String> getAnnotations() {
- // TODO convert to scufl2
- Map<String, String> result = new HashMap<>();
- //for (Class<?> c : annotationTools.getAnnotatingClasses(annotated)) {
- // String name = "";
- // try {
- // name = prb.getString(c.getCanonicalName());
- // } catch (MissingResourceException e) {
- // name = c.getCanonicalName();
- // }
- // String value = annotationTools.getAnnotationString(annotated, c,
- // MISSING_VALUE);
- // result.put(name,value);
- //}
- return result;
- }
- public void populatePanel() {
- JPanel scrollPanel = new JPanel();
- scrollPanel.setLayout(new BoxLayout(scrollPanel, Y_AXIS));
- panel.setBorder(new EmptyBorder(5, 5, 5, 5));
- Map<String,String>annotations = getAnnotations();
- for (String name : annotations.keySet()) {
- JPanel subPanel = new JPanel();
- subPanel.setBorder(new TitledBorder(name));
- subPanel.add(createTextArea(String.class, annotations.get(name)));
- scrollPanel.add(subPanel);
- }
- JScrollPane scrollPane = new JScrollPane(scrollPanel);
- panel.add(scrollPane);
- }
-
- private JScrollPane createTextArea(Class<?> c, String value) {
- DialogTextArea area = new DialogTextArea(value);
- area.setFocusable(true);
- area.addFocusListener(new TextAreaFocusListener(area, c));
- area.setColumns(DEFAULT_AREA_WIDTH);
- area.setRows(DEFAULT_AREA_ROWS);
- area.setLineWrap(true);
- area.setWrapStyleWord(true);
-
- return new JScrollPane(area);
- }
-
- private class TextAreaFocusListener implements FocusListener {
- String oldValue = null;
- Class<?> annotationClass;
- DialogTextArea area = null;
-
- public TextAreaFocusListener(DialogTextArea area, Class<?> c) {
- annotationClass = c;
- oldValue = area.getText();
- this.area = area;
- }
-
- @Override
- public void focusGained(FocusEvent e) {
- if (area.getText().equals(MISSING_VALUE))
- area.setText("");
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- String currentValue = area.getText();
- if (currentValue.isEmpty() || currentValue.equals(MISSING_VALUE)) {
- currentValue = MISSING_VALUE;
- area.setText(currentValue);
- }
- if (!currentValue.equals(oldValue)) {
- if (currentValue == MISSING_VALUE)
- currentValue = "";
- try {
- WorkflowBundle currentDataflow = selectionManager
- .getSelectedWorkflowBundle();
- List<Edit<?>> editList = new ArrayList<>();
- addWorkflowNameEdits(currentValue, currentDataflow,
- editList);
- if (!isStandalone)
- ContextualViewComponent.selfGenerated = true;
- editManager.doDataflowEdit(currentDataflow,
- new CompoundEdit(editList));
- ContextualViewComponent.selfGenerated = false;
- } catch (EditException e1) {
- logger.warn("Can't set annotation", e1);
- }
- oldValue = area.getText();
- }
- }
-
- private boolean isTitleAnnotation() {
- // TODO convert to scufl2
- return prb.getString(annotationClass.getCanonicalName()).equals(
- "Title");
- }
-
- // TODO convert to scufl2
- private void addWorkflowNameEdits(String currentValue,
- WorkflowBundle currentDataflow, List<Edit<?>> editList) {
- //editList.add(annotationTools.setAnnotationString(annotated,
- // annotationClass, currentValue, edits));
- if (annotated == currentDataflow && isTitleAnnotation()
- && !currentValue.isEmpty()) {
- @SuppressWarnings("unused")
- String sanitised = sanitiseName(currentValue);
- //editList.add(edits.getUpdateDataflowNameEdit(currentDataflow,
- // sanitised));
- }
- }
- }
-
- /**
- * Checks that the name does not have any characters that are invalid for a
- * processor name.
- * <p>
- * The resulting name must contain only the chars [A-Za-z_0-9].
- *
- * @param name
- * the original name
- * @return the sanitised name
- */
- private static String sanitiseName(String name) {
- if (name.length() > WORKFLOW_NAME_LENGTH)
- name = name.substring(0, WORKFLOW_NAME_LENGTH);
- if (Pattern.matches("\\w++", name))
- return name;
- StringBuilder temp = new StringBuilder();
- for (char c : name.toCharArray())
- temp.append(Character.isLetterOrDigit(c) || c == '_' ? c : '_');
- return temp.toString();
- }
-
- @Override
- public int getPreferredPosition() {
- return 500;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualViewFactory.java
deleted file mode 100644
index eb18803..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/annotated/AnnotatedContextualViewFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.annotated;
-
-import static java.util.Collections.singletonList;
-
-import java.util.List;
-
-import net.sf.taverna.t2.annotation.Annotated;
-import net.sf.taverna.t2.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
-
-public class AnnotatedContextualViewFactory implements
- ContextualViewFactory<Annotated<?>> {
- private EditManager editManager;
- private List<AnnotationBeanSPI> annotationBeans;
- private SelectionManager selectionManager;
-
- @Override
- public boolean canHandle(Object selection) {
- return ((selection instanceof Annotated) && !(selection instanceof Activity));
- }
-
- @Override
- public List<ContextualView> getViews(Annotated<?> selection) {
- return singletonList((ContextualView) new AnnotatedContextualView(
- selection, editManager, selectionManager, annotationBeans));
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
- public void setAnnotationBeans(List<AnnotationBeanSPI> annotationBeans) {
- this.annotationBeans = annotationBeans;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualView.java
deleted file mode 100644
index f9308b5..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualView.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.ui.views.contextualviews.condition;
-
-import java.awt.FlowLayout;
-
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import uk.org.taverna.scufl2.api.core.BlockingControlLink;
-
-/**
- * Contextual view for dataflow's control (condition) links.
- *
- * @author David Withers
- */
-class ConditionContextualView extends ContextualView {
- private static final long serialVersionUID = -894521200616176439L;
-
- private final BlockingControlLink condition;
- private JPanel contitionView;
-
- public ConditionContextualView(BlockingControlLink condition) {
- this.condition = condition;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- refreshView();
- return contitionView;
- }
-
- @Override
- public String getViewTitle() {
- return "Control link: " + condition.getBlock().getName()
- + " runs after " + condition.getUntilFinished().getName();
- }
-
- @Override
- public void refreshView() {
- contitionView = new JPanel(new FlowLayout(FlowLayout.LEFT));
- contitionView.setBorder(new EmptyBorder(5, 5, 5, 5));
- JLabel label = new JLabel(
- "<html><body><i>No details available.</i></body><html>");
- contitionView.add(label);
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualViewFactory.java
deleted file mode 100644
index ea69f1a..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/condition/ConditionContextualViewFactory.java
+++ /dev/null
@@ -1,51 +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.ui.views.contextualviews.condition;
-
-import static java.util.Arrays.asList;
-
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import net.sf.taverna.t2.workflowmodel.Condition;
-import uk.org.taverna.scufl2.api.core.BlockingControlLink;
-
-/**
- * A factory of contextual views for dataflow's condition links.
- *
- * @author David Withers
- *
- */
-public class ConditionContextualViewFactory implements
- ContextualViewFactory<BlockingControlLink> {
- @Override
- public boolean canHandle(Object object) {
- return object instanceof Condition;
- }
-
- @Override
- public List<ContextualView> getViews(BlockingControlLink condition) {
- return asList(new ContextualView[] { new ConditionContextualView(
- condition) });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualView.java
deleted file mode 100644
index 4a63868..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualView.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflow;
-
-import static net.sf.taverna.t2.lang.ui.HtmlUtils.buildTableOpeningTag;
-import static net.sf.taverna.t2.lang.ui.HtmlUtils.createEditorPane;
-import static net.sf.taverna.t2.lang.ui.HtmlUtils.getHtmlHead;
-import static net.sf.taverna.t2.lang.ui.HtmlUtils.panelForHtml;
-
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-
-import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-
-/**
- * @author alanrw
- */
-@SuppressWarnings("serial")
-class DataflowContextualView extends ContextualView {
- private static int MAX_LENGTH = 50;
- private static final String ELLIPSIS = "...";
-
- private Workflow dataflow;
- private JEditorPane editorPane;
- private final FileManager fileManager;
- private final ColourManager colourManager;
-
- public DataflowContextualView(Workflow dataflow, FileManager fileManager,
- ColourManager colourManager) {
- this.dataflow = dataflow;
- this.fileManager = fileManager;
- this.colourManager = colourManager;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- editorPane = createEditorPane(buildHtml());
- return panelForHtml(editorPane);
- }
-
- private String buildHtml() {
- StringBuilder html = new StringBuilder(getHtmlHead(getBackgroundColour()));
- html.append(buildTableOpeningTag());
-
- html.append("<tr><td colspan=\"2\" align=\"center\"><b>Source</b></td></tr>");
- String source = "Newly created";
- if (fileManager.getDataflowSource(dataflow.getParent()) != null)
- source = fileManager.getDataflowName(dataflow.getParent());
-
- html.append("<tr><td colspan=\"2\" align=\"center\">").append(source)
- .append("</td></tr>");
- if (!dataflow.getInputPorts().isEmpty()) {
- html.append("<tr><th>Input Port Name</th><th>Depth</th></tr>");
- for (InputWorkflowPort dip : dataflow.getInputPorts())
- html.append("<tr><td>")
- .append(dip.getName())
- .append("</td><td>")
- .append(dip.getDepth() < 0 ? "invalid/unpredicted"
- : dip.getDepth()).append("</td></tr>");
- }
- if (!dataflow.getOutputPorts().isEmpty()) {
- html.append("<tr><th>Output Port Name</th><th>Depth</th></tr>");
- for (OutputWorkflowPort dop : dataflow.getOutputPorts())
- html.append("<tr><td>")
- .append(dop.getName())
- .append("</td><td>")
- .append(/*(dop.getDepth() < 0 ?*/ "invalid/unpredicted" /*: dop.getDepth())*/)
- .append("</td>" + "</tr>");
- }
-
- return html.append("</table>").append("</body></html>").toString();
- }
-
- public String getBackgroundColour() {
- return colourManager.getDefaultPropertyMap().get(
- Dataflow.class.toString());
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-
- private String limitName(String fullName) {
- if (fullName.length() <= MAX_LENGTH)
- return fullName;
- return fullName.substring(0, MAX_LENGTH - ELLIPSIS.length()) + ELLIPSIS;
- }
-
- @Override
- public String getViewTitle() {
- return "Workflow " + limitName(dataflow.getName());
- }
-
- @Override
- public void refreshView() {
- editorPane.setText(buildHtml());
- repaint();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualViewFactory.java
deleted file mode 100644
index 0d7f3c0..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflow/DataflowContextualViewFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflow;
-
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
-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 uk.org.taverna.scufl2.api.core.Workflow;
-
-/**
- * @author alanrw
- */
-public class DataflowContextualViewFactory implements
- ContextualViewFactory<Workflow> {
- private FileManager fileManager;
- private ColourManager colourManager;
-
- @Override
- public boolean canHandle(Object selection) {
- return selection instanceof Workflow;
- }
-
- @Override
- public List<ContextualView> getViews(Workflow selection) {
- return Arrays.asList(new ContextualView[] {
- new DataflowContextualView(selection, fileManager, colourManager)});
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- public void setColourManager(ColourManager colourManager) {
- this.colourManager = colourManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
deleted file mode 100644
index 3f17a65..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
+++ /dev/null
@@ -1,96 +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.ui.views.contextualviews.dataflowinputport;
-
-import static java.awt.FlowLayout.LEFT;
-
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-/**
- * Contextual view for dataflow's input ports.
- *
- * @author Alex Nenadic
- */
-class DataflowInputPortContextualView extends ContextualView{
- private static final long serialVersionUID = -8746856072335775933L;
-
- private InputWorkflowPort dataflowInputPort;
- private JPanel dataflowInputPortView;
- @SuppressWarnings("unused")
- private FileManager fileManager;
-
- public DataflowInputPortContextualView(InputWorkflowPort inputport,
- FileManager fileManager) {
- this.dataflowInputPort = inputport;
- this.fileManager = fileManager;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- refreshView();
- return dataflowInputPortView;
- }
-
- @Override
- public String getViewTitle() {
- return "Workflow input port: " + dataflowInputPort.getName();
- }
-
- @Override
- public void refreshView() {
- dataflowInputPortView = new JPanel(new FlowLayout(LEFT));
- dataflowInputPortView.setBorder(new EmptyBorder(5, 5, 5, 5));
- JLabel label = new JLabel(getTextFromDepth("port",
- dataflowInputPort.getDepth()));
- dataflowInputPortView.add(label);
- }
-
- @SuppressWarnings("serial")
- @Override
- public Action getConfigureAction(Frame owner) {
- return new AbstractAction("Update prediction") {
- @Override
- public void actionPerformed(ActionEvent e) {
- // fileManager.getCurrentDataflow().checkValidity();
- refreshView();
- }
- };
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java
deleted file mode 100644
index 5dc5434..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.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.ui.views.contextualviews.dataflowinputport;
-
-import java.util.Arrays;
-import java.util.List;
-
-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 uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-
-/**
- * A factory of contextual views for dataflow's input ports.
- *
- * @author Alex Nenadic
- */
-public class DataflowInputPortContextualViewFactory implements
- ContextualViewFactory<InputWorkflowPort> {
- private FileManager fileManager;
-
- @Override
- public boolean canHandle(Object object) {
- return object instanceof InputWorkflowPort;
- }
-
- @Override
- public List<ContextualView> getViews(InputWorkflowPort inputport) {
- return Arrays.asList(new ContextualView[] {
- new DataflowInputPortContextualView(inputport, fileManager)});
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java
deleted file mode 100644
index 9ba55fe..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.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.ui.views.contextualviews.dataflowoutputport;
-
-import static java.awt.FlowLayout.LEFT;
-
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-/**
- * Contextual view for dataflow's output ports.
- *
- * @author Alex Nenadic
- */
-public class DataflowOutputPortContextualView extends ContextualView {
- private static final long serialVersionUID = 5496014085110553051L;
-
- private OutputWorkflowPort dataflowOutputPort;
- private JPanel dataflowOutputPortView;
- @SuppressWarnings("unused")
- private FileManager fileManager;
-
- public DataflowOutputPortContextualView(OutputWorkflowPort outputport,
- FileManager fileManager) {
- this.dataflowOutputPort = outputport;
- this.fileManager = fileManager;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- refreshView();
- return dataflowOutputPortView;
- }
-
- @Override
- public String getViewTitle() {
- return "Workflow output port: " + dataflowOutputPort.getName();
- }
-
- @Override
- public void refreshView() {
- dataflowOutputPortView = new JPanel(new FlowLayout(LEFT));
- dataflowOutputPortView.setBorder(new EmptyBorder(5,5,5,5));
- JLabel label = new JLabel(getTextForLabel());
- dataflowOutputPortView.add(label);
- }
-
- private String getTextForLabel() {
- //FIXME
- //return getTextFromDepth("port", dataflowOutputPort.getDepth());
- return "Fix depth for OutputWorkflowPort";
- }
-
- private void updatePrediction() {
- //FIXME
- // fileManager.getCurrentDataflow().checkValidity();
- }
-
- @Override
- @SuppressWarnings("serial")
- public Action getConfigureAction(Frame owner) {
- return new AbstractAction("Update prediction") {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePrediction();
- refreshView();
- }
- };
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
deleted file mode 100644
index 20ac960..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
+++ /dev/null
@@ -1,55 +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.ui.views.contextualviews.dataflowoutputport;
-
-import java.util.Arrays;
-import java.util.List;
-
-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 net.sf.taverna.t2.workflowmodel.DataflowOutputPort;
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-
-/**
- * A factory of contextual views for dataflow's output ports.
- *
- * @author Alex Nenadic
- */
-public class DataflowOutputPortContextualViewFactory implements
- ContextualViewFactory<OutputWorkflowPort> {
- private FileManager fileManager;
-
- @Override
- public boolean canHandle(Object object) {
- return object instanceof DataflowOutputPort;
- }
-
- @Override
- public List<ContextualView> getViews(OutputWorkflowPort outputport) {
- return Arrays.asList(new ContextualView[] {
- new DataflowOutputPortContextualView(outputport, fileManager)});
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java
deleted file mode 100644
index daa3414..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.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.ui.views.contextualviews.datalink;
-
-import static java.awt.FlowLayout.LEFT;
-
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import uk.org.taverna.scufl2.api.core.DataLink;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-/**
- * Contextual view for dataflow's datalinks.
- *
- * @author Alex Nenadic
- * @author Alan R Williams
- */
-class DatalinkContextualView extends ContextualView {
- private static final long serialVersionUID = -5031256519235454876L;
-
- private DataLink datalink;
- private JPanel datalinkView;
- @SuppressWarnings("unused")
- private final FileManager fileManager;
-
- public DatalinkContextualView(DataLink datalink, FileManager fileManager) {
- this.datalink = datalink;
- this.fileManager = fileManager;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- refreshView();
- return datalinkView;
- }
-
- @Override
- public String getViewTitle() {
- return "Data link: " + datalink.getReceivesFrom().getName() + " -> " + datalink.getSendsTo().getName();
- }
-
- @Override
- public void refreshView() {
- datalinkView = new JPanel(new FlowLayout(LEFT));
- datalinkView.setBorder(new EmptyBorder(5,5,5,5));
- JLabel label = new JLabel (getTextForLabel());
- datalinkView.add(label);
- }
-
- private String getTextForLabel() {
- //FIXME
- // return getTextFromDepth("link", datalink.getResolvedDepth());
- return "Fix DataLink resolved depth";
- }
-
- private void updatePrediction() {
- //FIXME
- // fileManager.getCurrentDataflow().checkValidity();
- }
-
- @Override
- @SuppressWarnings("serial")
- public Action getConfigureAction(Frame owner) {
- return new AbstractAction("Update prediction") {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePrediction();
- refreshView();
- }
- };
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
deleted file mode 100644
index fa8bf96..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
+++ /dev/null
@@ -1,55 +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.ui.views.contextualviews.datalink;
-
-import java.util.Arrays;
-import java.util.List;
-
-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 net.sf.taverna.t2.workflowmodel.Datalink;
-import uk.org.taverna.scufl2.api.core.DataLink;
-
-/**
- * A factory of contextual views for dataflow's datalinks.
- *
- * @author Alex Nenadic
- */
-public class DatalinkContextualViewFactory implements
- ContextualViewFactory<DataLink> {
- private FileManager fileManager;
-
- @Override
- public boolean canHandle(Object object) {
- return object instanceof Datalink;
- }
-
- @Override
- public List<ContextualView> getViews(DataLink datalink) {
- return Arrays.asList(new ContextualView[] {
- new DatalinkContextualView(datalink, fileManager)});
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
deleted file mode 100644
index 11306d0..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
+++ /dev/null
@@ -1,389 +0,0 @@
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.impl;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.CENTER;
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.LINE_START;
-import static java.awt.GridBagConstraints.NONE;
-import static net.sf.taverna.t2.lang.ui.ShadedLabel.BLUE;
-import static net.sf.taverna.t2.lang.ui.ShadedLabel.GREEN;
-import static net.sf.taverna.t2.lang.ui.ShadedLabel.ORANGE;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.minusIcon;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.plusIcon;
-
-import java.awt.Color;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.lang.observer.SwingAwareObserver;
-import net.sf.taverna.t2.lang.ui.ShadedLabel;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.edits.EditManager.EditManagerEvent;
-import net.sf.taverna.t2.workbench.selection.DataflowSelectionModel;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.selection.events.DataflowSelectionMessage;
-import net.sf.taverna.t2.workbench.selection.events.SelectionManagerEvent;
-import net.sf.taverna.t2.workbench.selection.events.WorkflowBundleSelectionEvent;
-import net.sf.taverna.t2.workbench.ui.Utils;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry;
-import net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-@SuppressWarnings("serial")
-public class ContextualViewComponent extends JScrollPane implements UIComponentSPI {
- /** delay before contextual view is redrawn */
- private static final int DELAY = 250;
- private static final Color[] colors = new Color[] { BLUE, GREEN, ORANGE };
- // HACK ALERT!
- public static boolean selfGenerated = false;
-
- private Observer<DataflowSelectionMessage> dataflowSelectionListener = new DataflowSelectionListener();
- private SelectionManager selectionManager;
- private ContextualViewFactoryRegistry contextualViewFactoryRegistry;
- GridBagConstraints gbc;
- protected Map<JPanel, SectionLabel> panelToLabelMap = new HashMap<>();
- private String lastOpenedSectionName = "";
- private JPanel mainPanel;
- private List<JPanel> shownComponents = null;
- int colorIndex = 0;
- private Timer updateSelectionTimer = null;
- private Object lastSelectedObject = null;
-
- private static final Comparator<ContextualView> viewComparator = new Comparator<ContextualView>() {
- @Override
- public int compare(ContextualView o1, ContextualView o2) {
- return o1.getPreferredPosition() - o2.getPreferredPosition();
- }
- };
-
- public ContextualViewComponent(EditManager editManager,
- SelectionManager selectionManager,
- ContextualViewFactoryRegistry contextualViewFactoryRegistry) {
- this.selectionManager = selectionManager;
- this.contextualViewFactoryRegistry = contextualViewFactoryRegistry;
- updateSelectionTimer = new Timer(DELAY, updateSelectionListener);
- updateSelectionTimer.setRepeats(false);
-
- initialise();
-
- editManager.addObserver(new EditManagerObserver());
- selectionManager.addObserver(new SelectionManagerObserver());
- }
-
- @Override
- public ImageIcon getIcon() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getName() {
- return "Details";
- }
-
- private void initialise() {
- mainPanel = new JPanel(new GridBagLayout());
- this.setViewportView(mainPanel);
- }
-
- @Override
- public void onDisplay() {
- }
-
- @Override
- public void onDispose() {
- updateSelectionTimer.stop();
- }
-
- @SuppressWarnings("unchecked")
- private void updateContextualView(List<ContextualViewFactory<?>> viewFactories,
- Object selection) {
- if (selection == lastSelectedObject)
- return;
- lastSelectedObject = selection;
- mainPanel = new JPanel(new GridBagLayout());
- panelToLabelMap.clear();
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.weightx = 0.1;
- gbc.fill = HORIZONTAL;
-
- gbc.gridy = 0;
- shownComponents = new ArrayList<>();
- List<ContextualView> views = new ArrayList<>();
- for (ContextualViewFactory<?> cvf : viewFactories)
- views.addAll(((ContextualViewFactory<Object>) cvf)
- .getViews(selection));
- Collections.sort(views, viewComparator);
- colorIndex = 0;
- if (views.isEmpty())
- mainPanel.add(new JLabel("No details available"));
- else
- populateContextualView(viewFactories, gbc, views);
- gbc.weighty = 0.1;
- gbc.fill = BOTH;
- mainPanel.add(new JPanel(), gbc);
- // mainPanel.revalidate();
- // mainPanel.repaint();
- this.setViewportView(mainPanel);
- // this.revalidate();
- // this.repaint();
- }
-
- private void populateContextualView(
- List<ContextualViewFactory<?>> viewFactories,
- GridBagConstraints gbc, List<ContextualView> views) {
- JPanel firstPanel = null;
- JPanel lastOpenedSection = null;
- for (ContextualView view : views) {
- SectionLabel label = new SectionLabel(view.getViewTitle(), nextColor());
- mainPanel.add(label, gbc);
- gbc.gridy++;
- JPanel subPanel = new JPanel();
- if (view.getViewTitle().equals(lastOpenedSectionName))
- lastOpenedSection = subPanel;
- subPanel.setLayout(new GridBagLayout());
-
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.weightx = 0.1;
- constraints.weighty = 0;
- constraints.anchor = CENTER;
- constraints.fill = HORIZONTAL;
-
- subPanel.add(view, constraints);
- Frame frame = Utils.getParentFrame(this);
- Action configureAction = view.getConfigureAction(frame);
- if (configureAction != null) {
- JButton configButton = new JButton(configureAction);
- if (configButton.getText() == null
- || configButton.getText().isEmpty())
- configButton.setText("Configure");
- constraints.gridy++;
- constraints.fill = NONE;
- constraints.anchor = LINE_START;
- subPanel.add(configButton, constraints);
- }
- if (firstPanel == null)
- firstPanel = subPanel;
- mainPanel.add(subPanel, gbc);
- shownComponents.add(subPanel);
- gbc.gridy++;
- if (viewFactories.size() != 1)
- makeCloseable(subPanel, label);
- else {
- lastOpenedSectionName = label.getText();
- lastOpenedSection = subPanel;
- panelToLabelMap.put(subPanel, label);
- subPanel.setVisible(false);
- }
- }
- if (lastOpenedSection != null)
- openSection(lastOpenedSection);
- else if (firstPanel != null)
- openSection(firstPanel);
- }
-
- private void clearContextualView() {
- lastSelectedObject = null;
- mainPanel = new JPanel(new GridBagLayout());
- mainPanel.add(new JLabel("No details available"));
- this.setViewportView(mainPanel);
- this.revalidate();
- }
-
- public void updateSelection(Object selectedItem) {
- findContextualView(selectedItem);
- }
-
- private Runnable updateSelectionRunnable = new Runnable() {
- @Override
- public void run() {
- Object selection = getSelection();
- if (selection == null)
- clearContextualView();
- else
- updateSelection(selection);
- }
- };
-
- private ActionListener updateSelectionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- SwingUtilities.invokeLater(updateSelectionRunnable);
- }
- };
-
- public void updateSelection() {
- updateSelectionTimer.restart();
- }
-
- private Object getSelection() {
- WorkflowBundle workflowBundle = selectionManager.getSelectedWorkflowBundle();
-
- /*
- * If there is no currently opened dataflow, clear the contextual view
- * panel
- */
- if (workflowBundle == null) {
- return null;
- }
- DataflowSelectionModel selectionModel = selectionManager
- .getDataflowSelectionModel(workflowBundle);
- Set<Object> selection = selectionModel.getSelection();
-
- /*
- * If the dataflow is opened but no component of the dataflow is
- * selected, clear the contextual view panel
- */
- if (selection.isEmpty())
- return null;
- return selection.iterator().next();
- }
-
- private void findContextualView(Object selection) {
- List<ContextualViewFactory<?>> viewFactoriesForBeanType = contextualViewFactoryRegistry
- .getViewFactoriesForObject(selection);
- updateContextualView(viewFactoriesForBeanType, selection);
- }
-
- private final class SelectionManagerObserver extends SwingAwareObserver<SelectionManagerEvent> {
- @Override
- public void notifySwing(Observable<SelectionManagerEvent> sender, SelectionManagerEvent message) {
- if (message instanceof WorkflowBundleSelectionEvent)
- bundleSelected((WorkflowBundleSelectionEvent) message);
- }
-
- private void bundleSelected(WorkflowBundleSelectionEvent event) {
- WorkflowBundle oldBundle = event
- .getPreviouslySelectedWorkflowBundle();
- WorkflowBundle newBundle = event.getSelectedWorkflowBundle();
-
- if (oldBundle != null)
- selectionManager.getDataflowSelectionModel(oldBundle)
- .removeObserver(dataflowSelectionListener);
- if (newBundle != null)
- selectionManager.getDataflowSelectionModel(newBundle)
- .addObserver(dataflowSelectionListener);
- lastSelectedObject = null;
- updateSelection();
- }
- }
-
- private final class DataflowSelectionListener extends SwingAwareObserver<DataflowSelectionMessage> {
- @Override
- public void notifySwing(Observable<DataflowSelectionMessage> sender,
- DataflowSelectionMessage message) {
- updateSelection();
- }
- }
-
- private final class EditManagerObserver extends SwingAwareObserver<EditManagerEvent> {
- @Override
- public void notifySwing(Observable<EditManagerEvent> sender, EditManagerEvent message) {
- Object selection = getSelection();
- if ((selection != lastSelectedObject) && !selfGenerated) {
- lastSelectedObject = null;
- refreshView();
- }
- }
- }
-
- public void refreshView() {
- if (mainPanel != null)
- updateSelection();
- }
-
- private final class SectionLabel extends ShadedLabel {
- private JLabel expand;
-
- private SectionLabel(String text, Color colour) {
- super(text, colour);
- expand = new JLabel(minusIcon);
- add(expand, 0);
- setExpanded(true);
- }
-
- public void setExpanded(boolean expanded) {
- if (expanded)
- expand.setIcon(minusIcon);
- else
- expand.setIcon(plusIcon);
- }
- }
-
- private void makeCloseable(JPanel panel, SectionLabel label) {
- panel.setVisible(false);
- if (panelToLabelMap.get(panel) != label) {
- panelToLabelMap.put(panel, label);
- // Only add mouse listener once
- label.addMouseListener(new SectionOpener(panel));
- }
- }
-
- protected class SectionOpener extends MouseAdapter {
- private final JPanel sectionToOpen;
-
- public SectionOpener(JPanel sectionToOpen) {
- this.sectionToOpen = sectionToOpen;
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- openSection(sectionToOpen);
- }
- }
-
- public synchronized void openSection(JPanel sectionToOpen) {
- lastOpenedSectionName = "";
- for (Entry<JPanel, SectionLabel> entry : panelToLabelMap.entrySet()) {
- JPanel section = entry.getKey();
- SectionLabel sectionLabel = entry.getValue();
-
- if (section != sectionToOpen)
- section.setVisible(false);
- else {
- section.setVisible(!section.isVisible());
- if (section.isVisible())
- lastOpenedSectionName = sectionLabel.getText();
- }
- sectionLabel.setExpanded(section.isVisible());
- }
- this.revalidate();
- this.repaint();
- }
-
- private Color nextColor() {
- if (colorIndex >= colors.length)
- colorIndex = 0;
- return colors[colorIndex++];
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
deleted file mode 100644
index db43a0d..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2008 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.ui.views.contextualviews.impl;
-
-import javax.swing.ImageIcon;
-
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry;
-import net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI;
-import net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI;
-
-public class ContextualViewComponentFactory implements UIComponentFactorySPI {
- private EditManager editManager;
- private SelectionManager selectionManager;
- private ContextualViewFactoryRegistry contextualViewFactoryRegistry;
-
- @Override
- public UIComponentSPI getComponent() {
- return new ContextualViewComponent(editManager, selectionManager,
- contextualViewFactoryRegistry);
- }
-
- @Override
- public ImageIcon getIcon() {
- return null;
- }
-
- @Override
- public String getName() {
- return "Details";
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
- public void setContextualViewFactoryRegistry(
- ContextualViewFactoryRegistry contextualViewFactoryRegistry) {
- this.contextualViewFactoryRegistry = contextualViewFactoryRegistry;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
deleted file mode 100644
index c1b3d06..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
+++ /dev/null
@@ -1,76 +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.ui.views.contextualviews.inputport;
-
-import static java.awt.FlowLayout.LEFT;
-
-import java.awt.FlowLayout;
-
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import uk.org.taverna.scufl2.api.port.InputActivityPort;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-/**
- * Contextual view for dataflow procerssor's input ports.
- *
- * @author Alex Nenadic
- */
-class InputPortContextualView extends ContextualView {
- private static final String NO_DETAILS_AVAILABLE_HTML = "<html><body>"
- + "<i>No details available.</i>" + "</body><html>";
- private static final long serialVersionUID = -7743029534480678624L;
-
- private InputActivityPort inputPort;
- private JPanel inputPortView;
-
- public InputPortContextualView(InputActivityPort inputport) {
- this.inputPort = inputport;
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- refreshView();
- return inputPortView;
- }
-
- @Override
- public String getViewTitle() {
- return "Service input port: " + inputPort.getName();
- }
-
- @Override
- public void refreshView() {
- inputPortView = new JPanel(new FlowLayout(LEFT));
- inputPortView.setBorder(new EmptyBorder(5, 5, 5, 5));
- JLabel label = new JLabel(NO_DETAILS_AVAILABLE_HTML);
- inputPortView.add(label);
- }
-
- @Override
- public int getPreferredPosition() {
- return 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java
deleted file mode 100644
index 490e5b7..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java
+++ /dev/null
@@ -1,48 +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.ui.views.contextualviews.inputport;
-
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import uk.org.taverna.scufl2.api.port.InputActivityPort;
-
-/**
- * A factory of contextual views for dataflow proessor's (i.e. its associated
- * activity's) input ports.
- *
- * @author Alex Nenadic
- */
-public class InputPortContextualViewFactory implements
- ContextualViewFactory<InputActivityPort> {
- @Override
- public boolean canHandle(Object object) {
- return object instanceof InputActivityPort;
- }
-
- @Override
- public List<ContextualView> getViews(InputActivityPort inputport) {
- return Arrays.asList(new ContextualView[] {
- new InputPortContextualView(inputport)});
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
deleted file mode 100644
index 567cc4b..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
+++ /dev/null
@@ -1,79 +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.ui.views.contextualviews.merge;
-
-import java.awt.event.ActionEvent;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-
-import net.sf.taverna.t2.workbench.edits.EditException;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workflow.edits.ReorderMergePositionsEdit;
-
-import org.apache.log4j.Logger;
-
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.api.core.DataLink;
-
-/**
- * Configuration action for a Merge. This action changes the order of
- * merge's incoming ports.
- *
- * @author Alex Nenadic
- *
- */
-@SuppressWarnings("serial")
-class MergeConfigurationAction extends AbstractAction {
- private static Logger logger = Logger
- .getLogger(MergeConfigurationAction.class);
-
- private final List<DataLink> reorderedDataLinksList;
- private final List<DataLink> datalinks;
- private final EditManager editManager;
- private final SelectionManager selectionManager;
-
- MergeConfigurationAction(List<DataLink> datalinks,
- List<DataLink> reorderedDataLinksList, EditManager editManager,
- SelectionManager selectionManager) {
- this.datalinks = datalinks;
- this.reorderedDataLinksList = reorderedDataLinksList;
- this.editManager = editManager;
- this.selectionManager = selectionManager;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- ReorderMergePositionsEdit edit = new ReorderMergePositionsEdit(
- datalinks, reorderedDataLinksList);
-
- WorkflowBundle bundle = selectionManager.getSelectedWorkflowBundle();
-
- try {
- editManager.doDataflowEdit(bundle, edit);
- } catch (IllegalStateException ex1) {
- logger.error("Could not configure merge", ex1);
- } catch (EditException ex2) {
- logger.error("Could not configure merge", ex2);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
----------------------------------------------------------------------
diff --git a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java b/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
deleted file mode 100644
index 66eeb3e..0000000
--- a/contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package net.sf.taverna.t2.workbench.ui.views.contextualviews.merge;
-
-import static java.awt.BorderLayout.EAST;
-import static java.awt.BorderLayout.NORTH;
-import static java.awt.BorderLayout.SOUTH;
-import static java.lang.Math.max;
-import static javax.swing.BoxLayout.Y_AXIS;
-import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
-import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
-import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
-import static javax.swing.SwingConstants.CENTER;
-import static javax.swing.SwingConstants.LEFT;
-import static javax.swing.SwingConstants.RIGHT;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.downArrowIcon;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.upArrowIcon;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.FontMetrics;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.BoxLayout;
-import javax.swing.DefaultListModel;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.EtchedBorder;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import uk.org.taverna.scufl2.api.core.DataLink;
-
-@SuppressWarnings("serial")
-public class MergeConfigurationView extends HelpEnabledDialog {
- private static final String TITLE = "<html><body><b>Order of incoming links</b></body></html>";
-
- private List<DataLink> dataLinks;
- private List<DataLink> reorderedDataLinks;
- /** Ordered list of labels for dataLinks to be displayed to the user */
- private DefaultListModel<String> labelListModel;
- /** JList that displays the labelListModel */
- JList<String> list;
- /** Button to push the dataLink up the list */
- private JButton upButton;
- /** Button to push the dataLink down the list */
- private JButton downButton;
- private final EditManager editManager;
- private final SelectionManager selectionManager;
-
- public MergeConfigurationView(List<DataLink> dataLinks, EditManager editManager,
- SelectionManager selectionManager) {
- super((Frame)null, "Merge Configuration", true);
-
- this.dataLinks = new ArrayList<>(dataLinks);
- reorderedDataLinks = new ArrayList<>(dataLinks);
- this.editManager = editManager;
- this.selectionManager = selectionManager;
- labelListModel = new DefaultListModel<>();
- for (DataLink dataLink : dataLinks)
- labelListModel.addElement(dataLink.toString());
-
- initComponents();
- }
-
- private void initComponents() {
- getContentPane().setLayout(new BorderLayout());
-
- JPanel listPanel = new JPanel();
- listPanel.setLayout(new BorderLayout());
- listPanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10),
- new EtchedBorder()));
-
- JLabel title = new JLabel(TITLE);
- title.setBorder(new EmptyBorder(5, 5, 5, 5));
- listPanel.add(title, NORTH);
-
- list = new JList<>(labelListModel);
- list.setSelectionMode(SINGLE_SELECTION);
- list.setVisibleRowCount(-1);
- list.addListSelectionListener(new ListSelectionListener() {
- /**
- * Enable and disable up and down buttons based on which item in the
- * list is selected
- */
- @Override
- public void valueChanged(ListSelectionEvent e) {
- int index = list.getSelectedIndex();
- if ((index == -1) || (index == 0 && labelListModel.size() == 0)) {
- // nothing selected or only one item in the list
- upButton.setEnabled(false);
- downButton.setEnabled(false);
- } else {
- upButton.setEnabled(index > 0);
- downButton.setEnabled(index < labelListModel.size() - 1);
- }
- }
- });
-
- final JScrollPane listScroller = new JScrollPane(list);
- listScroller.setBorder(new EmptyBorder(5, 5, 5, 5));
- listScroller.setBackground(listPanel.getBackground());
- listScroller.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_ALWAYS);
- listScroller.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);
- // Set the size of scroll pane to make all list items visible
- FontMetrics fm = listScroller.getFontMetrics(this.getFont());
- int listScrollerHeight = fm.getHeight() * labelListModel.size() + 75; //+75 just in case
- listScroller.setPreferredSize(new Dimension(listScroller
- .getPreferredSize().width, max(listScrollerHeight,
- listScroller.getPreferredSize().height)));
- listPanel.add(listScroller, BorderLayout.CENTER);
-
- JPanel upDownButtonPanel = new JPanel();
- upDownButtonPanel.setLayout(new BoxLayout(upDownButtonPanel, Y_AXIS));
- upDownButtonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
-
- upButton = new JButton(new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int index = list.getSelectedIndex();
- if (index != -1) {
- // Swap the labels
- String label = (String) labelListModel.elementAt(index);
- labelListModel.set(index, labelListModel.get(index - 1));
- labelListModel.set(index - 1, label);
- // Swap the dataLinks
- DataLink dataLink = reorderedDataLinks.get(index);
- reorderedDataLinks.set(index,
- reorderedDataLinks.get(index - 1));
- reorderedDataLinks.set(index - 1, dataLink);
- // Make the pushed item selected
- list.setSelectedIndex(index - 1);
- // Refresh the list
- listScroller.repaint();
- listScroller.revalidate();
- }
- }
- });
- upButton.setIcon(upArrowIcon);
- upButton.setText("Up");
- // Place text to the right of icon, vertically centered
- upButton.setVerticalTextPosition(CENTER);
- upButton.setHorizontalTextPosition(RIGHT);
- // Set the horizontal alignment of the icon and text
- upButton.setHorizontalAlignment(LEFT);
- upButton.setEnabled(false);
- upDownButtonPanel.add(upButton);
-
- downButton = new JButton(new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int index = list.getSelectedIndex();
- if (index != -1) {
- // Swap the labels
- String label = (String) labelListModel.elementAt(index);
- labelListModel.set(index, labelListModel.get(index + 1));
- labelListModel.set(index + 1, label);
- // Swap the dataLinks
- DataLink dataLink = reorderedDataLinks.get(index);
- reorderedDataLinks.set(index,
- reorderedDataLinks.get(index + 1));
- reorderedDataLinks.set(index + 1, dataLink);
- // Make the pushed item selected
- list.setSelectedIndex(index + 1);
- // Refresh the list
- list.repaint();
- listScroller.revalidate();
- }
- }
- });
- downButton.setIcon(downArrowIcon);
- downButton.setText("Down");
- // Place text to the right of icon, vertically centered
- downButton.setVerticalTextPosition(CENTER);
- downButton.setHorizontalTextPosition(RIGHT);
- // Set the horizontal alignment of the icon and text
- downButton.setHorizontalAlignment(LEFT);
- downButton.setEnabled(false);
- // set the up button to be of the same size as down button
- upButton.setPreferredSize(downButton.getPreferredSize());
- upButton.setMaximumSize(downButton.getPreferredSize());
- upButton.setMinimumSize(downButton.getPreferredSize());
- upDownButtonPanel.add(downButton);
-
- listPanel.add(upDownButtonPanel, EAST);
-
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-
- JButton jbOK = new JButton("OK");
- jbOK.addActionListener(new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new MergeConfigurationAction(dataLinks, reorderedDataLinks,
- editManager, selectionManager).actionPerformed(e);
- closeDialog();
- }
- });
-
- JButton jbCancel = new JButton("Cancel");
- jbCancel.addActionListener(new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- closeDialog();
- }
- });
-
- buttonPanel.add(jbOK);
- buttonPanel.add(jbCancel);
-
- getContentPane().add(listPanel, BorderLayout.CENTER);
- getContentPane().add(buttonPanel, SOUTH);
- pack();
- }
-
- /**
- * Close the dialog.
- */
- private void closeDialog() {
- setVisible(false);
- dispose();
- }
-}