01: package com.opensymphony.workflow.designer.actions;
02:
03: import java.awt.event.ActionEvent;
04: import javax.swing.*;
05:
06: import com.opensymphony.workflow.designer.event.WorkspaceListener;
07: import com.opensymphony.workflow.designer.event.WorkspaceEvent;
08: import com.opensymphony.workflow.designer.WorkflowDesigner;
09: import com.opensymphony.workflow.designer.ResourceManager;
10: import com.opensymphony.workflow.loader.WorkflowFactory;
11: import com.opensymphony.workflow.FactoryException;
12:
13: /**
14: * @author Hani Suleiman (hani@formicary.net)
15: * Date: May 21, 2003
16: * Time: 1:14:41 AM
17: */
18: public class NewWorkflow extends AbstractAction implements
19: WorkspaceListener {
20: //private Workspace currentWorkspace;
21: private WorkflowFactory currentWorkspace;
22:
23: public NewWorkflow() {
24: setEnabled(false);
25: }
26:
27: public void actionPerformed(ActionEvent e) {
28: String name = JOptionPane.showInputDialog(
29: WorkflowDesigner.INSTANCE, ResourceManager
30: .getString("createflow"), ResourceManager
31: .getString("createflow.long"));
32: if (name == null)
33: return;
34: try {
35: if (currentWorkspace.getWorkflow(name) != null) {
36: JOptionPane.showMessageDialog(
37: WorkflowDesigner.INSTANCE, ResourceManager
38: .getString("createflow.error",
39: new Object[] { name }),
40: ResourceManager.getString("createflow.error"),
41: JOptionPane.ERROR_MESSAGE);
42: return;
43: }
44: } catch (FactoryException ex) {
45: ex.printStackTrace();
46: return;
47: }
48: currentWorkspace.createWorkflow(name);
49: WorkflowDesigner.INSTANCE.newWorkflowCreated(name);
50: }
51:
52: public void workspaceChanged(WorkspaceEvent event) {
53: if (event.getId() == WorkspaceEvent.WORKSPACE_OPENED) {
54: setEnabled(true);
55: currentWorkspace = event.getWorkspace();
56: } else {
57: setEnabled(false);
58: currentWorkspace = null;
59: }
60: }
61: }
|