1 package hero.client.grapheditor; 2 3 import hero.util.BonitaClient; 4 5 import java.awt.BorderLayout ; 6 import java.awt.Dimension ; 7 import java.awt.Toolkit ; 8 import java.awt.event.WindowAdapter ; 9 import java.awt.event.WindowEvent ; 10 11 import javax.swing.BorderFactory ; 12 import javax.swing.JFrame ; 13 import javax.swing.JLabel ; 14 import javax.swing.JPanel ; 15 import javax.swing.JScrollPane ; 16 import javax.swing.ToolTipManager ; 17 import java.awt.Color ; 18 19 public class Frame extends JFrame { 20 21 static java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("resources.Traduction"); 22 23 private String project =null; 24 WFManager manager; 25 WFPersistence persistence; 26 WFGraph wfGraph; 27 JLabel statusBar = new JLabel (resource.getString("frame.workeditor")); 28 JScrollPane scrollPane=null; 29 public final static String imageBase = "images/"; 30 private final String CLOSE = "close"; 31 private static Frame frame; 32 33 public Frame(){ 34 frame = this; 35 frame.setBackground(new Color (177,177,251)); 36 } 37 38 public Frame(String managerProject, BonitaClient soapclient, boolean subProcess) throws Exception { 39 frame = this; 40 41 44 java.net.URL iconUrl = Thread.currentThread().getContextClassLoader().getResource(imageBase + "icon.png"); 45 setIconImage(Toolkit.getDefaultToolkit().getImage(iconUrl)); 46 47 persistence = new WFPersistence(managerProject,soapclient); 48 if (subProcess) 50 persistence.permission=false; 51 52 manager= new WFManager(this,persistence); 53 54 getContentPane().removeAll(); 55 getContentPane().setBackground(new Color (177,177,251)); 56 57 WFMenuBar menuBar = new WFMenuBar(this,manager); 59 menuBar.setBackground(new Color (153,153,255)); 60 this.setJMenuBar(menuBar); 61 62 this.project=managerProject; 63 64 wfGraph = new WFGraph(manager,persistence); 66 67 wfGraph.setEditable(false); 68 wfGraph.setBackground(new Color (177,177,251)); 69 70 71 ToolTipManager.sharedInstance().registerComponent(wfGraph); 73 ToolTipManager.sharedInstance().setInitialDelay(100); 74 75 scrollPane = new JScrollPane (wfGraph); 76 scrollPane.setBackground(new Color (177,177,251)); 77 78 manager.setWFGraph(wfGraph); 79 80 WFToolBar toolBar = new WFToolBar(this,manager); 81 toolBar.setBackground(new Color (177,177,251)); 82 toolBar.setFloatable(false); 83 WFToolBar2 toolBar2 = new WFToolBar2(this,manager); 84 toolBar2.setBackground(new Color (177,177,251)); 85 toolBar2.setFloatable(false); 86 87 JPanel toolPanel = new JPanel (); 88 toolPanel.setLayout(new BorderLayout ()); 89 toolPanel.setBackground(new Color (177,177,251)); 90 91 94 toolPanel.add(toolBar2, BorderLayout.CENTER); 95 toolPanel.add(statusBar, BorderLayout.SOUTH); 96 97 statusBar.setBorder(BorderFactory.createLoweredBevelBorder()); 98 statusBar.setBackground(new Color (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 107 108 frame.setSize(600, 600); 109 frame.setBackground(new Color (177,177,251)); 110 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 111 setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2); 112 113 this.setTitle(resource.getString("frame.grapheditor")); 114 116 117 this.addWindowListener(new WindowAdapter () { 118 public void windowClosing(WindowEvent e) { 119 setPropertyChange(); 120 manager.exit(); 121 } 122 123 public void windowActivated(WindowEvent e) { 124 try { 125 if (!(persistence.soapclient.getProjectName()).equals(persistence.getProjectName())) 126 persistence.openProject(persistence.getProjectName()); 127 }catch(Exception open){} 128 } 129 130 }); 131 manager.openProject(managerProject); 132 } 133 134 public String getProject(){ 135 return this.project; 136 } 137 138 public void setPropertyChange(){ 139 firePropertyChange(CLOSE, "", frame.getProject()); 140 } 141 142 public void setStatusBar(String info){ 143 statusBar.setText(info); 144 statusBar.setBackground(new Color (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 getScrollPane(){ 156 return scrollPane; 157 } 158 } 159 160 | Popular Tags |