http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopContextualViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopContextualViewFactory.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopContextualViewFactory.java new file mode 100644 index 0000000..b44480f --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopContextualViewFactory.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop; + +import java.util.Arrays; +import java.util.List; + +import org.apache.taverna.scufl2.api.core.Processor; + +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory; + +public class LoopContextualViewFactory implements ContextualViewFactory<Processor> { + + private EditManager editManager; + private FileManager fileManager; + + public boolean canHandle(Object selection) { + return selection instanceof Processor; + } + + public List<ContextualView> getViews(Processor selection) { + return Arrays.asList(new ContextualView[] {new LoopContextualView(selection, editManager, fileManager)}); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setFileManager(FileManager fileManager) { + this.fileManager = fileManager; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopRemoveMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopRemoveMenuAction.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopRemoveMenuAction.java new file mode 100644 index 0000000..0d8fb3c --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopRemoveMenuAction.java @@ -0,0 +1,92 @@ +/********************************************************************** + * 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 org.apache.taverna.workbench.loop; + +import java.awt.event.ActionEvent; +import java.net.URI; + +import javax.swing.AbstractAction; +import javax.swing.Action; + +import org.apache.taverna.ui.menu.AbstractContextualMenuAction; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; + +import org.apache.log4j.Logger; + +import org.apache.taverna.scufl2.api.core.Processor; + +public class LoopRemoveMenuAction extends AbstractContextualMenuAction { + + private static Logger logger = Logger + .getLogger(LoopRemoveMenuAction.class); + + public static final URI configureRunningSection = URI + .create("http://taverna.sf.net/2009/contextMenu/configureRunning"); + + private static final URI LOOP_REMOVE_URI = URI + .create("http://taverna.sf.net/2008/t2workbench/loopRemove"); + + private static final String LOOP_REMOVE = "Loop remove"; + + public LoopRemoveMenuAction() { + super(configureRunningSection, 25, LOOP_REMOVE_URI); + } + + private EditManager editManager; + private FileManager fileManager; + + + @SuppressWarnings("serial") + @Override + protected Action createAction() { + return new AbstractAction("Disable looping") { + public void actionPerformed(ActionEvent e) { + Processor p = (Processor) getContextualSelection().getSelection(); + Loop loopLayer = LoopConfigureMenuAction.getLoopLayer(p); + Edit<DispatchStack> deleteEdit = editManager.getEdits().getDeleteDispatchLayerEdit( + p.getDispatchStack(), loopLayer); + // TODO: Should warn before removing "essential" layers + try { + editManager.doDataflowEdit(fileManager.getCurrentDataflow(), + deleteEdit); + } catch (EditException ex) { + logger.warn("Could not remove layer " + loopLayer, ex); + } + + } + }; + } + + public boolean isEnabled() { + Object selection = getContextualSelection().getSelection(); + return (super.isEnabled() && (selection instanceof Processor) && (LoopConfigureMenuAction.getLoopLayer((Processor)selection) != null)); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setFileManager(FileManager fileManager) { + this.fileManager = fileManager; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Comparison.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Comparison.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Comparison.java new file mode 100644 index 0000000..a5b4c04 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Comparison.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +import org.apache.taverna.workbench.loop.LoopConfigurationPanel; + +/** + * A comparison beanshell template for {@link LoopConfigurationPanel}. + * <p> + * A comparison is a template for generating a beanshell that can be used for + * comparisons in say the {@link Loop} layer. + * + * @author Stian Soiland-Reyes + * + */ +public abstract class Comparison { + + public String toString() { + return getName(); + } + + public abstract String getId(); + + public abstract String getName(); + + public abstract String getValueType(); + + public abstract String getScriptTemplate(); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/EqualTo.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/EqualTo.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/EqualTo.java new file mode 100644 index 0000000..8cdf4d9 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/EqualTo.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class EqualTo extends Comparison { + + public String getId() { + return "EqualTo"; + } + + public String getName() { + return "is equal to"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + ! ${port}.equals(${value}); "; + } + + public String getValueType() { + return "string"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsGreaterThan.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsGreaterThan.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsGreaterThan.java new file mode 100644 index 0000000..19f6764 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsGreaterThan.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class IsGreaterThan extends Comparison { + + public String getId() { + return "IsGreaterThan"; + } + + public String getName() { + return "is greater than"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + (! (Double.parseDouble(${port}) > Double.parseDouble(${value})));"; + } + + public String getValueType() { + return "number"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsLessThan.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsLessThan.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsLessThan.java new file mode 100644 index 0000000..3ee5c24 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/IsLessThan.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class IsLessThan extends Comparison { + + public String getId() { + return "IsLessThan"; + } + + public String getName() { + return "is less than"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + (! (Double.parseDouble(${port}) < Double.parseDouble(${value})));"; + } + + public String getValueType() { + return "number"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Matches.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Matches.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Matches.java new file mode 100644 index 0000000..133e134 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/Matches.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class Matches extends Comparison { + + public String getId() { + return "Matches"; + } + + public String getName() { + return "matches"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + ! ${port}.matches(${value});"; + } + + public String getValueType() { + return "regular expression"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotEqualTo.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotEqualTo.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotEqualTo.java new file mode 100644 index 0000000..5657c52 --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotEqualTo.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class NotEqualTo extends Comparison { + + public String getId() { + return "NotEqualTo"; + } + + public String getName() { + return "is not equal to"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + ${port}.equals(${value});"; + } + + public String getValueType() { + return "string"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotMatches.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotMatches.java b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotMatches.java new file mode 100644 index 0000000..ed9766b --- /dev/null +++ b/taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/comparisons/NotMatches.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop.comparisons; + +public class NotMatches extends Comparison { + + public String getId() { + return "NotMatches"; + } + + public String getName() { + return "does not match"; + } + + public String getScriptTemplate() { + return "${loopPort} = \"\" + ${port}.matches(${value});"; + } + + public String getValueType() { + return "regular expression"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent deleted file mode 100644 index 1956a3f..0000000 --- a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent +++ /dev/null @@ -1,3 +0,0 @@ -net.sf.taverna.t2.workbench.loop.LoopConfigureMenuAction -net.sf.taverna.t2.workbench.loop.LoopAddMenuAction -net.sf.taverna.t2.workbench.loop.LoopRemoveMenuAction http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.AddLayerFactorySPI ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.AddLayerFactorySPI b/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.AddLayerFactorySPI deleted file mode 100644 index 52eafc4..0000000 --- a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.AddLayerFactorySPI +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.workbench.loop.AddLoopFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory deleted file mode 100644 index 9150066..0000000 --- a/taverna-loop-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.workbench.loop.LoopContextualViewFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent new file mode 100644 index 0000000..c941258 --- /dev/null +++ b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent @@ -0,0 +1,3 @@ +org.apache.taverna.workbench.loop.LoopConfigureMenuAction +org.apache.taverna.workbench.loop.LoopAddMenuAction +org.apache.taverna.workbench.loop.LoopRemoveMenuAction http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.AddLayerFactorySPI ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.AddLayerFactorySPI b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.AddLayerFactorySPI new file mode 100644 index 0000000..8a4213b --- /dev/null +++ b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.AddLayerFactorySPI @@ -0,0 +1 @@ +org.apache.taverna.workbench.loop.AddLoopFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory new file mode 100644 index 0000000..e4486eb --- /dev/null +++ b/taverna-loop-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory @@ -0,0 +1 @@ +org.apache.taverna.workbench.loop.LoopContextualViewFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context-osgi.xml b/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context-osgi.xml index 4abb75f..2e94fbf 100644 --- a/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context-osgi.xml +++ b/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context-osgi.xml @@ -6,16 +6,16 @@ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> - <service ref="AddLoopFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.AddLayerFactorySPI" /> + <service ref="AddLoopFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.AddLayerFactorySPI" /> <service ref="LoopConfigureMenuAction" auto-export="interfaces" /> <service ref="LoopAddMenuAction" auto-export="interfaces" /> <service ref="LoopRemoveMenuAction" auto-export="interfaces" /> - <service ref="LoopContextualViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> + <service ref="LoopContextualViewFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> - <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="editManager" interface="org.apache.taverna.workbench.edits.EditManager" /> + <reference id="fileManager" interface="org.apache.taverna.workbench.file.FileManager" /> + <reference id="selectionManager" interface="org.apache.taverna.workbench.selection.SelectionManager" /> <reference id="applicationConfig" interface="uk.org.taverna.configuration.app.ApplicationConfiguration"/> </beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context.xml ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context.xml b/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context.xml index 4c2133c..7dd7818 100644 --- a/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context.xml +++ b/taverna-loop-ui/src/main/resources/META-INF/spring/loop-ui-context.xml @@ -3,28 +3,28 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="AddLoopFactory" class="net.sf.taverna.t2.workbench.loop.AddLoopFactory"> + <bean id="AddLoopFactory" class="org.apache.taverna.workbench.loop.AddLoopFactory"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> <property name="selectionManager" ref="selectionManager" /> <property name="applicationConfig" ref="applicationConfig" /> </bean> - <bean id="LoopConfigureMenuAction" class="net.sf.taverna.t2.workbench.loop.LoopConfigureMenuAction"> + <bean id="LoopConfigureMenuAction" class="org.apache.taverna.workbench.loop.LoopConfigureMenuAction"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> </bean> - <bean id="LoopAddMenuAction" class="net.sf.taverna.t2.workbench.loop.LoopAddMenuAction"> + <bean id="LoopAddMenuAction" class="org.apache.taverna.workbench.loop.LoopAddMenuAction"> <property name="addLoopFactory"> <ref local="AddLoopFactory"/> </property> </bean> - <bean id="LoopRemoveMenuAction" class="net.sf.taverna.t2.workbench.loop.LoopRemoveMenuAction"> + <bean id="LoopRemoveMenuAction" class="org.apache.taverna.workbench.loop.LoopRemoveMenuAction"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> </bean> - <bean id="LoopContextualViewFactory" class="net.sf.taverna.t2.workbench.loop.LoopContextualViewFactory"> + <bean id="LoopContextualViewFactory" class="org.apache.taverna.workbench.loop.LoopContextualViewFactory"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> </bean> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/test/java/net/sf/taverna/t2/workbench/loop/ShowContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/test/java/net/sf/taverna/t2/workbench/loop/ShowContextualView.java b/taverna-loop-ui/src/test/java/net/sf/taverna/t2/workbench/loop/ShowContextualView.java deleted file mode 100644 index 9e63c6d..0000000 --- a/taverna-loop-ui/src/test/java/net/sf/taverna/t2/workbench/loop/ShowContextualView.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (C) 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.loop; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.core.Processor; - -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.edits.impl.EditManagerImpl; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.file.impl.FileManagerImpl; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.selection.impl.SelectionManagerImpl; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.impl.ContextualViewComponent; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.impl.ContextualViewFactoryRegistryImpl; - -/** - * A standalone application to show contextual views - * <p> - * The application shows a JFrame containing a contextual view, together with - * buttons which will select items in the {@link SelectionManager} for a - * (rather) empty current dataflow. - * - * @author Stian Soiland-Reyes. - * - */ -public class ShowContextualView { - - public static void main(String[] args) throws Exception { - EditManager editManager = new EditManagerImpl(); - FileManager fileManager = new FileManagerImpl(editManager); - ContextualViewFactoryRegistry contextualViewFactoryRegistry = new ContextualViewFactoryRegistryImpl(); - SelectionManagerImpl selectionMan = new SelectionManagerImpl(); - selectionMan.setFileManager(fileManager); - selectionMan.setEditManager(editManager); - new ShowContextualView(editManager, fileManager,selectionMan, contextualViewFactoryRegistry).showFrame(); - } - - private SelectionManager selectionManager; - private FileManager fileManager; - private EditManager editManager; - private ContextualViewFactoryRegistry contextualViewFactoryRegistry; - - private org.apache.taverna.scufl2.api.core.Processor processor; - - private WorkflowBundle currentDataflow; - - public ShowContextualView(EditManager editManager, FileManager fileManager, final SelectionManager selectionManager, ContextualViewFactoryRegistry contextualViewFactoryRegistry) { - this.editManager = editManager; - this.fileManager = fileManager; - this.selectionManager = selectionManager; - this.contextualViewFactoryRegistry = contextualViewFactoryRegistry; - currentDataflow = fileManager.newDataflow(); - makeProcessor(); - - } - - private void makeProcessor() { - processor = new Processor(currentDataflow.getMainWorkflow(), "Hello"); - } - - private List getSelections() { - return Arrays.asList(processor, currentDataflow); - } - - private Component makeSelectionButtons() { - JPanel buttons = new JPanel(); - for (final Object selection : getSelections()) { - buttons.add(new JButton(new AbstractAction("" + selection) { - public void actionPerformed(ActionEvent e) { - selectionManager.getDataflowSelectionModel( - currentDataflow).setSelection( - Collections.<Object> singleton(selection)); - } - })); - } - return buttons; - } - - protected void showFrame() { - JFrame frame = new JFrame(getClass().getName()); - ContextualViewComponent contextualViewComponent = new ContextualViewComponent(editManager, selectionManager, contextualViewFactoryRegistry); - frame.add(contextualViewComponent, BorderLayout.CENTER); - - frame.add(makeSelectionButtons(), BorderLayout.NORTH); - frame.setSize(400, 400); - frame.setVisible(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-loop-ui/src/test/java/org/apache/taverna/workbench/loop/ShowContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-loop-ui/src/test/java/org/apache/taverna/workbench/loop/ShowContextualView.java b/taverna-loop-ui/src/test/java/org/apache/taverna/workbench/loop/ShowContextualView.java new file mode 100644 index 0000000..2fe8351 --- /dev/null +++ b/taverna-loop-ui/src/test/java/org/apache/taverna/workbench/loop/ShowContextualView.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (C) 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 org.apache.taverna.workbench.loop; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.core.Processor; + +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.edits.impl.EditManagerImpl; +import org.apache.taverna.workbench.file.FileManager; +import net.sf.taverna.t2.workbench.file.impl.FileManagerImpl; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.selection.impl.SelectionManagerImpl; +import org.apache.taverna.workbench.ui.views.contextualviews.impl.ContextualViewComponent; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.impl.ContextualViewFactoryRegistryImpl; + +/** + * A standalone application to show contextual views + * <p> + * The application shows a JFrame containing a contextual view, together with + * buttons which will select items in the {@link SelectionManager} for a + * (rather) empty current dataflow. + * + * @author Stian Soiland-Reyes. + * + */ +public class ShowContextualView { + + public static void main(String[] args) throws Exception { + EditManager editManager = new EditManagerImpl(); + FileManager fileManager = new FileManagerImpl(editManager); + ContextualViewFactoryRegistry contextualViewFactoryRegistry = new ContextualViewFactoryRegistryImpl(); + SelectionManagerImpl selectionMan = new SelectionManagerImpl(); + selectionMan.setFileManager(fileManager); + selectionMan.setEditManager(editManager); + new ShowContextualView(editManager, fileManager,selectionMan, contextualViewFactoryRegistry).showFrame(); + } + + private SelectionManager selectionManager; + private FileManager fileManager; + private EditManager editManager; + private ContextualViewFactoryRegistry contextualViewFactoryRegistry; + + private org.apache.taverna.scufl2.api.core.Processor processor; + + private WorkflowBundle currentDataflow; + + public ShowContextualView(EditManager editManager, FileManager fileManager, final SelectionManager selectionManager, ContextualViewFactoryRegistry contextualViewFactoryRegistry) { + this.editManager = editManager; + this.fileManager = fileManager; + this.selectionManager = selectionManager; + this.contextualViewFactoryRegistry = contextualViewFactoryRegistry; + currentDataflow = fileManager.newDataflow(); + makeProcessor(); + + } + + private void makeProcessor() { + processor = new Processor(currentDataflow.getMainWorkflow(), "Hello"); + } + + private List getSelections() { + return Arrays.asList(processor, currentDataflow); + } + + private Component makeSelectionButtons() { + JPanel buttons = new JPanel(); + for (final Object selection : getSelections()) { + buttons.add(new JButton(new AbstractAction("" + selection) { + public void actionPerformed(ActionEvent e) { + selectionManager.getDataflowSelectionModel( + currentDataflow).setSelection( + Collections.<Object> singleton(selection)); + } + })); + } + return buttons; + } + + protected void showFrame() { + JFrame frame = new JFrame(getClass().getName()); + ContextualViewComponent contextualViewComponent = new ContextualViewComponent(editManager, selectionManager, contextualViewFactoryRegistry); + frame.add(contextualViewComponent, BorderLayout.CENTER); + + frame.add(makeSelectionButtons(), BorderLayout.NORTH); + frame.setSize(400, 400); + frame.setVisible(true); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractContextualMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractContextualMenuAction.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractContextualMenuAction.java deleted file mode 100644 index 7209cae..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractContextualMenuAction.java +++ /dev/null @@ -1,64 +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; - -import java.net.URI; - -/** - * An {@link AbstractMenuAction} that is {@link ContextualMenuComponent} aware. - * The contextual selection can be retrieved from - * {@link #getContextualSelection()}. - * <p> - * The cached action will be flushed everytime the contextual selection changes, - * forcing a new call to {@link #createAction()} - given that - * {@link #isEnabled()} returns true. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractContextualMenuAction extends AbstractMenuAction - implements ContextualMenuComponent { - - private ContextualSelection contextualSelection; - - public AbstractContextualMenuAction(URI parentId, int positionHint) { - super(parentId, positionHint); - } - - public AbstractContextualMenuAction(URI parentId, int positionHint, URI id) { - super(parentId, positionHint, id); - } - - public ContextualSelection getContextualSelection() { - return contextualSelection; - } - - @Override - public boolean isEnabled() { - return contextualSelection != null; - } - - @Override - public void setContextualSelection(ContextualSelection contextualSelection) { - this.contextualSelection = contextualSelection; - // Force new createAction() call - action = null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenu.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenu.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenu.java deleted file mode 100644 index 07eb8d2..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenu.java +++ /dev/null @@ -1,123 +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; - -import static net.sf.taverna.t2.ui.menu.MenuComponent.MenuType.menu; - -import java.net.URI; - -import javax.swing.Action; - -/** - * A {@link MenuComponent} of the type {@link MenuType#menu menu}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of a - * menu. The definition of "menu" includes both the menu bar and sub menus. A - * menu can contain {@linkplain AbstractMenuAction actions}, - * {@linkplain AbstractMenuToggle toggles} or {@linkplain AbstractMenuCustom - * custom components}, or any of the above grouped in a - * {@linkplain AbstractMenuSection section}, - * {@linkplain AbstractMenuOptionGroup option group} or a - * {@linkplain AbstractMenu submenu}. - * <p> - * Menu components are linked together using URIs, avoiding the need for compile - * time dependencies between SPI implementations. To add components to a menu, - * use the {@link URI} identifying this menu as their parent id. - * <p> - * <strong>Note:</strong> To avoid conflicts with other plugins, use a unique - * URI root that is related to the Java package name, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu</code>, and use hash - * identifiers for each menu item, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu#run</code> for a "Run" - * item. Use flat URI namespaces, don't base a child's URI on the parent's URI, - * as this might make it difficult to relocate the parent menu. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenu</code>) of the menu - * implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenu extends AbstractMenuItem { - /** - * Construct a menu bar (does not have a parent). This menu bar can be built - * and used through {@link MenuManager#createMenuBar(URI)}. There is a - * default menu bar implementation in {@link DefaultMenuBar} that can be - * built using {@link MenuManager#createMenuBar()}, but in case you need - * several menu bars for different windows or modes, use this constructor. - * - * @param id - * The {@link URI} to identify this menu bar. Use this as the - * parent ID for menu components to appear in this menu. - */ - public AbstractMenu(URI id) { - super(menu, (URI) null, id); - } - - /** - * Construct a submenu. - * - * @param parentId - * The {@link URI} of the parent menu. The parent should be of - * type - * {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#menu}. - * @param positionHint - * The position hint to determine the position of this submenu - * among its siblings in the parent menu. For extensibility, use - * BASIC style numbering such as 10, 20, etc. - * @param id - * The {@link URI} to identify this menu bar. Use this as the - * parent ID for menu components to appear in this submenu. - * @param label - * The label for presenting this sub-menu in the parent menu. - */ - public AbstractMenu(URI parentId, int positionHint, URI id, String label) { - this(parentId, positionHint, id, new DummyAction(label)); - } - - /** - * Construct a submenu. - * - * @param parentId - * The {@link URI} of the parent menu. The parent should be of - * type - * {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#menu}. - * @param positionHint - * The position hint to determine the position of this submenu - * among its siblings in the parent menu. For extensibility, use - * BASIC style numbering such as 10, 20, etc. - * @param id - * The {@link URI} to identify this menu bar. Use this as the - * parent ID for menu components to appear in this submenu. - * @param action - * The action containing a label and icon for presenting this - * sub-menu in the parent menu. - */ - public AbstractMenu(URI parentId, int positionHint, URI id, Action action) { - super(menu, parentId, id); - this.action = action; - this.positionHint = positionHint; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuAction.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuAction.java deleted file mode 100644 index 446a2ec..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuAction.java +++ /dev/null @@ -1,135 +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; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -/** - * A {@link MenuComponent} of the type {@link MenuType#action action}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of an - * action. An action is an item within a menu or toolbar that can be - * clicked/selected to invoke some action. - * <p> - * This action can have as an parent a {@linkplain AbstractMenu menu} or - * {@linkplain AbstractToolBar toolbar}, or grouped within an - * {@linkplain AbstractMenuSection section} or - * {@linkplain AbstractMenuOptionGroup option group}. - * <p> - * To define the {@link Action}, implement {@link #createAction()}. The action - * should provide both the label/icon (representation) and - * {@link ActionListener#actionPerformed(ActionEvent)}. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenuAction</code>) of the menu - * action implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenuAction extends AbstractMenuItem { - /** - * Construct a menu action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@linkplain MenuComponent.MenuType#isParentType() - * parent type} and must have been registered separately as an - * SPI. - * @param positionHint - * The position hint to determine the position of this action - * among its siblings in the parent menu, section or toolbar. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * {@linkplain AbstractMenuSection section} have their own - * position hint scheme.) - */ - public AbstractMenuAction(URI parentId, int positionHint) { - this(parentId, positionHint, null); - } - - /** - * Construct a menu action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@linkplain MenuComponent.MenuType#isParentType() - * parent type} and must have been registered separately as an - * SPI. - * @param positionHint - * The position hint to determine the position of this action - * among its siblings in the parent menu, section or toolbar. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * {@linkplain AbstractMenuSection section} have their own - * position hint scheme.) - * @param id - * The {@link URI} to identify this action. Although no - * components can have an action as their parent, this URI can be - * used to retrieve the realisation of this component using - * {@link MenuManager#getComponentByURI(URI)}. This ID might also - * be registered as a help identifier with the help system. - */ - public AbstractMenuAction(URI parentId, int positionHint, URI id) { - super(MenuType.action, parentId, id); - this.positionHint = positionHint; - } - - /** - * Call {@link #createAction()} on first call, after that return cached - * action. - * - * @see #createAction() - */ - @Override - public synchronized Action getAction() { - if (action == null) - action = createAction(); - return action; - } - - /** - * Create the {@link Action} that labels this menu action, in addition to - * performing the desired action on - * {@link ActionListener#actionPerformed(ActionEvent)}. - * <p> - * This method will be called by {@link #getAction()} on the first call. - * Concurrent calls to <tt>getAction()</tt> will return the same action. - * <p> - * Implementations might use {@link AbstractAction} as a superclass for menu - * actions. It is recommended to make the action a top level class so that - * it can be used both within an {@link AbstractMenuAction} of a menu bar - * and within an {@link AbstractMenuAction} of a tool bar. - * - * @see #getAction() - * @return A configured {@link Action} that should at least have a label or - * icon. - */ - protected abstract Action createAction(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuCustom.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuCustom.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuCustom.java deleted file mode 100644 index 9a64130..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuCustom.java +++ /dev/null @@ -1,144 +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; - -import java.awt.Component; -import java.net.URI; - -import javax.swing.JButton; -import javax.swing.JMenu; -import javax.swing.JMenuItem; - -/** - * A {@link MenuComponent} of the type {@link MenuType#custom}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of a - * custom menu or toolbar {@link Component}, for instance a {@link JMenu}, - * {@link JMenuItem} or {@link JButton}. - * <p> - * This type of component can be useful for adding third party components that - * are built using other menu systems, or to provide dynamic menus such as a - * list of open files. This is the recommended way to customise the menus, - * although it is also possible to modify the components returned using - * {@link MenuManager#getComponentByURI(URI)}, but as the components built by - * the menu manager might be refreshed by various actions forcing an update to - * the SPI registry, such as installing a plugin. By using a custom menu - * component it is possible to avoid these problems and to provide the - * {@link Component} to be inserted into the menu/toolbar as built by the - * {@link MenuManager}. - * <p> - * This component can have as an parent any menu component that - * {@linkplain MenuType#isParentType() is a parent type}. Note that although you - * can specify an {@link URI} to identify the custom component (to be used with - * {@link MenuManager#getComponentByURI(URI)} a custom component can't have - * children. Such children would have to be created manually and added to the - * component. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenuAction</code>) of the menu - * action implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenuCustom extends AbstractMenuItem { - /** - * Construct a menu action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@link MenuType#isParentType() parent type} and - * must have been registered separately as an SPI. - * @param positionHint - * The position hint to determine the position of this action - * among its siblings in the parent menu, section or toolbar. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * {@linkplain AbstractMenuSection section} have their own - * position hint scheme.) - */ - public AbstractMenuCustom(URI parentId, int positionHint) { - this(parentId, positionHint, null); - } - - /** - * Construct a menu action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@linkplain MenuType#isParentType() parent type} - * and must have been registered separately as an SPI. - * @param positionHint - * The position hint to determine the position of this action - * among its siblings in the parent menu, section or toolbar. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * {@linkplain AbstractMenuSection section} have their own - * position hint scheme.) - * @param id - * The {@link URI} to identify this action. Although no - * components can have an action as their parent, this URI can be - * used to retrieve the realisation of this component using - * {@link MenuManager#getComponentByURI(URI)}. This ID might also - * be registered as a help identifier with the help system. - */ - public AbstractMenuCustom(URI parentId, int positionHint, URI id) { - super(MenuType.custom, parentId, id); - this.positionHint = positionHint; - } - - /** - * Create the {@link Component} that is to be added to the parent. - * <p> - * The component must be compatible with the parent realisation from the - * {@link MenuManager}, for instance you can't add {@link JMenuItem}s to a - * toolbar. - * </p> - * <p> - * Note that the component might get assigned new parents if the - * menues/toolbars are rebuilt by the {@link MenuManager} is refreshed, - * although the menu manager will try to avoid a second call to - * {@link #createCustomComponent()}. - * </p> - * - * @return A custom {@link Component} such as {@link JMenu}, - * {@link JMenuItem} or {@link JButton} to be added to the parent - * menu component. - */ - protected abstract Component createCustomComponent(); - - /** - * Return the custom component created using - * {@link #createCustomComponent()} on first call, return cached instance on - * later calls. - * - * {@inheritDoc} - */ - @Override - public final synchronized Component getCustomComponent() { - if (customComponent == null) - customComponent = createCustomComponent(); - return customComponent; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuItem.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuItem.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuItem.java deleted file mode 100644 index 63b6c78..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuItem.java +++ /dev/null @@ -1,144 +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; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Icon; - -/** - * An abstract implementation of {@link MenuComponent} that can be used by - * convenience to create menu component SPIs for the {@link MenuManager}. - * <p> - * Abstract subclasses of this class are specialised by their - * {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType}. To create a menu, - * toolbar, section, action etc, create an SPI implementation by subclassing - * depending on the required type: - * </p> - * <dl> - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#menu}</dt> - * <dd>Subclass {@link AbstractMenu}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#toolBar}</dt> - * <dd>Subclass {@link AbstractToolBar}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#section}</dt> - * <dd>Subclass {@link AbstractMenuSection}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#action}</dt> - * <dd>Subclass {@link AbstractMenuAction}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#toggle}</dt> - * <dd>Subclass {@link AbstractMenuToggle}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#custom}</dt> - * <dd>Subclass {@link AbstractMenuCustom}</dd> - * - * <dt> {@link net.sf.taverna.t2.ui.menu.MenuComponent.MenuType#optionGroup}</dt> - * <dd>Subclass {@link AbstractMenuOptionGroup}</dd> - * - * </dl> - * <p> - * Note that you are not required to subclass any of these as long as your SPI - * implementations implement the {@link MenuComponent} interface. In all cases - * you are still required to list all your implementations, including - * intermediate menus and sections, in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> - * </p> - * - * @author Stian Soiland-Reyes - * - */ -public abstract class AbstractMenuItem implements MenuComponent { - /** - * An {@link Action} that does not perform any action, but only contains a - * name and icon. Used by {@link AbstractMenu} and others. - * - * @author Stian Soiland-Reyes - * - */ - @SuppressWarnings("serial") - public static class DummyAction extends AbstractAction { - public DummyAction(String name) { - super(name); - } - - public DummyAction(String name, Icon icon) { - super(name, icon); - } - - @Override - public void actionPerformed(ActionEvent e) { - } - } - - public AbstractMenuItem(MenuType type, URI parentId, URI id) { - this.type = type; - this.parentId = parentId; - this.id = id; - } - - private final MenuType type; - private final URI parentId; - private final URI id; - protected int positionHint = 100; - protected Action action; - protected Component customComponent; - - @Override - public Action getAction() { - return action; - } - - @Override - public Component getCustomComponent() { - return customComponent; - } - - @Override - public URI getId() { - return id; - } - - @Override - public URI getParentId() { - return parentId; - } - - @Override - public int getPositionHint() { - return positionHint; - } - - @Override - public MenuType getType() { - return type; - } - - @Override - public boolean isEnabled() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuOptionGroup.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuOptionGroup.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuOptionGroup.java deleted file mode 100644 index 091cc23..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuOptionGroup.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.ui.menu; - -import java.net.URI; - -/** - * A {@link MenuComponent} of the type {@link MenuType#optionGroup}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of an - * option group. An option group is similar to a - * {@linkplain AbstractMenuSection section}, but enforces that only one of the - * children are selected at any time. - * <p> - * Menu components are linked together using URIs, avoiding the need for compile - * time dependencies between SPI implementations. To add actions or toggles to - * an option group, use the {@link URI} identifying this section as their parent - * id. - * <p> - * <strong>Note:</strong> To avoid conflicts with other plugins, use a unique - * URI root that is related to the Java package name, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu</code>, and use hash - * identifiers for each menu item, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu#run</code> for a "Run" - * item. Use flat URI namespaces, don't base a child's URI on the parent's URI, - * as this might make it difficult to relocate the parent menu. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenu</code>) of the option - * group implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenuOptionGroup extends AbstractMenuItem { - /** - * Construct an option group. - * - * @param parentId - * The {@link URI} of the parent menu component. The parent - * should be of type {@link MenuType#menu} or - * {@link MenuType#toolBar}. - * @param positionHint - * The position hint to determine the position of this option - * group among its siblings in the parent menu. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * option group have their own position hint scheme for their - * children.) - * @param id - * The {@link URI} to identify this option group. Use this as the - * parent ID for menu components to appear in this option group. - */ - public AbstractMenuOptionGroup(URI parentId, int positionHint, URI id) { - super(MenuType.optionGroup, parentId, id); - this.positionHint = positionHint; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuSection.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuSection.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuSection.java deleted file mode 100644 index 2e649e0..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuSection.java +++ /dev/null @@ -1,113 +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; - -import java.awt.Color; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -/** - * A {@link MenuComponent} of the type {@link MenuType#section}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of a - * section. A section is a part of a {@linkplain AbstractMenu menu} or - * {@linkplain AbstractToolBar toolbar} that group together - * {@linkplain AbstractMenuAction actions} or {@linkplain AbstractMenuToggle - * toggles}, and separates them from siblings using separators if needed. - * <p> - * Menu components are linked together using URIs, avoiding the need for compile - * time dependencies between SPI implementations. To add actions to a section, - * use the {@link URI} identifying this section as their parent id. - * <p> - * <strong>Note:</strong> To avoid conflicts with other plugins, use a unique - * URI root that is related to the Java package name, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu</code>, and use hash - * identifiers for each menu item, for instance - * <code>http://cs.university.ac.uk/myplugin/2008/menu#run</code> for a "Run" - * item. Use flat URI namespaces, don't base a child's URI on the parent's URI, - * as this might make it difficult to relocate the parent menu. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenu</code>) of the section - * implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenuSection extends AbstractMenuItem { - public static final String SECTION_COLOR = "sectionColor"; - - /** - * Construct a menu section. - * - * @param parentId - * The {@link URI} of the parent menu component. The parent - * should be of type {@link MenuType#menu} or - * {@link MenuType#toolBar}. - * @param positionHint - * The position hint to determine the position of this section - * among its siblings in the parent menu. For extensibility, use - * BASIC style numbering such as 10, 20, etc. (Note that position - * hints are local to each parent, so each section have their own - * position hint scheme for their children.) - * @param id - * The {@link URI} to identify this menu section. Use this as the - * parent ID for menu components to appear in this section. - */ - public AbstractMenuSection(URI parentId, int positionHint, URI id) { - super(MenuType.section, parentId, id); - this.positionHint = positionHint; - } - - @Override - public synchronized Action getAction() { - if (action == null) - action = createAction(); - return action; - } - - /** - * (Optionally) Create the {@link Action} that labels this section. - * <p> - * The actual action will be ignored, but the label and/or icon will be used - * as a section header in the menu. If the property {@link #SECTION_COLOR} - * has been defined in the action, that {@link Color} will be used to make - * the section background. - * <p> - * The default implementation of this method returns <code>null</code>, - * meaning that no section header will be created - instead a simple line - * will separate this section from the items above (if needed). - * <p> - * Implementations might use {@link AbstractAction} as a superclass for menu - * actions. - * - * @return A configured {@link Action} that should at least have a label or - * icon. - */ - protected Action createAction() { - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuToggle.java ---------------------------------------------------------------------- diff --git a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuToggle.java b/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuToggle.java deleted file mode 100644 index 97e977d..0000000 --- a/taverna-menu-api/src/main/java/net/sf/taverna/t2/ui/menu/AbstractMenuToggle.java +++ /dev/null @@ -1,132 +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; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -/** - * A {@link MenuComponent} of the type {@link MenuType#toggle}. - * <p> - * Subclass to create an SPI implementation for the {@link MenuManager} of an - * toggle action. A toggle is a menu item that can be turned on/off and are - * typically represented with a check box when they are enabled. - * <p> - * This action can have as an parent a {@linkplain AbstractMenu menu} or - * {@linkplain AbstractToolBar toolbar}, or grouped within a - * {@linkplain AbstractMenuSection section} or - * {@linkplain AbstractMenuOptionGroup option group}. - * <p> - * To define the {@link Action}, implement {@link #createAction()}. The action - * should provide both the label/icon (representation) and - * {@link ActionListener#actionPerformed(ActionEvent)}. - * <p> - * You need to list the {@linkplain Class#getName() fully qualified class name} - * (for example <code>com.example.t2plugin.menu.MyMenuAction</code>) of the menu - * action implementation in the SPI description resource file - * <code>/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent</code> so - * that it can be discovered by the {@link MenuManager}. This requirement also - * applies to parent menu components (except {@link DefaultToolBar} and - * {@link DefaultMenuBar}, but ensure they are only listed once. - * - * @author Stian Soiland-Reyes - */ -public abstract class AbstractMenuToggle extends AbstractMenuItem { - /** - * Construct a toggle action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@linkplain MenuType#isParentType() parent type} - * and must have been registered separately as an SPI. - * @param positionHint - * The position hint to determine the position of this toggle - * action among its siblings in the parent menu, section or - * toolbar. For extensibility, use BASIC style numbering such as - * 10, 20, etc. (Note that position hints are local to each - * parent, so each {@linkplain AbstractMenuSection section} have - * their own position hint scheme.) - */ - public AbstractMenuToggle(URI parentId, int positionHint) { - this(parentId, null, positionHint); - } - - /** - * Construct a toggle action to appear within the specified menu component. - * - * @param parentId - * The {@link URI} of the parent menu component. The component - * should be a {@link MenuType#isParentType() parent type} and - * must have been registered separately as an SPI. - * @param id - * The {@link URI} to identify this toggle action. Although no - * components can have an action as their parent, this URI can be - * used to retrieve the realisation of this component using - * {@link MenuManager#getComponentByURI(URI)}. This ID might also - * be registered as a help identifier with the help system. - * @param positionHint - * The position hint to determine the position of this action - * among its siblings in the parent menu, section or toolbar. For - * extensibility, use BASIC style numbering such as 10, 20, etc. - * (Note that position hints are local to each parent, so each - * {@linkplain AbstractMenuSection section} have their own - * position hint scheme.) - */ - public AbstractMenuToggle(URI parentId, URI id, int positionHint) { - super(MenuType.toggle, parentId, id); - this.positionHint = positionHint; - } - - /** - * Call {@link #createAction()} on first call, after that return cached - * action. - * - * @see #createAction() - * - * {@inheritDoc} - */ - @Override - public synchronized Action getAction() { - if (action == null) - action = createAction(); - return action; - } - - /** - * Create the {@link Action} that labels this toggle action, in addition to - * performing the desired action on - * {@link ActionListener#actionPerformed(ActionEvent)}. - * <p> - * Implementations might use {@link AbstractAction} as a superclass for menu - * actions. It is recommended to make the action a top level class so that - * it can be used both within an {@link AbstractMenuAction} of a menu bar - * and within an {@link AbstractMenuAction} of a tool bar. - * </p> - * - * @return A configured {@link Action} that should at least have a label or - * icon. - */ - protected abstract Action createAction(); -}
