http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java deleted file mode 100644 index ecddc35..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration; - -import static java.awt.GridBagConstraints.*; -import static javax.swing.JFileChooser.APPROVE_OPTION; -import static javax.swing.JOptionPane.INFORMATION_MESSAGE; -import static javax.swing.JOptionPane.WARNING_MESSAGE; -import static javax.swing.JOptionPane.showMessageDialog; -import static net.sf.taverna.t2.workbench.helper.Helper.showHelp; -import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.openIcon; - -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; - -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.border.EmptyBorder; - -import net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration; - -import org.apache.log4j.Logger; - -@SuppressWarnings("serial") -public class WorkbenchConfigurationPanel extends JPanel { - private static final String RESTART_MSG = "For the new configuration to be fully applied, it is advised to restart Taverna."; - private static final String DOT_PATH_MSG = "Path to Graphviz executable <code>dot</code>:"; - private static final String CONTEXT_MENU_SIZE_MSG = "Maximum number of services/ports in right-click menu:"; - private static Logger logger = Logger - .getLogger(WorkbenchConfigurationUIFactory.class); - - private JTextField dotLocation = new JTextField(25); - private JTextField menuItems = new JTextField(10); - private JCheckBox warnInternal = new JCheckBox("Warn on internal errors"); - private JCheckBox captureConsole = new JCheckBox( - "Capture output on stdout/stderr to log file"); - - private final WorkbenchConfiguration workbenchConfiguration; - - public WorkbenchConfigurationPanel( - WorkbenchConfiguration workbenchConfiguration) { - super(); - this.workbenchConfiguration = workbenchConfiguration; - initComponents(); - } - - private static JLabel htmlLabel(String html) { - return new JLabel("<html><body>" + html + "</body></html>"); - } - - private void initComponents() { - this.setLayout(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - - // Title describing what kind of settings we are configuring here - JTextArea descriptionText = new JTextArea( - "General Workbench configuration"); - descriptionText.setLineWrap(true); - descriptionText.setWrapStyleWord(true); - descriptionText.setEditable(false); - descriptionText.setFocusable(false); - descriptionText.setBorder(new EmptyBorder(10, 10, 10, 10)); - gbc.anchor = WEST; - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 2; - gbc.weightx = 1.0; - gbc.weighty = 0.0; - gbc.fill = HORIZONTAL; - this.add(descriptionText, gbc); - - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 2; - gbc.weightx = 0.0; - gbc.weighty = 0.0; - gbc.insets = new Insets(10, 5, 0, 0); - gbc.fill = NONE; - this.add(htmlLabel(DOT_PATH_MSG), gbc); - - dotLocation.setText(workbenchConfiguration.getDotLocation()); - gbc.gridy++; - gbc.gridwidth = 1; - gbc.weightx = 1.0; - gbc.insets = new Insets(0, 0, 0, 0); - gbc.fill = HORIZONTAL; - this.add(dotLocation, gbc); - - JButton browseButton = new JButton(); - gbc.gridx = 1; - gbc.weightx = 0.0; - gbc.fill = NONE; - this.add(browseButton, gbc); - browseButton.setAction(new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - System.setProperty("com.apple.macos.use-file-dialog-packages", - "false"); - JFileChooser fileChooser = new JFileChooser(); - fileChooser.putClientProperty( - "JFileChooser.appBundleIsTraversable", "always"); - fileChooser.putClientProperty( - "JFileChooser.packageIsTraversable", "always"); - - fileChooser.setDialogTitle("Browse for dot"); - - fileChooser.resetChoosableFileFilters(); - fileChooser.setAcceptAllFileFilterUsed(false); - - fileChooser.setMultiSelectionEnabled(false); - - int returnVal = fileChooser - .showOpenDialog(WorkbenchConfigurationPanel.this); - if (returnVal == APPROVE_OPTION) - dotLocation.setText(fileChooser.getSelectedFile() - .getAbsolutePath()); - } - }); - browseButton.setIcon(openIcon); - - gbc.gridx = 0; - gbc.gridy++; - gbc.gridwidth = 2; - gbc.weightx = 0.0; - gbc.weighty = 0.0; - gbc.insets = new Insets(10, 5, 0, 0); - gbc.fill = HORIZONTAL; - this.add(htmlLabel(CONTEXT_MENU_SIZE_MSG), gbc); - - menuItems.setText(Integer.toString(workbenchConfiguration - .getMaxMenuItems())); - gbc.gridy++; - gbc.weightx = 1.0; - gbc.gridwidth = 1; - gbc.insets = new Insets(0, 0, 0, 0); - gbc.fill = HORIZONTAL; - this.add(menuItems, gbc); - - gbc.gridx = 0; - gbc.gridy++; - gbc.gridwidth = 2; - gbc.weightx = 1.0; - gbc.fill = HORIZONTAL; - gbc.insets = new Insets(10, 0, 0, 0); - warnInternal - .setSelected(workbenchConfiguration.getWarnInternalErrors()); - this.add(warnInternal, gbc); - - gbc.gridy++; - gbc.insets = new Insets(0, 0, 10, 0); - captureConsole.setSelected(workbenchConfiguration.getCaptureConsole()); - this.add(captureConsole, gbc); - - // Add the buttons panel - gbc.gridx = 0; - gbc.gridy++; - gbc.gridwidth = 3; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = BOTH; - gbc.anchor = SOUTH; - this.add(getButtonsPanel(), gbc); - } - - private Component getButtonsPanel() { - final JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.CENTER)); - - /** - * The helpButton shows help about the current component - */ - JButton helpButton = new JButton(new AbstractAction("Help") { - @Override - public void actionPerformed(ActionEvent arg0) { - showHelp(panel); - } - }); - panel.add(helpButton); - - /** - * The resetButton changes the property values shown to those - * corresponding to the configuration currently applied. - */ - JButton resetButton = new JButton(new AbstractAction("Reset") { - @Override - public void actionPerformed(ActionEvent arg0) { - resetFields(); - } - }); - panel.add(resetButton); - - JButton applyButton = new JButton(new AbstractAction("Apply") { - @Override - public void actionPerformed(ActionEvent arg0) { - String menus = menuItems.getText(); - try { - workbenchConfiguration.setMaxMenuItems(Integer - .valueOf(menus)); - } catch (IllegalArgumentException e) { - String message = "Invalid menu items number " + menus - + ":\n" + e.getLocalizedMessage(); - showMessageDialog(panel, message, "Invalid menu items", - WARNING_MESSAGE); - return; - } - - workbenchConfiguration.setCaptureConsole(captureConsole - .isSelected()); - workbenchConfiguration.setWarnInternalErrors(warnInternal - .isSelected()); - workbenchConfiguration.setDotLocation(dotLocation.getText()); - try { - showMessageDialog(panel, RESTART_MSG, "Restart adviced", - INFORMATION_MESSAGE); - } catch (Exception e) { - logger.error("Error storing updated configuration", e); - } - } - }); - panel.add(applyButton); - return panel; - } - - /** - * Resets the shown field values to those currently set (last saved) in the - * configuration. - * - * @param configurable - */ - private void resetFields() { - menuItems.setText(Integer.toString(workbenchConfiguration - .getMaxMenuItems())); - dotLocation.setText(workbenchConfiguration.getDotLocation()); - warnInternal - .setSelected(workbenchConfiguration.getWarnInternalErrors()); - captureConsole.setSelected(workbenchConfiguration.getCaptureConsole()); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java deleted file mode 100644 index 263233f..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration; - -import javax.swing.JPanel; - -import uk.org.taverna.configuration.Configurable; -import uk.org.taverna.configuration.ConfigurationUIFactory; - -import net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration; - -public class WorkbenchConfigurationUIFactory implements ConfigurationUIFactory { - private WorkbenchConfiguration workbenchConfiguration; - - @Override - public boolean canHandle(String uuid) { - return uuid.equals(workbenchConfiguration.getUUID()); - } - - @Override - public JPanel getConfigurationPanel() { - return new WorkbenchConfigurationPanel(workbenchConfiguration); - } - - @Override - public Configurable getConfigurable() { - return workbenchConfiguration; - } - - public void setWorkbenchConfiguration( - WorkbenchConfiguration workbenchConfiguration) { - this.workbenchConfiguration = workbenchConfiguration; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java deleted file mode 100644 index 4c03dbe..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.colour; - -import static java.awt.Color.WHITE; -import static java.awt.Color.decode; - -import java.awt.Color; -import java.util.HashMap; -import java.util.Map; - -import uk.org.taverna.configuration.AbstractConfigurable; -import uk.org.taverna.configuration.ConfigurationManager; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; - -/** - * A factory class that determines the colour that a Colourable UI component - * should be displayed as, according to a schema configured by the user. - * - * @author Stuart Owen - * @author Ian Dunlop - * @see Colourable - */ -public class ColourManagerImpl extends AbstractConfigurable implements - ColourManager { - // Names of things that may be coloured - private static final String WORKFLOW_PORT_OBJECT = "uk.org.taverna.scufl2.api.port.WorkflowPort"; - private static final String PROCESSOR_PORT_OBJECT = "uk.org.taverna.scufl2.api.port.ProcessorPort"; - private static final String PROCESSOR_OBJECT = "uk.org.taverna.scufl2.api.core.Processor"; - private static final String MERGE_OBJECT = "net.sf.taverna.t2.workflowmodel.Merge"; - private static final String NONEXECUTABLE_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/nonExecutable"; - private static final String XML_SPLITTER_OUT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/xml-splitter/out"; - private static final String XML_SPLITTER_IN_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/xml-splitter/in"; - private static final String LOCALWORKER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/localworker"; - private static final String WSDL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/wsdl"; - private static final String CONSTANT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/constant"; - private static final String SOAPLAB_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/soaplab"; - private static final String RSHELL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/rshell"; - private static final String NESTED_WORKFLOW = "http://ns.taverna.org.uk/2010/activity/nested-workflow"; - private static final String MOBY_PARSER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/parser"; - private static final String MOBY_OBJECT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/object"; - private static final String MOBY_SERVICE_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/service"; - private static final String BIOMART_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomart"; - private static final String BEANSHELL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/beanshell"; - private static final String APICONSUMER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/apiconsumer"; - - // Names of colours used - private static final String burlywood2 = "#deb887"; - private static final String darkgoldenrod1 = "#ffb90f"; - private static final String darkolivegreen3 = "#a2cd5a"; - private static final String gold = "#ffd700"; - private static final String grey = "#777777"; - private static final String lightcyan2 = "#d1eeee"; - private static final String lightgoldenrodyellow = "#fafad2"; - // light purple non standard - private static final String lightpurple = "#ab92ea"; - private static final String lightsteelblue = "#b0c4de"; - private static final String mediumorchid2 = "#d15fee"; - private static final String palegreen = "#98fb98"; - private static final String pink = "#ffc0cb"; - private static final String purplish = "#8070ff"; - // ShadedLabel.Orange - private static final String shadedorange = "#eece8f"; - // ShadedLabel.Green - private static final String shadedgreen = "#a1c69d"; - // slightly lighter than the real steelblue4 - private static final String steelblue4 = "#648faa"; - private static final String turquoise = "#77aadd"; - private static final String white = "#ffffff"; - - private Map<String, String> defaultPropertyMap; - private Map<Object, Color> cachedColours; - - public ColourManagerImpl(ConfigurationManager configurationManager) { - super(configurationManager); - initialiseDefaults(); - } - - @Override - public String getCategory() { - return "colour"; - } - - @Override - public Map<String, String> getDefaultPropertyMap() { - if (defaultPropertyMap == null) - initialiseDefaults(); - return defaultPropertyMap; - } - - @Override - public String getDisplayName() { - return "Colour Management"; - } - - @Override - public String getFilePrefix() { - return "ColourManagement"; - } - - /** - * Unique identifier for this ColourManager - */ - @Override - public String getUUID() { - return "a2148420-5967-11dd-ae16-0800200c9a66"; - } - - private void initialiseDefaults() { - defaultPropertyMap = new HashMap<>(); - cachedColours = new HashMap<>(); - - defaultPropertyMap.put(APICONSUMER_ACTIVITY, palegreen); - defaultPropertyMap.put(BEANSHELL_ACTIVITY, burlywood2); - defaultPropertyMap.put(BIOMART_ACTIVITY, lightcyan2); - defaultPropertyMap.put(CONSTANT_ACTIVITY, lightsteelblue); - defaultPropertyMap.put(LOCALWORKER_ACTIVITY, mediumorchid2); - defaultPropertyMap.put(MOBY_SERVICE_ACTIVITY, darkgoldenrod1); - defaultPropertyMap.put(MOBY_OBJECT_ACTIVITY, gold); - defaultPropertyMap.put(MOBY_PARSER_ACTIVITY, white); - defaultPropertyMap.put(NESTED_WORKFLOW, pink); - defaultPropertyMap.put(RSHELL_ACTIVITY, steelblue4); - defaultPropertyMap.put(SOAPLAB_ACTIVITY, lightgoldenrodyellow); - defaultPropertyMap.put(WSDL_ACTIVITY, darkolivegreen3); - defaultPropertyMap.put(XML_SPLITTER_IN_ACTIVITY, lightpurple); - defaultPropertyMap.put(XML_SPLITTER_OUT_ACTIVITY, lightpurple); - - defaultPropertyMap.put(NONEXECUTABLE_ACTIVITY, grey); - - defaultPropertyMap.put(MERGE_OBJECT, turquoise); - defaultPropertyMap.put(PROCESSOR_OBJECT, shadedgreen); - defaultPropertyMap.put(PROCESSOR_PORT_OBJECT, purplish); - defaultPropertyMap.put(WORKFLOW_PORT_OBJECT, shadedorange); - } - - @Override - public Color getPreferredColour(String itemKey) { - Color colour = cachedColours.get(itemKey); - if (colour == null) { - String colourString = (String) getProperty(itemKey); - colour = colourString == null ? WHITE : decode(colourString); - cachedColours.put(itemKey, colour); - } - return colour; - } - - @Override - public void setPreferredColour(String itemKey, Color colour) { - cachedColours.put(itemKey, colour); - } - - @Override - public void restoreDefaults() { - super.restoreDefaults(); - if (cachedColours == null) - cachedColours = new HashMap<>(); - else - cachedColours.clear(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java deleted file mode 100644 index 0ff6c65..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.mimetype; - -import java.util.HashMap; -import java.util.Map; - -import net.sf.taverna.t2.workbench.configuration.mimetype.MimeTypeManager; -import uk.org.taverna.configuration.AbstractConfigurable; -import uk.org.taverna.configuration.ConfigurationManager; - -public class MimeTypeManagerImpl extends AbstractConfigurable implements - MimeTypeManager { - /** - * Constructs a new <code>MimeTypeManagerImpl</code>. - * - * @param configurationManager - */ - public MimeTypeManagerImpl(ConfigurationManager configurationManager) { - super(configurationManager); - } - - @Override - public String getCategory() { - return "Mime Type"; - } - - @Override - public Map<String, String> getDefaultPropertyMap() { - HashMap<String, String> map = new HashMap<>(); - map.put("text/plain", "Plain Text"); - map.put("text/xml", "XML Text"); - map.put("text/html", "HTML Text"); - map.put("text/rtf", "Rich Text Format"); - map.put("text/x-graphviz", "Graphviz Dot File"); - map.put("image/png", "PNG Image"); - map.put("image/jpeg", "JPEG Image"); - map.put("image/gif", "GIF Image"); - map.put("application/octet-stream", "Binary Data"); - map.put("application/zip", "Zip File"); - map.put("chemical/x-swissprot", "SWISSPROT Flat File"); - map.put("chemical/x-embl-dl-nucleotide", "EMBL Flat File"); - map.put("chemical/x-ppd", "PPD File"); - map.put("chemical/seq-aa-genpept", "Genpept Protein"); - map.put("chemical/seq-na-genbank", "Genbank Nucleotide"); - map.put("chemical/x-pdb", "PDB 3D Structure File"); - return map; - } - - @Override - public String getUUID() { - return "b9277fa0-5967-11dd-ae16-0800200c9a66"; - } - - @Override - public String getDisplayName() { - return "Mime Type Manager"; - } - - @Override - public String getFilePrefix() { - return "MimeTypeManagerImpl"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java deleted file mode 100644 index 4910f78..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.ui; - -import static javax.swing.JSplitPane.HORIZONTAL_SPLIT; -import static net.sf.taverna.t2.workbench.helper.HelpCollator.registerComponent; -import static net.sf.taverna.t2.workbench.helper.Helper.setKeyCatcher; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import javax.swing.JFrame; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.ListModel; -import javax.swing.border.EmptyBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import net.sf.taverna.t2.workbench.configuration.workbench.ui.T2ConfigurationFrame; - -import org.apache.log4j.Logger; - -import uk.org.taverna.configuration.ConfigurationUIFactory; - -public class T2ConfigurationFrameImpl implements T2ConfigurationFrame { - private static Logger logger = Logger.getLogger(T2ConfigurationFrameImpl.class); - private static final int FRAME_WIDTH = 700; - private static final int FRAME_HEIGHT = 450; - - private List<ConfigurationUIFactory> configurationUIFactories = new ArrayList<>(); - - private JFrame frame; - private JSplitPane splitPane; - private JList<ConfigurableItem> list; - - public T2ConfigurationFrameImpl() { - } - - @Override - public void showFrame() { - getFrame().setVisible(true); - } - - @Override - public void showConfiguration(String name) { - showFrame(); - ListModel<ConfigurableItem> lm = list.getModel(); - for (int i = 0; i < lm.getSize(); i++) - if (lm.getElementAt(i).toString().equals(name)) { - list.setSelectedIndex(i); - break; - } - } - - private JFrame getFrame() { - if (frame != null) - return frame; - - frame = new JFrame(); - setKeyCatcher(frame); - registerComponent(frame); - frame.setLayout(new BorderLayout()); - - /* - * Split pane to hold list of properties (on the left) and their - * configurable options (on the right) - */ - splitPane = new JSplitPane(HORIZONTAL_SPLIT); - splitPane.setBorder(null); - - list = getConfigurationList(); - JScrollPane jspList = new JScrollPane(list); - jspList.setBorder(new EmptyBorder(5, 5, 5, 5)); - jspList.setMinimumSize(new Dimension(150, - jspList.getPreferredSize().height)); - - splitPane.setLeftComponent(jspList); - splitPane.setRightComponent(new JPanel()); - splitPane.setDividerSize(1); - - // select first item if one exists - if (list.getModel().getSize() > 0) - list.setSelectedValue(list.getModel().getElementAt(0), true); - - frame.add(splitPane); - frame.setSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT)); - return frame; - } - - private JList<ConfigurableItem> getConfigurationList() { - if (list != null) - return list; - - list = new JList<>(); - list.addListSelectionListener(new ListSelectionListener() { - @Override - public void valueChanged(ListSelectionEvent e) { - if (list.getSelectedValue() instanceof ConfigurableItem) { - ConfigurableItem item = (ConfigurableItem) list - .getSelectedValue(); - setMainPanel(item.getPanel()); - } - - /* - * Keep the split pane's divider at its current position - but - * looks ugly. The problem with divider moving from its current - * position after selecting an item from the list on the left is - * that the right hand side panels are loaded dynamically and it - * seems there is nothing we can do about it - it's just the - * JSplitPane's behaviour - */ - // splitPane.setDividerLocation(splitPane.getLastDividerLocation()); - } - }); - list.setListData(getListItems()); - return list; - } - - private void setMainPanel(JPanel panel) { - panel.setBorder(new EmptyBorder(15, 15, 15, 15)); - splitPane.setRightComponent(panel); - } - - public void setConfigurationUIFactories( - List<ConfigurationUIFactory> configurationUIFactories) { - this.configurationUIFactories = configurationUIFactories; - } - - private ConfigurableItem[] getListItems() { - List<ConfigurableItem> arrayList = new ArrayList<>(); - for (ConfigurationUIFactory fac : configurationUIFactories) { - String name = fac.getConfigurable().getDisplayName(); - if (name != null) { - logger.info("Adding configurable for name: " + name); - arrayList.add(new ConfigurableItem(fac)); - } else { - logger.warn("The configurable " + fac.getConfigurable().getClass() - + " has a null name"); - } - } - // Sort the list alphabetically - ConfigurableItem[] array = arrayList.toArray(new ConfigurableItem[0]); - Arrays.sort(array, new Comparator<ConfigurableItem>() { - @Override - public int compare(ConfigurableItem item1, ConfigurableItem item2) { - return item1.toString().compareToIgnoreCase(item2.toString()); - } - }); - return array; - } - - public void update(Object service, Map<?, ?> properties) { - getConfigurationList().setListData(getListItems()); - if (frame != null) { - frame.revalidate(); - frame.repaint(); - // select first item if one exists - if (list.getModel().getSize() > 0) - list.setSelectedValue(list.getModel().getElementAt(0), true); - } - } - - class ConfigurableItem { - private final ConfigurationUIFactory factory; - - public ConfigurableItem(ConfigurationUIFactory factory) { - this.factory = factory; - } - - public JPanel getPanel() { - return factory.getConfigurationPanel(); - } - - @Override - public String toString() { - return factory.getConfigurable().getDisplayName(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java deleted file mode 100644 index 453f0c0..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.ui; - -import java.awt.event.ActionEvent; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -import net.sf.taverna.t2.ui.menu.AbstractMenuAction; -import net.sf.taverna.t2.workbench.configuration.workbench.ui.T2ConfigurationFrame; - -public class WorkbenchConfigurationMenu extends AbstractMenuAction { - private static final String MAC_OS_X = "Mac OS X"; - - private T2ConfigurationFrame t2ConfigurationFrame; - - public WorkbenchConfigurationMenu() { - super(URI.create("http://taverna.sf.net/2008/t2workbench/menu#preferences"), - 100); - } - - @SuppressWarnings("serial") - @Override - protected Action createAction() { - return new AbstractAction("Preferences") { - @Override - public void actionPerformed(ActionEvent event) { - t2ConfigurationFrame.showFrame(); - } - }; - } - - @Override - public boolean isEnabled() { - return !MAC_OS_X.equalsIgnoreCase(System.getProperty("os.name")); - } - - public void setT2ConfigurationFrame(T2ConfigurationFrame t2ConfigurationFrame) { - this.t2ConfigurationFrame = t2ConfigurationFrame; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java b/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java deleted file mode 100644 index d131ac3..0000000 --- a/taverna-workbench-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.ui; - -import java.net.URI; - -import net.sf.taverna.t2.ui.menu.AbstractMenuSection; - -public class WorkbenchPreferencesSection extends AbstractMenuSection { - private static final URI FILE_MENU = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#file"); - private static final URI PREFERENCES_MENU_ITEM = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#preferences"); - - public WorkbenchPreferencesSection() { - super(FILE_MENU, 100, PREFERENCES_MENU_ITEM); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent deleted file mode 100644 index 3b51dd4..0000000 --- a/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent +++ /dev/null @@ -1,2 +0,0 @@ -net.sf.taverna.t2.workbench.ui.impl.configuration.ui.WorkbenchPreferencesSection -net.sf.taverna.t2.workbench.ui.impl.configuration.ui.WorkbenchConfigurationMenu http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory b/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory deleted file mode 100644 index 4af55ec..0000000 --- a/taverna-workbench-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.workbench.ui.impl.configuration.WorkbenchConfigurationUIFactory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml b/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml deleted file mode 100644 index 29aea44..0000000 --- a/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:beans="http://www.springframework.org/schema/beans" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/osgi - http://www.springframework.org/schema/osgi/spring-osgi.xsd"> - - <service ref="t2ConfigurationFrame" interface="net.sf.taverna.t2.workbench.configuration.workbench.ui.T2ConfigurationFrame" /> - - <service ref="WorkbenchConfigurationUIFactory" interface="uk.org.taverna.configuration.ConfigurationUIFactory" /> - - <service ref="WorkbenchPreferencesSection" auto-export="interfaces" /> - <service ref="WorkbenchConfigurationMenu" auto-export="interfaces" /> - - <service ref="ColourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" /> - <service ref="WorkbenchConfiguration" interface="net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration" /> - <service ref="MimeTypeManager" interface="net.sf.taverna.t2.workbench.configuration.mimetype.MimeTypeManager" /> - - <reference id="configurationManager" interface="uk.org.taverna.configuration.ConfigurationManager" /> - <reference id="applicationConfiguration" interface="uk.org.taverna.configuration.app.ApplicationConfiguration" /> - - <list id="configurationUIFactories" interface="uk.org.taverna.configuration.ConfigurationUIFactory" cardinality="0..N"> - <listener ref="t2ConfigurationFrame" bind-method="update" unbind-method="update"/> - </list> - -</beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml b/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml deleted file mode 100644 index 40da7fd..0000000 --- a/taverna-workbench-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <bean id="t2ConfigurationFrame" class="net.sf.taverna.t2.workbench.ui.impl.configuration.ui.T2ConfigurationFrameImpl"> - <property name="configurationUIFactories" ref="configurationUIFactories" /> - </bean> - - <bean id="WorkbenchConfigurationUIFactory" class="net.sf.taverna.t2.workbench.ui.impl.configuration.WorkbenchConfigurationUIFactory"> - <property name="workbenchConfiguration"> - <ref local="WorkbenchConfiguration"/> - </property> - </bean> - - <bean id="WorkbenchPreferencesSection" class="net.sf.taverna.t2.workbench.ui.impl.configuration.ui.WorkbenchPreferencesSection" /> - <bean id="WorkbenchConfigurationMenu" class="net.sf.taverna.t2.workbench.ui.impl.configuration.ui.WorkbenchConfigurationMenu"> - <property name="t2ConfigurationFrame"> - <ref local="t2ConfigurationFrame"/> - </property> - </bean> - - <bean id="ColourManager" class="net.sf.taverna.t2.workbench.ui.impl.configuration.colour.ColourManagerImpl"> - <constructor-arg ref="configurationManager"/> - </bean> - <bean id="WorkbenchConfiguration" class="net.sf.taverna.t2.workbench.ui.impl.configuration.WorkbenchConfigurationImpl"> - <constructor-arg ref="configurationManager"/> - <property name="applicationConfiguration" ref="applicationConfiguration" /> - </bean> - <bean id="MimeTypeManager" class="net.sf.taverna.t2.workbench.ui.impl.configuration.mimetype.MimeTypeManagerImpl"> - <constructor-arg ref="configurationManager"/> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ConfigurationManagerTest.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ConfigurationManagerTest.java b/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ConfigurationManagerTest.java deleted file mode 100644 index 1202c11..0000000 --- a/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ConfigurationManagerTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.util.UUID; - -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.ui.impl.configuration.colour.ColourManagerImpl; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import uk.org.taverna.configuration.app.impl.ApplicationConfigurationImpl; -import uk.org.taverna.configuration.impl.ConfigurationManagerImpl; - -public class ConfigurationManagerTest { - - ConfigurationManagerImpl configurationManager; - - @Before - public void setup() { - configurationManager = new ConfigurationManagerImpl(new ApplicationConfigurationImpl()); - } - - @Test - public void createConfigManager() { - assertNotNull("Config Manager should not be null", configurationManager); - } - - @Ignore("Hardcoded /Users/Ian") //FIXME: update test to work using File.createTempFile(...) - @Test - public void populateConfigOfColourmanager() { - ColourManager manager= new ColourManagerImpl(null); - - manager.setProperty("colour.first", "25"); - manager.setProperty("colour.second", "223"); - - configurationManager.setBaseConfigLocation(new File("/Users/Ian/scratch")); - try { - configurationManager.store(manager); - } catch (Exception e1) { - e1.printStackTrace(); - } - - ColourManager manager2 = new ColourManagerImpl(configurationManager); - - try { - configurationManager.populate(manager2); - } catch (Exception e) { - e.printStackTrace(); - } - - - assertEquals("Properties do not match", manager2.getProperty("colour.first"), manager.getProperty("colour.first")); - assertEquals("Properties do not match", manager2.getProperty("colour.second"), manager.getProperty("colour.second")); - - - } - - @Test - public void saveColoursForDummyColourable() { - String dummy = ""; - ColourManager manager=new ColourManagerImpl(configurationManager); - manager.setProperty(dummy.getClass().getCanonicalName(), "#000000"); - - File f = new File(System.getProperty("java.io.tmpdir")); - File d = new File(f, UUID.randomUUID().toString()); - d.mkdir(); - configurationManager.setBaseConfigLocation(d); - try { - configurationManager.store(manager); - } catch (Exception e1) { - e1.printStackTrace(); - } - - try { - configurationManager.populate(manager); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerTest.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerTest.java b/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerTest.java deleted file mode 100644 index 0239ea8..0000000 --- a/taverna-workbench-configuration-impl/src/test/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.impl.configuration.colour; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.awt.Color; -import java.io.File; -import java.util.UUID; - -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; - -import org.junit.Before; -import org.junit.Test; - -import uk.org.taverna.configuration.Configurable; -import uk.org.taverna.configuration.app.impl.ApplicationConfigurationImpl; -import uk.org.taverna.configuration.impl.ConfigurationManagerImpl; - -public class ColourManagerTest { - - private ConfigurationManagerImpl configurationManager; - - @Before - public void setup() { - configurationManager = new ConfigurationManagerImpl(new ApplicationConfigurationImpl()); - - File f = new File(System.getProperty("java.io.tmpdir")); - File d = new File(f, UUID.randomUUID().toString()); - d.mkdir(); - configurationManager.setBaseConfigLocation(d); - } - - @Test - public void testGetPreferredColourEqualsWhite() throws Exception { - String dummy = new String(); - - Color c = new ColourManagerImpl(configurationManager).getPreferredColour(dummy); - assertEquals("The default colour should be WHITE", Color.WHITE, c); - } - - @Test - public void testConfigurableness() throws Exception { - ColourManager manager = new ColourManagerImpl(configurationManager); - assertTrue(manager instanceof Configurable); - - assertEquals("wrong category", "colour", manager.getCategory()); - assertEquals("wrong name", "Colour Management", manager.getDisplayName()); - assertEquals("wrong UUID", "a2148420-5967-11dd-ae16-0800200c9a66", - manager.getUUID()); - assertNotNull("there is no default property map", manager - .getDefaultPropertyMap()); - } - - @Test - public void saveAsWrongArrayType() throws Exception { - String dummy = ""; - ColourManager manager = new ColourManagerImpl(configurationManager); - manager.setProperty(dummy.getClass().getCanonicalName(), "#ffffff"); - - File baseLoc = File.createTempFile("test", "scratch"); - baseLoc.delete(); - assertTrue("Could not make directory " + baseLoc, baseLoc.mkdir()); - configurationManager.setBaseConfigLocation(baseLoc); - configurationManager.store(manager); - configurationManager.populate(manager); - manager.getPreferredColour(dummy); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/pom.xml b/taverna-workbench-contextual-views-api/pom.xml deleted file mode 100644 index 5b8608f..0000000 --- a/taverna-workbench-contextual-views-api/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sf.taverna.t2</groupId> - <artifactId>ui-api</artifactId> - <version>2.0-SNAPSHOT</version> - </parent> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>contextual-views-api</artifactId> - <packaging>bundle</packaging> - <name>Contextual Views API</name> - <description>Contextual views for the activities</description> - <dependencies> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>activity-icons-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>activity-palette-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>configuration-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>edits-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>file-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>helper-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>workbench-api</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>net.sf.taverna.t2.lang</groupId> - <artifactId>ui</artifactId> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.lang</groupId> - <artifactId>observer</artifactId> - </dependency> - <dependency> - <groupId>uk.org.taverna.scufl2</groupId> - <artifactId>scufl2-api</artifactId> - </dependency> - <dependency> - <groupId>uk.org.taverna.commons</groupId> - <artifactId>taverna-services-api</artifactId> - </dependency> - - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </dependency> - <dependency> - <groupId>org.apache.log4j</groupId> - <artifactId>com.springsource.org.apache.log4j</artifactId> - </dependency> - </dependencies> - <repositories> - <repository> - <releases /> - <snapshots> - <enabled>false</enabled> - </snapshots> - <id>mygrid-repository</id> - <name>myGrid Repository</name> - <url>http://www.mygrid.org.uk/maven/repository - </url> - </repository> - <repository> - <releases> - <enabled>false</enabled> - </releases> - <snapshots /> - <id>mygrid-snapshot-repository</id> - <name>myGrid Snapshot Repository</name> - <url>http://www.mygrid.org.uk/maven/snapshot-repository</url> - </repository> - </repositories> -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityConfigurationAction.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityConfigurationAction.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityConfigurationAction.java deleted file mode 100644 index 4d2fcff..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityConfigurationAction.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.actions.activity; - -import java.util.List; -import java.util.WeakHashMap; - -import javax.swing.AbstractAction; -import javax.swing.JDialog; - -import net.sf.taverna.t2.lang.observer.Observable; -import net.sf.taverna.t2.lang.observer.Observer; -import net.sf.taverna.t2.servicedescriptions.ServiceDescription; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.file.events.ClosingDataflowEvent; -import net.sf.taverna.t2.workbench.file.events.FileManagerEvent; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog; -import uk.org.taverna.scufl2.api.activity.Activity; -import uk.org.taverna.scufl2.api.common.Scufl2Tools; -import uk.org.taverna.scufl2.api.container.WorkflowBundle; -import uk.org.taverna.scufl2.api.core.Processor; -import uk.org.taverna.scufl2.api.core.Workflow; -import uk.org.taverna.scufl2.api.profiles.ProcessorBinding; -import uk.org.taverna.scufl2.api.profiles.Profile; - -@SuppressWarnings("serial") -public abstract class ActivityConfigurationAction extends AbstractAction { - private static WeakHashMap<Activity, ActivityConfigurationDialog> configurationDialogs = new WeakHashMap<>(); - private static DataflowCloseListener listener; - - protected Activity activity; - private final ServiceDescriptionRegistry serviceDescriptionRegistry; - - public ActivityConfigurationAction(Activity activity, - ActivityIconManager activityIconManager, - ServiceDescriptionRegistry serviceDescriptionRegistry) { - this.activity = activity; - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - putValue(SMALL_ICON, - activityIconManager.iconForActivity(activity.getType())); - } - - protected Activity getActivity() { - return activity; - } - - protected ServiceDescription getServiceDescription() { - return serviceDescriptionRegistry.getServiceDescription(activity - .getType()); - } - - protected static void setDialog(Activity activity, - ActivityConfigurationDialog dialog, FileManager fileManager) { - if (listener == null) { - listener = new DataflowCloseListener(); - /* - * Ensure that the DataflowCloseListener is the first notified - * listener. Otherwise you cannot save the configurations. - */ - List<Observer<FileManagerEvent>> existingListeners = fileManager - .getObservers(); - fileManager.addObserver(listener); - for (Observer<FileManagerEvent> observer : existingListeners) - if (!observer.equals(listener)) { - fileManager.removeObserver(observer); - fileManager.addObserver(observer); - } - } - if (configurationDialogs.containsKey(activity)) { - ActivityConfigurationDialog currentDialog = configurationDialogs - .get(activity); - if (!currentDialog.equals(dialog) && currentDialog.isVisible()) - currentDialog.setVisible(false); - } - configurationDialogs.put(activity, dialog); - dialog.setVisible(true); - } - - public static void clearDialog(Activity activity) { - if (configurationDialogs.containsKey(activity)) { - ActivityConfigurationDialog currentDialog = configurationDialogs - .get(activity); - if (currentDialog.isVisible()) - currentDialog.setVisible(false); - configurationDialogs.remove(activity); - currentDialog.dispose(); - } - } - - protected static void clearDialog(JDialog dialog) { - if (configurationDialogs.containsValue(dialog)) { - if (dialog.isVisible()) - dialog.setVisible(false); - for (Activity activity : configurationDialogs.keySet()) - if (configurationDialogs.get(activity).equals(dialog)) - configurationDialogs.remove(activity); - dialog.dispose(); - } - } - - public static boolean closeDialog(Activity activity) { - boolean closeIt = true; - if (configurationDialogs.containsKey(activity)) { - ActivityConfigurationDialog currentDialog = configurationDialogs - .get(activity); - if (currentDialog.isVisible()) - closeIt = currentDialog.closeDialog(); - if (closeIt) - configurationDialogs.remove(activity); - } - return closeIt; - } - - public static ActivityConfigurationDialog getDialog(Activity activity) { - return configurationDialogs.get(activity); - } - - private static class DataflowCloseListener implements - Observer<FileManagerEvent> { - private Scufl2Tools scufl2Tools = new Scufl2Tools(); - - @Override - public void notify(Observable<FileManagerEvent> sender, - FileManagerEvent message) throws Exception { - if (message instanceof ClosingDataflowEvent) { - ClosingDataflowEvent closingDataflowEvent = (ClosingDataflowEvent) message; - if (closingDataflowEvent.isAbortClose()) - return; - closingDataflow(closingDataflowEvent, - ((ClosingDataflowEvent) message).getDataflow()); - } - } - - private void closingDataflow(ClosingDataflowEvent event, - WorkflowBundle bundle) { - Profile profile = bundle.getMainProfile(); - for (Workflow workflow : bundle.getWorkflows()) - for (Processor p : workflow.getProcessors()) { - ProcessorBinding processorBinding = scufl2Tools - .processorBindingForProcessor(p, profile); - Activity activity = processorBinding.getBoundActivity(); - if (!closeDialog(activity)) - event.setAbortClose(true); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityContextualView.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityContextualView.java deleted file mode 100644 index f063c02..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/ActivityContextualView.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.actions.activity; - -import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView; -import uk.org.taverna.scufl2.api.activity.Activity; -import uk.org.taverna.scufl2.api.common.Scufl2Tools; -import uk.org.taverna.scufl2.api.configurations.Configuration; - -/** - * A contextual view specific to an Activity. Concrete subclasses must - * initialise the view by calling {@link #initView()}. - * <p> - * The implementation provides a view based upon the properties set in the - * Configuration - * - * @author Stuart Owen - * @author Ian Dunlop - * - * @see Activity - * @see ContextualView - */ -@SuppressWarnings("serial") -public abstract class ActivityContextualView extends ContextualView { - private Activity activity; - private Scufl2Tools scufl2Tools = new Scufl2Tools(); - - /** - * Constructs an instance of the view. - * <p> - * The constructor parameter for the implementation of this class should - * define the specific Activity type itself. - * - * @param activity - */ - protected ActivityContextualView(Activity activity) { - super(); - this.activity = activity; - } - - public Activity getActivity() { - return activity; - } - - public Configuration getConfigBean() { - return scufl2Tools.configurationFor(activity, activity.getParent()); - } - - @Override - public abstract void refreshView(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/HTMLBasedActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/HTMLBasedActivityContextualView.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/HTMLBasedActivityContextualView.java deleted file mode 100644 index de3df33..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/actions/activity/HTMLBasedActivityContextualView.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.actions.activity; - -import static net.sf.taverna.t2.lang.ui.HtmlUtils.buildTableOpeningTag; -import static net.sf.taverna.t2.lang.ui.HtmlUtils.createEditorPane; -import static net.sf.taverna.t2.lang.ui.HtmlUtils.getHtmlHead; -import static net.sf.taverna.t2.lang.ui.HtmlUtils.panelForHtml; - -import javax.swing.JComponent; -import javax.swing.JEditorPane; - -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import uk.org.taverna.scufl2.api.activity.Activity; - -@SuppressWarnings("serial") -public abstract class HTMLBasedActivityContextualView extends ActivityContextualView { - private static final String BEANSHELL_URI = "http://ns.taverna.org.uk/2010/activity/beanshell"; - private static final String LOCALWORKER_URI = "http://ns.taverna.org.uk/2010/activity/localworker"; - private JEditorPane editorPane; - private final ColourManager colourManager; - - public HTMLBasedActivityContextualView(Activity activity, ColourManager colourManager) { - super(activity); - this.colourManager = colourManager; - initView(); - } - - @Override - public JComponent getMainFrame() { - editorPane = createEditorPane(buildHtml()); - return panelForHtml(editorPane); - } - - private String buildHtml() { - StringBuilder html = new StringBuilder(getHtmlHead(getBackgroundColour())); - html.append(buildTableOpeningTag()); - html.append("<tr><th colspan=\"2\">").append(getViewTitle()).append("</th></tr>"); - html.append(getRawTableRowsHtml()).append("</table>"); - html.append("</body></html>"); - return html.toString(); - } - - protected abstract String getRawTableRowsHtml(); - - public String getBackgroundColour() { - String activityType = getActivity().getType().toString(); - if (LOCALWORKER_URI.equals(activityType)) - if (getConfigBean().getJson().get("isAltered").booleanValue()) - return (String) colourManager.getProperty(BEANSHELL_URI); - String colour = (String) colourManager.getProperty(activityType); - return colour == null ? "#ffffff" : colour; - } - - /** - * Update the html view with the latest information in the configuration - * bean - */ - @Override - public void refreshView() { - editorPane.setText(buildHtml()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/AddLayerFactorySPI.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/AddLayerFactorySPI.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/AddLayerFactorySPI.java deleted file mode 100644 index 6b0245c..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/AddLayerFactorySPI.java +++ /dev/null @@ -1,43 +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.ui.views.contextualviews; - -import java.net.URI; - -import javax.swing.Action; - -import uk.org.taverna.scufl2.api.core.Processor; - -/** - * SPI for adding dispatch stack layers to a processor, such as - * {@link net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Loop}. - * <p> - * Buttons or similar will be added in the processor contextual view. - * - * @author Stian Soiland-Reyes - */ -public interface AddLayerFactorySPI { - boolean canAddLayerFor(Processor proc); - - Action getAddLayerActionFor(Processor proc); - - boolean canCreateLayerClass(URI dispatchLayerType); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/ContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/ContextualView.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/ContextualView.java deleted file mode 100644 index 45efaab..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/ContextualView.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews; - -import static java.awt.BorderLayout.CENTER; - -import java.awt.BorderLayout; -import java.awt.Frame; - -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.JPanel; - -/** - * An abstract class defining the base container to hold a contextual view over - * Dataflow element. - * <p> - * The specific implementation of this class to support a given dataflow element - * needs to implement the {@link #getMainFrame()} and {@link #getViewTitle()}. - * <p> - * If a view is associated with an action handler to configure this component, - * then the {@link #getConfigureAction(Frame) getConfigureAction} handler must - * be over-ridden. If this returns null then the configure button is left - * disabled and it is not possible to configure the element. - * - * @author Stuart Owen - * @author Ian Dunlop - * @author Alan R Williams - */ -@SuppressWarnings("serial") -public abstract class ContextualView extends JPanel { - /** - * When implemented, this method should define the main frame that is placed - * in this container, and provides a static view of the Dataflow element. - * - * @return a JComponent that represents the dataflow element. - */ - public abstract JComponent getMainFrame(); - - /** - * @return a String providing a title for the view - */ - public abstract String getViewTitle(); - - /** - * Allows the item to be configured, but returning an action handler that - * will be invoked when selecting to configure. By default this is provided - * by a button. - * <p> - * If there is no ability to configure the given item, then this should - * return null. - * - * @param owner - * the owning dialog to be used when displaying dialogues for - * configuration options - * @return an action that allows the element being viewed to be configured. - */ - public Action getConfigureAction(Frame owner) { - return null; - } - - /** - * This <i>must</i> be called by any sub-classes after they have initialised - * their own view since it gets their main panel and adds it to the main - * contextual view. If you don't do this you will get a very empty frame - * popping up! - */ - public void initView() { - setLayout(new BorderLayout()); - add(getMainFrame(), CENTER); - setName(getViewTitle()); - } - - public abstract void refreshView(); - - public abstract int getPreferredPosition(); - - public static String getTextFromDepth(String kind, Integer depth) { - String labelText = "The last prediction said the " + kind; - if (depth == null) { - labelText += " would not transmit a value"; - } else if (depth == -1) { - labelText += " was invalid/unpredicted"; - } else if (depth == 0) { - labelText += " would carry a single value"; - } else { - labelText += " would carry a list of depth " + depth; - } - return labelText; - } -}
