MCPcopy Create free account
hub / github.com/GateNLP/gate-core / lockGUI

Method lockGUI

src/main/java/gate/gui/MainFrame.java:2222–2303  ·  view source on GitHub ↗

This method will lock all input to the gui by means of a modal dialog. If Gate is not currently running in GUI mode this call will be ignored. A call to this method while the GUI is locked will cause the GUI to be unlocked and then locked again with the new message. If a message is provided it will

(final String message)

Source from the content-addressed store, hash-verified

2220 * @param message the message to be displayed while the GUI is locked
2221 */
2222 public synchronized static void lockGUI(final String message) {
2223 // check whether GUI is up
2224 if(getGuiRoots() == null || getGuiRoots().isEmpty()) return;
2225 // if the GUI is locked unlock it so we can show the new message
2226 unlockGUI();
2227
2228 // this call needs to return so we'll show the dialog from a
2229 // different thread
2230 // the Swing thread sounds good for that
2231 SwingUtilities.invokeLater(new Runnable() {
2232 @Override
2233 public void run() {
2234 // build the dialog contents
2235 Object[] options = new Object[]{new JButton(new StopAction())};
2236 JOptionPane pane =
2237 new JOptionPane(message, JOptionPane.WARNING_MESSAGE,
2238 JOptionPane.DEFAULT_OPTION, null, options, null);
2239
2240 // build the dialog
2241 Component parentComp = ((List<Component>)getGuiRoots()).get(0);
2242 JDialog dialog;
2243 Window parentWindow;
2244 if(parentComp instanceof Window)
2245 parentWindow = (Window)parentComp;
2246 else parentWindow = SwingUtilities.getWindowAncestor(parentComp);
2247 if(parentWindow instanceof Frame) {
2248 dialog = new JDialog((Frame)parentWindow, "Please wait", true) {
2249 private static final long serialVersionUID = 1L;
2250 @Override
2251 protected void processWindowEvent(WindowEvent e) {
2252 if(e.getID() == WindowEvent.WINDOW_CLOSING) {
2253 getToolkit().beep();
2254 }
2255 }
2256 };
2257 }
2258 else if(parentWindow instanceof Dialog) {
2259 dialog = new JDialog((Dialog)parentWindow, "Please wait", true) {
2260 private static final long serialVersionUID = 1L;
2261 @Override
2262 protected void processWindowEvent(WindowEvent e) {
2263 if(e.getID() == WindowEvent.WINDOW_CLOSING) {
2264 getToolkit().beep();
2265 }
2266 }
2267 };
2268 }
2269 else {
2270 dialog = new JDialog(JOptionPane.getRootFrame(), "Please wait", true) {
2271 private static final long serialVersionUID = 1L;
2272 @Override
2273 protected void processWindowEvent(WindowEvent e) {
2274 if(e.getID() == WindowEvent.WINDOW_CLOSING) {
2275 getToolkit().beep();
2276 }
2277 }
2278 };
2279 }

Callers 10

runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
actionPerformedMethod · 0.95
runMethod · 0.95
runMethod · 0.95
actionPerformedMethod · 0.95
runMethod · 0.80
runMethod · 0.80

Calls 3

getGuiRootsMethod · 0.95
unlockGUIMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected