http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java b/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java deleted file mode 100644 index ecddc35..0000000 --- a/taverna-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java b/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java deleted file mode 100644 index 263233f..0000000 --- a/taverna-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/colour/ColourManagerImpl.java b/taverna-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-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java b/taverna-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-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java b/taverna-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-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java b/taverna-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-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/a9a52bd5/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java b/taverna-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-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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationImpl.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationImpl.java new file mode 100644 index 0000000..b7bf1f2 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationImpl.java @@ -0,0 +1,209 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import org.apache.taverna.workbench.configuration.workbench.WorkbenchConfiguration; + +import org.apache.log4j.Logger; + +import uk.org.taverna.configuration.AbstractConfigurable; +import uk.org.taverna.configuration.ConfigurationManager; +import uk.org.taverna.configuration.app.ApplicationConfiguration; + +/** + * An implementation of Configurable for general Workbench configuration + * properties + * + * @author Stuart Owen + * @author Stian Soiland-Reyes + */ +public class WorkbenchConfigurationImpl extends AbstractConfigurable implements + WorkbenchConfiguration { + private static Logger logger = Logger + .getLogger(WorkbenchConfiguration.class); + private static final int DEFAULT_MAX_MENU_ITEMS = 20; + public static final String TAVERNA_DOTLOCATION = "taverna.dotlocation"; + public static final String MAX_MENU_ITEMS = "taverna.maxmenuitems"; + public static final String WARN_INTERNAL_ERRORS = "taverna.warninternal"; + public static final String CAPTURE_CONSOLE = "taverna.captureconsole"; + private static final String BIN = "bin"; + private static final String BUNDLE_CONTENTS = "Contents"; + private static final String BUNDLE_MAC_OS = "MacOS"; + private static final String DOT_EXE = "dot.exe"; + private static final String DOT_FALLBACK = "dot"; + public static String uuid = "c14856f0-5967-11dd-ae16-0800200c9a66"; + private static final String MAC_OS_X = "Mac OS X"; + private static final String WIN32I386 = "win32i386"; + private static final String WINDOWS = "Windows"; + + private ApplicationConfiguration applicationConfiguration; + + /** + * Constructs a new <code>WorkbenchConfigurationImpl</code>. + * + * @param configurationManager + */ + public WorkbenchConfigurationImpl(ConfigurationManager configurationManager) { + super(configurationManager); + } + + Map<String, String> defaultWorkbenchProperties = null; + Map<String, String> workbenchProperties = new HashMap<String, String>(); + + @Override + public String getCategory() { + return "general"; + } + + @Override + public Map<String, String> getDefaultPropertyMap() { + if (defaultWorkbenchProperties == null) { + defaultWorkbenchProperties = new HashMap<>(); + String dotLocation = System.getProperty(TAVERNA_DOTLOCATION) != null ? System + .getProperty(TAVERNA_DOTLOCATION) : getDefaultDotLocation(); + if (dotLocation != null) + defaultWorkbenchProperties + .put(TAVERNA_DOTLOCATION, dotLocation); + defaultWorkbenchProperties.put(MAX_MENU_ITEMS, + Integer.toString(DEFAULT_MAX_MENU_ITEMS)); + defaultWorkbenchProperties.put(WARN_INTERNAL_ERRORS, + Boolean.FALSE.toString()); + defaultWorkbenchProperties.put(CAPTURE_CONSOLE, + Boolean.TRUE.toString()); + } + return defaultWorkbenchProperties; + } + + @Override + public String getDisplayName() { + return "Workbench"; + } + + @Override + public String getFilePrefix() { + return "Workbench"; + } + + @Override + public String getUUID() { + return uuid; + } + + @Override + public boolean getWarnInternalErrors() { + String property = getProperty(WARN_INTERNAL_ERRORS); + return Boolean.parseBoolean(property); + } + + @Override + public boolean getCaptureConsole() { + String property = getProperty(CAPTURE_CONSOLE); + return Boolean.parseBoolean(property); + } + + @Override + public void setWarnInternalErrors(boolean warnInternalErrors) { + setProperty(WARN_INTERNAL_ERRORS, Boolean.toString(warnInternalErrors)); + } + + @Override + public void setCaptureConsole(boolean captureConsole) { + setProperty(CAPTURE_CONSOLE, Boolean.toString(captureConsole)); + } + + @Override + public void setMaxMenuItems(int maxMenuItems) { + if (maxMenuItems < 2) + throw new IllegalArgumentException( + "Maximum menu items must be at least 2"); + setProperty(MAX_MENU_ITEMS, Integer.toString(maxMenuItems)); + } + + @Override + public int getMaxMenuItems() { + String property = getProperty(MAX_MENU_ITEMS); + try { + int maxMenuItems = Integer.parseInt(property); + if (maxMenuItems >= 2) + return maxMenuItems; + logger.warn(MAX_MENU_ITEMS + " can't be less than 2"); + } catch (NumberFormatException ex) { + logger.warn("Invalid number for " + MAX_MENU_ITEMS + ": " + + property); + } + // We'll return the default instead + return DEFAULT_MAX_MENU_ITEMS; + } + + @Override + public String getDotLocation() { + return getProperty(TAVERNA_DOTLOCATION); + } + + @Override + public void setDotLocation(String dotLocation) { + setProperty(TAVERNA_DOTLOCATION, dotLocation); + } + + private String getDefaultDotLocation() { + if (applicationConfiguration == null) + return null; + File startupDir = applicationConfiguration.getStartupDir(); + if (startupDir == null) + return DOT_FALLBACK; + + String os = System.getProperty("os.name"); + if (os.equals(MAC_OS_X)) + if (startupDir.getParentFile() != null) { + File contentsDir = startupDir.getParentFile().getParentFile(); + if (contentsDir != null + && contentsDir.getName().equalsIgnoreCase( + BUNDLE_CONTENTS)) { + File dot = new File(new File(contentsDir, BUNDLE_MAC_OS), + DOT_FALLBACK); + if (dot.exists()) + return dot.getAbsolutePath(); + } + } else if (os.startsWith(WINDOWS)) { + File binWin386Dir = new File(new File(startupDir, BIN), + WIN32I386); + File dot = new File(binWin386Dir, DOT_EXE); + if (dot.exists()) + return dot.getAbsolutePath(); + } + return DOT_FALLBACK; + } + + /** + * Sets the applicationConfiguration. + * + * @param applicationConfiguration + * the new value of applicationConfiguration + */ + public void setApplicationConfiguration( + ApplicationConfiguration applicationConfiguration) { + this.applicationConfiguration = applicationConfiguration; + defaultWorkbenchProperties = null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java new file mode 100644 index 0000000..dec3d13 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationPanel.java @@ -0,0 +1,265 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.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 org.apache.taverna.workbench.helper.Helper.showHelp; +import static org.apache.taverna.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 org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java new file mode 100644 index 0000000..7351462 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/WorkbenchConfigurationUIFactory.java @@ -0,0 +1,51 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration; + +import javax.swing.JPanel; + +import uk.org.taverna.configuration.Configurable; +import uk.org.taverna.configuration.ConfigurationUIFactory; + +import org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/colour/ColourManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/colour/ColourManagerImpl.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/colour/ColourManagerImpl.java new file mode 100644 index 0000000..1f5ccd6 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/colour/ColourManagerImpl.java @@ -0,0 +1,177 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.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 org.apache.taverna.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 = "org.apache.taverna.scufl2.api.port.WorkflowPort"; + private static final String PROCESSOR_PORT_OBJECT = "org.apache.taverna.scufl2.api.port.ProcessorPort"; + private static final String PROCESSOR_OBJECT = "org.apache.taverna.scufl2.api.core.Processor"; + private static final String MERGE_OBJECT = "org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java new file mode 100644 index 0000000..a0a6b0f --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/mimetype/MimeTypeManagerImpl.java @@ -0,0 +1,81 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration.mimetype; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java new file mode 100644 index 0000000..678cdc3 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/T2ConfigurationFrameImpl.java @@ -0,0 +1,204 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration.ui; + +import static javax.swing.JSplitPane.HORIZONTAL_SPLIT; +import static org.apache.taverna.workbench.helper.HelpCollator.registerComponent; +import static org.apache.taverna.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 org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java new file mode 100644 index 0000000..f5caf8d --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchConfigurationMenu.java @@ -0,0 +1,60 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration.ui; + +import java.awt.event.ActionEvent; +import java.net.URI; + +import javax.swing.AbstractAction; +import javax.swing.Action; + +import org.apache.taverna.ui.menu.AbstractMenuAction; +import org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java new file mode 100644 index 0000000..02d11a0 --- /dev/null +++ b/taverna-configuration-impl/src/main/java/org/apache/taverna/workbench/ui/impl/configuration/ui/WorkbenchPreferencesSection.java @@ -0,0 +1,35 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.ui.impl.configuration.ui; + +import java.net.URI; + +import org.apache.taverna.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/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent deleted file mode 100644 index 3b51dd4..0000000 --- a/taverna-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/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory b/taverna-configuration-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.configuration.ConfigurationUIFactory deleted file mode 100644 index 4af55ec..0000000 --- a/taverna-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/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent b/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent new file mode 100644 index 0000000..c3a2e75 --- /dev/null +++ b/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent @@ -0,0 +1,2 @@ +org.apache.taverna.workbench.ui.impl.configuration.ui.WorkbenchPreferencesSection +org.apache.taverna.workbench.ui.impl.configuration.ui.WorkbenchConfigurationMenu http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.workbench.configuration.ConfigurationUIFactory ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.workbench.configuration.ConfigurationUIFactory b/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.workbench.configuration.ConfigurationUIFactory new file mode 100644 index 0000000..7c40f64 --- /dev/null +++ b/taverna-configuration-impl/src/main/resources/META-INF/services/org.apache.taverna.workbench.configuration.ConfigurationUIFactory @@ -0,0 +1 @@ +org.apache.taverna.workbench.ui.impl.configuration.WorkbenchConfigurationUIFactory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml b/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml index 29aea44..0597ed6 100644 --- a/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml +++ b/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context-osgi.xml @@ -6,16 +6,16 @@ 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="t2ConfigurationFrame" interface="org.apache.taverna.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" /> + <service ref="ColourManager" interface="org.apache.taverna.workbench.configuration.colour.ColourManager" /> + <service ref="WorkbenchConfiguration" interface="org.apache.taverna.workbench.configuration.workbench.WorkbenchConfiguration" /> + <service ref="MimeTypeManager" interface="org.apache.taverna.workbench.configuration.mimetype.MimeTypeManager" /> <reference id="configurationManager" interface="uk.org.taverna.configuration.ConfigurationManager" /> <reference id="applicationConfiguration" interface="uk.org.taverna.configuration.app.ApplicationConfiguration" /> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml ---------------------------------------------------------------------- diff --git a/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml b/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml index 40da7fd..9b6f529 100644 --- a/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml +++ b/taverna-configuration-impl/src/main/resources/META-INF/spring/configuration-impl-context.xml @@ -3,31 +3,31 @@ 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"> + <bean id="t2ConfigurationFrame" class="org.apache.taverna.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"> + <bean id="WorkbenchConfigurationUIFactory" class="org.apache.taverna.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"> + <bean id="WorkbenchPreferencesSection" class="org.apache.taverna.workbench.ui.impl.configuration.ui.WorkbenchPreferencesSection" /> + <bean id="WorkbenchConfigurationMenu" class="org.apache.taverna.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"> + <bean id="ColourManager" class="org.apache.taverna.workbench.ui.impl.configuration.colour.ColourManagerImpl"> <constructor-arg ref="configurationManager"/> </bean> - <bean id="WorkbenchConfiguration" class="net.sf.taverna.t2.workbench.ui.impl.configuration.WorkbenchConfigurationImpl"> + <bean id="WorkbenchConfiguration" class="org.apache.taverna.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"> + <bean id="MimeTypeManager" class="org.apache.taverna.workbench.ui.impl.configuration.mimetype.MimeTypeManagerImpl"> <constructor-arg ref="configurationManager"/> </bean>
