You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 12:45:26 UTC
[02/52] [abbrv] incubator-taverna-workbench git commit:
taverna-ui-impl/
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationForm.java
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationForm.java b/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationForm.java
deleted file mode 100644
index 97f831f..0000000
--- a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationForm.java
+++ /dev/null
@@ -1,995 +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;
-
-import static java.awt.BorderLayout.CENTER;
-import static java.awt.BorderLayout.NORTH;
-import static java.awt.Color.LIGHT_GRAY;
-import static java.awt.Color.WHITE;
-import static java.awt.FlowLayout.LEFT;
-import static java.awt.Font.BOLD;
-import static java.awt.GridBagConstraints.FIRST_LINE_START;
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.LINE_START;
-import static java.awt.GridBagConstraints.NONE;
-import static java.awt.GridBagConstraints.WEST;
-import static java.awt.event.KeyEvent.VK_ENTER;
-import static java.awt.event.KeyEvent.VK_TAB;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static javax.swing.SwingConstants.BOTTOM;
-import static javax.swing.SwingConstants.TOP;
-import static javax.swing.event.HyperlinkEvent.EventType.ACTIVATED;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.tavernaCogs32x32Icon;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Desktop;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.ConnectException;
-import java.net.MalformedURLException;
-import java.net.SocketTimeoutException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.util.Properties;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.border.Border;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-import javax.swing.text.Document;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.StyleSheet;
-
-import net.sf.taverna.t2.lang.ui.DialogTextArea;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
-/**
- * User registration form.
- *
- * @author Alex Nenadic
- */
-@SuppressWarnings("serial")
-public class UserRegistrationForm extends HelpEnabledDialog {
- private static final String FAILED = "User registration failed: ";
-
- private static final String REGISTRATION_FAILED_MSG = "User registration failed. Please try again later.";
-
- private static final String REGISTRATION_URL = "http://www.mygrid.org.uk/taverna/registration/";
-
- public static final String TAVERNA_VERSION_PROPERTY_NAME = "Taverna version";
- public static final String FIRST_NAME_PROPERTY_NAME = "First name";
- public static final String LAST_NAME_PROPERTY_NAME = "Last name";
- public static final String EMAIL_ADDRESS_PROPERTY_NAME = "Email address";
- public static final String INSTITUTION_OR_COMPANY_PROPERTY_NAME = "Institution or company name";
- public static final String INDUSTRY_PROPERTY_NAME = "Industry";
- public static final String FIELD_PROPERTY_NAME = "Field of investigation";
- public static final String PURPOSE_PROPERTY_NAME = "Purpose of using Taverna";
- public static final String KEEP_ME_INFORMED_PROPERTY_NAME = "Keep me informed by email";
-
- public static final String TAVERNA_REGISTRATION_POST_PARAMETER_NAME = "taverna_registration";
- public static final String TAVERNA_VERSION_POST_PARAMETER_NAME = "taverna_version";
- public static final String FIRST_NAME_POST_PARAMETER_NAME = "first_name";
- public static final String LAST_NAME_POST_PARAMETER_NAME = "last_name";
- public static final String EMAIL_ADDRESS_POST_PARAMETER_NAME = "email";
- public static final String INSTITUTION_OR_COMPANY_POST_PARAMETER_NAME = "institution_or_company";
- public static final String INDUSTRY_TYPE_POST_PARAMETER_NAME = "industry_type";
- public static final String FIELD_POST_PARAMETER_NAME = "field";
- public static final String PURPOSE_POST_PARAMETER_NAME = "purpose";
- public static final String KEEP_ME_INFORMED_POST_PARAMETER_PROPERTY_NAME = "keep_me_informed";
-
- private static String TRUE = Boolean.TRUE.toString();
- private static String FALSE = Boolean.FALSE.toString();
-
- private static final String WELCOME = "Welcome to the Taverna User Registration Form";
- private static final String PLEASE_FILL_IN_THIS_REGISTRATION_FORM = "Please fill in this registration form to let us know that you are using Taverna";
-
- private static final String WE_DO = "Note that by registering:\n"
- + " \u25CF We do not have access to your data\n"
- + " \u25CF We do not have access to your service usage\n"
- + " \u25CF You will not be monitored\n"
- + " \u25CF We do record the information you provide\n"
- + " at registration time";
-
- private static final String WHY_REGISTER = "By registering you will:\n"
- + " \u25CF Allow us to support you better; future plans will be\n"
- + " directed towards solutions Taverna users require\n"
- + " \u25CF Help sustain Taverna development; our continued\n"
- + " funding relies on us showing usage\n"
- + " \u25CF (Optionally) Hear about news and product updates";
-
- private static final String FIRST_NAME = "*First name:";
- private static final String LAST_NAME = "*Last name:";
- private static final String EMAIL_ADDRESS = "*Email address:";
- private static final String KEEP_ME_INFORMED = "Keep me informed of news and product updates via email";
- private static final String INSTITUTION_COMPANY_NAME = "*Institution/Company name:";
- private static final String FIELD_OF_INVESTIGATION = " Field of investigation:\n"
- + " (e.g. bioinformatics)";
- private static final String WHY_YOU_INTEND_TO_USE_TAVERNA = " A brief description of how you intend\n"
- + " to use Taverna: (e.g. genome analysis\n"
- + " for bacterial strain identification)";
-
- private static String[] industryTypes = { "", "Academia - Life Sciences",
- "Academia - Social Sciences", "Academia - Physical Sciences",
- "Academia - Environmental Sciences", "Academia - Other",
- "Industry - Biotechnology", "Industry - Pharmaceutical",
- "Industry - Engineering", "Industry - Other",
- "Healthcare Services", "Goverment and Public Sector", "Other" };
-
- private static final String I_AGREE_TO_THE_TERMS_AND_CONDITIONS = "I agree to the terms and conditions of registration at";
- private static final String TERMS_AND_CONDITIONS_URL = "http://www.taverna.org.uk/legal/terms";
-
- private Logger logger = Logger.getLogger(UserRegistrationForm.class);
- private UserRegistrationData previousRegistrationData;
- private JTextField firstNameTextField;
- private JTextField lastNameTextField;
- private JTextField emailTextField;
- private JCheckBox keepMeInformedCheckBox;
- private JTextField institutionOrCompanyTextField;
- private JComboBox<String> industryTypeTextField;
- private JTextField fieldTextField;
- private JTextArea purposeTextArea;
- private JCheckBox termsAndConditionsCheckBox;
-
- private final File registrationDataFile;
- private final File remindMeLaterFile;
- private final File doNotRegisterMeFile;
- private final String appName;
-
- public UserRegistrationForm(String appName, File registrationDataFile,
- File doNotRegisterMeFile, File remindMeLaterFile) {
- super((Frame) null, "Taverna User Registration", true);
- this.appName = appName;
- this.registrationDataFile = registrationDataFile;
- this.doNotRegisterMeFile = doNotRegisterMeFile;
- this.remindMeLaterFile = remindMeLaterFile;
- initComponents();
- }
-
- public UserRegistrationForm(String appName,
- File previousRegistrationDataFile, File registrationDataFile,
- File doNotRegisterMeFile, File remindMeLaterFile) {
- super((Frame) null, "Taverna User Registration", true);
- this.appName = appName;
- this.registrationDataFile = registrationDataFile;
- this.doNotRegisterMeFile = doNotRegisterMeFile;
- this.remindMeLaterFile = remindMeLaterFile;
- previousRegistrationData = loadUserRegistrationData(previousRegistrationDataFile);
- initComponents();
- }
-
- // For testing only
- // public static void main(String[] args) throws ClassNotFoundException,
- // InstantiationException, IllegalAccessException,
- // UnsupportedLookAndFeelException{
- // WorkbenchImpl.setLookAndFeel();
- // UserRegistrationForm form = new UserRegistrationForm();
- // form.setVisible(true);
- // }
-
- private void initComponents() {
- JPanel mainPanel = new JPanel(new GridBagLayout());
-
- // Base font for all components on the form
- Font baseFont = new JLabel("base font").getFont().deriveFont(11f);
-
- // Title panel
- JPanel titlePanel = new JPanel(new FlowLayout(LEFT));
- titlePanel.setBackground(WHITE);
- // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
- JLabel titleLabel = new JLabel(WELCOME);
- titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f));
- // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
- JLabel titleIcon = new JLabel(tavernaCogs32x32Icon);
- // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10));
- DialogTextArea titleMessage = new DialogTextArea(
- PLEASE_FILL_IN_THIS_REGISTRATION_FORM);
- titleMessage.setMargin(new Insets(0, 20, 0, 10));
- titleMessage.setFont(baseFont);
- titleMessage.setEditable(false);
- titleMessage.setFocusable(false);
- // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10));
- JPanel messagePanel = new JPanel(new BorderLayout());
- messagePanel.add(titleLabel, NORTH);
- messagePanel.add(titleMessage, CENTER);
- messagePanel.setBackground(WHITE);
- titlePanel.add(titleIcon);
- titlePanel.add(messagePanel);
- addDivider(titlePanel, BOTTOM, true);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 2;
- // gbc.insets = new Insets(5, 10, 0, 0);
- mainPanel.add(titlePanel, gbc);
-
- // Registration messages
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 2;
- // gbc.insets = new Insets(5, 0, 0, 10);
- DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER);
- registrationMessage1.setMargin(new Insets(0, 10, 0, 0));
- registrationMessage1.setFont(baseFont);
- registrationMessage1.setEditable(false);
- registrationMessage1.setFocusable(false);
- registrationMessage1.setBackground(getBackground());
-
- DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO);
- registrationMessage2.setMargin(new Insets(0, 10, 0, 10));
- registrationMessage2.setFont(baseFont);
- registrationMessage2.setEditable(false);
- registrationMessage2.setFocusable(false);
- registrationMessage2.setBackground(getBackground());
- JPanel registrationMessagePanel = new JPanel(new FlowLayout(
- FlowLayout.CENTER));
- registrationMessagePanel.add(registrationMessage1);
- registrationMessagePanel.add(registrationMessage2);
- addDivider(registrationMessagePanel, BOTTOM, true);
- mainPanel.add(registrationMessagePanel, gbc);
-
- // Mandatory label
- // JLabel mandatoryLabel = new JLabel("* Mandatory fields");
- // mandatoryLabel.setFont(baseFont);
- // gbc.weightx = 0.0;
- // gbc.weighty = 0.0;
- // gbc.gridx = 0;
- // gbc.gridy = 3;
- // gbc.fill = NONE;
- // gbc.anchor = GridBagConstraints.EAST;
- // gbc.gridwidth = 2;
- // gbc.insets = new Insets(0, 10, 0, 20);
- // mainPanel.add(mandatoryLabel, gbc);
-
- // First name
- JLabel firstNameLabel = new JLabel(FIRST_NAME);
- firstNameLabel.setFont(baseFont);
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 4;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(0, 10, 0, 10);
- mainPanel.add(firstNameLabel, gbc);
-
- firstNameTextField = new JTextField();
- firstNameTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- firstNameTextField.setText(previousRegistrationData.getFirstName());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 4;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(firstNameTextField, gbc);
-
- // Last name
- JLabel lastNameLabel = new JLabel(LAST_NAME);
- lastNameLabel.setFont(baseFont);
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 5;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(0, 10, 0, 10);
- mainPanel.add(lastNameLabel, gbc);
-
- lastNameTextField = new JTextField();
- lastNameTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- lastNameTextField.setText(previousRegistrationData.getLastName());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 5;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(lastNameTextField, gbc);
-
- // Email address
- JLabel emailLabel = new JLabel(EMAIL_ADDRESS);
- emailLabel.setFont(baseFont);
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 6;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(emailLabel, gbc);
-
- emailTextField = new JTextField();
- emailTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- emailTextField.setText(previousRegistrationData.getEmailAddress());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 6;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(emailTextField, gbc);
-
- // Keep me informed
- keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED);
- keepMeInformedCheckBox.setFont(baseFont);
- if (previousRegistrationData != null)
- keepMeInformedCheckBox.setSelected(previousRegistrationData
- .getKeepMeInformed());
- keepMeInformedCheckBox.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_ENTER) {
- evt.consume();
- keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox
- .isSelected());
- }
- }
- });
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 7;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 2;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(keepMeInformedCheckBox, gbc);
-
- // Institution name
- JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME);
- institutionLabel.setFont(baseFont);
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 8;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(institutionLabel, gbc);
-
- institutionOrCompanyTextField = new JTextField();
- institutionOrCompanyTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- institutionOrCompanyTextField.setText(previousRegistrationData
- .getInstitutionOrCompanyName());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 8;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(institutionOrCompanyTextField, gbc);
-
- // Industry type
- JLabel industryLabel = new JLabel(" Industry type:");
- industryLabel.setFont(baseFont);
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 9;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(industryLabel, gbc);
-
- industryTypeTextField = new JComboBox<>(industryTypes);
- industryTypeTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- industryTypeTextField.setSelectedItem(previousRegistrationData
- .getIndustry());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 9;
- gbc.fill = HORIZONTAL;
- gbc.anchor = WEST;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(industryTypeTextField, gbc);
-
- // Field of investigation
- JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION);
- fieldLabel.setFont(baseFont);
- fieldLabel.setEditable(false);
- fieldLabel.setFocusable(false);
- fieldLabel.setBackground(getBackground());
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 10;
- gbc.fill = NONE;
- gbc.anchor = LINE_START;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(fieldLabel, gbc);
-
- fieldTextField = new JTextField();
- fieldTextField.setFont(baseFont);
- if (previousRegistrationData != null)
- fieldTextField.setText(previousRegistrationData.getField());
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 10;
- gbc.fill = HORIZONTAL;
- gbc.anchor = FIRST_LINE_START;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(fieldTextField, gbc);
-
- // Purpose of using Taverna
- JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA);
- purposeLabel.setFont(baseFont);
- purposeLabel.setEditable(false);
- purposeLabel.setFocusable(false);
- purposeLabel.setBackground(getBackground());
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 11;
- gbc.fill = NONE;
- gbc.anchor = LINE_START;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(purposeLabel, gbc);
-
- purposeTextArea = new JTextArea(4, 30);
- purposeTextArea.setFont(baseFont);
- purposeTextArea.setLineWrap(true);
- purposeTextArea.setAutoscrolls(true);
- if (previousRegistrationData != null)
- purposeTextArea.setText(previousRegistrationData
- .getPurposeOfUsingTaverna());
- purposeTextArea.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_TAB) {
- if (evt.getModifiers() > 0)
- purposeTextArea.transferFocusBackward();
- else
- purposeTextArea.transferFocus();
- evt.consume();
- }
- }
- });
- JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea);
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridx = 1;
- gbc.gridy = 11;
- gbc.fill = HORIZONTAL;
- gbc.anchor = FIRST_LINE_START;
- gbc.gridwidth = 1;
- gbc.insets = new Insets(5, 10, 0, 10);
- mainPanel.add(purposeScrollPane, gbc);
-
- // Terms and conditions
- termsAndConditionsCheckBox = new JCheckBox(
- I_AGREE_TO_THE_TERMS_AND_CONDITIONS);
- termsAndConditionsCheckBox.setFont(baseFont);
- termsAndConditionsCheckBox.setBorder(null);
- termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_ENTER) {
- evt.consume();
- termsAndConditionsCheckBox
- .setSelected(!termsAndConditionsCheckBox
- .isSelected());
- }
- }
- });
- // gbc.weightx = 0.0;
- // gbc.weighty = 0.0;
- // gbc.gridx = 0;
- // gbc.gridy = 12;
- // gbc.fill = NONE;
- // gbc.anchor = WEST;
- // gbc.gridwidth = 2;
- // gbc.insets = new Insets(10, 10, 0, 0);
- // mainPanel.add(termsAndConditionsCheckBox, gbc);
-
- // Terms and conditions link
- JEditorPane termsAndConditionsURL = new JEditorPane();
- termsAndConditionsURL.setEditable(false);
- termsAndConditionsURL.setBackground(getBackground());
- termsAndConditionsURL.setFocusable(false);
- HTMLEditorKit kit = new HTMLEditorKit();
- termsAndConditionsURL.setEditorKit(kit);
- StyleSheet styleSheet = kit.getStyleSheet();
- // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}");
- // // base font looks bigger when rendered as HTML
- styleSheet.addRule("body {font-family:" + baseFont.getFamily()
- + "; font-size:9px;}");
- Document doc = kit.createDefaultDocument();
- termsAndConditionsURL.setDocument(doc);
- termsAndConditionsURL.setText("<html><body><a href=\""
- + TERMS_AND_CONDITIONS_URL + "\">" + TERMS_AND_CONDITIONS_URL
- + "</a></body></html>");
- termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() {
- @Override
- public void hyperlinkUpdate(HyperlinkEvent he) {
- if (he.getEventType() == ACTIVATED)
- followHyperlinkToTandCs();
- }
- });
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 13;
- gbc.fill = NONE;
- gbc.anchor = WEST;
- gbc.gridwidth = 2;
- gbc.insets = new Insets(5, 10, 0, 10);
- JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT));
- termsAndConditionsPanel.add(termsAndConditionsCheckBox);
- termsAndConditionsPanel.add(termsAndConditionsURL);
- mainPanel.add(termsAndConditionsPanel, gbc);
-
- // Button panel
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- JButton registerButton = new JButton("Register");
- registerButton.setFont(baseFont);
- registerButton.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_ENTER) {
- evt.consume();
- register();
- }
- }
- });
- registerButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- register();
- }
- });
- JButton doNotRegisterButton = new JButton("Do not ask me again");
- doNotRegisterButton.setFont(baseFont);
- doNotRegisterButton.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_ENTER) {
- evt.consume();
- doNotRegister();
- }
- }
- });
- doNotRegisterButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- doNotRegister();
- }
- });
- JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks
- remindMeLaterButton.setFont(baseFont);
- remindMeLaterButton.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent evt) {
- if (evt.getKeyCode() == VK_ENTER) {
- evt.consume();
- remindMeLater();
- }
- }
- });
- remindMeLaterButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- remindMeLater();
- }
- });
- buttonPanel.add(registerButton);
- buttonPanel.add(remindMeLaterButton);
- buttonPanel.add(doNotRegisterButton);
- addDivider(buttonPanel, TOP, true);
- gbc.gridx = 0;
- gbc.gridy = 14;
- gbc.fill = HORIZONTAL;
- gbc.anchor = GridBagConstraints.CENTER;
- gbc.insets = new Insets(5, 10, 0, 10);
- gbc.gridwidth = 2;
- mainPanel.add(buttonPanel, gbc);
-
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(mainPanel, CENTER);
-
- pack();
- setResizable(false);
- // Center the dialog on the screen (we do not have the parent)
- Dimension dimension = getToolkit().getScreenSize();
- Rectangle abounds = getBounds();
- setLocation((dimension.width - abounds.width) / 2,
- (dimension.height - abounds.height) / 2);
- setSize(getPreferredSize());
- }
-
- protected void remindMeLater() {
- try {
- FileUtils.touch(remindMeLaterFile);
- } catch (IOException ioex) {
- logger.error(
- "Failed to touch the 'Remind me later' file at user registration.",
- ioex);
- }
- closeDialog();
- }
-
- protected void doNotRegister() {
- try {
- FileUtils.touch(doNotRegisterMeFile);
- if (remindMeLaterFile.exists())
- remindMeLaterFile.delete();
- } catch (IOException ioex) {
- logger.error(
- "Failed to touch the 'Do not register me' file at user registration.",
- ioex);
- }
- closeDialog();
- }
-
- private void register() {
- if (!validateForm())
- return;
- UserRegistrationData regData = new UserRegistrationData();
- regData.setTavernaVersion(appName);
- regData.setFirstName(firstNameTextField.getText());
- regData.setLastName(lastNameTextField.getText());
- regData.setEmailAddress(emailTextField.getText());
- regData.setKeepMeInformed(keepMeInformedCheckBox.isSelected());
- regData.setInstitutionOrCompanyName(institutionOrCompanyTextField
- .getText());
- regData.setIndustry(industryTypeTextField.getSelectedItem().toString());
- regData.setField(fieldTextField.getText());
- regData.setPurposeOfUsingTaverna(purposeTextArea.getText());
-
- if (postUserRegistrationDataToServer(regData)) {
- saveUserRegistrationData(regData, registrationDataFile);
- if (remindMeLaterFile.exists())
- remindMeLaterFile.delete();
- closeDialog();
- }
- }
-
- private boolean validateForm() {
- String errorMessage = "";
- if (firstNameTextField.getText().isEmpty())
- errorMessage += "Please provide your first name.<br>";
- if (lastNameTextField.getText().isEmpty())
- errorMessage += "Please provide your last name.<br>";
- if (emailTextField.getText().isEmpty())
- errorMessage += "Please provide your email address.<br>";
- if (institutionOrCompanyTextField.getText().isEmpty())
- errorMessage += "Please provide your institution or company name.";
- if (!errorMessage.isEmpty()) {
- showMessageDialog(this, new JLabel("<html><body>"
- + errorMessage + "</body></html>"), "Error in form",
- ERROR_MESSAGE);
- return false;
- }
- if (!termsAndConditionsCheckBox.isSelected()) {
- showMessageDialog(this, new JLabel(
- "You must agree to the terms and conditions."),
- "Error in form", ERROR_MESSAGE);
- return false;
- }
- return true;
- }
-
- public UserRegistrationData loadUserRegistrationData(File propertiesFile) {
- UserRegistrationData regData = new UserRegistrationData();
- Properties props = new Properties();
-
- // Try to retrieve data from file
- try {
- props.load(new FileInputStream(propertiesFile));
- } catch (IOException e) {
- logger.error("Failed to load old user registration data from "
- + propertiesFile.getAbsolutePath(), e);
- return null;
- }
- regData.setTavernaVersion(props
- .getProperty(TAVERNA_VERSION_PROPERTY_NAME));
- regData.setFirstName(props.getProperty(FIRST_NAME_PROPERTY_NAME));
- regData.setLastName(props.getProperty(LAST_NAME_PROPERTY_NAME));
- regData.setEmailAddress(props.getProperty(EMAIL_ADDRESS_PROPERTY_NAME));
- regData.setKeepMeInformed(props.getProperty(
- KEEP_ME_INFORMED_PROPERTY_NAME).equals(TRUE));
- regData.setInstitutionOrCompanyName(props
- .getProperty(INSTITUTION_OR_COMPANY_PROPERTY_NAME));
- regData.setIndustry(props.getProperty(INDUSTRY_PROPERTY_NAME));
- regData.setField(props.getProperty(FIELD_PROPERTY_NAME));
- regData.setPurposeOfUsingTaverna(props
- .getProperty(PURPOSE_PROPERTY_NAME));
- return regData;
- }
-
- private void enc(StringBuilder buffer, String name, Object value)
- throws UnsupportedEncodingException {
- if (buffer.length() != 0)
- buffer.append('&');
- buffer.append(URLEncoder.encode(name, "UTF-8"));
- buffer.append('=');
- buffer.append(URLEncoder.encode(value.toString(), "UTF-8"));
- }
-
- /**
- * Post registration data to our server.
- */
- private boolean postUserRegistrationDataToServer(
- UserRegistrationData regData) {
- StringBuilder parameters = new StringBuilder();
-
- /*
- * The 'submit' parameter - to let the server-side script know we are
- * submitting the user's registration form - all other requests will be
- * silently ignored
- */
- try {
- // value does not matter
- enc(parameters, TAVERNA_REGISTRATION_POST_PARAMETER_NAME, "submit");
-
- enc(parameters, TAVERNA_VERSION_POST_PARAMETER_NAME,
- regData.getTavernaVersion());
- enc(parameters, FIRST_NAME_POST_PARAMETER_NAME,
- regData.getFirstName());
- enc(parameters, LAST_NAME_POST_PARAMETER_NAME,
- regData.getLastName());
- enc(parameters, EMAIL_ADDRESS_POST_PARAMETER_NAME,
- regData.getEmailAddress());
- enc(parameters, KEEP_ME_INFORMED_POST_PARAMETER_PROPERTY_NAME,
- regData.getKeepMeInformed());
- enc(parameters, INSTITUTION_OR_COMPANY_POST_PARAMETER_NAME,
- regData.getInstitutionOrCompanyName());
- enc(parameters, INDUSTRY_TYPE_POST_PARAMETER_NAME,
- regData.getIndustry());
- enc(parameters, FIELD_POST_PARAMETER_NAME, regData.getField());
- enc(parameters, PURPOSE_POST_PARAMETER_NAME,
- regData.getPurposeOfUsingTaverna());
- } catch (UnsupportedEncodingException ueex) {
- logger.error(FAILED + "Could not url encode post parameters", ueex);
- showMessageDialog(null, REGISTRATION_FAILED_MSG,
- "Error encoding registration data", ERROR_MESSAGE);
- return false;
- }
- String server = REGISTRATION_URL;
- logger.info("Posting user registartion to " + server
- + " with parameters: " + parameters);
- String response = "";
- String failure;
- try {
- URL url = new URL(server);
- URLConnection conn = url.openConnection();
- /*
- * Set timeout to e.g. 7 seconds, otherwise we might hang too long
- * if server is not responding and it will block Taverna
- */
- conn.setConnectTimeout(7000);
- // Set connection parameters
- conn.setDoInput(true);
- conn.setDoOutput(true);
- conn.setUseCaches(false);
- // Make server believe we are HTML form data...
- conn.setRequestProperty("Content-Type",
- "application/x-www-form-urlencoded");
- // Write out the bytes of the content string to the stream.
- try (DataOutputStream out = new DataOutputStream(
- conn.getOutputStream())) {
- out.writeBytes(parameters.toString());
- out.flush();
- }
- // Read response from the input stream.
- try (BufferedReader in = new BufferedReader(new InputStreamReader(
- conn.getInputStream()))) {
- String temp;
- while ((temp = in.readLine()) != null)
- response += temp + "\n";
- // Remove the last \n character
- if (!response.isEmpty())
- response = response.substring(0, response.length() - 1);
- }
- if (response.equals("Registration successful!"))
- return true;
- logger.error(FAILED + "Response form server was: " + response);
- failure = "Error saving registration data on the server";
- } catch (ConnectException ceex) {
- /*
- * the connection was refused remotely (e.g. no process is listening
- * on the remote address/port).
- */
- logger.error(
- FAILED
- + "Registration server is not listening of the specified url.",
- ceex);
- failure = "Registration server is not listening at the specified url";
- } catch (SocketTimeoutException stex) {
- // timeout has occurred on a socket read or accept.
- logger.error(FAILED + "Socket timeout occurred.", stex);
- failure = "Registration server timeout";
- } catch (MalformedURLException muex) {
- logger.error(FAILED + "Registartion server's url is malformed.",
- muex);
- failure = "Error with registration server's url";
- } catch (IOException ioex) {
- logger.error(
- FAILED
- + "Failed to open url connection to registration server or writing/reading to/from it.",
- ioex);
- failure = "Error opening connection to the registration server";
- }
- showMessageDialog(null, REGISTRATION_FAILED_MSG, failure, ERROR_MESSAGE);
- return false;
- }
-
- private void saveUserRegistrationData(UserRegistrationData regData,
- File propertiesFile) {
- Properties props = new Properties();
- props.setProperty(TAVERNA_VERSION_PROPERTY_NAME,
- regData.getTavernaVersion());
- props.setProperty(FIRST_NAME_PROPERTY_NAME, regData.getFirstName());
- props.setProperty(LAST_NAME_PROPERTY_NAME, regData.getLastName());
- props.setProperty(EMAIL_ADDRESS_PROPERTY_NAME,
- regData.getEmailAddress());
- props.setProperty(KEEP_ME_INFORMED_PROPERTY_NAME,
- regData.getKeepMeInformed() ? TRUE : FALSE);
- props.setProperty(INSTITUTION_OR_COMPANY_PROPERTY_NAME,
- regData.getInstitutionOrCompanyName());
- props.setProperty(INDUSTRY_PROPERTY_NAME, regData.getIndustry());
- props.setProperty(FIELD_PROPERTY_NAME,
- regData.getPurposeOfUsingTaverna());
- props.setProperty(PURPOSE_PROPERTY_NAME,
- regData.getPurposeOfUsingTaverna());
-
- // Write the properties file.
- try {
- props.store(new FileOutputStream(propertiesFile), null);
- } catch (Exception e) {
- logger.error("Failed to save user registration data locally on disk.");
- }
- }
-
- private void closeDialog() {
- setVisible(false);
- dispose();
- }
-
- /**
- * Adds a light gray or etched border to the top or bottom of a JComponent.
- *
- * @author David Withers
- * @param component
- */
- protected void addDivider(JComponent component, final int position,
- final boolean etched) {
- component.setBorder(new Border() {
- private final Color borderColor = new Color(.6f, .6f, .6f);
-
- @Override
- public Insets getBorderInsets(Component c) {
- if (position == TOP)
- return new Insets(5, 0, 0, 0);
- else
- return new Insets(0, 0, 5, 0);
- }
-
- @Override
- public boolean isBorderOpaque() {
- return false;
- }
-
- @Override
- public void paintBorder(Component c, Graphics g, int x, int y,
- int width, int height) {
- if (position == TOP) {
- if (etched) {
- g.setColor(borderColor);
- g.drawLine(x, y, x + width, y);
- g.setColor(WHITE);
- g.drawLine(x, y + 1, x + width, y + 1);
- } else {
- g.setColor(LIGHT_GRAY);
- g.drawLine(x, y, x + width, y);
- }
- } else {
- if (etched) {
- g.setColor(borderColor);
- g.drawLine(x, y + height - 2, x + width, y + height - 2);
- g.setColor(WHITE);
- g.drawLine(x, y + height - 1, x + width, y + height - 1);
- } else {
- g.setColor(LIGHT_GRAY);
- g.drawLine(x, y + height - 1, x + width, y + height - 1);
- }
- }
- }
- });
- }
-
- private void followHyperlinkToTandCs() {
- // Open a Web browser
- try {
- Desktop.getDesktop().browse(new URI(TERMS_AND_CONDITIONS_URL));
- } catch (Exception ex) {
- logger.error("User registration: Failed to launch browser to show terms and conditions at "
- + TERMS_AND_CONDITIONS_URL);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationHook.java
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationHook.java b/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationHook.java
deleted file mode 100644
index 257c3f3..0000000
--- a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/UserRegistrationHook.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009-2010 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;
-
-import static java.awt.GraphicsEnvironment.isHeadless;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.Date;
-
-import net.sf.taverna.t2.workbench.StartupSPI;
-import uk.org.taverna.configuration.app.ApplicationConfiguration;
-
-public class UserRegistrationHook implements StartupSPI {
- /** Delay between when we ask the user about registration, in milliseconds */
- private static final int TWO_WEEKS = 14 * 24 * 3600 * 1000;
- public static final String REGISTRATION_DIRECTORY_NAME = "registration";
- public static final String REGISTRATION_DATA_FILE_NAME = "registration_data.properties";
- public static final String REMIND_ME_LATER_FILE_NAME = "remind_me_later";
- public static final String DO_NOT_REGISTER_ME_FILE_NAME = "do_not_register_me";
-
- private ApplicationConfiguration applicationConfiguration;
-
- @Override
- public int positionHint() {
- return 50;
- }
-
- @Override
- public boolean startup() {
- File registrationDirectory = getRegistrationDirectory();
- File registrationDataFile = new File(registrationDirectory,
- REGISTRATION_DATA_FILE_NAME);
- File doNotRegisterMeFile = new File(registrationDirectory,
- DO_NOT_REGISTER_ME_FILE_NAME);
- File remindMeLaterFile = new File(registrationDirectory,
- REMIND_ME_LATER_FILE_NAME);
-
- // if we are running headlessly just return
- if (isHeadless())
- return true;
- // For Taverna snapshots - do not ask user to register
- if (applicationConfiguration.getName().toLowerCase().contains("snapshot"))
- return true;
-
- // If there is already user's registration data present - exit.
- if (registrationDataFile.exists())
- return true;
-
- // If user did not want to register - exit.
- if (doNotRegisterMeFile.exists())
- return true;
-
- /*
- * If user said to remind them - check if more than 2 weeks passed since
- * we asked previously.
- */
- if (remindMeLaterFile.exists()) {
- long lastModified = remindMeLaterFile.lastModified();
- long now = new Date().getTime();
- if (now - lastModified < TWO_WEEKS)
- // 2 weeks have not passed since we last asked
- return true;
-
- // Ask user again if they want to register
- UserRegistrationForm form = new UserRegistrationForm(
- applicationConfiguration.getName(), registrationDataFile,
- doNotRegisterMeFile, remindMeLaterFile);
- form.setVisible(true);
- return true;
- }
-
- /*
- * Check if there are previous Taverna versions installed and find the
- * latest one that contains user registration data, if any. Ask user if
- * they want to upload that previous data.
- */
- final File appHomeDirectory = applicationConfiguration.getApplicationHomeDir();
- File parentDirectory = appHomeDirectory.getParentFile();
- FileFilter fileFilter = new FileFilter() {
- @Override
- public boolean accept(File file) {
- return !(file.getName().equals(appHomeDirectory.getName())
- // Exclude Taverna home directory for this app
- && file.isDirectory()
- && file.getName().toLowerCase().startsWith("taverna-")
- // exclude snapshots
- && !file.getName().toLowerCase().contains("snapshot")
- // exclude command line tool
- && !file.getName().toLowerCase().contains("cmd")
- // exclude dataviewer
- && !file.getName().toLowerCase().contains("dataviewer"));
- }
- };
- File[] tavernaDirectories = parentDirectory.listFiles(fileFilter);
- // Find the latest previous registration data file, if any
- File previousRegistrationDataFile = null;
- for (File tavernaDirectory : tavernaDirectories) {
- File regFile = new File(tavernaDirectory, REGISTRATION_DIRECTORY_NAME
- + System.getProperty("file.separator") + REGISTRATION_DATA_FILE_NAME);
- if (!regFile.exists())
- continue;
- if (previousRegistrationDataFile == null)
- previousRegistrationDataFile = regFile;
- else if (previousRegistrationDataFile.lastModified() < regFile
- .lastModified())
- previousRegistrationDataFile = regFile;
- }
-
- UserRegistrationForm form;
- if (previousRegistrationDataFile == null)
- // No previous registration file - ask user to register
- form = new UserRegistrationForm(applicationConfiguration.getName(),
- registrationDataFile, doNotRegisterMeFile,
- remindMeLaterFile);
- else
- /*
- * Fill in user's old registration data in the form and ask them to
- * register
- */
- form = new UserRegistrationForm(applicationConfiguration.getName(),
- previousRegistrationDataFile, registrationDataFile,
- doNotRegisterMeFile, remindMeLaterFile);
- form.setVisible(true);
- return true;
- }
-
- /**
- * Gets the registration directory where info about registration will be
- * saved to.
- */
- public File getRegistrationDirectory() {
- File home = applicationConfiguration.getApplicationHomeDir();
-
- File registrationDirectory = new File(home, REGISTRATION_DIRECTORY_NAME);
- if (!registrationDirectory.exists())
- registrationDirectory.mkdir();
- return registrationDirectory;
- }
-
- public void setApplicationConfiguration(
- ApplicationConfiguration applicationConfiguration) {
- this.applicationConfiguration = applicationConfiguration;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchImpl.java
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchImpl.java b/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchImpl.java
deleted file mode 100644
index 16f189e..0000000
--- a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchImpl.java
+++ /dev/null
@@ -1,538 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007-2010 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;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.CENTER;
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.LINE_START;
-import static java.lang.Thread.setDefaultUncaughtExceptionHandler;
-import static java.util.prefs.Preferences.userNodeForPackage;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.WARNING_MESSAGE;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static javax.swing.SwingUtilities.invokeLater;
-import static javax.swing.UIManager.getCrossPlatformLookAndFeelClassName;
-import static javax.swing.UIManager.getLookAndFeel;
-import static javax.swing.UIManager.getLookAndFeelDefaults;
-import static javax.swing.UIManager.getSystemLookAndFeelClassName;
-import static net.sf.taverna.t2.workbench.MainWindow.setMainWindow;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.errorMessageIcon;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.infoMessageIcon;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.questionMessageIcon;
-import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.warningMessageIcon;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.CardLayout;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.io.IOException;
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.prefs.Preferences;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JMenuBar;
-import javax.swing.JPanel;
-import javax.swing.JToolBar;
-import javax.swing.UIManager;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.SwingAwareObserver;
-import net.sf.taverna.t2.ui.menu.MenuManager;
-import net.sf.taverna.t2.ui.menu.MenuManager.MenuManagerEvent;
-import net.sf.taverna.t2.ui.menu.MenuManager.UpdatedMenuManagerEvent;
-import net.sf.taverna.t2.workbench.ShutdownSPI;
-import net.sf.taverna.t2.workbench.StartupSPI;
-import net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration;
-import net.sf.taverna.t2.workbench.configuration.workbench.ui.T2ConfigurationFrame;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.exceptions.OpenException;
-import net.sf.taverna.t2.workbench.helper.Helper;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.ui.Workbench;
-import net.sf.taverna.t2.workbench.ui.zaria.PerspectiveSPI;
-
-import org.apache.log4j.Logger;
-import org.simplericity.macify.eawt.Application;
-import org.simplericity.macify.eawt.ApplicationAdapter;
-import org.simplericity.macify.eawt.ApplicationEvent;
-import org.simplericity.macify.eawt.ApplicationListener;
-import org.simplericity.macify.eawt.DefaultApplication;
-
-import uk.org.taverna.commons.plugin.PluginException;
-import uk.org.taverna.commons.plugin.PluginManager;
-import uk.org.taverna.configuration.app.ApplicationConfiguration;
-
-/**
- * The main workbench frame.
- *
- * @author David Withers
- * @author Stian Soiland-Reyes
- */
-public class WorkbenchImpl extends JFrame implements Workbench {
- private static final String NIMBUS = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
- private static final String LAUNCHER_LOGO_PNG = "/launcher_logo.png";
- private static final long serialVersionUID = 1L;
- private static Logger logger = getLogger(WorkbenchImpl.class);
- private static Preferences userPreferences = userNodeForPackage(WorkbenchImpl.class);
-
- private Application osxApp = new DefaultApplication();
- private ApplicationListener osxAppListener = new OSXAppListener();
- private MenuManager menuManager;
- private FileManager fileManager;
- @SuppressWarnings("unused")
- private EditManager editManager;
- private PluginManager pluginManager;
- private SelectionManager selectionManager;
- private WorkbenchConfiguration workbenchConfiguration;
- private ApplicationConfiguration applicationConfiguration;
- private WorkbenchPerspectives workbenchPerspectives;
- private T2ConfigurationFrame t2ConfigurationFrame;
- private JToolBar perspectiveToolBar;
- private List<StartupSPI> startupHooks;
- private List<ShutdownSPI> shutdownHooks;
- private final List<PerspectiveSPI> perspectives;
- private JMenuBar menuBar;
- private JToolBar toolBar;
- private MenuManagerObserver menuManagerObserver;
-
- public WorkbenchImpl(List<StartupSPI> startupHooks,
- List<ShutdownSPI> shutdownHooks, List<PerspectiveSPI> perspectives) {
- this.perspectives = perspectives;
- this.startupHooks = startupHooks;
- this.shutdownHooks = shutdownHooks;
- setMainWindow(this);
- }
-
- protected void initialize() {
- setExceptionHandler();
- setLookAndFeel();
-
- // Set icons for Error, Information, Question and Warning messages
- UIManager.put("OptionPane.errorIcon", errorMessageIcon);
- UIManager.put("OptionPane.informationIcon", infoMessageIcon);
- UIManager.put("OptionPane.questionIcon", questionMessageIcon);
- UIManager.put("OptionPane.warningIcon", warningMessageIcon);
-
- // Call the startup hooks
- if (!callStartupHooks()) {
- System.exit(0);
- }
-
- makeGUI();
- fileManager.newDataflow();
- try {
- pluginManager.loadPlugins();
- } catch (PluginException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- /*
- * the DataflowEditsListener changes the WorkflowBundle ID for every
- * workflow edit and changes the URI so port definitions can't find the
- * port they refer to
- */
- // TODO check if it's OK to not update the WorkflowBundle ID
- //editManager.addObserver(new DataflowEditsListener());
-
- closeTheSplashScreen();
- setVisible(true);
- }
-
- private void closeTheSplashScreen() {
-// SplashScreen splash = SplashScreen.getSplashScreen();
-// if (splash != null) {
-// splash.setClosable();
-// splash.requestClose();
-// }
- }
-
- private void showAboutDialog() {
- // TODO implement this!
- }
-
- private void makeGUI() {
- setLayout(new GridBagLayout());
-
- addWindowListener(new WindowClosingListener());
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
-
- Helper.setKeyCatcher(this);
-
- URL launcherLogo = getClass().getResource(LAUNCHER_LOGO_PNG);
- if (launcherLogo != null) {
- ImageIcon imageIcon = new ImageIcon(launcherLogo);
- setIconImage(imageIcon.getImage());
- }
- setTitle(applicationConfiguration.getTitle());
-
- osxApp.setEnabledPreferencesMenu(true);
- osxApp.setEnabledAboutMenu(true);
- osxApp.addApplicationListener(osxAppListener);
-
- /*
- * Set the size and position of the Workbench to the last saved values
- * or use the default ones the first time it is launched
- */
- loadSizeAndLocationPrefs();
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 0.1;
- gbc.fill = HORIZONTAL;
- gbc.anchor = LINE_START;
-
- add(makeToolbarPanel(), gbc);
-
- gbc.anchor = CENTER;
- gbc.fill = BOTH;
- gbc.gridy = 1;
- gbc.weightx = 0.1;
- gbc.weighty = 0.1;
-
- add(makePerspectivePanel(), gbc);
-
- menuBar = menuManager.createMenuBar();
- setJMenuBar(menuBar);
- }
-
- protected JPanel makeToolbarPanel() {
- JPanel toolbarPanel = new JPanel(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.gridwidth = 2;
- gbc.anchor = LINE_START;
-
- toolBar = menuManager.createToolBar();
- toolBar.setFloatable(false);
- toolbarPanel.add(toolBar, gbc);
-
- perspectiveToolBar = new JToolBar("Perspectives");
- perspectiveToolBar.setFloatable(false);
- gbc.gridy = 1;
- gbc.weightx = 0.1;
- gbc.fill = HORIZONTAL;
- toolbarPanel.add(perspectiveToolBar, gbc);
-
- return toolbarPanel;
- }
-
- private JPanel makePerspectivePanel() {
- CardLayout perspectiveLayout = new CardLayout();
- JPanel perspectivePanel = new JPanel(perspectiveLayout);
- workbenchPerspectives = new WorkbenchPerspectives(perspectiveToolBar,
- perspectivePanel, perspectiveLayout, selectionManager);
- workbenchPerspectives.setPerspectives(perspectives);
- return perspectivePanel;
- }
-
- @Override
- public void makeNamedComponentVisible(String componentName) {
- // basePane.makeNamedComponentVisible(componentName);
- }
-
- protected void setExceptionHandler() {
- setDefaultUncaughtExceptionHandler(new ExceptionHandler());
- }
-
- public void setStartupHooks(List<StartupSPI> startupHooks) {
- this.startupHooks = startupHooks;
- }
-
- /**
- * Calls the startup methods on all the {@link StartupSPI}s. If any startup
- * method returns <code>false</code> (meaning that the Workbench will not
- * function at all) then this method returns <code>false</code>.
- */
- private boolean callStartupHooks() {
- for (StartupSPI startupSPI : startupHooks)
- if (!startupSPI.startup())
- return false;
- return true;
- }
-
- @Override
- public void exit() {
- if (callShutdownHooks())
- System.exit(0);
- }
-
- public void setShutdownHooks(List<ShutdownSPI> shutdownHooks) {
- this.shutdownHooks = shutdownHooks;
- }
-
- /**
- * Calls all the shutdown on all the {@link ShutdownSPI}s. If a shutdown
- * returns <code>false</code> (meaning that the shutdown process should be
- * aborted) then this method returns with a value of <code>false</code>
- * immediately.
- *
- * @return <code>true</code> if all the <code>ShutdownSPIs</code> return
- * <code>true</code> and the workbench shutdown should proceed
- */
- private boolean callShutdownHooks() {
- for (ShutdownSPI shutdownSPI : shutdownHooks)
- if (!shutdownSPI.shutdown())
- return false;
- return true;
- }
-
- /**
- * Store current Workbench position and size.
- */
- @Override
- public void storeSizeAndLocationPrefs() throws IOException {
- userPreferences.putInt("width", getWidth());
- userPreferences.putInt("height", getHeight());
- userPreferences.putInt("x", getX());
- userPreferences.putInt("y", getY());
- }
-
- /**
- * Loads last saved Workbench position and size.
- */
- private void loadSizeAndLocationPrefs() {
- Dimension screen = getToolkit().getScreenSize();
-
- int width = userPreferences.getInt("width", (int) (screen.getWidth() * 0.75));
- int height = userPreferences.getInt("height", (int) (screen.getHeight() * 0.75));
- int x = userPreferences.getInt("x", 0);
- int y = userPreferences.getInt("y", 0);
-
- // Make sure our window is not too big
- width = Math.min((int) screen.getWidth(), width);
- height = Math.min((int) screen.getHeight(), height);
-
- // Move to upper left corner if we are too far off
- if (x > (screen.getWidth() - 50) || x < 0)
- x = 0;
- if (y > (screen.getHeight() - 50) || y < 0)
- y = 0;
-
- this.setSize(width, height);
- this.setLocation(x, y);
- }
-
- public static void setLookAndFeel() {
- String defaultLaf = System.getProperty("swing.defaultlaf");
- try {
- if (defaultLaf != null) {
- UIManager.setLookAndFeel(defaultLaf);
- return;
- }
- } catch (Exception e) {
- logger.info("Can't set requested look and feel -Dswing.defaultlaf="
- + defaultLaf, e);
- }
- String os = System.getProperty("os.name");
- if (os.contains("Mac") || os.contains("Windows")) {
- // For OSX and Windows use the system look and feel
- String systemLF = getSystemLookAndFeelClassName();
- try {
- UIManager.setLookAndFeel(systemLF);
- getLookAndFeelDefaults().put("ClassLoader",
- WorkbenchImpl.class.getClassLoader());
- logger.info("Using system L&F " + systemLF);
- return;
- } catch (Exception ex2) {
- logger.error("Unable to load system look and feel " + systemLF,
- ex2);
- }
- }
- /*
- * The system look and feel on *NIX
- * (com.sun.java.swing.plaf.gtk.GTKLookAndFeel) looks like Windows 3.1..
- * try to use Nimbus (Java 6e10 and later)
- */
- try {
- UIManager.setLookAndFeel(NIMBUS);
- logger.info("Using Nimbus look and feel");
- return;
- } catch (Exception e) {
- }
-
- // Metal should be better than GTK still
- try {
- String crossPlatform = getCrossPlatformLookAndFeelClassName();
- UIManager.setLookAndFeel(crossPlatform);
- logger.info("Using cross platform Look and Feel " + crossPlatform);
- return;
- } catch (Exception e){
- }
-
- // Final fallback
- try {
- String systemLF = getSystemLookAndFeelClassName();
- UIManager.setLookAndFeel(systemLF);
- logger.info("Using system platform Look and Feel " + systemLF);
- } catch (Exception e){
- logger.info("Using default Look and Feel " + getLookAndFeel());
- }
- }
-
- public void setMenuManager(MenuManager menuManager) {
- if (this.menuManager != null && menuManagerObserver != null)
- this.menuManager.removeObserver(menuManagerObserver);
- this.menuManager = menuManager;
- menuManagerObserver = new MenuManagerObserver();
- menuManager.addObserver(menuManagerObserver);
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void refreshPerspectives(Object service, Map<?,?> properties) {
- workbenchPerspectives.refreshPerspectives();
- }
-
- public void setWorkbenchConfiguration(WorkbenchConfiguration workbenchConfiguration) {
- this.workbenchConfiguration = workbenchConfiguration;
- }
-
- public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
- this.applicationConfiguration = applicationConfiguration;
- }
-
- public void setT2ConfigurationFrame(T2ConfigurationFrame t2ConfigurationFrame) {
- this.t2ConfigurationFrame = t2ConfigurationFrame;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
- public void setPluginManager(PluginManager pluginManager) {
- this.pluginManager = pluginManager;
- }
-
- private final class MenuManagerObserver extends
- SwingAwareObserver<MenuManagerEvent> {
- @Override
- public void notifySwing(Observable<MenuManagerEvent> sender,
- MenuManagerEvent message) {
- if (message instanceof UpdatedMenuManagerEvent
- && WorkbenchImpl.this.isVisible())
- refreshMenus();
- }
- }
-
- private void refreshMenus() {
- if (menuBar != null) {
- menuBar.revalidate();
- menuBar.repaint();
- }
- if (toolBar != null) {
- toolBar.revalidate();
- toolBar.repaint();
- }
- }
-
- private final class ExceptionHandler implements UncaughtExceptionHandler {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- logger.error("Uncaught exception in " + t, e);
- if (e instanceof Exception
- && !workbenchConfiguration.getWarnInternalErrors()) {
- /*
- * User preference disables warnings - but we'll show it anyway
- * if it is an Error (which is more serious)
- */
- return;
- }
- final String message;
- final String title;
- final int style;
- if (t.getClass().getName().equals("java.awt.EventDispatchThread")) {
- message = "The user action could not be completed due to an unexpected error:\n"
- + e;
- title = "Could not complete user action";
- style = ERROR_MESSAGE;
- } else {
- message = "An unexpected internal error occured in \n" + t + ":\n" + e;
- title = "Unexpected internal error";
- style = WARNING_MESSAGE;
- }
- invokeLater(new Runnable() {
- @Override
- public void run() {
- showMessageDialog(WorkbenchImpl.this, message, title, style);
- }
- });
- }
- }
-
- private class WindowClosingListener extends WindowAdapter {
- @Override
- public void windowClosing(WindowEvent e) {
- exit();
- }
- }
-
- private class OSXAppListener extends ApplicationAdapter {
- @Override
- public void handleAbout(ApplicationEvent e) {
- showAboutDialog();
- e.setHandled(true);
- }
-
- @Override
- public void handleQuit(ApplicationEvent e) {
- e.setHandled(true);
- exit();
- }
-
- @Override
- public void handlePreferences(ApplicationEvent e) {
- e.setHandled(true);
- t2ConfigurationFrame.showFrame();
- }
-
- @Override
- public void handleOpenFile(ApplicationEvent e) {
- try {
- if (e.getFilename() != null) {
- fileManager.openDataflow(null, new File(e.getFilename()));
- e.setHandled(true);
- }
- } catch (OpenException | IllegalStateException ex) {
- logger.warn("Could not open file " + e.getFilename(), ex);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchPerspectives.java
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchPerspectives.java b/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchPerspectives.java
deleted file mode 100644
index 921260a..0000000
--- a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/WorkbenchPerspectives.java
+++ /dev/null
@@ -1,229 +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;
-
-import static java.awt.Image.SCALE_SMOOTH;
-import static javax.swing.Action.NAME;
-import static javax.swing.Action.SMALL_ICON;
-import static javax.swing.SwingUtilities.invokeLater;
-
-import java.awt.CardLayout;
-import java.awt.Component;
-import java.awt.Image;
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import javax.swing.Action;
-import javax.swing.ButtonGroup;
-import javax.swing.ImageIcon;
-import javax.swing.JPanel;
-import javax.swing.JToggleButton;
-import javax.swing.JToolBar;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.SwingAwareObserver;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.selection.events.PerspectiveSelectionEvent;
-import net.sf.taverna.t2.workbench.selection.events.SelectionManagerEvent;
-import net.sf.taverna.t2.workbench.ui.zaria.PerspectiveSPI;
-
-import org.apache.log4j.Logger;
-
-@SuppressWarnings("serial")
-public class WorkbenchPerspectives {
- private static Logger logger = Logger
- .getLogger(WorkbenchPerspectives.class);
-
- private PerspectiveSPI currentPerspective;
- private ButtonGroup perspectiveButtonGroup = new ButtonGroup();
- private Map<String, JToggleButton> perspectiveButtonMap = new HashMap<>();
- private JToolBar toolBar;
- private JPanel panel;
- private CardLayout cardLayout;
- private List<PerspectiveSPI> perspectives = new ArrayList<>();
- private boolean refreshing;
- private final SelectionManager selectionManager;
-
- public WorkbenchPerspectives(JToolBar toolBar, JPanel panel,
- CardLayout cardLayout, SelectionManager selectionManager) {
- this.panel = panel;
- this.toolBar = toolBar;
- this.cardLayout = cardLayout;
- this.selectionManager = selectionManager;
- refreshing = true;
- selectionManager.addObserver(new SelectionManagerObserver());
- refreshing = false;
- }
-
- public List<PerspectiveSPI> getPerspectives() {
- return this.perspectives;
- }
-
- public void setPerspectives(List<PerspectiveSPI> perspectives) {
- this.perspectives = perspectives;
- initialisePerspectives();
- }
-
- private void initialisePerspectives() {
- for (final PerspectiveSPI perspective : perspectives)
- addPerspective(perspective, false);
- selectFirstPerspective();
- }
-
- private void setPerspective(PerspectiveSPI perspective) {
- if (perspective != currentPerspective) {
- if (!perspectiveButtonMap.containsKey(perspective.getID()))
- addPerspective(perspective, true);
- if (!(perspective instanceof BlankPerspective))
- perspectiveButtonMap.get(perspective.getID()).setSelected(true);
- cardLayout.show(panel, perspective.getID());
- currentPerspective = perspective;
- }
- }
-
- private void addPerspective(final PerspectiveSPI perspective,
- boolean makeActive) {
- // ensure icon image is always 16x16
- ImageIcon buttonIcon = null;
- if (perspective.getButtonIcon() != null) {
- Image buttonImage = perspective.getButtonIcon().getImage();
- buttonIcon = new ImageIcon(buttonImage.getScaledInstance(16, 16,
- SCALE_SMOOTH));
- }
-
- final JToggleButton toolbarButton = new JToggleButton(
- perspective.getText(), buttonIcon);
- toolbarButton.setToolTipText(perspective.getText() + " perspective");
- Action action = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- selectionManager.setSelectedPerspective(perspective);
- }
- };
- action.putValue(NAME, perspective.getText());
- action.putValue(SMALL_ICON, buttonIcon);
-
- toolbarButton.setAction(action);
- toolBar.add(toolbarButton);
- perspectiveButtonGroup.add(toolbarButton);
- perspectiveButtonMap.put(perspective.getID(), toolbarButton);
-
- panel.add(perspective.getPanel(), perspective.getID());
- if (makeActive)
- toolbarButton.doClick();
- }
-
- /**
- * Recreates the toolbar buttons. Useful if a perspective has been removed.
- */
- public void refreshPerspectives() {
- invokeLater(new RefreshRunner());
- }
-
- /** selects the first visible perspective by clicking on the toolbar button */
- private void selectFirstPerspective() {
- boolean set = false;
- for (Component c : toolBar.getComponents())
- if (c instanceof AbstractButton && c.isVisible()) {
- ((AbstractButton) c).doClick();
- set = true;
- break;
- }
-
- if (!set) {
- // no visible perspectives were found
- logger.info("No visible perspectives.");
- selectionManager.setSelectedPerspective(new BlankPerspective());
- }
- }
-
- private final class RefreshRunner implements Runnable {
- @Override
- public void run() {
- synchronized (WorkbenchPerspectives.this) {
- if (refreshing)
- // We only need one run
- return;
- refreshing = true;
- }
- try {
- toolBar.removeAll();
- toolBar.repaint();
- initialisePerspectives();
- } finally {
- synchronized (WorkbenchPerspectives.this) {
- refreshing = false;
- }
- }
- }
- }
-
- private final class SelectionManagerObserver extends
- SwingAwareObserver<SelectionManagerEvent> {
- @Override
- public void notifySwing(Observable<SelectionManagerEvent> sender,
- SelectionManagerEvent message) {
- if (message instanceof PerspectiveSelectionEvent) {
- PerspectiveSPI selectedPerspective = ((PerspectiveSelectionEvent) message)
- .getSelectedPerspective();
- setPerspective(selectedPerspective);
- }
- }
- }
-
- /**
- * A dummy blank perspective for when there are no visible perspectives
- * available
- *
- * @author Stuart Owen
- */
- private class BlankPerspective implements PerspectiveSPI {
- @Override
- public String getID() {
- return BlankPerspective.class.getName();
- }
-
- @Override
- public JPanel getPanel() {
- return new JPanel();
- }
-
- @Override
- public ImageIcon getButtonIcon() {
- return null;
- }
-
- @Override
- public String getText() {
- return null;
- }
-
- @Override
- public int positionHint() {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/menu/ExitAction.java
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/menu/ExitAction.java b/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/menu/ExitAction.java
deleted file mode 100644
index d5573be..0000000
--- a/workbench-impl/src/main/java/net/sf/taverna/t2/workbench/ui/impl/menu/ExitAction.java
+++ /dev/null
@@ -1,66 +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.menu;
-
-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.ui.Workbench;
-
-/**
- * Exit the workbench
- *
- * @author Stian Soiland-Reyes
- */
-public class ExitAction extends AbstractMenuAction {
- private static final String EXIT_LABEL = "Exit";
- private static final String MAC_OS_X = "Mac OS X";
- private Workbench workbench;
-
- public ExitAction() {
- super(URI.create("http://taverna.sf.net/2008/t2workbench/menu#file"),
- 10000);
- }
-
- @SuppressWarnings("serial")
- @Override
- protected Action createAction() {
- return new AbstractAction(EXIT_LABEL) {
- @Override
- public void actionPerformed(ActionEvent e) {
- workbench.exit();
- }
- };
- }
-
- @Override
- public boolean isEnabled() {
- return !MAC_OS_X.equalsIgnoreCase(System.getProperty("os.name"));
- }
-
- public void setWorkbench(Workbench workbench) {
- this.workbench = workbench;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.raven.launcher.Launchable
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.raven.launcher.Launchable b/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.raven.launcher.Launchable
deleted file mode 100644
index a9fa855..0000000
--- a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.raven.launcher.Launchable
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.workbench.ui.impl.WorkbenchLauncher
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent
deleted file mode 100644
index 0c43dec..0000000
--- a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent
+++ /dev/null
@@ -1,18 +0,0 @@
-
-net.sf.taverna.t2.workbench.ui.impl.menu.FileMenu
-net.sf.taverna.t2.workbench.ui.impl.menu.ExitAction
-
-net.sf.taverna.t2.workbench.ui.impl.menu.EditMenu
-
-net.sf.taverna.t2.workbench.ui.impl.menu.AdvancedMenu
-net.sf.taverna.t2.workbench.ui.impl.menu.DisplayPerspectivesMenu
-net.sf.taverna.t2.workbench.ui.impl.menu.EditPerspectivesMenu
-
-net.sf.taverna.t2.workbench.ui.impl.menu.HelpMenu
-net.sf.taverna.t2.workbench.ui.impl.menu.OnlineHelpMenuAction
-net.sf.taverna.t2.workbench.ui.impl.menu.FeedbackMenuAction
-
-#net.sf.taverna.t2.workbench.ui.impl.menu.ViewShowMenuSection
-#net.sf.taverna.t2.workbench.ui.impl.menu.ChangePerspectiveMenuAction
-
-net.sf.taverna.t2.workbench.ui.impl.menu.ShowLogsAndDataMenuAction
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ShutdownSPI
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ShutdownSPI b/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ShutdownSPI
deleted file mode 100644
index c022389..0000000
--- a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ShutdownSPI
+++ /dev/null
@@ -1 +0,0 @@
-net.sf.taverna.t2.workbench.ui.impl.StoreWindowStateOnShutdown
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.StartupSPI
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.StartupSPI b/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.StartupSPI
deleted file mode 100644
index 86349aa..0000000
--- a/workbench-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.StartupSPI
+++ /dev/null
@@ -1,2 +0,0 @@
-net.sf.taverna.t2.workbench.ui.impl.UserRegistrationHook
-net.sf.taverna.t2.workbench.ui.impl.SetConsoleLoggerStartup
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context-osgi.xml
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context-osgi.xml b/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context-osgi.xml
deleted file mode 100644
index 0dc7efc..0000000
--- a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context-osgi.xml
+++ /dev/null
@@ -1,38 +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="UserRegistrationHook" interface="net.sf.taverna.t2.workbench.StartupSPI" />
- <!-- <service ref="SetConsoleLoggerStartup" interface="net.sf.taverna.t2.workbench.StartupSPI" /> -->
-
- <service ref="StoreWindowStateOnShutdown" interface="net.sf.taverna.t2.workbench.ShutdownSPI" />
-
- <service ref="ExitAction" auto-export="interfaces">
- <service-properties>
- <beans:entry key="menu.action" value="file.exit" />
- </service-properties>
- </service>
-
- <service ref="Workbench" interface="net.sf.taverna.t2.workbench.ui.Workbench" />
-
- <reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" />
- <reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" />
- <reference id="menuManager" interface="net.sf.taverna.t2.ui.menu.MenuManager" />
- <reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" />
- <reference id="pluginManager" interface="uk.org.taverna.commons.plugin.PluginManager" />
- <reference id="workbenchConfiguration" interface="net.sf.taverna.t2.workbench.configuration.workbench.WorkbenchConfiguration" />
- <reference id="applicationConfiguration" interface="uk.org.taverna.configuration.app.ApplicationConfiguration" />
- <reference id="t2ConfigurationFrame" interface="net.sf.taverna.t2.workbench.configuration.workbench.ui.T2ConfigurationFrame" />
-
- <list id="perspectives" interface="net.sf.taverna.t2.workbench.ui.zaria.PerspectiveSPI" cardinality="0..N" comparator-ref="PerspectiveComparator" greedy-proxying="true">
- <listener ref="Workbench" bind-method="refreshPerspectives" unbind-method="refreshPerspectives" />
- </list>
-
- <list id="startupHooks" interface="net.sf.taverna.t2.workbench.StartupSPI" cardinality="0..N" comparator-ref="StartupComparator"/>
- <list id="shutdownHooks" interface="net.sf.taverna.t2.workbench.ShutdownSPI" cardinality="0..N" comparator-ref="ShutdownComparator"/>
-
-</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context.xml
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context.xml b/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context.xml
deleted file mode 100644
index 78c4eb2..0000000
--- a/workbench-impl/src/main/resources/META-INF/spring/workbench-impl-context.xml
+++ /dev/null
@@ -1,43 +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="UserRegistrationHook" class="net.sf.taverna.t2.workbench.ui.impl.UserRegistrationHook">
- <property name="applicationConfiguration" ref="applicationConfiguration"/>
- </bean>
- <bean id="SetConsoleLoggerStartup" class="net.sf.taverna.t2.workbench.ui.impl.SetConsoleLoggerStartup">
- <constructor-arg ref="workbenchConfiguration" />
- </bean>
-
- <bean id="StoreWindowStateOnShutdown" class="net.sf.taverna.t2.workbench.ui.impl.StoreWindowStateOnShutdown">
- <property name="workbench">
- <ref local="Workbench"/>
- </property>
- </bean>
-
- <bean id="ExitAction" class="net.sf.taverna.t2.workbench.ui.impl.menu.ExitAction">
- <property name="workbench">
- <ref local ="Workbench"/>
- </property>
- </bean>
-
- <bean id="Workbench" class="net.sf.taverna.t2.workbench.ui.impl.WorkbenchImpl" init-method="initialize">
- <constructor-arg ref="startupHooks"/>
- <constructor-arg ref="shutdownHooks"/>
- <constructor-arg ref="perspectives"/>
- <property name="editManager" ref="editManager"/>
- <property name="fileManager" ref="fileManager"/>
- <property name="menuManager" ref="menuManager"/>
- <property name="t2ConfigurationFrame" ref="t2ConfigurationFrame"/>
- <property name="workbenchConfiguration" ref="workbenchConfiguration"/>
- <property name="applicationConfiguration" ref="applicationConfiguration"/>
- <property name="selectionManager" ref="selectionManager"/>
- <property name="pluginManager" ref="pluginManager"/>
- </bean>
-
- <bean id="PerspectiveComparator" class="net.sf.taverna.t2.workbench.ui.zaria.PerspectiveSPI$PerspectiveComparator" />
- <bean id="StartupComparator" class="net.sf.taverna.t2.workbench.StartupSPI$StartupComparator" />
- <bean id="ShutdownComparator" class="net.sf.taverna.t2.workbench.ShutdownSPI$ShutdownComparator" />
-
-</beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/Map.jhm
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/Map.jhm b/workbench-impl/src/main/resources/Map.jhm
deleted file mode 100644
index ab5f560..0000000
--- a/workbench-impl/src/main/resources/Map.jhm
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version='1.0' encoding='ISO-8859-1' ?>
-<!DOCTYPE map
- PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN"
- "http://java.sun.com/javase/technologies/desktop/javahelp/map_1_0.dtd">
-
-<map version="1.0">
- <mapID target="toplevelfolder" url="images/toplevel.gif" />
- <mapID target="top" url="help/welcome.html" />
-
- <mapID target="intro" url="help/welcome.html" />
- <mapID target="start" url="help/start.html" />
- <mapID target="overview" url="help/welcome.html" />
- <mapID target="one" url="help/start.html" />
- <mapID target="two" url="help/start.html" />
-
- <mapID target="bean.story" url="help/welcome.html" />
- <mapID target="bean.story" url="help/start.html" />
- <mapID target="bean.story" url="help/welcome.html" />
-
- <mapID target="http://taverna.sf.net/2008/t2workbench/menu#help"
- url="http://www.google.com" />
-
- <mapID target="http://taverna.sf.net/2008/t2workbench/menu#fileOpen"
- url="http://www.google.com" />
-
-
-
-</map>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/example-registration-form.xml
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/example-registration-form.xml b/workbench-impl/src/main/resources/example-registration-form.xml
deleted file mode 100644
index 5d84369..0000000
--- a/workbench-impl/src/main/resources/example-registration-form.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<registration_data>
- <taverna_version>taverna-2.2.0</taverna_version>
- <first_name>John</first_name>
- <last_name>Doe</last_name>
- <email_address>john.doe@jd-consulting.com</email_address>
- <keep_me_informed>false</keep_me_informed>
- <institution_or_company_name>JD Consulting</institution_or_company_name>
- <industry_type>Industry - Pharmaceutical</industry_type>
- <field_of_interest>bioinformatics</field_of_interest>
- <purpose_of_using_taverna>pharmacogenomics</purpose_of_using_taverna>
-</registration_data>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/72850d5a/workbench-impl/src/main/resources/registration-form.xsd
----------------------------------------------------------------------
diff --git a/workbench-impl/src/main/resources/registration-form.xsd b/workbench-impl/src/main/resources/registration-form.xsd
deleted file mode 100644
index 776f8e5..0000000
--- a/workbench-impl/src/main/resources/registration-form.xsd
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
- <xs:element name="registration_data">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="taverna_version"/>
- <xs:element ref="first_name"/>
- <xs:element ref="last_name"/>
- <xs:element ref="email_address"/>
- <xs:element ref="keep_me_informed"/>
- <xs:element ref="institution_or_company_name"/>
- <xs:element ref="industry_type"/>
- <xs:element ref="field_of_interest"/>
- <xs:element ref="purpose_of_using_taverna"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="taverna_version" type="xs:string"/>
- <xs:element name="first_name" type="xs:string"/>
- <xs:element name="last_name" type="xs:string"/>
- <xs:element name="email_address" type="xs:string"/>
- <xs:element name="keep_me_informed" type="xs:boolean"/>
- <xs:element name="institution_or_company_name" type="xs:string"/>
- <xs:element name="industry_type" type="xs:string"/>
- <xs:element name="field_of_interest" type="xs:string"/>
- <xs:element name="purpose_of_using_taverna" type="xs:string"/>
-</xs:schema>