Changeset 6641
- Timestamp:
- 2004-01-28T14:50:48+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java
r6622 r6641 133 133 */ 134 134 public void setVisible (boolean visible) { 135 ///ystem.err.println("setVisible(" + visible + ")"); 136 getParent ().setEnabled (!(visible && modal)); 137 super.setVisible (visible); 138 if (modal && visible) { 135 if(visible) { 139 136 Gatherer.current_modal = this; 140 try { 141 if (SwingUtilities.isEventDispatchThread ()) { 142 ///ystem.err.println("is Event Dispatch Thread. Only process certain events."); 143 EventQueue theQueue = getToolkit().getSystemEventQueue(); 144 while (isVisible ()) { 137 } 138 else { 139 Gatherer.current_modal = null; 140 } 141 // If we are in the AWT Dispatch thread then it is all good. 142 if (SwingUtilities.isEventDispatchThread ()) { 143 getParent ().setEnabled (!(visible && modal)); 144 super.setVisible (visible); 145 if (modal && visible) { 146 ///ystem.err.println("is Event Dispatch Thread. Only process certain events."); 147 EventQueue theQueue = getToolkit().getSystemEventQueue(); 148 while (isVisible ()) { 149 try { 145 150 AWTEvent event = theQueue.getNextEvent(); 146 151 Object src = event.getSource (); … … 156 161 } 157 162 } 158 ///ystem.err.println("No longer visible - AWT"); 159 } else synchronized (getTreeLock ()) { 160 ///ystem.err.println("is other Thread. Block all events."); 161 while (isVisible ()) { 162 try { 163 waiting = true; 164 getTreeLock().wait(); 165 waiting = false; 166 } catch (InterruptedException e) { 167 ///ystem.err.println("Interrupted!!!"); 168 break; 169 } 163 catch(Exception exception) { 164 Gatherer.printStackTrace(exception); 170 165 } 171 ///ystem.err.println("No longer visible - Other");172 166 } 173 } catch (Exception ex) {174 ex.printStackTrace();175 167 } 176 168 } 177 else if(modal && !visible && waiting) { 178 Gatherer.current_modal = null; 179 ///ystem.err.println("Hiding dialog. Tree lock is: " + getTreeLock()); 180 synchronized(getTreeLock()) { 181 ///ystem.err.println("Notify!"); 182 getTreeLock().notify(); 169 else { 170 try { 171 SwingUtilities.invokeAndWait(new MakeDialogVisibleTask(this, visible)); 183 172 } 184 } 185 else if(modal && !waiting) { 186 Gatherer.current_modal = null; 187 ///ystem.err.println("Modal Dialog is not currently waiting."); 188 } 189 else if(!modal) { 190 ///ystem.err.println("Dialog is not modal."); 173 catch(Exception exception) { 174 Gatherer.printStackTrace(exception); 175 } 191 176 } 192 177 } 193 178 179 private class MakeDialogVisibleTask 180 implements Runnable { 181 private boolean make_visible; 182 private ModalDialog dialog; 183 public MakeDialogVisibleTask(ModalDialog dialog, boolean make_visible) { 184 this.dialog = dialog; 185 this.make_visible = make_visible; 186 } 187 public void run() { 188 // Blocks until the user dismisses the dialog 189 dialog.setVisible(make_visible); 190 } 191 } 192 194 193 /** Overridden method so we can control modality and not rely on the Dialog default. 195 194 * @param modal true if this dialog should be modal, ie block user actions to its owner window, false otherwise.
Note:
See TracChangeset
for help on using the changeset viewer.