home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.Dialog.4;
- import java.awt.event.ComponentEvent;
- import java.awt.event.InvocationEvent;
- import java.awt.peer.DialogPeer;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.lang.ref.WeakReference;
- import java.security.AccessController;
- import java.util.Vector;
- import java.util.concurrent.atomic.AtomicLong;
- import javax.accessibility.AccessibleContext;
- import sun.awt.AppContext;
- import sun.awt.PeerEvent;
- import sun.awt.SunToolkit;
- import sun.security.util.SecurityConstants;
-
- public class Dialog extends Window {
- boolean resizable;
- boolean undecorated;
- public static final ModalityType DEFAULT_MODALITY_TYPE;
- boolean modal;
- ModalityType modalityType;
- private static final ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE;
- static transient Vector<Dialog> modalDialogs;
- transient Vector<Window> blockedWindows;
- String title;
- private transient boolean keepBlocking;
- private transient ModalEventFilter modalFilter;
- transient volatile boolean isInHide;
- transient volatile boolean isInDispose;
- private static final String base = "dialog";
- private static int nameCounter;
- private static final long serialVersionUID = 5920926903803293709L;
- private transient AppContext showAppContext;
-
- public Dialog(Frame var1) {
- this(var1, "", false);
- }
-
- public Dialog(Frame var1, boolean var2) {
- this(var1, "", var2);
- }
-
- public Dialog(Frame var1, String var2) {
- this(var1, var2, false);
- }
-
- public Dialog(Frame var1, String var2, boolean var3) {
- this(var1, var2, var3 ? DEFAULT_MODALITY_TYPE : java.awt.Dialog.ModalityType.MODELESS);
- }
-
- public Dialog(Frame var1, String var2, boolean var3, GraphicsConfiguration var4) {
- this(var1, var2, var3 ? DEFAULT_MODALITY_TYPE : java.awt.Dialog.ModalityType.MODELESS, var4);
- }
-
- public Dialog(Dialog var1) {
- this(var1, "", false);
- }
-
- public Dialog(Dialog var1, String var2) {
- this(var1, var2, false);
- }
-
- public Dialog(Dialog var1, String var2, boolean var3) {
- this(var1, var2, var3 ? DEFAULT_MODALITY_TYPE : java.awt.Dialog.ModalityType.MODELESS);
- }
-
- public Dialog(Dialog var1, String var2, boolean var3, GraphicsConfiguration var4) {
- this(var1, var2, var3 ? DEFAULT_MODALITY_TYPE : java.awt.Dialog.ModalityType.MODELESS, var4);
- }
-
- public Dialog(Window var1) {
- this(var1, (String)null, java.awt.Dialog.ModalityType.MODELESS);
- }
-
- public Dialog(Window var1, String var2) {
- this(var1, var2, java.awt.Dialog.ModalityType.MODELESS);
- }
-
- public Dialog(Window var1, ModalityType var2) {
- this(var1, (String)null, var2);
- }
-
- public Dialog(Window var1, String var2, ModalityType var3) {
- super(var1);
- this.resizable = true;
- this.undecorated = false;
- this.blockedWindows = new Vector();
- this.keepBlocking = false;
- this.isInHide = false;
- this.isInDispose = false;
- if (var1 != null && !(var1 instanceof Frame) && !(var1 instanceof Dialog)) {
- throw new IllegalArgumentException("Wrong parent window");
- } else {
- this.title = var2;
- this.setModalityType(var3);
- SunToolkit.checkAndSetPolicy(this, false);
- }
- }
-
- public Dialog(Window var1, String var2, ModalityType var3, GraphicsConfiguration var4) {
- super(var1, var4);
- this.resizable = true;
- this.undecorated = false;
- this.blockedWindows = new Vector();
- this.keepBlocking = false;
- this.isInHide = false;
- this.isInDispose = false;
- if (var1 != null && !(var1 instanceof Frame) && !(var1 instanceof Dialog)) {
- throw new IllegalArgumentException("wrong owner window");
- } else {
- this.title = var2;
- this.setModalityType(var3);
- SunToolkit.checkAndSetPolicy(this, false);
- }
- }
-
- String constructComponentName() {
- synchronized(this.getClass()) {
- return "dialog" + nameCounter++;
- }
- }
-
- public void addNotify() {
- synchronized(this.getTreeLock()) {
- if (this.parent != null && this.parent.getPeer() == null) {
- this.parent.addNotify();
- }
-
- if (this.peer == null) {
- this.peer = this.getToolkit().createDialog(this);
- }
-
- super.addNotify();
- }
- }
-
- public boolean isModal() {
- return this.modalityType != java.awt.Dialog.ModalityType.MODELESS;
- }
-
- public void setModal(boolean var1) {
- this.modal = var1;
- this.setModalityType(var1 ? DEFAULT_MODALITY_TYPE : java.awt.Dialog.ModalityType.MODELESS);
- }
-
- public ModalityType getModalityType() {
- return this.modalityType;
- }
-
- public void setModalityType(ModalityType var1) {
- if (var1 == null) {
- var1 = java.awt.Dialog.ModalityType.MODELESS;
- }
-
- if (this.modalityType != var1) {
- if (var1 == java.awt.Dialog.ModalityType.TOOLKIT_MODAL) {
- SecurityManager var2 = System.getSecurityManager();
- if (var2 != null) {
- var2.checkPermission(SecurityConstants.TOOLKIT_MODALITY_PERMISSION);
- }
- }
-
- this.modalityType = var1;
- this.modal = this.modalityType != java.awt.Dialog.ModalityType.MODELESS;
- }
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String var1) {
- String var2 = this.title;
- synchronized(this) {
- this.title = var1;
- DialogPeer var4 = (DialogPeer)this.peer;
- if (var4 != null) {
- var4.setTitle(var1);
- }
- }
-
- this.firePropertyChange("title", var2, var1);
- }
-
- private boolean conditionalShow(Component var1, AtomicLong var2) {
- boolean var3;
- synchronized(this.getTreeLock()) {
- if (this.peer == null) {
- this.addNotify();
- }
-
- this.validate();
- if (this.visible) {
- this.toFront();
- var3 = false;
- } else {
- var3 = true;
- this.visible = true;
- if (!this.isModal()) {
- checkShouldBeBlocked(this);
- } else {
- this.modalShow();
- }
-
- if (var1 != null && var2 != null && this.isFocusable() && this.isEnabled() && !this.isModalBlocked()) {
- var2.set(Toolkit.getEventQueue().getMostRecentEventTimeEx());
- KeyboardFocusManager.getCurrentKeyboardFocusManager().enqueueKeyEvents(var2.get(), var1);
- }
-
- this.peer.show();
- if (this.isModalBlocked()) {
- this.modalBlocker.toFront();
- }
-
- this.setLocationByPlatform(false);
-
- for(int var5 = 0; var5 < this.ownedWindowList.size(); ++var5) {
- Window var6 = (Window)((WeakReference)this.ownedWindowList.elementAt(var5)).get();
- if (var6 != null && var6.showWithParent) {
- var6.show();
- var6.showWithParent = false;
- }
- }
-
- Window.updateChildFocusableWindowState(this);
- this.createHierarchyEvents(1400, this, this.parent, 4L, Toolkit.enabledOnToolkit(32768L));
- if (this.componentListener != null || (this.eventMask & 1L) != 0L || Toolkit.enabledOnToolkit(1L)) {
- ComponentEvent var9 = new ComponentEvent(this, 102);
- Toolkit.getEventQueue().postEvent(var9);
- }
- }
- }
-
- if (var3 && (this.state & 1) == 0) {
- this.postWindowEvent(200);
- this.state |= 1;
- }
-
- return var3;
- }
-
- public void setVisible(boolean var1) {
- super.setVisible(var1);
- }
-
- /** @deprecated */
- @Deprecated
- public void show() {
- this.beforeFirstShow = false;
- if (!this.isModal()) {
- this.conditionalShow((Component)null, (AtomicLong)null);
- } else {
- this.keepBlocking = true;
- this.showAppContext = AppContext.getAppContext();
- AtomicLong var1 = new AtomicLong();
- Component var2 = null;
-
- try {
- var2 = this.getMostRecentFocusOwner();
- if (this.conditionalShow(var2, var1)) {
- this.modalFilter = ModalEventFilter.createFilterForDialog(this);
- 1 var3 = new 1(this);
- if (this.modalityType == java.awt.Dialog.ModalityType.TOOLKIT_MODAL) {
- for(AppContext var5 : AppContext.getAppContexts()) {
- if (var5 != this.showAppContext) {
- EventQueue var6 = (EventQueue)var5.get(AppContext.EVENT_QUEUE_KEY);
- 2 var7 = new 2(this);
- var6.postEvent(new InvocationEvent(this, var7));
- EventDispatchThread var8 = var6.getDispatchThread();
- var8.addEventFilter(this.modalFilter);
- }
- }
- }
-
- this.modalityPushed();
-
- try {
- if (EventQueue.isDispatchThread()) {
- SequencedEvent var24 = KeyboardFocusManager.getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
- if (var24 != null) {
- var24.dispose();
- }
-
- AccessController.doPrivileged(new 3(this, var3));
- } else {
- synchronized(this.getTreeLock()) {
- Toolkit.getEventQueue().postEvent(new PeerEvent(this, var3, 1L));
-
- while(this.keepBlocking && this.windowClosingException == null) {
- try {
- this.getTreeLock().wait();
- } catch (InterruptedException var20) {
- break;
- }
- }
- }
- }
- } finally {
- this.modalityPopped();
- }
-
- if (this.modalityType == java.awt.Dialog.ModalityType.TOOLKIT_MODAL) {
- for(AppContext var26 : AppContext.getAppContexts()) {
- if (var26 != this.showAppContext) {
- EventQueue var27 = (EventQueue)var26.get(AppContext.EVENT_QUEUE_KEY);
- EventDispatchThread var28 = var27.getDispatchThread();
- var28.removeEventFilter(this.modalFilter);
- }
- }
- }
-
- if (this.windowClosingException != null) {
- this.windowClosingException.fillInStackTrace();
- throw this.windowClosingException;
- }
- }
- } finally {
- if (var2 != null) {
- KeyboardFocusManager.getCurrentKeyboardFocusManager().dequeueKeyEvents(var1.get(), var2);
- }
-
- }
- }
-
- }
-
- final void modalityPushed() {
- Toolkit var1 = Toolkit.getDefaultToolkit();
- if (var1 instanceof SunToolkit) {
- SunToolkit var2 = (SunToolkit)var1;
- var2.notifyModalityPushed(this);
- }
-
- }
-
- final void modalityPopped() {
- Toolkit var1 = Toolkit.getDefaultToolkit();
- if (var1 instanceof SunToolkit) {
- SunToolkit var2 = (SunToolkit)var1;
- var2.notifyModalityPopped(this);
- }
-
- }
-
- void interruptBlocking() {
- if (this.isModal()) {
- this.disposeImpl();
- } else if (this.windowClosingException != null) {
- this.windowClosingException.fillInStackTrace();
- this.windowClosingException.printStackTrace();
- this.windowClosingException = null;
- }
-
- }
-
- private void hideAndDisposePreHandler() {
- this.isInHide = true;
- if (this.keepBlocking) {
- synchronized(this.getTreeLock()) {
- if (modalDialogs.contains(this)) {
- this.modalHide();
- if (this.modalFilter != null) {
- this.modalFilter.disable();
- }
- }
- }
- }
-
- }
-
- private void hideAndDisposeHandler() {
- if (this.keepBlocking) {
- synchronized(this.getTreeLock()) {
- this.keepBlocking = false;
- if (this.showAppContext != null) {
- SunToolkit.postEvent(this.showAppContext, new PeerEvent(this, new WakingRunnable(), 1L));
- this.showAppContext = null;
- }
-
- EventQueue.invokeLater(new WakingRunnable());
- this.getTreeLock().notifyAll();
- }
- }
-
- this.isInHide = false;
- }
-
- /** @deprecated */
- @Deprecated
- public void hide() {
- this.hideAndDisposePreHandler();
- super.hide();
- if (!this.isInDispose) {
- this.hideAndDisposeHandler();
- }
-
- }
-
- void doDispose() {
- this.isInDispose = true;
- super.doDispose();
- this.hideAndDisposeHandler();
- this.isInDispose = false;
- }
-
- public void toBack() {
- super.toBack();
- if (this.visible) {
- synchronized(this.getTreeLock()) {
- for(Window var3 : this.blockedWindows) {
- var3.toBack_NoClientCode();
- }
- }
- }
-
- }
-
- public boolean isResizable() {
- return this.resizable;
- }
-
- public void setResizable(boolean var1) {
- boolean var2 = false;
- synchronized(this) {
- this.resizable = var1;
- DialogPeer var4 = (DialogPeer)this.peer;
- if (var4 != null) {
- var4.setResizable(var1);
- var2 = true;
- }
- }
-
- if (var2 && this.valid) {
- this.invalidate();
- }
-
- }
-
- public void setUndecorated(boolean var1) {
- synchronized(this.getTreeLock()) {
- if (this.isDisplayable()) {
- throw new IllegalComponentStateException("The dialog is displayable.");
- } else {
- this.undecorated = var1;
- }
- }
- }
-
- public boolean isUndecorated() {
- return this.undecorated;
- }
-
- protected String paramString() {
- String var1 = super.paramString() + "," + this.modalityType;
- if (this.title != null) {
- var1 = var1 + ",title=" + this.title;
- }
-
- return var1;
- }
-
- private static native void initIDs();
-
- void modalShow() {
- modalDialogs.add(this);
- Vector var1 = new Vector();
-
- for(Dialog var3 : modalDialogs) {
- if (var3.shouldBlock(this)) {
- Object var4;
- for(var4 = var3; var4 != null && var4 != this; var4 = ((Window)var4).getOwner()) {
- }
-
- if (var4 == this || !this.shouldBlock(var3) || this.modalityType.compareTo(var3.getModalityType()) < 0) {
- var1.add(var3);
- }
- }
- }
-
- for(int var10 = 0; var10 < var1.size(); ++var10) {
- Dialog var12 = (Dialog)var1.get(var10);
- if (var12.isModalBlocked()) {
- Dialog var14 = var12.getModalBlocker();
- if (!var1.contains(var14)) {
- var1.add(var10 + 1, var14);
- }
- }
- }
-
- if (var1.size() > 0) {
- ((Dialog)var1.get(0)).blockWindow(this);
- }
-
- Vector var11 = new Vector(var1);
-
- for(int var13 = 0; var13 < var11.size(); ++var13) {
- Window var15 = (Window)var11.get(var13);
- Window[] var5 = var15.getOwnedWindows();
-
- for(Window var9 : var5) {
- var11.add(var9);
- }
- }
-
- for(Window var18 : Window.getAllUnblockedWindows()) {
- if (this.shouldBlock(var18) && !var11.contains(var18)) {
- if (var18 instanceof Dialog && ((Dialog)var18).isModal()) {
- Dialog var19 = (Dialog)var18;
- if (var19.shouldBlock(this) && modalDialogs.indexOf(var19) > modalDialogs.indexOf(this)) {
- continue;
- }
- }
-
- this.blockWindow(var18);
- }
- }
-
- if (!this.isModalBlocked()) {
- this.updateChildrenBlocking();
- }
-
- }
-
- void modalHide() {
- modalDialogs.remove(this);
- Vector var1 = new Vector();
- int var2 = this.blockedWindows.size();
-
- for(int var3 = 0; var3 < var2; ++var3) {
- Window var4 = (Window)this.blockedWindows.get(0);
- var1.add(var4);
- this.unblockWindow(var4);
- }
-
- for(int var6 = 0; var6 < var2; ++var6) {
- Window var7 = (Window)var1.get(var6);
- if (var7 instanceof Dialog && ((Dialog)var7).isModal()) {
- Dialog var5 = (Dialog)var7;
- var5.modalShow();
- } else {
- checkShouldBeBlocked(var7);
- }
- }
-
- }
-
- boolean shouldBlock(Window var1) {
- if (this.isVisible() && (var1.isVisible() || var1.isInShow) && !this.isInHide && var1 != this && this.isModal()) {
- if (var1 instanceof Dialog && ((Dialog)var1).isInHide) {
- return false;
- } else {
- for(Dialog var2 = this; var2 != null; var2 = ((Window)var2).getModalBlocker()) {
- Object var3;
- for(var3 = var1; var3 != null && var3 != var2; var3 = ((Component)var3).getParent_NoClientCode()) {
- }
-
- if (var3 == var2) {
- return false;
- }
- }
-
- switch (4.$SwitchMap$java$awt$Dialog$ModalityType[this.modalityType.ordinal()]) {
- case 1:
- return false;
- case 2:
- if (!var1.isModalExcluded(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE)) {
- return this.getDocumentRoot() == var1.getDocumentRoot();
- }
-
- Object var4;
- for(var4 = this; var4 != null && var4 != var1; var4 = ((Component)var4).getParent_NoClientCode()) {
- }
-
- return var4 == var1;
- case 3:
- return !var1.isModalExcluded(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE) && this.appContext == var1.appContext;
- case 4:
- return !var1.isModalExcluded(java.awt.Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
- default:
- return false;
- }
- }
- } else {
- return false;
- }
- }
-
- void blockWindow(Window var1) {
- if (!var1.isModalBlocked()) {
- var1.setModalBlocked(this, true);
- this.blockedWindows.add(var1);
- }
-
- }
-
- void unblockWindow(Window var1) {
- if (var1.isModalBlocked() && this.blockedWindows.contains(var1)) {
- this.blockedWindows.remove(var1);
- var1.setModalBlocked(this, false);
- }
-
- }
-
- static void checkShouldBeBlocked(Window var0) {
- synchronized(var0.getTreeLock()) {
- for(int var2 = 0; var2 < modalDialogs.size(); ++var2) {
- Dialog var3 = (Dialog)modalDialogs.get(var2);
- if (var3.shouldBlock(var0)) {
- var3.blockWindow(var0);
- break;
- }
- }
-
- }
- }
-
- private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException, HeadlessException {
- GraphicsEnvironment.checkHeadless();
- var1.defaultReadObject();
- if (this.modalityType == null) {
- this.setModal(this.modal);
- }
-
- this.blockedWindows = new Vector();
- }
-
- public AccessibleContext getAccessibleContext() {
- if (this.accessibleContext == null) {
- this.accessibleContext = new AccessibleAWTDialog(this);
- }
-
- return this.accessibleContext;
- }
-
- // $FF: synthetic method
- static boolean access$000(Dialog var0) {
- return var0.keepBlocking;
- }
-
- // $FF: synthetic method
- static ModalEventFilter access$100(Dialog var0) {
- return var0.modalFilter;
- }
-
- static {
- Toolkit.loadLibraries();
- if (!GraphicsEnvironment.isHeadless()) {
- initIDs();
- }
-
- DEFAULT_MODALITY_TYPE = java.awt.Dialog.ModalityType.APPLICATION_MODAL;
- DEFAULT_MODAL_EXCLUSION_TYPE = java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
- modalDialogs = new Vector();
- nameCounter = 0;
- }
- }
-