1 19 package org.openharmonise.workfloweditor; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 import java.awt.geom.*; 24 import java.util.*; 25 import java.util.List ; 26 27 import javax.swing.*; 28 29 import org.openharmonise.him.*; 30 import org.openharmonise.him.dnd.*; 31 import org.openharmonise.him.harmonise.*; 32 import org.openharmonise.him.swing.resourcetree.*; 33 import org.openharmonise.vfs.*; 34 import org.openharmonise.vfs.gui.*; 35 import org.openharmonise.vfs.servers.*; 36 import org.openharmonise.workfloweditor.flowchart.*; 37 import org.openharmonise.workfloweditor.flowchart.shapes.*; 38 import org.openharmonise.workfloweditor.vfs.*; 39 40 41 49 public class DisplayManager extends JFrame { 50 51 54 private FlowChart m_chart = null; 55 56 59 private WorkflowEditor m_editor = null; 60 61 66 public DisplayManager(WorkflowEditor editor) { 67 super(); 68 this.m_editor = editor; 69 this.setup(); 70 } 71 72 76 private void setup() { 77 78 this.setTitle("Workflow Editor"); 79 80 this.setIconImage( ((ImageIcon)IconManager.getInstance().getIcon("16-command-change-status.gif")).getImage()); 81 82 83 this.setSize(700,700); 84 int x = this.getGraphicsConfiguration().getBounds().width/2-this.getSize().width/2; 85 int y = this.getGraphicsConfiguration().getBounds().height/2-this.getSize().height/2; 86 87 this.setLocation(x, y); 88 89 this.addWindowListener(new WindowAdapter() { 90 public void windowClosing(WindowEvent woo) { 91 shutdown(); 92 } 93 }); 94 95 JPanel leftPanel = new JPanel(); 96 leftPanel.setLayout( new BorderLayout()); 97 98 ResourceTree tree = new ResourceTree(); 99 tree.setShowLeafNodes(true); 100 tree.setShowApprovedOnly(true); 101 102 Server server = ServerList.getInstance().getHarmoniseServer(); 103 104 VirtualFile vfFile = server.getVFS().getVirtualFile( HarmonisePaths.PATH_WORKFLOW_STAGES ).getResource(); 105 106 tree.addCollection(vfFile); 107 108 109 leftPanel.add( tree ); 110 leftPanel.setBackground(Color.RED); 111 112 JPanel rightPanel = new JPanel(); 113 rightPanel.setLayout( new BorderLayout()); 114 this.m_chart = new FlowChart(); 115 this.m_chart.setPreferredSize(new Dimension(2000,2000)); 116 117 WorkflowDropTarget dropTarget = new WorkflowDropTarget(this.m_chart, tree); 118 119 JScrollPane scroller = new JScrollPane(this.m_chart, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 120 scroller.getVerticalScrollBar().setUnitIncrement(50); 121 scroller.getHorizontalScrollBar().setUnitIncrement(50); 122 123 rightPanel.add( scroller ); 124 rightPanel.setBackground(Color.YELLOW); 125 126 JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); 127 splitPane.setOneTouchExpandable(true); 128 splitPane.setContinuousLayout(true); 129 splitPane.setDividerLocation(150); 130 this.getContentPane().add(splitPane); 131 this.show(); 132 133 } 134 135 140 public FlowChart getFlowChart() { 141 return this.m_chart; 142 } 143 144 147 protected void shutdown() { 148 this.saveChartLayout(); 149 this.hide(); 150 this.m_editor.shutdown(); 151 } 152 153 157 private void saveChartLayout() { 158 try { 159 List shapes = this.m_chart.getShapes(); 160 Iterator itor = shapes.iterator(); 161 while (itor.hasNext()) { 162 AbstractWorkflowShape shape = (AbstractWorkflowShape) itor.next(); 163 if(shape instanceof StageShape) { 164 VFSWorkflowStage vfsStage = (VFSWorkflowStage) ((StageShape)shape).getStage(); 165 String sWorkflowPath = ((VFSWorkflowModel)this.m_chart.getModel()).getStagesCollection().getFullPath(); 166 String sStagePath = vfsStage.getPath(); 167 Point2D.Float point = new Point2D.Float(shape.getX(), shape.getY()); 168 169 WorkflowLayoutStore.getInstance().setStageLayout(sWorkflowPath, sStagePath, point); 170 } 171 } 172 } catch(Exception e) { 173 e.printStackTrace(); 174 } 175 } 176 } 177 | Popular Tags |