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/03/20 15:22:58 UTC
[44/51] [abbrv] [partial] incubator-taverna-workbench git commit:
taverna-workbench-* -> taverna-*
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
new file mode 100644
index 0000000..3f17a65
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualView.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.java
new file mode 100644
index 0000000..5dc5434
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowinputport/DataflowInputPortContextualViewFactory.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 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java
new file mode 100644
index 0000000..9ba55fe
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualView.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
new file mode 100644
index 0000000..20ac960
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/dataflowoutputport/DataflowOutputPortContextualViewFactory.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java
new file mode 100644
index 0000000..daa3414
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualView.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
new file mode 100644
index 0000000..fa8bf96
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/datalink/DatalinkContextualViewFactory.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
new file mode 100644
index 0000000..11306d0
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponent.java
@@ -0,0 +1,389 @@
+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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
new file mode 100644
index 0000000..db43a0d
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/impl/ContextualViewComponentFactory.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
new file mode 100644
index 0000000..c1b3d06
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualView.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.java
new file mode 100644
index 0000000..490e5b7
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/inputport/InputPortContextualViewFactory.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 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
new file mode 100644
index 0000000..567cc4b
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationAction.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
new file mode 100644
index 0000000..66eeb3e
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeConfigurationView.java
@@ -0,0 +1,233 @@
+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();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualView.java
new file mode 100644
index 0000000..deb09fb
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualView.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * 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 static java.awt.BorderLayout.CENTER;
+import static java.awt.BorderLayout.SOUTH;
+import static java.awt.FlowLayout.LEFT;
+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 java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JPanel;
+
+import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
+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.workflowmodel.Merge;
+import uk.org.taverna.scufl2.api.common.Scufl2Tools;
+import uk.org.taverna.scufl2.api.container.WorkflowBundle;
+import uk.org.taverna.scufl2.api.core.DataLink;
+
+/**
+ * Contextual view for a {@link Merge}.
+ *
+ * @author Alex Nenadic
+ */
+@SuppressWarnings("serial")
+class MergeContextualView extends ContextualView {
+ @SuppressWarnings("unused")
+ private DataLink dataLink;
+ private List<DataLink> datalinks;
+ @SuppressWarnings("unused")
+ private WorkflowBundle workflow;
+ private JEditorPane editorPane;
+ private final EditManager editManager;
+ private final ColourManager colourManager;
+ private final SelectionManager selectionManager;
+
+ // TODO inject from Spring via factory?
+ private Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ public MergeContextualView(DataLink dataLink, EditManager editManager,
+ SelectionManager selectionManager, ColourManager colourManager) {
+ this.dataLink = dataLink;
+ this.selectionManager = selectionManager;
+ datalinks = scufl2Tools.datalinksTo(dataLink.getSendsTo());
+ this.editManager = editManager;
+ this.colourManager = colourManager;
+ workflow = selectionManager.getSelectedWorkflowBundle();
+ initView();
+ }
+
+ @Override
+ public JComponent getMainFrame() {
+ editorPane = createEditorPane(buildHtml());
+ return panelForHtml(editorPane);
+ }
+
+ @Override
+ public String getViewTitle() {
+ return "Merge Position";
+ }
+
+ /**
+ * Update the view with the latest information from the configuration bean.
+ */
+ @Override
+ public void refreshView() {
+ editorPane.setText(buildHtml());
+ repaint();
+ }
+
+ private String buildHtml() {
+ StringBuilder html = new StringBuilder(
+ getHtmlHead(getBackgroundColour()));
+ html.append(buildTableOpeningTag())
+ .append("<tr><td colspan=\"2\"><b>")
+ .append(getViewTitle())
+ .append("</b></td></tr>")
+ .append("<tr><td colspan=\"2\"><b>Ordered incoming links</b></td></tr>");
+
+ int counter = 1;
+ for (DataLink datalink : datalinks)
+ html.append("<tr><td>").append(counter++).append(".</td><td>")
+ .append(datalink).append("</td></tr>");
+
+ return html.append("</table>").append("</body></html>").toString();
+ }
+
+ protected JPanel panelForHtml(JEditorPane editorPane) {
+ final JPanel panel = new JPanel();
+
+ JPanel buttonPanel = new JPanel(new FlowLayout(LEFT));
+
+ JButton configureButton = new JButton(new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ MergeConfigurationView mergeConfigurationView = new MergeConfigurationView(
+ datalinks, editManager, selectionManager);
+ mergeConfigurationView.setLocationRelativeTo(panel);
+ mergeConfigurationView.setVisible(true);
+ }
+ });
+ configureButton.setText("Configure");
+ buttonPanel.add(configureButton);
+
+ panel.setLayout(new BorderLayout());
+ panel.add(editorPane, CENTER);
+ panel.add(buttonPanel, SOUTH);
+ return panel;
+ }
+
+ public String getBackgroundColour() {
+ return colourManager.getDefaultPropertyMap().get(
+ "net.sf.taverna.t2.workflowmodel.Merge");
+ }
+
+ @Override
+ public int getPreferredPosition() {
+ return 100;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualViewFactory.java
new file mode 100644
index 0000000..712b183
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/merge/MergeContextualViewFactory.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.util.Arrays;
+import java.util.List;
+
+import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
+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 uk.org.taverna.scufl2.api.core.DataLink;
+
+/**
+ * A factory of contextual views for dataflow's merges.
+ *
+ * @author Alex Nenadic
+ */
+public class MergeContextualViewFactory implements ContextualViewFactory<DataLink> {
+ private EditManager editManager;
+ private SelectionManager selectionManager;
+ private ColourManager colourManager;
+
+ @Override
+ public boolean canHandle(Object object) {
+ return object instanceof DataLink
+ && ((DataLink) object).getMergePosition() != null;
+ }
+
+ @Override
+ public List<ContextualView> getViews(DataLink merge) {
+ return Arrays.asList(new ContextualView[] {
+ new MergeContextualView(merge, editManager, selectionManager, colourManager)});
+ }
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setColourManager(ColourManager colourManager) {
+ this.colourManager = colourManager;
+ }
+
+ public void setSelectionManager(SelectionManager selectionManager) {
+ this.selectionManager = selectionManager;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualView.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualView.java
new file mode 100644
index 0000000..f2c7861
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualView.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.outputport;
+
+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 net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
+import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
+
+/**
+ * Contextual view for dataflow procerssor's output ports.
+ *
+ * @author Alex Nenadic
+ */
+public class OutputPortContextualView 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 ActivityOutputPort outputPort;
+ private JPanel outputPortView;
+
+ public OutputPortContextualView(ActivityOutputPort outputport) {
+ this.outputPort = outputport;
+ initView();
+ }
+
+ @Override
+ public JComponent getMainFrame() {
+ refreshView();
+ return outputPortView;
+ }
+
+ @Override
+ public String getViewTitle() {
+ return "Service output port: " + outputPort.getName();
+ }
+
+ @Override
+ public void refreshView() {
+ outputPortView = new JPanel(new FlowLayout(LEFT));
+ outputPortView.setBorder(new EmptyBorder(5,5,5,5));
+ JLabel label = new JLabel(NO_DETAILS_AVAILABLE_HTML);
+ outputPortView.add(label);
+ }
+
+ @Override
+ public int getPreferredPosition() {
+ return 100;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualViewFactory.java b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualViewFactory.java
new file mode 100644
index 0000000..71e2cd4
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/outputport/OutputPortContextualViewFactory.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 net.sf.taverna.t2.workbench.ui.views.contextualviews.outputport;
+
+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 net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
+
+/**
+ * A factory of contextual views for dataflow proessor's (i.e. its associated
+ * activity's) output ports.
+ *
+ * @author Alex Nenadic
+ */
+public class OutputPortContextualViewFactory implements
+ ContextualViewFactory<ActivityOutputPort> {
+ @Override
+ public boolean canHandle(Object object) {
+ return object instanceof ActivityOutputPort;
+ }
+
+ @Override
+ public List<ContextualView> getViews(ActivityOutputPort outputport) {
+ return Arrays.asList(new ContextualView[] {
+ new OutputPortContextualView(outputport)});
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory
new file mode 100644
index 0000000..7744cb3
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory
@@ -0,0 +1,9 @@
+net.sf.taverna.t2.workbench.ui.views.contextualviews.outputport.OutputPortContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.inputport.InputPortContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflowoutputport.DataflowOutputPortContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflowinputport.DataflowInputPortContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.datalink.DatalinkContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.condition.ConditionContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.merge.MergeContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.annotated.AnnotatedContextualViewFactory
+net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflow.DataflowContextualViewFactory
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI b/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI
new file mode 100644
index 0000000..a564691
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI
@@ -0,0 +1 @@
+net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualViewComponentFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context-osgi.xml b/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context-osgi.xml
new file mode 100644
index 0000000..767943d
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context-osgi.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <service ref="ContextualViewComponentFactory" interface="net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI" />
+
+ <service ref="OutputPortContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="InputPortContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="DataflowOutputPortContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="DataflowInputPortContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="DatalinkContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="ConditionContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="MergeContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="AnnotatedContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+ <service ref="DataflowContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+
+ <service ref="ContextualViewFactoryRegistry" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry" />
+
+ <reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" />
+ <reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" />
+ <reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" />
+ <reference id="colourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" />
+
+ <list id="annotationBeans" interface="net.sf.taverna.t2.annotation.AnnotationBeanSPI" />
+ <list id="contextualViewFactories" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" cardinality="0..N" />
+
+</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context.xml b/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context.xml
new file mode 100644
index 0000000..18bbd36
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/resources/META-INF/spring/contextual-views-impl-context.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="ContextualViewComponentFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.impl.ContextualViewComponentFactory">
+ <property name="editManager" ref="editManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="contextualViewFactoryRegistry" ref="ContextualViewFactoryRegistry"/>
+ </bean>
+
+ <bean id="OutputPortContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.outputport.OutputPortContextualViewFactory" />
+ <bean id="InputPortContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.inputport.InputPortContextualViewFactory" />
+ <bean id="DataflowOutputPortContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflowoutputport.DataflowOutputPortContextualViewFactory">
+ <property name="fileManager" ref="fileManager" />
+ </bean>
+ <bean id="DataflowInputPortContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflowinputport.DataflowInputPortContextualViewFactory">
+ <property name="fileManager" ref="fileManager" />
+ </bean>
+ <bean id="DatalinkContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.datalink.DatalinkContextualViewFactory">
+ <property name="fileManager" ref="fileManager" />
+ </bean>
+ <bean id="ConditionContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.condition.ConditionContextualViewFactory" />
+ <bean id="MergeContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.merge.MergeContextualViewFactory">
+ <property name="editManager" ref="editManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="colourManager" ref="colourManager" />
+ </bean>
+ <bean id="AnnotatedContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.annotated.AnnotatedContextualViewFactory">
+ <property name="editManager" ref="editManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="annotationBeans" ref ="annotationBeans"/>
+ </bean>
+ <bean id="DataflowContextualViewFactory" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.dataflow.DataflowContextualViewFactory">
+ <property name="fileManager" ref="fileManager" />
+ <property name="colourManager" ref="colourManager" />
+ </bean>
+
+ <bean id="ContextualViewFactoryRegistry" class="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.impl.ContextualViewFactoryRegistryImpl">
+ <property name="contextualViewFactories" ref="contextualViewFactories" />
+ </bean>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views-impl/src/main/resources/annotatedcontextualview.properties
----------------------------------------------------------------------
diff --git a/taverna-contextual-views-impl/src/main/resources/annotatedcontextualview.properties b/taverna-contextual-views-impl/src/main/resources/annotatedcontextualview.properties
new file mode 100644
index 0000000..e3196f6
--- /dev/null
+++ b/taverna-contextual-views-impl/src/main/resources/annotatedcontextualview.properties
@@ -0,0 +1,4 @@
+net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription: Description
+net.sf.taverna.t2.annotation.annotationbeans.Author: Author
+net.sf.taverna.t2.annotation.annotationbeans.DescriptiveTitle: Title
+net.sf.taverna.t2.annotation.annotationbeans.ExampleValue: Example
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52fd79dd/taverna-contextual-views/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-contextual-views/pom.xml b/taverna-contextual-views/pom.xml
new file mode 100644
index 0000000..13a8746
--- /dev/null
+++ b/taverna-contextual-views/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.taverna.workbench</groupId>
+ <artifactId>taverna-workbench</artifactId>
+ <version>3.1.0-incubating-SNAPSHOT</version>
+ </parent>
+ <artifactId>taverna-contextual-views</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Taverna Contextual views</name>
+ <dependencies>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna-contextual-views-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna-edits-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna-file-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna=selection-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>