1 19 package org.openharmonise.workfloweditor; 20 21 import java.util.*; 22 23 import org.openharmonise.him.*; 24 import org.openharmonise.him.context.StateHandler; 25 import org.openharmonise.him.window.messages.*; 26 import org.openharmonise.vfs.*; 27 import org.openharmonise.vfs.context.*; 28 import org.openharmonise.vfs.servers.ServerList; 29 import org.openharmonise.vfs.status.*; 30 import org.openharmonise.workfloweditor.flowchart.*; 31 import org.openharmonise.workfloweditor.model.*; 32 import org.openharmonise.workfloweditor.vfs.*; 33 34 35 44 public class WorkflowEditor { 45 46 49 private FlowChart m_chart = null; 50 51 54 private DisplayManager m_display = null; 55 56 59 public WorkflowEditor() { 60 super(); 61 this.setup(); 62 } 63 64 68 private void setup() { 69 m_display = new DisplayManager(this); 70 71 m_chart = m_display.getFlowChart(); 72 } 73 74 79 public void setModel(WorkflowModel model) { 80 this.m_chart.setModel(model); 81 this.m_chart.repaint(); 82 } 83 84 89 public void shutdown() { 90 StateHandler.getInstance().addWait("WORKFLOWSAVE"); 91 try { 92 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 93 94 VFSWorkflowModel model = (VFSWorkflowModel) m_chart.getModel(); 95 Iterator itor = model.getWorkflowStages().iterator(); 96 97 while (itor.hasNext()) { 98 VFSWorkflowStage stage = (VFSWorkflowStage) itor.next(); 99 VersionedVirtualFile vfFile = (VersionedVirtualFile) vfs.getVirtualFile(stage.getPath()).getResource(); 100 if(vfFile.isChanged()) { 101 StatusData status = vfFile.sync(); 102 if( status.isOK() ) { 103 if(vfFile.getState()==VirtualFile.STATE_LIVE && vfFile.getPendingVersionPath()!=null) { 104 VersionedVirtualFile vfPending = (VersionedVirtualFile) vfs.getVirtualFile(vfFile.getPendingVersionPath()).getResource(); 105 if(vfPending!=null) { 106 vfPending.checkin(); 107 } 108 } else if(vfFile.getState()==VirtualFile.STATE_PENDING) { 109 vfFile.checkin(); 110 } 111 } else { 112 113 } 114 } 115 } 116 } catch(Exception e) { 117 e.printStackTrace(); 118 MessageHandler.getInstance().fireMessageEvent("There were problems saving the workflow changes.", MessageHandler.TYPE_ERROR); 119 } finally { 120 StateHandler.getInstance().removeWait("WORKFLOWSAVE"); 121 MessageHandler.getInstance().fireMessageEvent("Workflow changes saved.", MessageHandler.TYPE_CONFIRM); 122 } 123 } 124 125 public static void main(String [] args) { 126 WorkflowEditor editor = new WorkflowEditor(); 127 } 128 } 129 | Popular Tags |