You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/26 19:51:51 UTC
[02/51] [partial] incubator-taverna-workbench git commit: all
packages are moved to org.apache.taverna.*
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/FileMenu.java
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/FileMenu.java b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/FileMenu.java
new file mode 100644
index 0000000..a9ad154
--- /dev/null
+++ b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/FileMenu.java
@@ -0,0 +1,47 @@
+/*
+* 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.
+*/
+
+package org.apache.taverna.workbench.ui.impl.menu;
+
+import static java.awt.event.KeyEvent.VK_F;
+import static javax.swing.Action.MNEMONIC_KEY;
+import static org.apache.taverna.ui.menu.DefaultMenuBar.DEFAULT_MENU_BAR;
+
+import java.net.URI;
+
+import org.apache.taverna.ui.menu.AbstractMenu;
+
+/**
+ * File menu
+ *
+ * @author Stian Soiland-Reyes
+ */
+public class FileMenu extends AbstractMenu {
+ public FileMenu() {
+ super(DEFAULT_MENU_BAR, 10, URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#file"),
+ makeAction());
+ }
+
+ public static DummyAction makeAction() {
+ DummyAction action = new DummyAction("File");
+ action.putValue(MNEMONIC_KEY, Integer.valueOf(VK_F));
+ return action;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/HelpMenu.java
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/HelpMenu.java b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/HelpMenu.java
new file mode 100644
index 0000000..a8520fc
--- /dev/null
+++ b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/HelpMenu.java
@@ -0,0 +1,43 @@
+/*
+* 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.
+*/
+
+package org.apache.taverna.workbench.ui.impl.menu;
+
+import static java.awt.event.KeyEvent.VK_H;
+import static javax.swing.Action.MNEMONIC_KEY;
+import static org.apache.taverna.ui.menu.DefaultMenuBar.DEFAULT_MENU_BAR;
+
+import java.net.URI;
+
+import org.apache.taverna.ui.menu.AbstractMenu;
+
+public class HelpMenu extends AbstractMenu {
+ public static final URI HELP_URI = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#help");
+
+ public HelpMenu() {
+ super(DEFAULT_MENU_BAR, 1024, HELP_URI, makeAction());
+ }
+
+ public static DummyAction makeAction() {
+ DummyAction action = new DummyAction("Help");
+ action.putValue(MNEMONIC_KEY, Integer.valueOf(VK_H));
+ return action;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/OnlineHelpMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/OnlineHelpMenuAction.java b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/OnlineHelpMenuAction.java
new file mode 100644
index 0000000..eec26af
--- /dev/null
+++ b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/OnlineHelpMenuAction.java
@@ -0,0 +1,67 @@
+/*
+* 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.
+*/
+
+package org.apache.taverna.workbench.ui.impl.menu;
+
+import static java.awt.event.KeyEvent.VK_F1;
+import static javax.swing.KeyStroke.getKeyStroke;
+import static org.apache.taverna.workbench.helper.Helper.displayDefaultHelp;
+import static org.apache.taverna.workbench.ui.impl.menu.HelpMenu.HELP_URI;
+
+import java.awt.AWTEvent;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+
+import org.apache.taverna.ui.menu.AbstractMenuAction;
+
+/**
+ * MenuItem for help
+ *
+ * @author alanrw
+ */
+public class OnlineHelpMenuAction extends AbstractMenuAction {
+ public OnlineHelpMenuAction() {
+ super(HELP_URI, 10);
+ }
+
+ @Override
+ protected Action createAction() {
+ return new OnlineHelpAction();
+ }
+
+ @SuppressWarnings("serial")
+ private final class OnlineHelpAction extends AbstractAction {
+ private OnlineHelpAction() {
+ super("Online help");
+ putValue(ACCELERATOR_KEY, getKeyStroke(VK_F1, 0));
+
+ }
+
+ /**
+ * When selected, use the Helper to display the default help.
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ displayDefaultHelp((AWTEvent) e);
+ // TODO change helper to bean?
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ShowLogsAndDataMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ShowLogsAndDataMenuAction.java b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ShowLogsAndDataMenuAction.java
new file mode 100644
index 0000000..00d7817
--- /dev/null
+++ b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ShowLogsAndDataMenuAction.java
@@ -0,0 +1,108 @@
+/*
+* 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.
+*/
+
+package org.apache.taverna.workbench.ui.impl.menu;
+
+import static java.lang.Runtime.getRuntime;
+import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
+import static javax.swing.JOptionPane.showInputDialog;
+import static org.apache.taverna.workbench.MainWindow.getMainWindow;
+import static org.apache.taverna.workbench.ui.impl.menu.AdvancedMenu.ADVANCED_URI;
+
+import java.awt.event.ActionEvent;
+import java.io.File;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+
+import org.apache.taverna.ui.menu.AbstractMenuAction;
+
+import org.apache.log4j.Logger;
+
+import uk.org.taverna.configuration.app.ApplicationConfiguration;
+
+public class ShowLogsAndDataMenuAction extends AbstractMenuAction {
+ private static final String OPEN = "open";
+ private static final String EXPLORER = "explorer";
+ // TODO Consider using xdg-open instead of gnome-open
+ private static final String GNOME_OPEN = "gnome-open";
+ private static final String WINDOWS = "Windows";
+ private static final String MAC_OS_X = "Mac OS X";
+
+ private ApplicationConfiguration applicationConfiguration;
+
+ public ShowLogsAndDataMenuAction() {
+ super(ADVANCED_URI, 200);
+ }
+
+ private static Logger logger = Logger.getLogger(ShowLogsAndDataMenuAction.class);
+
+ @Override
+ protected Action createAction() {
+ return new AbstractAction("Show logs and data folder") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ File logsAndDataDir = applicationConfiguration.getApplicationHomeDir();
+ showDirectory(logsAndDataDir, "Taverna logs and data folder");
+ }
+ };
+ }
+
+ public static void showDirectory(File dir, String title) {
+ String path = dir.getAbsolutePath();
+ String os = System.getProperty("os.name");
+ String cmd;
+ boolean isWindows = false;
+ if (os.equals(MAC_OS_X))
+ cmd = OPEN;
+ else if (os.startsWith(WINDOWS)) {
+ cmd = EXPLORER;
+ isWindows = true;
+ } else
+ // Assume Unix - best option is gnome-open
+ cmd = GNOME_OPEN;
+
+ String[] cmdArray = new String[2];
+ cmdArray[0] = cmd;
+ cmdArray[1] = path;
+ try {
+ Process exec = getRuntime().exec(cmdArray);
+ Thread.sleep(300);
+ exec.getErrorStream().close();
+ exec.getInputStream().close();
+ exec.getOutputStream().close();
+ exec.waitFor();
+ if (exec.exitValue() == 0 || isWindows && exec.exitValue() == 1)
+ // explorer.exe thinks 1 means success
+ return;
+ logger.warn("Exit value from " + cmd + " " + path + ": " + exec.exitValue());
+ } catch (Exception ex) {
+ logger.warn("Could not call " + cmd + " " + path, ex);
+ }
+ // Fall-back - just show a dialogue with the path
+ showInputDialog(getMainWindow(), "Copy path from below:", title,
+ INFORMATION_MESSAGE, null, null, path);
+ }
+
+ public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
+ this.applicationConfiguration = applicationConfiguration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ViewShowMenuSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ViewShowMenuSection.java b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ViewShowMenuSection.java
new file mode 100644
index 0000000..3acd0ae
--- /dev/null
+++ b/taverna-menu-impl/src/main/java/org/apache/taverna/workbench/ui/impl/menu/ViewShowMenuSection.java
@@ -0,0 +1,39 @@
+/*
+* 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.
+*/
+
+package org.apache.taverna.workbench.ui.impl.menu;
+
+import java.net.URI;
+
+import org.apache.taverna.ui.menu.AbstractMenuSection;
+
+/**
+ * @author Alex Nenadic
+ * @author Alan R Williams
+ */
+public class ViewShowMenuSection extends AbstractMenuSection {
+ public static final URI DIAGRAM_MENU = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#diagram");
+ public static final URI VIEW_SHOW_MENU_SECTION = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#viewShowMenuSection");
+
+ public ViewShowMenuSection() {
+ super(DIAGRAM_MENU, 10, VIEW_SHOW_MENU_SECTION);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuManager
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuManager b/taverna-menu-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuManager
deleted file mode 100644
index 3b06fd9..0000000
--- a/taverna-menu-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuManager
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.ui.menu.impl.MenuManagerImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuManager
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuManager b/taverna-menu-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuManager
new file mode 100644
index 0000000..3b06fd9
--- /dev/null
+++ b/taverna-menu-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuManager
@@ -0,0 +1 @@
+net.sf.taverna.t2.ui.menu.impl.MenuManagerImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context-osgi.xml b/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context-osgi.xml
index 3a1eadf..f2a3342 100644
--- a/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context-osgi.xml
+++ b/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context-osgi.xml
@@ -6,7 +6,7 @@
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">
- <service ref="MenuManagerImpl" interface="net.sf.taverna.t2.ui.menu.MenuManager" />
+ <service ref="MenuManagerImpl" interface="org.apache.taverna.ui.menu.MenuManager" />
<service ref="FileMenu" auto-export="interfaces" />
<service ref="EditMenu" auto-export="interfaces" />
@@ -17,9 +17,9 @@
<service ref="ShowLogsAndDataMenuAction" auto-export="interfaces" />
<reference id="applicationConfiguration" interface="uk.org.taverna.configuration.app.ApplicationConfiguration" />
- <reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" />
+ <reference id="selectionManager" interface="org.apache.taverna.workbench.selection.SelectionManager" />
- <list id="menuComponents" interface="net.sf.taverna.t2.ui.menu.MenuComponent" cardinality="0..N" greedy-proxying="true">
+ <list id="menuComponents" interface="org.apache.taverna.ui.menu.MenuComponent" cardinality="0..N" greedy-proxying="true">
<listener ref="MenuManagerImpl" bind-method="update" unbind-method="update" />
</list>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context.xml b/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context.xml
index 62fd24e..4c93185 100644
--- a/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context.xml
+++ b/taverna-menu-impl/src/main/resources/META-INF/spring/menu-impl-context.xml
@@ -4,21 +4,21 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="MenuManagerImpl" class="net.sf.taverna.t2.ui.menu.impl.MenuManagerImpl">
+ <bean id="MenuManagerImpl" class="org.apache.taverna.ui.menu.impl.MenuManagerImpl">
<property name="menuComponents" ref="menuComponents" />
<property name="selectionManager" ref="selectionManager" />
</bean>
- <bean id="FileMenu" class="net.sf.taverna.t2.workbench.ui.impl.menu.FileMenu" />
- <bean id="EditMenu" class="net.sf.taverna.t2.workbench.ui.impl.menu.EditMenu" />
- <bean id="AdvancedMenu" class="net.sf.taverna.t2.workbench.ui.impl.menu.AdvancedMenu" />
- <bean id="HelpMenu" class="net.sf.taverna.t2.workbench.ui.impl.menu.HelpMenu" />
+ <bean id="FileMenu" class="org.apache.taverna.workbench.ui.impl.menu.FileMenu" />
+ <bean id="EditMenu" class="org.apache.taverna.workbench.ui.impl.menu.EditMenu" />
+ <bean id="AdvancedMenu" class="org.apache.taverna.workbench.ui.impl.menu.AdvancedMenu" />
+ <bean id="HelpMenu" class="org.apache.taverna.workbench.ui.impl.menu.HelpMenu" />
<bean id="OnlineHelpMenuAction"
- class="net.sf.taverna.t2.workbench.ui.impl.menu.OnlineHelpMenuAction" />
+ class="org.apache.taverna.workbench.ui.impl.menu.OnlineHelpMenuAction" />
<bean id="FeedbackMenuAction"
- class="net.sf.taverna.t2.workbench.ui.impl.menu.FeedbackMenuAction" />
+ class="org.apache.taverna.workbench.ui.impl.menu.FeedbackMenuAction" />
<bean id="ShowLogsAndDataMenuAction"
- class="net.sf.taverna.t2.workbench.ui.impl.menu.ShowLogsAndDataMenuAction">
+ class="org.apache.taverna.workbench.ui.impl.menu.ShowLogsAndDataMenuAction">
<property name="applicationConfiguration" ref="applicationConfiguration" />
</bean>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AbstractConnectPortMenuActions.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AbstractConnectPortMenuActions.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AbstractConnectPortMenuActions.java
deleted file mode 100644
index 041b6be..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AbstractConnectPortMenuActions.java
+++ /dev/null
@@ -1,267 +0,0 @@
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.InputPort;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.Port;
-import org.apache.taverna.scufl2.api.port.ProcessorPort;
-import org.apache.taverna.scufl2.api.port.ReceiverPort;
-import org.apache.taverna.scufl2.api.port.SenderPort;
-import org.apache.taverna.scufl2.api.port.WorkflowPort;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-import net.sf.taverna.t2.lang.ui.ShadedLabel;
-import net.sf.taverna.t2.ui.menu.AbstractMenuCustom;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-import net.sf.taverna.t2.ui.menu.MenuManager;
-import net.sf.taverna.t2.ui.menu.MenuManager.ComponentFactory;
-import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
-import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
-import net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
-
-public abstract class AbstractConnectPortMenuActions extends AbstractMenuCustom
- implements ContextualMenuComponent {
-
- protected ActivityIconManager activityIconManager;
- protected ContextualSelection contextualSelection;
- protected MenuManager menuManager;
- protected WorkbenchConfiguration workbenchConfiguration;
- protected ColourManager colourManager;
- private EditManager editManager;
-
- public static final String CONNECT_AS_INPUT_TO = "Connect as input to...";
- public static final String CONNECT_WITH_OUTPUT_FROM = "Connect with output from...";
-
- public static final String SERVICE_INPUT_PORTS = "Service input ports";
- public static final String SERVICE_OUTPUT_PORTS = "Service output ports";
-
- public static final String NEW_WORKFLOW_INPUT_PORT = "New workflow input port...";
- public static final String NEW_WORKFLOW_OUTPUT_PORT = "New workflow output port...";
-
- public static final String WORKFLOW_INPUT_PORTS = "Workflow input ports";
- public static final String WORKFLOW_OUTPUT_PORTS = "Workflow output ports";
-
- public static final String SERVICES = "Services";
-
- private Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- public AbstractConnectPortMenuActions(URI parentId, int positionHint) {
- super(parentId, positionHint);
- }
-
- public ContextualSelection getContextualSelection() {
- return contextualSelection;
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- this.customComponent = null;
- }
-
- @Override
- protected Component createCustomComponent() {
- Workflow workflow = (Workflow) getContextualSelection().getParent();
- Profile profile = workflow.getParent().getMainProfile();
- Port port = getSelectedPort();
- // Component component =
- // getContextualSelection().getRelativeToComponent();
-
- String label;
- if (port instanceof ReceiverPort) {
- label = CONNECT_WITH_OUTPUT_FROM;
- } else {
- label = CONNECT_AS_INPUT_TO;
- }
- JMenu connectMenu = new JMenu(new DummyAction(label,
- WorkbenchIcons.datalinkIcon));
- addPortMenuItems(workflow, port, connectMenu);
- addProcessorMenuItems(workflow, profile, port, connectMenu);
- return connectMenu;
- }
-
- private Port getSelectedPort() {
- Port port = (Port) getContextualSelection().getSelection();
- return port;
- }
-
- protected void addPortMenuItems(Workflow workflow, Port port, JMenu connectMenu) {
- Color workflowPortColour = colourManager.getPreferredColour(WorkflowPort.class.getCanonicalName());
-
- boolean addedPorts = false;
- if (port instanceof SenderPort) {
- connectMenu.add(new ShadedLabel(WORKFLOW_OUTPUT_PORTS, workflowPortColour));
- for (OutputWorkflowPort outputWorkflowPort : workflow.getOutputPorts()) {
- ConnectPortsAction connectPortsAction =
- new ConnectPortsAction(workflow, (SenderPort) port, outputWorkflowPort, editManager);
- connectPortsAction.putValue(Action.SMALL_ICON, WorkbenchIcons.outputIcon);
- connectPortsAction.putValue(Action.NAME, outputWorkflowPort.getName());
- connectMenu.add(new JMenuItem(connectPortsAction));
- addedPorts = true;
- }
- } else if (port instanceof ReceiverPort) {
- connectMenu.add(new ShadedLabel(WORKFLOW_INPUT_PORTS, workflowPortColour));
- for (InputWorkflowPort inputWorkflowPort : workflow.getInputPorts()) {
- ConnectPortsAction connectPortsAction =
- new ConnectPortsAction(workflow, inputWorkflowPort, (ReceiverPort) port, editManager);
- connectPortsAction.putValue(Action.SMALL_ICON, WorkbenchIcons.inputIcon);
- connectPortsAction.putValue(Action.NAME, inputWorkflowPort.getName());
- connectMenu.add(new JMenuItem(connectPortsAction));
- addedPorts = true;
- }
- }
- if (addedPorts) {
- connectMenu.addSeparator();
- }
- CreateAndConnectDataflowPortAction newDataflowPortAction = new CreateAndConnectDataflowPortAction(
- workflow, port, getSuggestedName(port), contextualSelection.getRelativeToComponent(), editManager);
-
- if (port instanceof ReceiverPort) {
- newDataflowPortAction.putValue(Action.NAME, NEW_WORKFLOW_INPUT_PORT);
- } else if (port instanceof SenderPort) {
- newDataflowPortAction.putValue(Action.NAME, NEW_WORKFLOW_OUTPUT_PORT);
- }
- newDataflowPortAction.putValue(Action.SMALL_ICON, WorkbenchIcons.newIcon);
- connectMenu.add(new JMenuItem(newDataflowPortAction));
- }
-
- /**
- * @param port
- * @return
- */
- private String getSuggestedName(Port port) {
- String suggestedName;
- if (port instanceof ProcessorPort) {
- suggestedName = ((ProcessorPort) port).getParent().getName() + "_" + port.getName();
- } else {
- suggestedName = port.getName();
- }
- return suggestedName;
- }
-
- protected void addProcessorMenuItems(Workflow dataflow, Profile profile,
- final Port targetPort, JMenu connectMenu) {
- final Set<Processor> processors = findProcessors(dataflow, targetPort);
- if (processors.isEmpty()) {
- return;
- }
- connectMenu.add(new ShadedLabel(SERVICES, colourManager.getPreferredColour(Processor.class.getCanonicalName())));
-
- List<JMenuItem> menuItems = new ArrayList<JMenuItem>();
- for (Processor processor : processors) {
- Activity activity = scufl2Tools.processorBindingForProcessor(processor, profile).getBoundActivity();
- Icon icon = activityIconManager.iconForActivity(activity);
- final Color processorPortColour = colourManager.getPreferredColour(ProcessorPort.class.getCanonicalName());
-
- JMenu processorMenu = new JMenu(new DummyAction(processor.getName(), icon));
- List<JMenuItem> processorMenuItems = new ArrayList<JMenuItem>();
- if (targetPort instanceof ReceiverPort) {
- processorMenu.add(new ShadedLabel(SERVICE_OUTPUT_PORTS,
- processorPortColour));
- menuItems.add(processorMenu);
- for (OutputProcessorPort outputProcessorPort : processor.getOutputPorts()) {
- ConnectPortsAction connectPortsAction = new ConnectPortsAction(dataflow,
- outputProcessorPort, (ReceiverPort) targetPort, editManager);
- connectPortsAction.putValue(Action.SMALL_ICON,
- WorkbenchIcons.outputPortIcon);
- connectPortsAction.putValue(Action.NAME, outputProcessorPort.getName());
- processorMenuItems.add(new JMenuItem(connectPortsAction));
- }
- } else if (targetPort instanceof SenderPort) {
- processorMenu.add(new ShadedLabel(SERVICE_INPUT_PORTS,
- processorPortColour));
- menuItems.add(processorMenu);
- for (InputProcessorPort inputProcessorPort : processor.getInputPorts()) {
- ConnectPortsAction connectPortsAction = new ConnectPortsAction(dataflow,
- (SenderPort) targetPort, inputProcessorPort, editManager);
- connectPortsAction.putValue(Action.SMALL_ICON,
- WorkbenchIcons.inputPortIcon);
- connectPortsAction.putValue(Action.NAME, inputProcessorPort.getName());
- processorMenuItems.add(new JMenuItem(connectPortsAction));
- }
- }
-
- menuManager.addMenuItemsWithExpansion(processorMenuItems,
- processorMenu, workbenchConfiguration.getMaxMenuItems(),
- new ComponentFactory() {
- public Component makeComponent() {
- if (targetPort instanceof InputPort) {
- return new ShadedLabel(SERVICE_OUTPUT_PORTS, processorPortColour);
- } else {
- return new ShadedLabel(SERVICE_INPUT_PORTS, processorPortColour);
- }
- }
- });
- }
- menuManager.addMenuItemsWithExpansion(menuItems, connectMenu,
- workbenchConfiguration.getMaxMenuItems(),
- new ComponentFactory() {
- public Component makeComponent() {
- return new ShadedLabel(SERVICES, colourManager
- .getPreferredColour(Processor.class
- .getCanonicalName()));
- }
- });
- }
-
- protected Set<Processor> findProcessors(Workflow dataflow, Port targetPort) {
- Set<Processor> possibleProcessors = new HashSet<Processor>();
- if (targetPort instanceof InputProcessorPort) {
- InputProcessorPort inputProcessorPort = (InputProcessorPort) targetPort;
- possibleProcessors = scufl2Tools.possibleUpStreamProcessors(dataflow, inputProcessorPort.getParent());
- } else if (targetPort instanceof OutputProcessorPort) {
- OutputProcessorPort outputProcessorPort = (OutputProcessorPort) targetPort;
- possibleProcessors = scufl2Tools.possibleDownStreamProcessors(dataflow, outputProcessorPort.getParent());
- } else {
- // Probably a dataflow port, everything is allowed
- possibleProcessors = dataflow.getProcessors();
- }
- return possibleProcessors;
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setMenuManager(MenuManager menuManager) {
- this.menuManager = menuManager;
- }
-
- public void setActivityIconManager(ActivityIconManager activityIconManager) {
- this.activityIconManager = activityIconManager;
- }
-
- public void setWorkbenchConfiguration(WorkbenchConfiguration workbenchConfiguration) {
- this.workbenchConfiguration = workbenchConfiguration;
- }
-
- public void setColourManager(ColourManager colourManager) {
- this.colourManager = colourManager;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityInputPortSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityInputPortSection.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityInputPortSection.java
deleted file mode 100644
index d98bc1b..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityInputPortSection.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-import net.sf.taverna.t2.ui.menu.DefaultContextualMenu;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-
-public class ActivityInputPortSection extends AbstractMenuSection implements
- ContextualMenuComponent {
-
- private static final String ACTIVITY_INPUT_PORT = "Service input port: ";
- public static final URI activityInputPortSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/activityInputPort");
- private ContextualSelection contextualSelection;
-
- public ActivityInputPortSection() {
- super(DefaultContextualMenu.DEFAULT_CONTEXT_MENU, 10,
- activityInputPortSection);
- }
-
- public ContextualSelection getContextualSelection() {
- return contextualSelection;
- }
-
- @Override
- public boolean isEnabled() {
- return getContextualSelection().getSelection() instanceof InputProcessorPort;
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- this.action = null;
- }
-
- @Override
- protected Action createAction() {
- InputProcessorPort port = (InputProcessorPort) getContextualSelection().getSelection();
- String name = ACTIVITY_INPUT_PORT + port.getName();
- return new DummyAction(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityOutputPortSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityOutputPortSection.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityOutputPortSection.java
deleted file mode 100644
index ba37860..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ActivityOutputPortSection.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-import net.sf.taverna.t2.ui.menu.DefaultContextualMenu;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-
-public class ActivityOutputPortSection extends AbstractMenuSection implements
- ContextualMenuComponent {
-
- private static final String ACTIVITY_OUTPUT_PORT = "Service output port: ";
- public static final URI activityOutputPortSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/activityOutputPort");
- private ContextualSelection contextualSelection;
-
- public ActivityOutputPortSection() {
- super(DefaultContextualMenu.DEFAULT_CONTEXT_MENU, 10,
- activityOutputPortSection);
- }
-
- public ContextualSelection getContextualSelection() {
- return contextualSelection;
- }
-
- @Override
- public boolean isEnabled() {
- return getContextualSelection().getSelection() instanceof OutputProcessorPort;
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- this.action = null;
- }
-
- @Override
- protected Action createAction() {
- OutputProcessorPort port = (OutputProcessorPort) getContextualSelection().getSelection();
- String name = ACTIVITY_OUTPUT_PORT + port.getName();
- return new DummyAction(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AddInputPortDefaultValueAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AddInputPortDefaultValueAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AddInputPortDefaultValueAction.java
deleted file mode 100644
index 2843008..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/AddInputPortDefaultValueAction.java
+++ /dev/null
@@ -1,150 +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.ui.menu.items.activityport;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
-import net.sf.taverna.t2.activities.stringconstant.views.StringConstantConfigView;
-import net.sf.taverna.t2.workbench.design.actions.DataflowEditAction;
-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.icons.WorkbenchIcons;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workflow.edits.AddChildEdit;
-import net.sf.taverna.t2.workflow.edits.AddDataLinkEdit;
-import net.sf.taverna.t2.workflow.edits.AddProcessorEdit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.taverna.commons.services.ServiceRegistry;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.configurations.Configuration;
-import org.apache.taverna.scufl2.api.core.DataLink;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-import org.apache.taverna.scufl2.api.port.OutputActivityPort;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-import org.apache.taverna.scufl2.api.profiles.ProcessorOutputPortBinding;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Action for adding a default value to an input port of a processor.
- *
- * @author Alex Nenadic
- */
-@SuppressWarnings("serial")
-public class AddInputPortDefaultValueAction extends DataflowEditAction {
-
- private static Logger logger = Logger.getLogger(AddInputPortDefaultValueAction.class);
-
- private static final URI STRING_CONSTANT = URI
- .create("http://ns.taverna.org.uk/2010/activity/constant");
-
- private InputProcessorPort inputPort;
-
- private final ServiceRegistry serviceRegistry;
-
- public AddInputPortDefaultValueAction(Workflow workflow, InputProcessorPort inputPort,
- Component component, EditManager editManager, SelectionManager selectionManager,
- ServiceRegistry serviceRegistry) {
- super(workflow, component, editManager, selectionManager);
- this.inputPort = inputPort;
- this.serviceRegistry = serviceRegistry;
- putValue(SMALL_ICON, WorkbenchIcons.inputValueIcon);
- putValue(NAME, "Set constant value");
- }
-
- public void actionPerformed(ActionEvent e) {
- try {
- Activity activity = new Activity();
- activity.setType(STRING_CONSTANT);
- Configuration configuration = new Configuration();
- configuration.setType(STRING_CONSTANT.resolve("#Config"));
- configuration.getJsonAsObjectNode().put("string", "");
- configuration.setConfigures(activity);
-
- StringConstantConfigView configView = new StringConstantConfigView(activity,
- configuration, serviceRegistry);
-
- int answer = JOptionPane.showConfirmDialog(component, configView,
- "Text constant value", JOptionPane.OK_CANCEL_OPTION);
- if (answer != JOptionPane.CANCEL_OPTION) {
-
- configView.noteConfiguration();
- configuration.setJson(configView.getJson());
-
- Profile profile = selectionManager.getSelectedProfile();
-
- Processor processor = new Processor();
- processor.setName(inputPort.getName() + "_value");
-
- CrossProduct crossProduct = new CrossProduct();
- crossProduct.setParent(processor.getIterationStrategyStack());
-
- ProcessorBinding processorBinding = new ProcessorBinding();
- processorBinding.setBoundProcessor(processor);
- processorBinding.setBoundActivity(activity);
-
- // create activity port
- OutputActivityPort activityPort = new OutputActivityPort(activity, "value");
- activityPort.setDepth(0);
- activityPort.setGranularDepth(0);
- // create processor port
- OutputProcessorPort processorPort = new OutputProcessorPort(processor,
- activityPort.getName());
- processorPort.setDepth(0);
- processorPort.setGranularDepth(0);
- // add a new port binding
- new ProcessorOutputPortBinding(processorBinding, activityPort, processorPort);
-
- // Add a data link between the string constant processor's output port
- // and the processor containing the passed inputPort.
- DataLink datalink = new DataLink();
- datalink.setReceivesFrom(processorPort);
- datalink.setSendsTo(inputPort);
-
- List<Edit<?>> editList = new ArrayList<Edit<?>>();
- editList.add(new AddChildEdit<Profile>(profile, activity));
- editList.add(new AddChildEdit<Profile>(profile, configuration));
- editList.add(new AddChildEdit<Profile>(profile, processorBinding));
- editList.add(new AddProcessorEdit(dataflow, processor));
- editList.add(new AddDataLinkEdit(dataflow, datalink));
-
- editManager.doDataflowEdit(dataflow.getParent(), new CompoundEdit(editList));
-
- }
- } catch (EditException ex) {
- logger.error("Adding default value for input port failed", ex);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectInputPortMenuActions.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectInputPortMenuActions.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectInputPortMenuActions.java
deleted file mode 100644
index bd416ce..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectInputPortMenuActions.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-
-public class ConnectInputPortMenuActions extends AbstractConnectPortMenuActions
- implements ContextualMenuComponent {
-
- public ConnectInputPortMenuActions() {
- super(ActivityInputPortSection.activityInputPortSection, 20);
- }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled()
- && getContextualSelection().getSelection() instanceof InputProcessorPort
- && getContextualSelection().getParent() instanceof Workflow;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectOutputPortMenuActions.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectOutputPortMenuActions.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectOutputPortMenuActions.java
deleted file mode 100644
index 0d68970..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectOutputPortMenuActions.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-
-
-public class ConnectOutputPortMenuActions extends AbstractConnectPortMenuActions {
-
- public ConnectOutputPortMenuActions() {
- super(ActivityOutputPortSection.activityOutputPortSection, 20);
- }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled()
- && getContextualSelection().getSelection() instanceof OutputProcessorPort
- && getContextualSelection().getParent() instanceof Workflow;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectPortsAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectPortsAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectPortsAction.java
deleted file mode 100644
index 84f4291..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/ConnectPortsAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-
-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.workflow.edits.AddDataLinkEdit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.taverna.scufl2.api.core.DataLink;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.ReceiverPort;
-import org.apache.taverna.scufl2.api.port.SenderPort;
-
-@SuppressWarnings("serial")
-public class ConnectPortsAction extends AbstractAction {
- private static Logger logger = Logger.getLogger(ConnectPortsAction.class);
- private final Workflow workflow;
- private final ReceiverPort receiverPort;
- private final SenderPort senderPort;
- private final EditManager editManager;
-
- public ConnectPortsAction(Workflow workflow,
- SenderPort senderPort, ReceiverPort receiverPort, EditManager editManager) {
- super("Connect " + senderPort.getName() + " to " + receiverPort.getName());
- this.workflow = workflow;
- this.receiverPort = receiverPort;
- this.senderPort = senderPort;
- this.editManager = editManager;
- }
-
- public void actionPerformed(ActionEvent e) {
- DataLink dataLink = new DataLink();
- dataLink.setReceivesFrom(senderPort);
- dataLink.setSendsTo(receiverPort);
- Edit<Workflow> edit = new AddDataLinkEdit(workflow, dataLink);
- try {
- editManager.doDataflowEdit(workflow.getParent(), edit);
- } catch (EditException ex) {
- logger.warn("Can't create connection between " + senderPort
- + " and " + receiverPort, ex);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/CreateAndConnectDataflowPortAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/CreateAndConnectDataflowPortAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/CreateAndConnectDataflowPortAction.java
deleted file mode 100644
index c179f10..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/CreateAndConnectDataflowPortAction.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.AbstractAction;
-
-import net.sf.taverna.t2.lang.ui.ValidatingUserInputDialog;
-import net.sf.taverna.t2.workbench.design.ui.DataflowInputPortPanel;
-import net.sf.taverna.t2.workbench.design.ui.DataflowOutputPortPanel;
-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.workflow.edits.AddChildEdit;
-import net.sf.taverna.t2.workflow.edits.AddDataLinkEdit;
-import net.sf.taverna.t2.workflow.edits.AddWorkflowInputPortEdit;
-import net.sf.taverna.t2.workflow.edits.AddWorkflowOutputPortEdit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.taverna.scufl2.api.core.DataLink;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.DepthPort;
-import org.apache.taverna.scufl2.api.port.InputPort;
-import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.OutputPort;
-import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.Port;
-import org.apache.taverna.scufl2.api.port.ReceiverPort;
-import org.apache.taverna.scufl2.api.port.SenderPort;
-
-/**
- * Action to create a dataflow input/output port and connect it to the specified
- * processor/activity output/input port.
- * <p>
- * The created dataflow port name will be taken from the name of the provided
- * port.
- *
- * @author Stian Soiland-Reyes
- *
- */
-@SuppressWarnings("serial")
-public class CreateAndConnectDataflowPortAction extends AbstractAction {
-
- private static final String VALID_PORT_NAME_REGEX = "[\\p{L}\\p{Digit}_.]+";
- private static final Dimension INPUT_PORT_DIALOGUE_SIZE = new Dimension(400, 250);
- private static final Dimension OUTPUT_PORT_DIALOGUE_SIZE = new Dimension(400, 200);
-
- private static final String INVALID_WORKFLOW_OUTPUT_PORT_NAME = "Invalid workflow output port name.";
- private static final String DUPLICATE_WORKFLOW_OUTPUT_PORT_NAME = "Duplicate workflow output port name.";
- private static final String SET_THE_WORKFLOW_OUTPUT_PORT_NAME = "Set the workflow output port name.";
- private static final String ADD_WORKFLOW_OUTPUT_PORT = "Add workflow output port";
- private static final String SET_THE_INPUT_PORT_LIST_DEPTH = "Set the input port list depth.";
- private static final String SET_THE_INPUT_PORT_TYPE = "Set the input port type.";
- private static final String INVALID_WORKFLOW_INPUT_PORT_NAME = "Invalid workflow input port name.";
- private static final String DUPLICATE_WORKFLOW_INPUT_PORT_NAME = "Duplicate workflow input port name.";
- private static final String SET_THE_WORKFLOW_INPUT_PORT_NAME = "Set the workflow input port name.";
- private static final String ADD_WORKFLOW_INPUT_PORT = "Add workflow input port";
- private static Logger logger = Logger.getLogger(CreateAndConnectDataflowPortAction.class);
- private final Workflow workflow;
-
- private final Port port;
- private final String suggestedName;
- private final Component parentComponent;
- private final EditManager editManager;
-
- /**
- * Action for creating a Workflow input/output port and linking it to the
- * specified port.
- * <p>
- * If the provided port is an InputPort then a
- * Workflow OutputPort will be created and linked. Vice versa, if the
- * provided port is an OutputPort, a Workflow InputPort will be created.
- *
- * @param workflow
- * Workflow where to create the Workflow input/output port
- * @param port
- * Existing Processor port to connect to
- * @param suggestedName
- * suggested port name
- * @param parentComponent
- * Component to be parent of any pop-ups
- */
- public CreateAndConnectDataflowPortAction(Workflow workflow, Port port,
- String suggestedName, Component parentComponent, EditManager editManager) {
- super("Connect to new workflow port");
- this.workflow = workflow;
- this.port = port;
- this.suggestedName = suggestedName;
- this.parentComponent = parentComponent;
- this.editManager = editManager;
- if (!(port instanceof InputPort || port instanceof OutputPort)) {
- throw new IllegalArgumentException("Port " + port
- + " must be either an InputPort or OutputPort");
- }
- }
-
- public void actionPerformed(ActionEvent e) {
- if (port instanceof ReceiverPort) {
- InputWorkflowPort inputWorkflowPort = new InputWorkflowPort();
- inputWorkflowPort.setName(suggestedName);
- workflow.getInputPorts().addWithUniqueName(inputWorkflowPort);
- workflow.getInputPorts().remove(inputWorkflowPort);
- if (port instanceof DepthPort) {
- inputWorkflowPort.setDepth(((DepthPort) port).getDepth());
- } else {
- inputWorkflowPort.setDepth(0);
- }
- showDialogue(inputWorkflowPort);
-
- } else if (port instanceof SenderPort) {
- OutputWorkflowPort outputWorkflowPort = new OutputWorkflowPort();
- outputWorkflowPort.setName(suggestedName);
- workflow.getOutputPorts().addWithUniqueName(outputWorkflowPort);
- workflow.getOutputPorts().remove(outputWorkflowPort);
- showDialogue(outputWorkflowPort);
- } else {
- throw new IllegalStateException("Port " + port
- + " must be either an InputPort or OutputPort");
- }
-
- }
-
- protected void showDialogue(InputWorkflowPort portTemplate) {
- Set<String> usedInputPorts = new HashSet<String>();
- for (InputWorkflowPort usedInputPort : workflow.getInputPorts()) {
- usedInputPorts.add(usedInputPort.getName());
- }
- DataflowInputPortPanel inputPanel = new DataflowInputPortPanel();
-
- ValidatingUserInputDialog vuid = new ValidatingUserInputDialog(
- ADD_WORKFLOW_INPUT_PORT, inputPanel);
- vuid.addTextComponentValidation(inputPanel.getPortNameField(),
- SET_THE_WORKFLOW_INPUT_PORT_NAME, usedInputPorts,
- DUPLICATE_WORKFLOW_INPUT_PORT_NAME, VALID_PORT_NAME_REGEX,
- INVALID_WORKFLOW_INPUT_PORT_NAME);
- vuid.addMessageComponent(inputPanel.getSingleValueButton(),
- SET_THE_INPUT_PORT_TYPE);
- vuid.addMessageComponent(inputPanel.getListValueButton(),
- SET_THE_INPUT_PORT_LIST_DEPTH);
- vuid.setSize(INPUT_PORT_DIALOGUE_SIZE);
-
- inputPanel.setPortName(portTemplate.getName());
- inputPanel.setPortDepth(portTemplate.getDepth());
-
- if (vuid.show(parentComponent)) {
- InputWorkflowPort inputWorkflowPort = new InputWorkflowPort();
- inputWorkflowPort.setName(inputPanel.getPortName());
- inputWorkflowPort.setDepth(inputPanel.getPortDepth());
- List<Edit<?>> editList = new ArrayList<Edit<?>>();
- editList.add(new AddWorkflowInputPortEdit(workflow, inputWorkflowPort));
- DataLink dataLink = new DataLink();
- dataLink.setReceivesFrom(inputWorkflowPort);
- dataLink.setSendsTo((ReceiverPort) port);
- editList.add(new AddDataLinkEdit(workflow, dataLink));
- try {
- CompoundEdit compoundEdit = new CompoundEdit(editList);
- editManager.doDataflowEdit(workflow.getParent(), compoundEdit);
- } catch (EditException ex) {
- logger.warn("Can't create or connect new input port", ex);
- }
-
- }
- }
-
- protected void showDialogue(OutputWorkflowPort portTemplate) {
- Set<String> usedOutputPorts = new HashSet<String>();
- for (OutputWorkflowPort usedInputPort : workflow.getOutputPorts()) {
- usedOutputPorts.add(usedInputPort.getName());
- }
- DataflowOutputPortPanel outputPanel = new DataflowOutputPortPanel();
-
- ValidatingUserInputDialog vuid = new ValidatingUserInputDialog(
- ADD_WORKFLOW_OUTPUT_PORT, outputPanel);
- vuid.addTextComponentValidation(outputPanel.getPortNameField(),
- SET_THE_WORKFLOW_OUTPUT_PORT_NAME, usedOutputPorts,
- DUPLICATE_WORKFLOW_OUTPUT_PORT_NAME,
- VALID_PORT_NAME_REGEX, INVALID_WORKFLOW_OUTPUT_PORT_NAME);
- vuid.setSize(OUTPUT_PORT_DIALOGUE_SIZE);
- outputPanel.setPortName(portTemplate.getName());
-
- if (vuid.show(parentComponent)) {
- OutputWorkflowPort outputWorkflowPort = new OutputWorkflowPort();
- outputWorkflowPort.setName(outputPanel.getPortName());
- List<Edit<?>> editList = new ArrayList<Edit<?>>();
- editList.add(new AddWorkflowOutputPortEdit(workflow, outputWorkflowPort));
- DataLink dataLink = new DataLink();
- dataLink.setReceivesFrom((SenderPort) port);
- dataLink.setSendsTo(outputWorkflowPort);
- editList.add(new AddDataLinkEdit(workflow, dataLink));
- try {
- CompoundEdit compoundEdit = new CompoundEdit(editList);
- editManager.doDataflowEdit(workflow.getParent(), compoundEdit);
- } catch (EditException ex) {
- logger.warn("Can't create or connect new workflow output port", ex);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetConstantInputPortValueMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetConstantInputPortValueMenuAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetConstantInputPortValueMenuAction.java
deleted file mode 100644
index 8bea960..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetConstantInputPortValueMenuAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.activityport;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import org.apache.taverna.commons.services.ServiceRegistry;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-
-public class SetConstantInputPortValueMenuAction extends AbstractContextualMenuAction {
-
- private EditManager editManager;
- private SelectionManager selectionManager;
- private ServiceRegistry serviceRegistry;
-
- public SetConstantInputPortValueMenuAction() {
- super(ActivityInputPortSection.activityInputPortSection, 10);
- }
-
- @Override
- public synchronized Action getAction() {
- SetDefaultInputPortValueAction action = (SetDefaultInputPortValueAction) super.getAction();
- action.updateStatus();
- return action;
- }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled()
- && getContextualSelection().getSelection() instanceof InputProcessorPort
- && getContextualSelection().getParent() instanceof Workflow;
- }
-
- @Override
- protected Action createAction() {
- return new SetDefaultInputPortValueAction(editManager, selectionManager, serviceRegistry);
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
- public void setServiceRegistry(ServiceRegistry serviceRegistry) {
- this.serviceRegistry = serviceRegistry;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetDefaultInputPortValueAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetDefaultInputPortValueAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetDefaultInputPortValueAction.java
deleted file mode 100644
index bb40da7..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/activityport/SetDefaultInputPortValueAction.java
+++ /dev/null
@@ -1,171 +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.ui.menu.items.activityport;
-
-import java.awt.event.ActionEvent;
-import java.util.Set;
-
-import javax.swing.AbstractAction;
-import javax.swing.JOptionPane;
-
-import org.apache.taverna.lang.observer.Observable;
-import org.apache.taverna.lang.observer.Observer;
-import org.apache.taverna.lang.observer.SwingAwareObserver;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
-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.PerspectiveSelectionEvent;
-import net.sf.taverna.t2.workbench.selection.events.SelectionManagerEvent;
-import net.sf.taverna.t2.workbench.selection.events.WorkflowBundleSelectionEvent;
-import org.apache.taverna.commons.services.ServiceRegistry;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-
-/**
- * An action that sets a default value to a processor's input port, in case
- * the input port is selected on the Graph View.
- *
- * @author Alex Nenadic
- */
-@SuppressWarnings("serial")
-public class SetDefaultInputPortValueAction extends AbstractAction {
-
- /* Current workflow's selection model event observer. */
- private Observer<DataflowSelectionMessage> workflowSelectionObserver = new DataflowSelectionObserver();
-
- private final EditManager editManager;
- private final SelectionManager selectionManager;
- private final ServiceRegistry serviceRegistry;
-
- private Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- public SetDefaultInputPortValueAction(EditManager editManager,
- SelectionManager selectionManager, ServiceRegistry serviceRegistry) {
- super();
- this.editManager = editManager;
- this.selectionManager = selectionManager;
- this.serviceRegistry = serviceRegistry;
- putValue(SMALL_ICON, WorkbenchIcons.inputValueIcon);
- putValue(NAME, "Constant value");
- putValue(SHORT_DESCRIPTION, "Add a constant value for an input port");
- setEnabled(false);
-
- selectionManager.addObserver(new SelectionManagerObserver());
-
- }
-
- public void actionPerformed(ActionEvent e) {
- WorkflowBundle workflowBundle = selectionManager.getSelectedWorkflowBundle();
- DataflowSelectionModel dataFlowSelectionModel = selectionManager
- .getDataflowSelectionModel(workflowBundle);
- // Get selected port
- Set<Object> selectedWFComponents = dataFlowSelectionModel.getSelection();
- if (selectedWFComponents.size() > 1) {
- JOptionPane.showMessageDialog(null,
- "Only one workflow component should be selected for this action.", "Warning",
- JOptionPane.WARNING_MESSAGE);
- } else {
- Object selectedWFComponent = selectedWFComponents.toArray()[0];
- if (selectedWFComponent instanceof InputProcessorPort) {
- new AddInputPortDefaultValueAction(workflowBundle.getMainWorkflow(),
- (InputProcessorPort) selectedWFComponent, null, editManager,
- selectionManager, serviceRegistry).actionPerformed(e);
- }
- }
- }
-
- /**
- * Check if action should be enabled or disabled and update its status.
- */
- public void updateStatus() {
- WorkflowBundle workflowBundle = selectionManager.getSelectedWorkflowBundle();
- DataflowSelectionModel selectionModel = selectionManager
- .getDataflowSelectionModel(workflowBundle);
-
- // List of all selected objects in the graph view
- Set<Object> selection = selectionModel.getSelection();
-
- if (selection.isEmpty()) {
- setEnabled(false);
- } else {
- // Take the first selected item - we only support single selections anyway
- Object selected = selection.toArray()[0];
- if (selected instanceof InputProcessorPort) {
- // If this input port is not already connected to something - enable the button
- setEnabled(scufl2Tools.datalinksTo((InputProcessorPort) selected).isEmpty());
- }
- }
- }
-
- /**
- * Observes events on workflow Selection Manager, i.e. when a workflow
- * node is selected in the graph view, and enables/disables this action accordingly.
- */
- private final class DataflowSelectionObserver implements Observer<DataflowSelectionMessage> {
-
- public void notify(Observable<DataflowSelectionMessage> sender,
- DataflowSelectionMessage message) throws Exception {
- updateStatus();
- }
- }
-
- private final class SelectionManagerObserver extends SwingAwareObserver<SelectionManagerEvent> {
-
- private static final String DESIGN_PERSPECTIVE_ID = "net.sf.taverna.t2.ui.perspectives.design.DesignPerspective";
-
- @Override
- public void notifySwing(Observable<SelectionManagerEvent> sender,
- SelectionManagerEvent message) {
- if (message instanceof WorkflowBundleSelectionEvent) {
- WorkflowBundleSelectionEvent workflowBundleSelectionEvent = (WorkflowBundleSelectionEvent) message;
- WorkflowBundle oldFlow = workflowBundleSelectionEvent
- .getPreviouslySelectedWorkflowBundle();
- WorkflowBundle newFlow = workflowBundleSelectionEvent.getSelectedWorkflowBundle();
- // Update the buttons status as current dataflow has changed
- updateStatus();
-
- // Remove the workflow selection model listener from the previous (if any)
- // and add to the new workflow (if any)
- if (oldFlow != null) {
- selectionManager.getDataflowSelectionModel(oldFlow).removeObserver(
- workflowSelectionObserver);
- }
-
- if (newFlow != null) {
- selectionManager.getDataflowSelectionModel(newFlow).addObserver(
- workflowSelectionObserver);
- }
- } else if (message instanceof PerspectiveSelectionEvent) {
- PerspectiveSelectionEvent perspectiveSelectionEvent = (PerspectiveSelectionEvent) message;
- if (DESIGN_PERSPECTIVE_ID.equals(perspectiveSelectionEvent.getSelectedPerspective().getID())) {
- updateStatus();
- } else {
- setEnabled(false);
- }
- }
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/annotated/AnnotatedConfigureMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/annotated/AnnotatedConfigureMenuAction.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/annotated/AnnotatedConfigureMenuAction.java
deleted file mode 100644
index 0105f21..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/annotated/AnnotatedConfigureMenuAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.annotated;
-
-import java.awt.event.ActionEvent;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JOptionPane;
-
-import org.apache.taverna.annotation.Annotated;
-import org.apache.taverna.annotation.AnnotationBeanSPI;
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.ui.menu.items.contextualviews.ConfigureSection;
-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.annotated.AnnotatedContextualView;
-
-public class AnnotatedConfigureMenuAction extends AbstractContextualMenuAction {
- private static final String ANNOTATE = "Annotate...";
- private EditManager editManager;
- private SelectionManager selectionManager;
- private List<AnnotationBeanSPI> annotationBeans;
-
- public AnnotatedConfigureMenuAction() {
- super(ConfigureSection.configureSection, 40);
- }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled() && (getContextualSelection().getSelection() instanceof Annotated);
- }
-
- @SuppressWarnings("serial")
- @Override
- protected Action createAction() {
- return new AbstractAction(ANNOTATE) {
- public void actionPerformed(ActionEvent e) {
- AnnotatedContextualView view = new AnnotatedContextualView((Annotated) getContextualSelection().getSelection(),
- editManager, selectionManager, annotationBeans);
- JOptionPane.showMessageDialog(null, view.getMainFrame(), "Annotation", JOptionPane.PLAIN_MESSAGE);
- }
- };
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setAnnotationBeans(List<AnnotationBeanSPI> annotationBeans) {
- this.annotationBeans = annotationBeans;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureRunningContextualMenuSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureRunningContextualMenuSection.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureRunningContextualMenuSection.java
deleted file mode 100644
index 9c459e2..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureRunningContextualMenuSection.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.contextualviews;
-
-import java.net.URI;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenu;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-
-public class ConfigureRunningContextualMenuSection extends AbstractMenu
-implements ContextualMenuComponent {
- public static final String CONFIGURE_RUNNING = "Configure running";
- public static final URI configureRunningSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/configureRunning");
- private ContextualSelection contextualSelection;
-
- public ConfigureRunningContextualMenuSection() {
- super(ConfigureSection.configureSection, 45, configureRunningSection, CONFIGURE_RUNNING);
- }
-
- @Override
- public boolean isEnabled() {
- return true;
-// return super.isEnabled() && contextualSelection instanceof Processor;
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureSection.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureSection.java
deleted file mode 100644
index 0f1a17f..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/ConfigureSection.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.contextualviews;
-
-import java.net.URI;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-
-/**
- * Menu section containing the actions to add service templates, i.e. activities
- * than are not readily runnable but need to be configured first. The actual actions that
- * go into this menu can be found in the ui modules for the activities.
- *
- * @author Alex Nenadic
- *
- */
-public class ConfigureSection extends AbstractMenuSection
- implements ContextualMenuComponent {
-
- public static final URI configureSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/configure");
- private ContextualSelection contextualSelection;
-
- public ConfigureSection() {
- super(EditSection.editSection, 100, configureSection);
- }
-
- public ContextualSelection getContextualSelection() {
- return contextualSelection;
- }
-
- @Override
- public boolean isEnabled() {
- Object selection = getContextualSelection().getSelection();
- return super.isEnabled();
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/EditSection.java
----------------------------------------------------------------------
diff --git a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/EditSection.java b/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/EditSection.java
deleted file mode 100644
index d23ec6e..0000000
--- a/taverna-menu-items/src/main/java/net/sf/taverna/t2/ui/menu/items/contextualviews/EditSection.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**********************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- **********************************************************************/
-package net.sf.taverna.t2.ui.menu.items.contextualviews;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.lang.ui.ShadedLabel;
-import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.ContextualSelection;
-import net.sf.taverna.t2.ui.menu.DefaultContextualMenu;
-
-/**
- * Menu section containing the actions to add service templates, i.e. activities
- * than are not readily runnable but need to be configured first. The actual actions that
- * go into this menu can be found in the ui modules for the activities.
- *
- * @author Alex Nenadic
- *
- */
-public class EditSection extends AbstractMenuSection
- implements ContextualMenuComponent {
-
- private static final String EDIT = "Edit";
- public static final URI editSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/edit");
- private ContextualSelection contextualSelection;
-
- public EditSection() {
- super(DefaultContextualMenu.DEFAULT_CONTEXT_MENU, 10, editSection);
- }
-
- public ContextualSelection getContextualSelection() {
- return contextualSelection;
- }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled();
- }
-
- public void setContextualSelection(ContextualSelection contextualSelection) {
- this.contextualSelection = contextualSelection;
- }
-
- @Override
- protected Action createAction() {
- DummyAction action = new DummyAction(EDIT);
- // Set the colour for the section
- action.putValue(AbstractMenuSection.SECTION_COLOR, ShadedLabel.ORANGE);
- return action;
- }
-}