1 19 20 package org.openharmonise.him.context; 21 22 import java.awt.*; 23 import java.util.*; 24 25 import javax.swing.*; 26 27 import org.openharmonise.vfs.context.ContextEvent; 28 import org.openharmonise.vfs.context.ContextHandler; 29 import org.openharmonise.vfs.context.ContextType; 30 31 42 public class StateHandler { 43 44 47 private static StateHandler m_instance = null; 48 49 52 private JFrame m_frame = null; 53 54 57 private ArrayList m_aWaits = new ArrayList(); 58 59 62 private String m_sBarText = null; 63 64 67 private StateHandler() { 68 super(); 69 } 70 71 76 public String getBarText() { 77 return this.m_sBarText; 78 } 79 80 85 public static StateHandler getInstance() { 86 if(m_instance==null) { 87 m_instance = new StateHandler(); 88 } 89 return m_instance; 90 } 91 92 98 public void setApplicationWindow(JFrame frame) { 99 this.m_frame = frame; 100 } 101 102 107 public void addWait(String sWaitName) { 108 this.addWait(sWaitName, null); 109 } 110 111 117 public void addWait(String sWaitName, String sBarText) { 118 if(this.m_aWaits.size()==0) { 119 if(sBarText!=null) { 120 this.m_sBarText = sBarText; 121 } 122 ContextEvent ce = new ContextEvent(ContextType.CONTEXT_WAIT, "ON"); 123 ContextHandler.getInstance().fireContextEvent(ce); 124 this.m_frame.setCursor(Cursor.WAIT_CURSOR); 125 } 126 this.m_aWaits.add(sWaitName); 127 } 128 129 135 public void addWait(Component comp, String sWaitName) { 136 this.addWait(comp, sWaitName, null); 137 } 138 139 146 public void addWait(Component comp, String sWaitName, String sBarText) { 147 comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 148 this.addWait(sWaitName, sBarText); 149 } 150 151 157 public void removeWait(Component comp, String sWaitName) { 158 comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 159 this.removeWait(sWaitName); 160 } 161 162 167 public void removeWait(String sWaitName) { 168 this.m_aWaits.remove(sWaitName); 169 this.m_sBarText = null; 170 if(this.m_aWaits.size()==0) { 171 ContextEvent ce = new ContextEvent(ContextType.CONTEXT_WAIT, "OFF"); 172 ContextHandler.getInstance().fireContextEvent(ce); 173 this.m_frame.setCursor(Cursor.DEFAULT_CURSOR); 174 } 175 } 176 177 } 178
| Popular Tags
|