001: package hero.client.grapheditor;
002:
003: import hero.util.BonitaClient;
004:
005: import java.awt.BorderLayout;
006: import java.awt.Dimension;
007: import java.awt.Toolkit;
008: import java.awt.event.WindowAdapter;
009: import java.awt.event.WindowEvent;
010:
011: import javax.swing.BorderFactory;
012: import javax.swing.JFrame;
013: import javax.swing.JLabel;
014: import javax.swing.JPanel;
015: import javax.swing.JScrollPane;
016: import javax.swing.ToolTipManager;
017: import java.awt.Color;
018:
019: public class Frame extends JFrame {
020:
021: static java.util.ResourceBundle resource = java.util.ResourceBundle
022: .getBundle("resources.Traduction")/*#BundleType=List*/;
023:
024: private String project = null;
025: WFManager manager;
026: WFPersistence persistence;
027: WFGraph wfGraph;
028: JLabel statusBar = new JLabel(resource
029: .getString("frame.workeditor"));
030: JScrollPane scrollPane = null;
031: public final static String imageBase = "images/";
032: private final String CLOSE = "close";
033: private static Frame frame;
034:
035: public Frame() {
036: frame = this ;
037: frame.setBackground(new Color(177, 177, 251));
038: }
039:
040: public Frame(String managerProject, BonitaClient soapclient,
041: boolean subProcess) throws Exception {
042: frame = this ;
043:
044: // java.awt.Frame f = new java.awt.Frame();
045: // SplashWindow sw = new SplashWindow(f,this);
046:
047: java.net.URL iconUrl = Thread.currentThread()
048: .getContextClassLoader().getResource(
049: imageBase + "icon.png");
050: setIconImage(Toolkit.getDefaultToolkit().getImage(iconUrl));
051:
052: persistence = new WFPersistence(managerProject, soapclient);
053: // If open subprocess GraphEditor = only in visualization mode
054: if (subProcess)
055: persistence.permission = false;
056:
057: manager = new WFManager(this , persistence);
058:
059: getContentPane().removeAll();
060: getContentPane().setBackground(new Color(177, 177, 251));
061:
062: //this.setJMenuBar(new WFMenuBar(this,manager));
063: WFMenuBar menuBar = new WFMenuBar(this , manager);
064: menuBar.setBackground(new Color(153, 153, 255));
065: this .setJMenuBar(menuBar);
066:
067: this .project = managerProject;
068:
069: // JGraph graph = new JGraph();
070: wfGraph = new WFGraph(manager, persistence);
071:
072: wfGraph.setEditable(false);
073: wfGraph.setBackground(new Color(177, 177, 251));
074:
075: //Register ToolTip
076: ToolTipManager.sharedInstance().registerComponent(wfGraph);
077: ToolTipManager.sharedInstance().setInitialDelay(100);
078:
079: scrollPane = new JScrollPane(wfGraph);
080: scrollPane.setBackground(new Color(177, 177, 251));
081:
082: manager.setWFGraph(wfGraph);
083:
084: WFToolBar toolBar = new WFToolBar(this , manager);
085: toolBar.setBackground(new Color(177, 177, 251));
086: toolBar.setFloatable(false);
087: WFToolBar2 toolBar2 = new WFToolBar2(this , manager);
088: toolBar2.setBackground(new Color(177, 177, 251));
089: toolBar2.setFloatable(false);
090:
091: JPanel toolPanel = new JPanel();
092: toolPanel.setLayout(new BorderLayout());
093: toolPanel.setBackground(new Color(177, 177, 251));
094:
095: //toolPanel.add(scrollPane, BorderLayout.CENTER);
096: //toolPanel.add(toolBar2, BorderLayout.NORTH);
097:
098: toolPanel.add(toolBar2, BorderLayout.CENTER);
099: toolPanel.add(statusBar, BorderLayout.SOUTH);
100:
101: statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
102: statusBar.setBackground(new Color(177, 177, 251));
103: getContentPane().add(toolBar, BorderLayout.NORTH);
104: getContentPane().add(scrollPane, BorderLayout.CENTER);
105: getContentPane().add(toolPanel, BorderLayout.SOUTH);
106:
107: pack();
108: /*Dimension screenSize =Toolkit.getDefaultToolkit().getScreenSize();
109: Dimension dim = getPreferredSize();
110: setLocation(screenSize.width/2 - (dim.width/2), screenSize.height/2 - (dim.height/2));*/
111:
112: frame.setSize(600, 600);
113: frame.setBackground(new Color(177, 177, 251));
114: Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
115: setLocation((screen.width - getWidth()) / 2,
116: (screen.height - getHeight()) / 2);
117:
118: this .setTitle(resource.getString("frame.grapheditor"));
119: //this.setBackground(new Color(177,177,251));
120:
121: this .addWindowListener(new WindowAdapter() {
122: public void windowClosing(WindowEvent e) {
123: setPropertyChange();
124: manager.exit();
125: }
126:
127: public void windowActivated(WindowEvent e) {
128: try {
129: if (!(persistence.soapclient.getProjectName())
130: .equals(persistence.getProjectName()))
131: persistence.openProject(persistence
132: .getProjectName());
133: } catch (Exception open) {
134: }
135: }
136:
137: });
138: manager.openProject(managerProject);
139: }
140:
141: public String getProject() {
142: return this .project;
143: }
144:
145: public void setPropertyChange() {
146: firePropertyChange(CLOSE, "", frame.getProject());
147: }
148:
149: public void setStatusBar(String info) {
150: statusBar.setText(info);
151: statusBar.setBackground(new Color(177, 177, 251));
152: }
153:
154: public WFGraph getWorkflowGraph() {
155: return this .wfGraph;
156: }
157:
158: public static Frame getFrame() {
159: return frame;
160: }
161:
162: public JScrollPane getScrollPane() {
163: return scrollPane;
164: }
165: }
|