Cleaning up
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/OpenWorkflowRunAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/OpenWorkflowRunAction.java
index 1ffe535..9c50e31 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/OpenWorkflowRunAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/OpenWorkflowRunAction.java
@@ -20,6 +20,11 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.actions;
+import static javax.swing.JFileChooser.APPROVE_OPTION;
+import static javax.swing.JOptionPane.WARNING_MESSAGE;
+import static javax.swing.JOptionPane.showMessageDialog;
+import static javax.swing.SwingUtilities.invokeLater;
+
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.File;
@@ -27,8 +32,6 @@
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.filechooser.FileFilter;
@@ -45,13 +48,10 @@
*/
@SuppressWarnings("serial")
public class OpenWorkflowRunAction extends AbstractAction {
-
private static Logger logger = Logger.getLogger(OpenWorkflowRunAction.class);
-
private static final String OPEN_WORKFLOW_RUN = "Open workflow run...";
private final RunService runService;
-
private final File runStore;
public OpenWorkflowRunAction(RunService runService, File runStore) {
@@ -63,11 +63,10 @@
@Override
public void actionPerformed(ActionEvent e) {
final Component parentComponent;
- if (e.getSource() instanceof Component) {
+ if (e.getSource() instanceof Component)
parentComponent = (Component) e.getSource();
- } else {
+ else
parentComponent = null;
- }
openWorkflowRuns(parentComponent);
}
@@ -90,8 +89,7 @@
fileChooser.setCurrentDirectory(runStore);
fileChooser.setMultiSelectionEnabled(true);
- int returnVal = fileChooser.showOpenDialog(parentComponent);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
+ if (fileChooser.showOpenDialog(parentComponent) == APPROVE_OPTION) {
final File[] selectedFiles = fileChooser.getSelectedFiles();
if (selectedFiles.length == 0) {
logger.warn("No files selected");
@@ -100,13 +98,12 @@
new SwingWorker<Void, Void>() {
@Override
public Void doInBackground() {
- for (final File file : selectedFiles) {
+ for (File file : selectedFiles)
try {
runService.open(file);
} catch (IOException e) {
showErrorMessage(parentComponent, file, e);
}
- }
return null;
}
}.execute();
@@ -115,25 +112,24 @@
/**
* Show an error message if a file could not be opened
- *
+ *
* @param parentComponent
* @param file
* @param throwable
*/
- protected void showErrorMessage(final Component parentComponent, final File file,
- final Throwable throwable) {
- SwingUtilities.invokeLater(new Runnable() {
+ protected void showErrorMessage(final Component parentComponent,
+ final File file, Throwable throwable) {
+ Throwable cause = throwable;
+ while (cause.getCause() != null)
+ cause = cause.getCause();
+ final String message = cause.getMessage();
+ invokeLater(new Runnable() {
+ @Override
public void run() {
- Throwable cause = throwable;
- while (cause.getCause() != null) {
- cause = cause.getCause();
- }
- JOptionPane.showMessageDialog(parentComponent, "Failed to open workflow from "
- + file + ": \n" + cause.getMessage(), "Warning",
- JOptionPane.WARNING_MESSAGE);
+ showMessageDialog(parentComponent,
+ "Failed to open workflow from " + file + ":\n"
+ + message, "Warning", WARNING_MESSAGE);
}
});
-
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/RunWorkflowAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/RunWorkflowAction.java
index f4344f0..b87d35a 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/RunWorkflowAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/RunWorkflowAction.java
@@ -20,32 +20,33 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.actions;
-import java.awt.Frame;
-import java.awt.Toolkit;
+import static java.awt.Frame.ICONIFIED;
+import static java.awt.Frame.NORMAL;
+import static java.awt.Toolkit.getDefaultToolkit;
+import static java.awt.event.KeyEvent.VK_R;
+import static javax.swing.KeyStroke.getKeyStroke;
+import static javax.swing.SwingUtilities.invokeLater;
+import static net.sf.taverna.t2.reference.ui.InvalidDataflowReport.showErrorDialog;
+import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.runIcon;
+
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-import javax.swing.SwingUtilities;
import net.sf.taverna.t2.lang.observer.Observable;
import net.sf.taverna.t2.lang.observer.Observer;
import net.sf.taverna.t2.reference.ui.CopyWorkflowInProgressDialog;
import net.sf.taverna.t2.reference.ui.CopyWorkflowSwingWorker;
-import net.sf.taverna.t2.reference.ui.InvalidDataflowReport;
import net.sf.taverna.t2.reference.ui.WorkflowLaunchWindow;
import net.sf.taverna.t2.reference.ui.referenceactions.ReferenceActionSPI;
import net.sf.taverna.t2.workbench.edits.EditManager;
import net.sf.taverna.t2.workbench.file.FileManager;
import net.sf.taverna.t2.workbench.file.events.ClosedDataflowEvent;
import net.sf.taverna.t2.workbench.file.events.FileManagerEvent;
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
import net.sf.taverna.t2.workbench.report.ReportManager;
import net.sf.taverna.t2.workbench.selection.SelectionManager;
import net.sf.taverna.t2.workbench.ui.SwingWorkerCompletionWaiter;
@@ -73,15 +74,15 @@
* Note that running a workflow will force a clone of the WorkflowBundle, allowing further edits to
* the current WorkflowBundle without obstructing the run.
*/
+@SuppressWarnings("serial")
public class RunWorkflowAction extends AbstractAction {
-
- private static final long serialVersionUID = 1L;
-
private static Logger logger = Logger.getLogger(RunWorkflowAction.class);
- // A map of workflows and their corresponding WorkflowLaunchWindowS
- // We only create one window per workflow and then update its content if the
- // workflow gets updated
+ /**
+ * A map of workflows and their corresponding {@link WorkflowLaunchWindow}s.
+ * We only create one window per workflow and then update its content if the
+ * workflow gets updated
+ */
private static HashMap<WorkflowBundle, WorkflowLaunchWindow> workflowLaunchWindowMap = new HashMap<>();
private final EditManager editManager;
@@ -100,61 +101,74 @@
this.workbench = workbench;
this.runService = runService;
this.selectionManager = selectionManager;
- putValue(SMALL_ICON, WorkbenchIcons.runIcon);
+ putValue(SMALL_ICON, runIcon);
putValue(NAME, "Run workflow...");
putValue(SHORT_DESCRIPTION, "Run the current workflow");
- putValue(Action.MNEMONIC_KEY, Integer.valueOf(KeyEvent.VK_R));
- putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit
- .getDefaultToolkit().getMenuShortcutKeyMask()));
+ putValue(MNEMONIC_KEY, VK_R);
+ putValue(
+ ACCELERATOR_KEY,
+ getKeyStroke(VK_R, getDefaultToolkit().getMenuShortcutKeyMask()));
fileManager.addObserver(new Observer<FileManagerEvent>() {
+ @Override
public void notify(Observable<FileManagerEvent> sender, FileManagerEvent message)
throws Exception {
- if (message instanceof ClosedDataflowEvent) {
- workflowLaunchWindowMap.remove(((ClosedDataflowEvent) message).getDataflow());
- }
+ if (message instanceof ClosedDataflowEvent)
+ workflowLaunchWindowMap
+ .remove(((ClosedDataflowEvent) message)
+ .getDataflow());
}
});
}
+ @Override
public void actionPerformed(ActionEvent e) {
final WorkflowBundle workflowBundle = selectionManager.getSelectedWorkflowBundle();
final Profile profile = selectionManager.getSelectedProfile();
Set<ExecutionEnvironment> executionEnvironments = runService
.getExecutionEnvironments(profile);
if (executionEnvironments.isEmpty()) {
- InvalidDataflowReport.showErrorDialog(
+ showErrorDialog(
"There are no execution environments capable of running this workflow",
"Can't run workflow");
- } else {
- // TODO ask user to choose execution environment
- final ExecutionEnvironment executionEnvironment = executionEnvironments.iterator().next();
- // TODO update to use Scufl2 validation
- // if (CheckWorkflowStatus.checkWorkflow(selectedProfile, workbench, editManager,
- // fileManager,reportManager)) {
- try {
+ return;
+ }
+
+ // TODO ask user to choose execution environment
+ final ExecutionEnvironment executionEnvironment = executionEnvironments.iterator().next();
+ try {
+ if (validate(workflowBundle, profile)) {
if (workflowBundle.getMainWorkflow().getInputPorts().isEmpty()) {
final Bundle bundle = DataBundles.createBundle();
- SwingUtilities.invokeLater(new Runnable() {
+ invokeLater(new Runnable() {
+ @Override
public void run() {
- runWorkflow(workflowBundle, profile, executionEnvironment, bundle);
+ runWorkflow(workflowBundle, profile,
+ executionEnvironment, bundle);
}
});
- } else { // workflow had inputs - show the input dialog
- SwingUtilities.invokeLater(new Runnable() {
+ } else // workflow had inputs - show the input dialog
+ invokeLater(new Runnable() {
+ @Override
public void run() {
- showInputDialog(workflowBundle, profile, executionEnvironment);
+ showInputDialog(workflowBundle, profile,
+ executionEnvironment);
}
});
}
- } catch (Exception ex) {
- String message = "Could not run workflow " + workflowBundle.getName();
- logger.warn(message);
- InvalidDataflowReport.showErrorDialog(ex.getMessage(), message);
- }
- // }
+ } catch (Exception ex) {
+ String message = "Could not run workflow " + workflowBundle.getName();
+ logger.warn(message);
+ showErrorDialog(ex.getMessage(), message);
}
}
+ // TODO update to use Scufl2 validation
+ private boolean validate(WorkflowBundle workflowBundle, Profile selectedProfile) {
+ //CheckWorkflowStatus.checkWorkflow(selectedProfile, workbench, editManager,
+ // fileManager,reportManager);
+ return true;
+ }
+
private void runWorkflow(WorkflowBundle workflowBundle, Profile profile,
ExecutionEnvironment executionEnvironment, Bundle workflowInputs) {
try {
@@ -168,21 +182,25 @@
| RunStateException | InvalidExecutionIdException e) {
String message = "Could not run workflow " + workflowBundle.getName();
logger.warn(message, e);
- InvalidDataflowReport.showErrorDialog(e.getMessage(), message);
+ showErrorDialog(e.getMessage(), message);
}
}
private RunProfile createRunProfile(WorkflowBundle workflowBundle, Profile profile,
ExecutionEnvironment executionEnvironment, Bundle inputDataBundle) {
- // Make a copy of the workflow to run so user can still
- // modify the original workflow
+ /*
+ * Make a copy of the workflow to run so user can still modify the
+ * original workflow
+ */
WorkflowBundle workflowBundleCopy = null;
- // CopyWorkflowSwingWorker will make a copy of the workflow and pop
- // up a modal dialog that will block the GUI while
- // CopyWorkflowSwingWorker is doing it to let the user know that something is being done.
- // Blocking of the GUI is needed here so that the user cannot modify the
- // original workflow while it is being copied.
+ /*
+ * CopyWorkflowSwingWorker will make a copy of the workflow and pop up a
+ * modal dialog that will block the GUI while CopyWorkflowSwingWorker is
+ * doing it to let the user know that something is being done. Blocking
+ * of the GUI is needed here so that the user cannot modify the original
+ * workflow while it is being copied.
+ */
CopyWorkflowSwingWorker copyWorkflowSwingWorker = new CopyWorkflowSwingWorker(
workflowBundle);
@@ -190,59 +208,65 @@
copyWorkflowSwingWorker.addPropertyChangeListener(new SwingWorkerCompletionWaiter(dialog));
copyWorkflowSwingWorker.execute();
- // Give a chance to the SwingWorker to finish so we do not have to display
- // the dialog if copying of the workflow is quick (so it won't flicker on the screen)
+ /*
+ * Give a chance to the SwingWorker to finish so we do not have to
+ * display the dialog if copying of the workflow is quick (so it won't
+ * flicker on the screen)
+ */
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// do nothing
}
- if (!copyWorkflowSwingWorker.isDone()) {
+
+ if (!copyWorkflowSwingWorker.isDone())
dialog.setVisible(true); // this will block the GUI
- }
// see if user cancelled the dialog
boolean userCancelled = dialog.hasUserCancelled();
if (userCancelled) {
// Stop the CopyWorkflowSwingWorker if it is still working
copyWorkflowSwingWorker.cancel(true);
- } else {
- // Get the workflow copy from the copyWorkflowSwingWorker
- try {
- workflowBundleCopy = copyWorkflowSwingWorker.get();
- } catch (InterruptedException | ExecutionException e) {
- logger.error("Failed to get the workflow copy", e);
- }
-
- if (workflowBundleCopy == null) {
- InvalidDataflowReport.showErrorDialog(
- "Unable to make a copy of the workflow to run", "Workflow copy failed");
- }
- }
-
- if (workflowBundleCopy != null) {
- return new RunProfile(executionEnvironment, workflowBundleCopy, workflowBundleCopy
- .getMainWorkflow().getName(), profile.getName(), inputDataBundle);
- } else {
return null;
}
+
+ // Get the workflow copy from the copyWorkflowSwingWorker
+ try {
+ workflowBundleCopy = copyWorkflowSwingWorker.get();
+ } catch (InterruptedException | ExecutionException e) {
+ logger.error("Failed to get the workflow copy", e);
+ }
+
+ if (workflowBundleCopy == null) {
+ showErrorDialog("Unable to make a copy of the workflow to run",
+ "Workflow copy failed");
+ return null;
+ }
+
+ return new RunProfile(executionEnvironment, workflowBundleCopy,
+ workflowBundleCopy.getMainWorkflow().getName(),
+ profile.getName(), inputDataBundle);
}
- @SuppressWarnings("serial")
- private void showInputDialog(final WorkflowBundle workflowBundle, final Profile profile,
+ private void showInputDialog(final WorkflowBundle workflowBundle,
+ final Profile profile,
final ExecutionEnvironment executionEnvironment) {
// Get the WorkflowLauchWindow
WorkflowLaunchWindow launchWindow = null;
synchronized (workflowLaunchWindowMap) {
- WorkflowLaunchWindow savedLaunchWindow = workflowLaunchWindowMap.get(workflowBundle);
+ WorkflowLaunchWindow savedLaunchWindow = workflowLaunchWindowMap
+ .get(workflowBundle);
if (savedLaunchWindow == null) {
- launchWindow = new WorkflowLaunchWindow(workflowBundle.getMainWorkflow(),
- editManager, fileManager, reportManager, workbench, new ArrayList<ReferenceActionSPI>(), null) {
-
+ launchWindow = new WorkflowLaunchWindow(
+ workflowBundle.getMainWorkflow(), editManager,
+ fileManager, reportManager, workbench,
+ new ArrayList<ReferenceActionSPI>(), null) {
@Override
public void handleLaunch(Bundle workflowInputs) {
- runWorkflow(workflowBundle, profile, executionEnvironment, workflowInputs);
- setState(Frame.ICONIFIED); // minimise the window
+ runWorkflow(workflowBundle, profile,
+ executionEnvironment, workflowInputs);
+ //TODO T2 now makes the launch window vanish
+ setState(ICONIFIED); // minimise the window
}
@Override
@@ -252,24 +276,24 @@
}
};
- // Add this window to the map of the workflow input/launch
- // windows
+ /*
+ * Add this window to the map of the workflow input/launch
+ * windows
+ */
workflowLaunchWindowMap.put(workflowBundle, launchWindow);
-
launchWindow.setLocationRelativeTo(null);
- } else {
+ } else
launchWindow = savedLaunchWindow;
- }
// Display the window
launchWindow.setVisible(true);
- // On Win XP setting the window visible seems not to be enough to
- // bring the window up if it was minimised previously so we restore
- // it here
- if (launchWindow.getState() == Frame.ICONIFIED) {
- launchWindow.setState(Frame.NORMAL); // restore the window
- }
+ /*
+ * On Win XP setting the window visible seems not to be enough to
+ * bring the window up if it was minimised previously so we restore
+ * it here
+ */
+ if (launchWindow.getState() == ICONIFIED)
+ launchWindow.setState(NORMAL); // restore the window
}
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/ValidateWorkflowAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/ValidateWorkflowAction.java
index 57b2e49..ce13c2a 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/ValidateWorkflowAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/actions/ValidateWorkflowAction.java
@@ -20,34 +20,37 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.actions;
+import static java.awt.event.KeyEvent.VK_V;
+import static net.sf.taverna.t2.workbench.icons.WorkbenchIcons.searchIcon;
+
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import net.sf.taverna.t2.workbench.edits.EditManager;
import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.icons.WorkbenchIcons;
import net.sf.taverna.t2.workbench.report.ReportManager;
import net.sf.taverna.t2.workbench.ui.Workbench;
@SuppressWarnings("serial")
public class ValidateWorkflowAction extends AbstractAction {
-
private static final String VALIDATE_WORKFLOW = "Validate workflow";
-// protected ReportOnWorkflowAction subAction;
+ protected Action subAction;
- public ValidateWorkflowAction(EditManager editManager, FileManager fileManager,
- ReportManager reportManager, Workbench workbench) {
- super(VALIDATE_WORKFLOW, WorkbenchIcons.searchIcon);
- putValue(Action.MNEMONIC_KEY, KeyEvent.VK_V);
-// subAction = new ReportOnWorkflowAction("", true, false, editManager, fileManager, reportManager, workbench);
+ public ValidateWorkflowAction(EditManager editManager,
+ FileManager fileManager, ReportManager reportManager,
+ Workbench workbench) {
+ super(VALIDATE_WORKFLOW, searchIcon);
+ putValue(MNEMONIC_KEY, VK_V);
+ // subAction = new ReportOnWorkflowAction("", true, false, editManager,
+ // fileManager, reportManager, workbench);
}
+ @Override
public void actionPerformed(ActionEvent ev) {
-// subAction.actionPerformed(ev);
+ if (subAction != null)
+ subAction.actionPerformed(ev);
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownDialog.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownDialog.java
index 7d9a8ab..4718fd7 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownDialog.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownDialog.java
@@ -20,8 +20,18 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.cleanup;
-import java.awt.Color;
-import java.awt.Font;
+import static java.awt.Color.WHITE;
+import static java.awt.Font.BOLD;
+import static java.awt.GridBagConstraints.HORIZONTAL;
+import static java.awt.GridBagConstraints.NONE;
+import static java.awt.GridBagConstraints.NORTHWEST;
+import static java.awt.GridBagConstraints.SOUTHEAST;
+import static java.awt.GridBagConstraints.SOUTHWEST;
+import static javax.swing.JOptionPane.WARNING_MESSAGE;
+import static javax.swing.JOptionPane.YES_NO_OPTION;
+import static javax.swing.JOptionPane.YES_OPTION;
+import static javax.swing.JOptionPane.showConfirmDialog;
+
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -31,9 +41,7 @@
import javax.swing.JButton;
import javax.swing.JLabel;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import javax.swing.WindowConstants;
import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
@@ -43,44 +51,39 @@
*
* @author David Withers
*/
+@SuppressWarnings("serial")
public class WorkflowRunStatusShutdownDialog extends HelpEnabledDialog {
-
- private static final long serialVersionUID = 1L;
-
private JButton abortButton;
-
private JButton cancelButton;
-
private boolean confirmShutdown = true;
public WorkflowRunStatusShutdownDialog(int runningWorkflows, int pausedWorkflows) {
super((Frame) null, "Workflows still running", true);
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setLocationRelativeTo(null);
GridBagConstraints c = new GridBagConstraints();
setLayout(new GridBagLayout());
JLabel title = new JLabel("Running or paused workflows detected.");
- title.setFont(title.getFont().deriveFont(Font.BOLD, 14));
+ title.setFont(title.getFont().deriveFont(BOLD, 14));
abortButton = new JButton("Shutdown now");
abortButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
- int result = JOptionPane
- .showConfirmDialog(
- WorkflowRunStatusShutdownDialog.this,
- "If you close Taverna now all workflows will be cancelled.\nAre you sure you want to close now?",
- "Confirm Shutdown", JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
- if (result == JOptionPane.YES_OPTION) {
+ if (showConfirmDialog(
+ WorkflowRunStatusShutdownDialog.this,
+ "If you close Taverna now all workflows will be cancelled.\n"
+ + "Are you sure you want to close now?",
+ "Confirm Shutdown", YES_NO_OPTION, WARNING_MESSAGE) == YES_OPTION)
setVisible(false);
- }
}
});
cancelButton = new JButton("Cancel shutdown");
cancelButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
confirmShutdown = false;
setVisible(false);
@@ -94,13 +97,11 @@
sb.append(runningWorkflows);
sb.append(" running ");
sb.append(runningWorkflows > 1 ? "workflows" : "workflow");
- } else {
+ } else
sb.append(pausedWorkflows > 1 ? "are " : "is ");
- }
if (pausedWorkflows > 0) {
- if (runningWorkflows > 0) {
+ if (runningWorkflows > 0)
sb.append(" and ");
- }
sb.append(pausedWorkflows);
sb.append(" paused ");
sb.append(pausedWorkflows > 1 ? "workflows" : "workflow");
@@ -108,16 +109,16 @@
JLabel message = new JLabel(sb.toString());
JPanel topPanel = new JPanel(new GridBagLayout());
- topPanel.setBackground(Color.WHITE);
+ topPanel.setBackground(WHITE);
- c.anchor = GridBagConstraints.NORTHWEST;
+ c.anchor = NORTHWEST;
c.insets = new Insets(20, 30, 20, 30);
c.weightx = 1d;
c.weighty = 0d;
topPanel.add(title, c);
c.insets = new Insets(0, 0, 0, 0);
- c.fill = GridBagConstraints.HORIZONTAL;
+ c.fill = HORIZONTAL;
c.gridwidth = 2;
c.gridx = 0;
add(topPanel, c);
@@ -127,8 +128,8 @@
c.weighty = 1d;
add(message, c);
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.SOUTHWEST;
+ c.fill = NONE;
+ c.anchor = SOUTHWEST;
c.insets = new Insets(10, 20, 10, 20);
c.weightx = 0.5;
c.weighty = 0d;
@@ -136,21 +137,17 @@
c.gridwidth = 1;
add(cancelButton, c);
- c.anchor = GridBagConstraints.SOUTHEAST;
+ c.anchor = SOUTHEAST;
c.gridx = 1;
add(abortButton, c);
setSize(400, 230);
-
}
/**
- * Returns <code>true</code> if it's OK to proceed with the shutdown.
- *
* @return <code>true</code> if it's OK to proceed with the shutdown
*/
public boolean confirmShutdown() {
return confirmShutdown;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownHook.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownHook.java
index b7d89b5..717b2c1 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownHook.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/cleanup/WorkflowRunStatusShutdownHook.java
@@ -28,47 +28,43 @@
import net.sf.taverna.t2.workbench.ShutdownSPI;
import uk.org.taverna.configuration.app.ApplicationConfiguration;
import uk.org.taverna.platform.execution.api.InvalidExecutionIdException;
-import uk.org.taverna.platform.report.State;
import uk.org.taverna.platform.run.api.InvalidRunIdException;
import uk.org.taverna.platform.run.api.RunService;
import uk.org.taverna.platform.run.api.RunStateException;
/**
* Shutdown hook that detects running and paused workflows.
- *
+ *
* @author David Withers
*/
public class WorkflowRunStatusShutdownHook implements ShutdownSPI {
-
private static final String RUN_STORE_DIRECTORY = "workflow-runs";
private RunService runService;
private ApplicationConfiguration applicationConfiguration;
+ @Override
public int positionHint() {
return 40;
}
+ @Override
public boolean shutdown() {
boolean shutdown = true;
List<String> workflowRuns = runService.getRuns();
List<String> runningWorkflows = new ArrayList<>();
List<String> pausedWorkflows = new ArrayList<>();
- for (String workflowRun : workflowRuns) {
- State runState;
+ for (String workflowRun : workflowRuns)
try {
- runState = runService.getState(workflowRun);
- switch (runState) {
+ switch (runService.getState(workflowRun)) {
case PAUSED:
- pausedWorkflows.add(workflowRun);
- break;
case RUNNING:
- runningWorkflows.add(workflowRun);
+ pausedWorkflows.add(workflowRun);
+ default:
break;
}
} catch (InvalidRunIdException e) {
}
- }
if (runningWorkflows.size() + pausedWorkflows.size() > 0) {
WorkflowRunStatusShutdownDialog dialog = new WorkflowRunStatusShutdownDialog(
runningWorkflows.size(), pausedWorkflows.size());
@@ -76,25 +72,27 @@
shutdown = dialog.confirmShutdown();
}
if (shutdown) {
- for (String workflowRun : pausedWorkflows) {
+ for (String workflowRun : pausedWorkflows)
try {
runService.cancel(workflowRun);
- } catch (InvalidRunIdException | RunStateException | InvalidExecutionIdException e) {
+ } catch (InvalidRunIdException | RunStateException
+ | InvalidExecutionIdException e) {
}
- }
- for (String workflowRun : runningWorkflows) {
+ for (String workflowRun : runningWorkflows)
try {
runService.cancel(workflowRun);
- } catch (InvalidRunIdException | RunStateException | InvalidExecutionIdException e) {
+ } catch (InvalidRunIdException | RunStateException
+ | InvalidExecutionIdException e) {
}
- }
for (String workflowRun : workflowRuns) {
- File runStore = new File(applicationConfiguration.getApplicationHomeDir(), RUN_STORE_DIRECTORY);
+ File runStore = new File(
+ applicationConfiguration.getApplicationHomeDir(),
+ RUN_STORE_DIRECTORY);
try {
- File file = new File(runStore, runService.getRunName(workflowRun) + ".wfRun");
- if (!file.exists()) {
+ File file = new File(runStore,
+ runService.getRunName(workflowRun) + ".wfRun");
+ if (!file.exists())
runService.save(workflowRun, file);
- }
} catch (InvalidRunIdException | IOException e) {
}
}
@@ -106,8 +104,7 @@
this.runService = runService;
}
- public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
- this.applicationConfiguration = applicationConfiguration;
+ public void setApplicationConfiguration(ApplicationConfiguration appConfig) {
+ this.applicationConfiguration = appConfig;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileOpenRunMenuAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileOpenRunMenuAction.java
index 6d1bb7c..6914ac7 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileOpenRunMenuAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileOpenRunMenuAction.java
@@ -20,6 +20,8 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.menu;
+import static net.sf.taverna.t2.workbench.run.menu.FileRunMenuSection.FILE_RUN_SECTION_URI;
+
import java.io.File;
import java.net.URI;
@@ -27,28 +29,26 @@
import uk.org.taverna.configuration.app.ApplicationConfiguration;
import uk.org.taverna.platform.run.api.RunService;
-
import net.sf.taverna.t2.ui.menu.AbstractMenuAction;
import net.sf.taverna.t2.workbench.run.actions.OpenWorkflowRunAction;
public class FileOpenRunMenuAction extends AbstractMenuAction {
-
private static final String RUN_STORE_DIRECTORY = "workflow-runs";
-
private static final URI FILE_OPEN_RUN_URI = URI
.create("http://taverna.sf.net/2008/t2workbench/menu#fileOpenRun");
private RunService runService;
-
private ApplicationConfiguration applicationConfiguration;
public FileOpenRunMenuAction() {
- super(FileRunMenuSection.FILE_RUN_SECTION_URI, 20, FILE_OPEN_RUN_URI);
+ super(FILE_RUN_SECTION_URI, 20, FILE_OPEN_RUN_URI);
}
@Override
protected Action createAction() {
- File runStore = new File(applicationConfiguration.getApplicationHomeDir(), RUN_STORE_DIRECTORY);
+ File runStore = new File(
+ applicationConfiguration.getApplicationHomeDir(),
+ RUN_STORE_DIRECTORY);
return new OpenWorkflowRunAction(runService, runStore);
}
@@ -56,8 +56,8 @@
this.runService = runService;
}
- public void setApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
+ public void setApplicationConfiguration(
+ ApplicationConfiguration applicationConfiguration) {
this.applicationConfiguration = applicationConfiguration;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuAction.java
index 88c3e3f..d1a73c1 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuAction.java
@@ -20,6 +20,8 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.menu;
+import static net.sf.taverna.t2.workbench.run.menu.FileRunMenuSection.FILE_RUN_SECTION_URI;
+
import java.net.URI;
import javax.swing.Action;
@@ -34,9 +36,9 @@
import uk.org.taverna.platform.run.api.RunService;
public class FileRunMenuAction extends AbstractMenuAction {
-
private static final URI FILE_RUN_URI = URI
.create("http://taverna.sf.net/2008/t2workbench/menu#fileRun");
+
private EditManager editManager;
private FileManager fileManager;
private ReportManager reportManager;
@@ -45,7 +47,7 @@
private SelectionManager selectionManager;
public FileRunMenuAction() {
- super(FileRunMenuSection.FILE_RUN_SECTION_URI, 10, FILE_RUN_URI);
+ super(FILE_RUN_SECTION_URI, 10, FILE_RUN_URI);
}
@Override
@@ -77,5 +79,4 @@
public void setSelectionManager(SelectionManager selectionManager) {
this.selectionManager = selectionManager;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuSection.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuSection.java
index 19cd534..6af6eb9 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuSection.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileRunMenuSection.java
@@ -25,7 +25,6 @@
import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
public class FileRunMenuSection extends AbstractMenuSection {
-
public static final URI FILE_URI = URI
.create("http://taverna.sf.net/2008/t2workbench/menu#file");
public static final URI FILE_RUN_SECTION_URI = URI
@@ -34,5 +33,4 @@
public FileRunMenuSection() {
super(FILE_URI, 40, FILE_RUN_SECTION_URI);
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileValidateMenuAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileValidateMenuAction.java
index 9d59927..3558c41 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileValidateMenuAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/menu/FileValidateMenuAction.java
@@ -20,6 +20,8 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.menu;
+import static net.sf.taverna.t2.workbench.run.menu.FileRunMenuSection.FILE_RUN_SECTION_URI;
+
import java.net.URI;
import javax.swing.Action;
@@ -32,22 +34,22 @@
import net.sf.taverna.t2.workbench.ui.Workbench;
public class FileValidateMenuAction extends AbstractMenuAction {
-
private static final URI FILE_VALIDATE_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#fileValidate");
+ .create("http://taverna.sf.net/2008/t2workbench/menu#fileValidate");
+
private EditManager editManager;
private FileManager fileManager;
private ReportManager reportManager;
private Workbench workbench;
-
public FileValidateMenuAction() {
- super(FileRunMenuSection.FILE_RUN_SECTION_URI, 5, FILE_VALIDATE_URI);
+ super(FILE_RUN_SECTION_URI, 5, FILE_VALIDATE_URI);
}
@Override
protected Action createAction() {
- return new ValidateWorkflowAction(editManager, fileManager, reportManager, workbench);
+ return new ValidateWorkflowAction(editManager, fileManager,
+ reportManager, workbench);
}
public void setEditManager(EditManager editManager) {
@@ -65,5 +67,4 @@
public void setWorkbench(Workbench workbench) {
this.workbench = workbench;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarAction.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarAction.java
index ce8ee5d..5e84653 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarAction.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarAction.java
@@ -20,6 +20,8 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.toolbar;
+import static net.sf.taverna.t2.workbench.run.toolbar.RunToolbarSection.RUN_TOOLBAR_SECTION;
+
import java.net.URI;
import javax.swing.Action;
@@ -34,9 +36,9 @@
import uk.org.taverna.platform.run.api.RunService;
public class RunToolbarAction extends AbstractMenuAction {
-
private static final URI RUN_URI = URI
.create("http://taverna.sf.net/2008/t2workbench/menu#runToolbarRun");
+
private EditManager editManager;
private FileManager fileManager;
private ReportManager reportManager;
@@ -45,12 +47,13 @@
private SelectionManager selectionManager;
public RunToolbarAction() {
- super(RunToolbarSection.RUN_TOOLBAR_SECTION, 10, RUN_URI);
+ super(RUN_TOOLBAR_SECTION, 10, RUN_URI);
}
@Override
protected Action createAction() {
- return new RunWorkflowAction(editManager, fileManager, reportManager, workbench, runService, selectionManager);
+ return new RunWorkflowAction(editManager, fileManager, reportManager,
+ workbench, runService, selectionManager);
}
public void setEditManager(EditManager editManager) {
@@ -76,5 +79,4 @@
public void setSelectionManager(SelectionManager selectionManager) {
this.selectionManager = selectionManager;
}
-
}
diff --git a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarSection.java b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarSection.java
index 9b9abd4..b023f16 100644
--- a/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarSection.java
+++ b/run-ui/src/main/java/net/sf/taverna/t2/workbench/run/toolbar/RunToolbarSection.java
@@ -20,18 +20,17 @@
******************************************************************************/
package net.sf.taverna.t2.workbench.run.toolbar;
+import static net.sf.taverna.t2.ui.menu.DefaultToolBar.DEFAULT_TOOL_BAR;
+
import java.net.URI;
import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-import net.sf.taverna.t2.ui.menu.DefaultToolBar;
public class RunToolbarSection extends AbstractMenuSection {
-
public static final URI RUN_TOOLBAR_SECTION = URI
.create("http://taverna.sf.net/2008/t2workbench/menu#runToolbarSection");
public RunToolbarSection() {
- super(DefaultToolBar.DEFAULT_TOOL_BAR, 15, RUN_TOOLBAR_SECTION);
+ super(DEFAULT_TOOL_BAR, 15, RUN_TOOLBAR_SECTION);
}
-
}