01: package com.opensymphony.workflow.designer.actions;
02:
03: import java.awt.event.ActionEvent;
04: import java.awt.*;
05: import java.io.File;
06: import javax.swing.*;
07:
08: import com.opensymphony.workflow.designer.event.WorkspaceListener;
09: import com.opensymphony.workflow.designer.event.WorkspaceEvent;
10: import com.opensymphony.workflow.designer.*;
11: import com.opensymphony.workflow.loader.Workspace;
12: import com.opensymphony.workflow.loader.WorkflowFactory;
13:
14: /**
15: * @author Hani Suleiman (hani@formicary.net)
16: * Date: May 21, 2003
17: * Time: 1:02:27 AM
18: */
19: public class SaveWorkspace extends AbstractAction implements
20: WorkspaceListener {
21: //private Workspace currentWorkspace;
22: private WorkflowFactory currentWorkspace;
23:
24: public SaveWorkspace() {
25: setEnabled(false);
26: }
27:
28: public void actionPerformed(ActionEvent e) {
29: if (currentWorkspace instanceof Workspace) {
30: Workspace space = (Workspace) currentWorkspace;
31: if (space.getLocation() == null) {
32: File toSave = Utils.promptUserForFile((Component) e
33: .getSource(),
34: JFileChooser.FILES_AND_DIRECTORIES, true,
35: WorkflowDesigner.WORKSPACE_SUFFIX,
36: ResourceManager.getString("workspace.files"));
37: if (toSave != null) {
38: space.setLocation(toSave);
39: Prefs.INSTANCE.put(Prefs.LAST_WORKSPACE, toSave
40: .toString());
41: WorkflowDesigner.INSTANCE.navigator().setWorkspace(
42: space);
43: } else {
44: return;
45: }
46: }
47: }
48: WorkflowDesigner.INSTANCE.saveWorkspace();
49: WorkflowDesigner.INSTANCE.saveOpenGraphs();
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: }
62: }
|