KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.opensymphony.workflow.designer.actions;
2
3 import java.awt.event.ActionEvent JavaDoc;
4 import javax.swing.*;
5
6 import com.opensymphony.workflow.designer.WorkflowGraph;
7 import com.opensymphony.workflow.designer.WorkflowDesigner;
8 import com.opensymphony.workflow.designer.event.WorkspaceListener;
9 import com.opensymphony.workflow.designer.event.WorkspaceEvent;
10
11 /**
12  * @author Hani Suleiman (hani@formicary.net)
13  * Date: May 20, 2003
14  * Time: 8:25:28 PM
15  */

16 public class AutoLayout extends AbstractAction implements WorkspaceListener
17 {
18   private WorkflowGraph graph;
19
20   /**
21    * Create an auto layout action.
22    * This action calls an auto layout algorithm on the specified graph.
23    * @param graph the graph to autolayout. If the graph is null, then the currently
24    * showing graph has auto layout applied to it.
25    */

26   public AutoLayout(WorkflowGraph graph)
27   {
28     this.graph = graph;
29   }
30
31   public void actionPerformed(ActionEvent JavaDoc e)
32   {
33     if(graph==null)
34     {
35       WorkflowGraph selected = WorkflowDesigner.INSTANCE.getCurrentGraph();
36       if(selected!=null)
37         selected.autoLayout();
38     }
39     else
40     {
41       graph.autoLayout();
42     }
43   }
44
45   public void workspaceChanged(WorkspaceEvent event)
46   {
47     if(event.getId()==WorkspaceEvent.WORKSPACE_OPENED)
48     {
49       setEnabled(true);
50     }
51     else
52     {
53       setEnabled(false);
54     }
55   }
56 }
57
Popular Tags