KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > grapheditor > Frame


1 package hero.client.grapheditor;
2
3 import hero.util.BonitaClient;
4
5 import java.awt.BorderLayout JavaDoc;
6 import java.awt.Dimension JavaDoc;
7 import java.awt.Toolkit JavaDoc;
8 import java.awt.event.WindowAdapter JavaDoc;
9 import java.awt.event.WindowEvent JavaDoc;
10
11 import javax.swing.BorderFactory JavaDoc;
12 import javax.swing.JFrame JavaDoc;
13 import javax.swing.JLabel JavaDoc;
14 import javax.swing.JPanel JavaDoc;
15 import javax.swing.JScrollPane JavaDoc;
16 import javax.swing.ToolTipManager JavaDoc;
17 import java.awt.Color JavaDoc;
18
19 public class Frame extends JFrame JavaDoc{
20
21 static java.util.ResourceBundle JavaDoc resource = java.util.ResourceBundle.getBundle("resources.Traduction")/*#BundleType=List*/;
22
23     private String JavaDoc project =null;
24     WFManager manager;
25     WFPersistence persistence;
26     WFGraph wfGraph;
27     JLabel JavaDoc statusBar = new JLabel JavaDoc(resource.getString("frame.workeditor"));
28     JScrollPane JavaDoc scrollPane=null;
29     public final static String JavaDoc imageBase = "images/";
30     private final String JavaDoc CLOSE = "close";
31     private static Frame frame;
32     
33     public Frame(){
34         frame = this;
35         frame.setBackground(new Color JavaDoc(177,177,251));
36     }
37     
38     public Frame(String JavaDoc managerProject, BonitaClient soapclient, boolean subProcess) throws Exception JavaDoc{
39         frame = this;
40         
41         // java.awt.Frame f = new java.awt.Frame();
42
// SplashWindow sw = new SplashWindow(f,this);
43

44         java.net.URL JavaDoc iconUrl = Thread.currentThread().getContextClassLoader().getResource(imageBase + "icon.png");
45         setIconImage(Toolkit.getDefaultToolkit().getImage(iconUrl));
46         
47         persistence = new WFPersistence(managerProject,soapclient);
48         // If open subprocess GraphEditor = only in visualization mode
49
if (subProcess)
50             persistence.permission=false;
51         
52         manager= new WFManager(this,persistence);
53         
54         getContentPane().removeAll();
55         getContentPane().setBackground(new Color JavaDoc(177,177,251));
56         
57         //this.setJMenuBar(new WFMenuBar(this,manager));
58
WFMenuBar menuBar = new WFMenuBar(this,manager);
59         menuBar.setBackground(new Color JavaDoc(153,153,255));
60         this.setJMenuBar(menuBar);
61                     
62         this.project=managerProject;
63         
64         // JGraph graph = new JGraph();
65
wfGraph = new WFGraph(manager,persistence);
66         
67         wfGraph.setEditable(false);
68         wfGraph.setBackground(new Color JavaDoc(177,177,251));
69                 
70                 
71         //Register ToolTip
72
ToolTipManager.sharedInstance().registerComponent(wfGraph);
73         ToolTipManager.sharedInstance().setInitialDelay(100);
74         
75         scrollPane = new JScrollPane JavaDoc(wfGraph);
76         scrollPane.setBackground(new Color JavaDoc(177,177,251));
77             
78         manager.setWFGraph(wfGraph);
79         
80         WFToolBar toolBar = new WFToolBar(this,manager);
81         toolBar.setBackground(new Color JavaDoc(177,177,251));
82         toolBar.setFloatable(false);
83         WFToolBar2 toolBar2 = new WFToolBar2(this,manager);
84         toolBar2.setBackground(new Color JavaDoc(177,177,251));
85         toolBar2.setFloatable(false);
86                         
87         JPanel JavaDoc toolPanel = new JPanel JavaDoc();
88         toolPanel.setLayout(new BorderLayout JavaDoc());
89         toolPanel.setBackground(new Color JavaDoc(177,177,251));
90                 
91         //toolPanel.add(scrollPane, BorderLayout.CENTER);
92
//toolPanel.add(toolBar2, BorderLayout.NORTH);
93

94         toolPanel.add(toolBar2, BorderLayout.CENTER);
95         toolPanel.add(statusBar, BorderLayout.SOUTH);
96         
97         statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
98         statusBar.setBackground(new Color JavaDoc(177,177,251));
99         getContentPane().add(toolBar, BorderLayout.NORTH);
100         getContentPane().add(scrollPane, BorderLayout.CENTER);
101         getContentPane().add(toolPanel, BorderLayout.SOUTH);
102                 
103         pack();
104         /*Dimension screenSize =Toolkit.getDefaultToolkit().getScreenSize();
105         Dimension dim = getPreferredSize();
106         setLocation(screenSize.width/2 - (dim.width/2), screenSize.height/2 - (dim.height/2));*/

107         
108         frame.setSize(600, 600);
109         frame.setBackground(new Color JavaDoc(177,177,251));
110         Dimension JavaDoc screen = Toolkit.getDefaultToolkit().getScreenSize();
111         setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);
112         
113         this.setTitle(resource.getString("frame.grapheditor"));
114         //this.setBackground(new Color(177,177,251));
115

116         
117         this.addWindowListener(new WindowAdapter JavaDoc() {
118             public void windowClosing(WindowEvent JavaDoc e) {
119               setPropertyChange();
120               manager.exit();
121             }
122             
123             public void windowActivated(WindowEvent JavaDoc e) {
124               try {
125                 if (!(persistence.soapclient.getProjectName()).equals(persistence.getProjectName()))
126                     persistence.openProject(persistence.getProjectName());
127               }catch(Exception JavaDoc open){}
128             }
129             
130         });
131         manager.openProject(managerProject);
132     }
133
134     public String JavaDoc getProject(){
135         return this.project;
136     }
137     
138     public void setPropertyChange(){
139         firePropertyChange(CLOSE, "", frame.getProject());
140     }
141     
142     public void setStatusBar(String JavaDoc info){
143     statusBar.setText(info);
144     statusBar.setBackground(new Color JavaDoc(177,177,251));
145     }
146     
147     public WFGraph getWorkflowGraph() {
148         return this.wfGraph;
149     }
150     
151     public static Frame getFrame() {
152         return frame;
153     }
154
155     public JScrollPane JavaDoc getScrollPane(){
156     return scrollPane;
157     }
158 }
159
160
Popular Tags