Changeset 8480
- Timestamp:
- 2004-11-08T11:52:49+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8474 r8480 46 46 import org.greenstone.gatherer.file.FileAssociationManager; 47 47 import org.greenstone.gatherer.gui.GUIManager; 48 import org.greenstone.gatherer.gui.ModalDialog;49 48 import org.greenstone.gatherer.gui.Splash; 50 49 import org.greenstone.gatherer.gui.URLField; -
trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java
r8257 r8480 27 27 28 28 import java.awt.*; 29 import java.awt.event.*; 29 30 import javax.swing.*; 30 31 import org.greenstone.gatherer.DebugStream; 32 31 33 32 34 /** An extension of the JDialog that overrides the JVM's typical modal behaviour. This typical behaviour is that when a modal dialog is opened, all other windows cease to respond to user events until the modal dialog is disposed. However this prevents us opening the help documents property whenever a modal dialog is open. Thus we override the modal behaviour so that only the owner frame or dialog is blocked. … … 133 135 * @param visible true if this dialog should be painted on-screen, false otherwise. 134 136 */ 135 public void setVisible (boolean visible) { 136 if(visible) { 137 public void setVisible(boolean visible) 138 { 139 if (visible) { 137 140 current_modal = this; 138 141 } … … 140 143 current_modal = null; 141 144 } 145 142 146 // If we are in the AWT Dispatch thread then it is all good. 143 if (SwingUtilities.isEventDispatchThread ()) { 144 getParent ().setEnabled (!(visible && modal)); 145 super.setVisible (visible); 147 if (SwingUtilities.isEventDispatchThread()) { 148 super.setVisible(visible); 146 149 if (modal && visible) { 147 ///ystem.err.println("is Event Dispatch Thread. Only process certain events.");148 150 EventQueue theQueue = getToolkit().getSystemEventQueue(); 149 while (isVisible 151 while (isVisible()) { 150 152 try { 151 153 AWTEvent event = theQueue.getNextEvent(); 152 Object src = event.getSource (); 154 Object src = event.getSource(); 155 156 // Block all keyboard and mouse events to the parent component 157 if (src.equals(getParent())) { 158 if (event instanceof KeyEvent || event instanceof MouseEvent) { 159 // System.err.println("Event to parent component blocked."); 160 continue; 161 } 162 } 163 164 // Re-dispatch other events 153 165 if (event instanceof ActiveEvent) { 154 ///ystem.err.println("ActiveEvent:"); 155 ((ActiveEvent) event).dispatch (); 156 } else if (src instanceof Component) { 157 ///ystem.err.println("Source is component"); 158 ((Component) src).dispatchEvent (event); 159 } 160 else { 161 ///ystem.err.println("Event blocked"); 166 ((ActiveEvent) event).dispatch(); 167 } 168 else if (src instanceof Component) { 169 ((Component) src).dispatchEvent(event); 162 170 } 163 171 } 164 catch (Exception exception) {172 catch (Exception exception) { 165 173 DebugStream.printStackTrace(exception); 166 174 } 167 175 } 168 176 } 169 }170 else {171 try {172 SwingUtilities.invokeAndWait(new MakeDialogVisibleTask(this, visible));173 }174 catch(Exception exception) {175 DebugStream.printStackTrace(exception);176 }177 }177 } 178 else { 179 try { 180 SwingUtilities.invokeAndWait(new MakeDialogVisibleTask(this, visible)); 181 } 182 catch (Exception exception) { 183 DebugStream.printStackTrace(exception); 184 } 185 } 178 186 } 179 187
Note:
See TracChangeset
for help on using the changeset viewer.