KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > actions > SaveWorkspace


1 package com.opensymphony.workflow.designer.actions;
2
3 import java.awt.event.ActionEvent JavaDoc;
4 import java.awt.*;
5 import java.io.File JavaDoc;
6 import javax.swing.*;
7
8 import com.opensymphony.workflow.designer.event.WorkspaceListener;
9 import com.opensymphony.workflow.designer.event.WorkspaceEvent;
10 import com.opensymphony.workflow.designer.*;
11 import com.opensymphony.workflow.loader.Workspace;
12
13 /**
14  * @author Hani Suleiman (hani@formicary.net)
15  * Date: May 21, 2003
16  * Time: 1:02:27 AM
17  */

18 public class SaveWorkspace extends AbstractAction implements WorkspaceListener
19 {
20   private Workspace currentWorkspace;
21
22   public SaveWorkspace()
23   {
24     setEnabled(false);
25   }
26
27   public void actionPerformed(ActionEvent JavaDoc e)
28   {
29     if(currentWorkspace.getLocation()==null)
30     {
31       File JavaDoc toSave = Utils.promptUserForFile((Component)e.getSource(), JFileChooser.FILES_AND_DIRECTORIES, true, WorkflowDesigner.WORKSPACE_SUFFIX, ResourceManager.getString("workspace.files"));
32       if(toSave!=null)
33       {
34         currentWorkspace.setLocation(toSave);
35         Prefs.INSTANCE.put(Prefs.LAST_WORKSPACE, toSave.toString());
36         WorkflowDesigner.INSTANCE.navigator().setWorkspace(currentWorkspace);
37       }
38       else
39       {
40         return;
41       }
42     }
43     WorkflowDesigner.INSTANCE.saveWorkspace();
44     WorkflowDesigner.INSTANCE.saveOpenGraphs();
45   }
46
47   public void workspaceChanged(WorkspaceEvent event)
48   {
49     if(event.getId()==WorkspaceEvent.WORKSPACE_OPENED)
50     {
51       setEnabled(true);
52       currentWorkspace = event.getWorkspace();
53     }
54     else
55     {
56       setEnabled(false);
57       currentWorkspace = null;
58     }
59
60   }
61 }
62
Popular Tags