Skip to content

Commit 07aa0b9

Browse files
hansonrhansonr
authored andcommitted
disallowing tooltip for modal-blocked dialog
1 parent b5e7018 commit 07aa0b9

File tree

3 files changed

+92
-78
lines changed

3 files changed

+92
-78
lines changed

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,13 +1364,13 @@ boolean isModalBlocked() {
13641364
}
13651365

13661366
void setModalBlocked(JSDialog blocker, boolean blocked, boolean peerCall) {
1367-
// this.modalBlocker = blocked ? blocker : null;
1368-
// if (peerCall) {
1369-
// WindowPeer peer = (WindowPeer)this.peer;
1370-
// if (peer != null) {
1371-
// peer.setModalBlocked(blocker, blocked);
1372-
// }
1373-
// }
1367+
this.modalBlocker = blocked ? blocker : null;
1368+
if (peerCall) {
1369+
WindowPeer peer = (WindowPeer)this.peer;
1370+
if (peer != null) {
1371+
peer.setModalBlocked(blocker, blocked);
1372+
}
1373+
}
13741374
}
13751375

13761376
void setModalBlocked(Dialog blocker, boolean blocked, boolean peerCall) {

sources/net.sf.j2s.java.core/src/java/awt/peer/WindowPeer.java

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,52 +35,60 @@
3535
import java.awt.image.BufferedImage;
3636

3737
/**
38-
* The peer interfaces are intended only for use in porting
39-
* the AWT. They are not intended for use by application
40-
* developers, and developers should not implement peers
41-
* nor invoke any of the peer methods directly on the peer
38+
* The peer interfaces are intended only for use in porting the AWT. They are
39+
* not intended for use by application developers, and developers should not
40+
* implement peers nor invoke any of the peer methods directly on the peer
4241
* instances.
4342
*
4443
* Not a LightWeightPeer
4544
*
4645
*/
4746
public interface WindowPeer extends ContainerPeer {
48-
void toFront();
49-
void toBack();
50-
void updateAlwaysOnTopState();
51-
void updateFocusableWindowState();
52-
boolean requestWindowFocus();
53-
void setModalBlocked(Dialog blocker, boolean blocked);
54-
void updateMinimumSize();
55-
void updateIconImages();
56-
57-
/**
58-
* Sets the level of opacity for the window.
59-
*
60-
* @see Window#setOpacity(float)
61-
*/
62-
void setOpacity(float opacity);
63-
64-
/**
65-
* Enables the per-pixel alpha support for the window.
66-
*
67-
* @see Window#setBackground(Color)
68-
*/
69-
void setOpaque(boolean isOpaque);
70-
71-
/**
72-
* Updates the native part of non-opaque window using
73-
* the given image with color+alpha values for each pixel.
74-
*
75-
* @see Window#setBackground(Color)
76-
*/
77-
void updateWindow(BufferedImage backBuffer);
78-
79-
/**
80-
* Instructs the peer to update the position of the security warning.
81-
*/
82-
void repositionSecurityWarning();
83-
84-
WindowPeer setFrame(Window target, boolean b);
85-
47+
void toFront();
48+
49+
void toBack();
50+
51+
void updateAlwaysOnTopState();
52+
53+
void updateFocusableWindowState();
54+
55+
boolean requestWindowFocus();
56+
57+
void setModalBlocked(Dialog blocker, boolean blocked);
58+
59+
void setModalBlocked(JSDialog blocker, boolean blocked);
60+
61+
void updateMinimumSize();
62+
63+
void updateIconImages();
64+
65+
/**
66+
* Sets the level of opacity for the window.
67+
*
68+
* @see Window#setOpacity(float)
69+
*/
70+
void setOpacity(float opacity);
71+
72+
/**
73+
* Enables the per-pixel alpha support for the window.
74+
*
75+
* @see Window#setBackground(Color)
76+
*/
77+
void setOpaque(boolean isOpaque);
78+
79+
/**
80+
* Updates the native part of non-opaque window using the given image with
81+
* color+alpha values for each pixel.
82+
*
83+
* @see Window#setBackground(Color)
84+
*/
85+
void updateWindow(BufferedImage backBuffer);
86+
87+
/**
88+
* Instructs the peer to update the position of the security warning.
89+
*/
90+
void repositionSecurityWarning();
91+
92+
WindowPeer setFrame(Window target, boolean b);
93+
8694
}

sources/net.sf.j2s.java.core/src/javax/swing/ToolTipManager.java

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
100100

101101
private FocusListener focusChangeListener = null;
102102
private MouseMotionListener moveBeforeEnterListener = null;
103-
private KeyListener accessibilityKeyListener = null;
103+
// private KeyListener accessibilityKeyListener = null;
104104

105105
// PENDING(ges)
106106
protected boolean lightWeightPopupEnabled = false; // BH 2018 true;
@@ -155,7 +155,7 @@ public void actionPerformed(ActionEvent e) {
155155
insideTimer.setRepeats(false);
156156

157157
moveBeforeEnterListener = new MoveBeforeEnterListener();
158-
accessibilityKeyListener = new AccessibilityKeyListener();
158+
// accessibilityKeyListener = new AccessibilityKeyListener();
159159
}
160160

161161
/**
@@ -274,7 +274,13 @@ public int getReshowDelay() {
274274
void showTipWindow() {
275275
if (insideComponent == null || !insideComponent.isShowing())
276276
return;
277+
Component win = insideComponent.getTopLevelAncestor();
278+
if (win instanceof Window) {
279+
if (((Window) win).getModalBlocker() != null)
280+
return;
281+
}
277282

283+
278284
// System.out.println("TTM showTipWindow1");
279285

280286
// String mode = UIManager.getString("ToolTipManager.enableToolTipMode");
@@ -432,8 +438,8 @@ public void registerComponent(JComponent component) {
432438
component.addMouseListener(this);
433439
component.removeMouseMotionListener(moveBeforeEnterListener);
434440
component.addMouseMotionListener(moveBeforeEnterListener);
435-
component.removeKeyListener(accessibilityKeyListener);
436-
component.addKeyListener(accessibilityKeyListener);
441+
// component.removeKeyListener(accessibilityKeyListener);
442+
// component.addKeyListener(accessibilityKeyListener);
437443
}
438444

439445
/**
@@ -444,7 +450,7 @@ public void registerComponent(JComponent component) {
444450
public void unregisterComponent(JComponent component) {
445451
component.removeMouseListener(this);
446452
component.removeMouseMotionListener(moveBeforeEnterListener);
447-
component.removeKeyListener(accessibilityKeyListener);
453+
// component.removeKeyListener(accessibilityKeyListener);
448454
}
449455

450456
// implements java.awt.event.MouseListener
@@ -823,28 +829,28 @@ private void hide(JComponent source) {
823829
insideComponent = null;
824830
}
825831

826-
/*
827-
* This listener is registered when the tooltip is first registered on a
828-
* component in order to process accessibility keybindings. This will apply
829-
* globally across L&F
830-
*
831-
* Post Tip: Ctrl+F1 Unpost Tip: Esc and Ctrl+F1
832-
*/
833-
private class AccessibilityKeyListener extends KeyAdapter {
834-
public void keyPressed(KeyEvent e) {
835-
if (!e.isConsumed()) {
836-
JComponent source = (JComponent) e.getComponent();
837-
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
838-
if (tipWindow != null) {
839-
hide(source);
840-
e.consume();
841-
}
842-
} else if (e.getKeyCode() == KeyEvent.VK_F1 && e.getModifiers() == Event.CTRL_MASK) {
843-
// Shown tooltip will be hidden
844-
ToolTipManager.this.show(source);
845-
e.consume();
846-
}
847-
}
848-
}
849-
}
832+
// /*
833+
// * This listener is registered when the tooltip is first registered on a
834+
// * component in order to process accessibility keybindings. This will apply
835+
// * globally across L&F
836+
// *
837+
// * Post Tip: Ctrl+F1 Unpost Tip: Esc and Ctrl+F1
838+
// */
839+
// private class AccessibilityKeyListener extends KeyAdapter {
840+
// public void keyPressed(KeyEvent e) {
841+
// if (!e.isConsumed()) {
842+
// JComponent source = (JComponent) e.getComponent();
843+
// if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
844+
// if (tipWindow != null) {
845+
// hide(source);
846+
// e.consume();
847+
// }
848+
// } else if (e.getKeyCode() == KeyEvent.VK_F1 && e.getModifiers() == Event.CTRL_MASK) {
849+
// // Shown tooltip will be hidden
850+
// ToolTipManager.this.show(source);
851+
// e.consume();
852+
// }
853+
// }
854+
// }
855+
// }
850856
}

0 commit comments

Comments
 (0)