From 282e8719f2b9c5b32392a75c356c6484efcd9b7e Mon Sep 17 00:00:00 2001 From: malenkov Date: Tue, 27 Aug 2013 13:37:38 +0400 Subject: 8022398: javax/swing/JFileChooser/8013442/Test8013442.java fails Reviewed-by: alexsch --- .../classes/com/apple/laf/AquaFileChooserUI.java | 62 ++-------------------- 1 file changed, 4 insertions(+), 58 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java index b7598f99d..be4b5b72a 100644 --- a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -42,6 +42,7 @@ import javax.swing.filechooser.*; import javax.swing.plaf.*; import javax.swing.table.*; +import sun.swing.AbstractFilterComboBoxModel; import sun.swing.SwingUtilities2; public class AquaFileChooserUI extends FileChooserUI { @@ -1266,64 +1267,9 @@ public class AquaFileChooserUI extends FileChooserUI { /** * Data model for a type-face selection combo-box. */ - protected class FilterComboBoxModel extends DefaultListModel implements ComboBoxModel, PropertyChangeListener { - int selectedIndex = -1; - - protected FilterComboBoxModel() { - super(); - final FileFilter filters[] = getFileChooser().getChoosableFileFilters(); - for (int i = 0; i < filters.length; i++) { - this.add(i, filters[i]); - } - } - - public void propertyChange(final PropertyChangeEvent e) { - final String prop = e.getPropertyName(); - if (prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { - this.clear(); - final FileFilter filters[] = (FileFilter[])e.getNewValue(); - - for (int i = 0; i < filters.length; i++) { - this.add(i, filters[i]); - } - - fireContentsChanged(this, -1, -1); - } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { - final FileFilter currentFilter = (FileFilter)e.getNewValue(); - FileFilter filters[] = getFileChooser().getChoosableFileFilters(); - - boolean found = false; - if (currentFilter != null) { - for (final FileFilter element : filters) { - if (element == currentFilter) { - found = true; - } - } - if (found == false) { - getFileChooser().addChoosableFileFilter(currentFilter); - } - } - - filters = getFileChooser().getChoosableFileFilters(); - setSelectedItem(e.getNewValue()); - } - } - - public void setSelectedItem(final Object filter) { - if (filter != null) { - selectedIndex = this.indexOf(filter); - fireContentsChanged(this, -1, -1); - } - } - - public Object getSelectedItem() { - final Object returnValue = null; - - if (this.size() > 0) { - if ((selectedIndex != -1) && (selectedIndex < size())) { return this.get(selectedIndex); } - } - - return returnValue; + protected class FilterComboBoxModel extends AbstractFilterComboBoxModel { + protected JFileChooser getFileChooser() { + return AquaFileChooserUI.this.getFileChooser(); } } -- cgit v1.2.3 From 1cdc6e41a161a16b1e0d39143d1bdf0bbd2f5cb0 Mon Sep 17 00:00:00 2001 From: alanb Date: Wed, 4 Sep 2013 11:40:23 +0100 Subject: 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess Reviewed-by: anthony, art, mchung --- src/macosx/classes/sun/lwawt/LWToolkit.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWToolkit.java b/src/macosx/classes/sun/lwawt/LWToolkit.java index fb7032f0b..9765066d9 100644 --- a/src/macosx/classes/sun/lwawt/LWToolkit.java +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java @@ -38,6 +38,7 @@ import java.util.*; import sun.awt.*; import sun.lwawt.macosx.*; import sun.print.*; +import sun.security.util.SecurityConstants; public abstract class LWToolkit extends SunToolkit implements Runnable { @@ -502,7 +503,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { public Clipboard getSystemClipboard() { SecurityManager security = System.getSecurityManager(); if (security != null) { - security.checkSystemClipboardAccess(); + security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION); } synchronized (this) { -- cgit v1.2.3 From 699cc1f9147358bf922973454a34113427a6f25a Mon Sep 17 00:00:00 2001 From: alexsch Date: Tue, 3 Sep 2013 17:27:20 +0400 Subject: 8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date Reviewed-by: leonidr --- src/macosx/classes/sun/lwawt/LWComponentPeer.java | 2 ++ src/macosx/classes/sun/lwawt/LWWindowPeer.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/src/macosx/classes/sun/lwawt/LWComponentPeer.java index 05d1d5d1f..5b081b1f2 100644 --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -1254,6 +1254,8 @@ public abstract class LWComponentPeer KeyEvent ke = (KeyEvent) e; delegateEvent = new KeyEvent(getDelegateFocusOwner(), ke.getID(), ke.getWhen(), ke.getModifiers(), ke.getKeyCode(), ke.getKeyChar(), ke.getKeyLocation()); + AWTAccessor.getKeyEventAccessor().setExtendedKeyCode((KeyEvent) delegateEvent, + ke.getExtendedKeyCode()); } else if (e instanceof FocusEvent) { FocusEvent fe = (FocusEvent) e; delegateEvent = new FocusEvent(getDelegateFocusOwner(), fe.getID(), fe.isTemporary()); diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java index 2be41cf3b..600001630 100644 --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -933,7 +933,12 @@ public class LWWindowPeer focusOwner = this.getTarget(); } } - postEvent(new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation)); + + KeyEvent keyEvent = new KeyEvent(focusOwner, id, when, modifiers, + keyCode, keyChar, keyLocation); + AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent, + ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar)); + postEvent(keyEvent); } // ---- UTILITY METHODS ---- // -- cgit v1.2.3 From 58bd100d5bfdad0541d9ac167d39a479d7ea86d9 Mon Sep 17 00:00:00 2001 From: serb Date: Thu, 12 Sep 2013 18:21:06 +0400 Subject: 7124537: [macosx] Menu shortcuts for all menu items should be disabled if a menu itself is disabled Reviewed-by: anthony, leonidr --- src/macosx/classes/sun/lwawt/macosx/CMenu.java | 16 ++++++++++++++++ src/macosx/classes/sun/lwawt/macosx/CMenuItem.java | 17 +++++++++++++++-- src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java | 6 +++--- 3 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/macosx/CMenu.java b/src/macosx/classes/sun/lwawt/macosx/CMenu.java index 56a706132..cad1b36aa 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CMenu.java +++ b/src/macosx/classes/sun/lwawt/macosx/CMenu.java @@ -26,9 +26,11 @@ package sun.lwawt.macosx; import java.awt.*; +import java.awt.peer.MenuItemPeer; import java.awt.peer.MenuPeer; public class CMenu extends CMenuItem implements MenuPeer { + public CMenu(Menu target) { super(target); } @@ -40,6 +42,20 @@ public class CMenu extends CMenuItem implements MenuPeer { setEnabled(target.isEnabled()); } + @Override + public final void setEnabled(final boolean b) { + super.setEnabled(b); + final Menu target = (Menu) getTarget(); + final int count = target.getItemCount(); + for (int i = 0; i < count; ++i) { + MenuItem item = target.getItem(i); + MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); + if (p != null) { + p.setEnabled(b && item.isEnabled()); + } + } + } + @Override protected long createModel() { CMenuComponent parent = (CMenuComponent) diff --git a/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java b/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java index ac3bea392..b1492bd0a 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java +++ b/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java @@ -28,17 +28,20 @@ package sun.lwawt.macosx; import sun.awt.SunToolkit; import sun.lwawt.LWToolkit; +import java.awt.MenuContainer; import java.awt.MenuItem; import java.awt.MenuShortcut; import java.awt.event.*; import java.awt.peer.MenuItemPeer; +import java.util.concurrent.atomic.AtomicBoolean; public class CMenuItem extends CMenuComponent implements MenuItemPeer { + private final AtomicBoolean enabled = new AtomicBoolean(true); + public CMenuItem(MenuItem target) { super(target); initialize(target); - } // This way we avoiding invocation of the setters twice @@ -124,9 +127,19 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { setEnabled(false); } + public final boolean isEnabled() { + return enabled.get(); + } + @Override public void setEnabled(boolean b) { - nativeSetEnabled(getModel(), b); + final Object parent = LWToolkit.targetToPeer(getTarget().getParent()); + if (parent instanceof CMenuItem) { + b &= ((CMenuItem) parent).isEnabled(); + } + if (enabled.compareAndSet(!b, b)) { + nativeSetEnabled(getModel(), b); + } } private native long nativeCreate(long parentMenu, boolean isSeparator); diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 943dbe2fe..e028df560 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -207,9 +207,9 @@ public final class LWCToolkit extends LWToolkit { @Override public MenuBarPeer createMenuBar(MenuBar target) { - MenuBarPeer peer = new CMenuBar(target); - targetCreatedPeer(target, peer); - return peer; + MenuBarPeer peer = new CMenuBar(target); + targetCreatedPeer(target, peer); + return peer; } @Override -- cgit v1.2.3 From 0355355124dbba3648a09423750dc9807719e164 Mon Sep 17 00:00:00 2001 From: pchelko Date: Fri, 13 Sep 2013 11:58:39 +0400 Subject: 8024170: [SwingNode] Implement cursor change Reviewed-by: anthony, ant --- src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java b/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java index 90e2e88c4..624be6bfc 100644 --- a/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java +++ b/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java @@ -34,6 +34,8 @@ import java.awt.dnd.DropTarget; import sun.awt.CausedFocusEvent; import sun.awt.LightweightFrame; +import sun.swing.JLightweightFrame; +import sun.swing.SwingAccessor; public class LWLightweightFramePeer extends LWWindowPeer { @@ -90,11 +92,6 @@ public class LWLightweightFramePeer extends LWWindowPeer { setBounds(x, y, w, h, op, true, false); } - @Override - public void updateCursorImmediately() { - // TODO: tries to switch to the awt/fx toolkit thread and causes a deadlock on macosx - } - @Override public void addDropTarget(DropTarget dt) { } @@ -112,4 +109,9 @@ public class LWLightweightFramePeer extends LWWindowPeer { public void ungrab() { getLwTarget().ungrabFocus(); } + + @Override + public void updateCursorImmediately() { + SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); + } } -- cgit v1.2.3 From 846ea717bfbf4f3f6117a787a8b2e6d83460c4a4 Mon Sep 17 00:00:00 2001 From: pchelko Date: Fri, 13 Sep 2013 18:02:18 +0400 Subject: 8012026: [macosx] Component.getMousePosition() does not work in an applet on MacOS Reviewed-by: anthony, serb --- .../classes/sun/lwawt/macosx/CMouseInfoPeer.java | 45 ---------------------- .../classes/sun/lwawt/macosx/LWCToolkit.java | 5 --- 2 files changed, 50 deletions(-) delete mode 100644 src/macosx/classes/sun/lwawt/macosx/CMouseInfoPeer.java (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/macosx/CMouseInfoPeer.java b/src/macosx/classes/sun/lwawt/macosx/CMouseInfoPeer.java deleted file mode 100644 index 8ee580108..000000000 --- a/src/macosx/classes/sun/lwawt/macosx/CMouseInfoPeer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.lwawt.macosx; - -import java.awt.Window; -import sun.lwawt.LWMouseInfoPeer; -import sun.lwawt.LWWindowPeer; - -public class CMouseInfoPeer extends LWMouseInfoPeer -{ - //If a new window is to appear under the cursor, - //we get wrong window. - //This is a workaround for macosx. - @Override - public boolean isWindowUnderMouse(Window w) { - if (w == null) { - return false; - } - - return ((LWWindowPeer)w.getPeer()).getPlatformWindow().isUnderMouse(); - } -} diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index e028df560..cf395f3ab 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -302,11 +302,6 @@ public final class LWCToolkit extends LWToolkit { return new OSXPlatformFont(name, style); } - @Override - protected MouseInfoPeer createMouseInfoPeerImpl() { - return new CMouseInfoPeer(); - } - @Override protected int getScreenHeight() { return GraphicsEnvironment.getLocalGraphicsEnvironment() -- cgit v1.2.3 From 78cc330a76dc94ce5936066d853b27e91a599355 Mon Sep 17 00:00:00 2001 From: alexsch Date: Mon, 16 Sep 2013 17:45:07 +0400 Subject: 8008728: [macosx] Swing. JDialog. Modal dialog goes to background Reviewed-by: serb --- src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index d38946d43..b85942002 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -820,6 +820,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo } nativeSetEnabled(getNSWindowPtr(), !blocked); + checkBlockingAndOrder(); } public final void invalidateShadow(){ @@ -984,7 +985,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once } - private boolean checkBlocking() { + private boolean checkBlockingAndOrder() { LWWindowPeer blocker = (peer == null)? null : peer.getBlocker(); if (blocker == null) { return false; @@ -1040,7 +1041,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private void windowDidBecomeMain() { assert CThreading.assertAppKit(); - if (checkBlocking()) return; + if (checkBlockingAndOrder()) return; // If it's not blocked, make sure it's above its siblings orderAboveSiblings(); } -- cgit v1.2.3 From 560acc4f6e7480f38749d35c375bdd1fbb0b321c Mon Sep 17 00:00:00 2001 From: leonidr Date: Thu, 19 Sep 2013 22:33:21 +0400 Subject: 7144065: [macosx] Orphaned Choice popup window Reviewed-by: anthony, serb Contributed-by: alexander.potochkin@oracle.com --- src/macosx/classes/sun/lwawt/LWChoicePeer.java | 35 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWChoicePeer.java b/src/macosx/classes/sun/lwawt/LWChoicePeer.java index dc781d3d6..c90300e8d 100644 --- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java +++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,13 +26,13 @@ package sun.lwawt; -import java.awt.Choice; -import java.awt.Point; +import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.peer.ChoicePeer; -import javax.swing.JComboBox; +import javax.accessibility.Accessible; +import javax.swing.*; final class LWChoicePeer extends LWComponentPeer> implements ChoicePeer, ItemListener { @@ -159,5 +159,32 @@ final class LWChoicePeer extends LWComponentPeer> } super.setSelectedItem(anObject); } + + @Override + public void firePopupMenuWillBecomeVisible() { + super.firePopupMenuWillBecomeVisible(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JPopupMenu popupMenu = getPopupMenu(); + if (popupMenu != null) { + if (popupMenu.getInvoker() != LWChoicePeer.this.getTarget()) { + popupMenu.setVisible(false); + popupMenu.show(LWChoicePeer.this.getTarget(), 0, 0); + } + } + } + }); + } + + private JPopupMenu getPopupMenu() { + for (int i = 0; i < getAccessibleContext().getAccessibleChildrenCount(); i++) { + Accessible child = getAccessibleContext().getAccessibleChild(i); + if (child instanceof JPopupMenu) { + return (JPopupMenu) child; + } + } + return null; + } } } -- cgit v1.2.3 From 5ddc89c8827c5580d3b44b86651833e52b26e78a Mon Sep 17 00:00:00 2001 From: leonidr Date: Thu, 19 Sep 2013 23:46:15 +0400 Subject: 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol Reviewed-by: anthony, serb --- .../classes/sun/awt/resources/awtosx.properties | 71 ++++++++++++++++++++++ .../classes/sun/lwawt/macosx/LWCToolkit.java | 23 ++++++- 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/macosx/classes/sun/awt/resources/awtosx.properties (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/awt/resources/awtosx.properties b/src/macosx/classes/sun/awt/resources/awtosx.properties new file mode 100644 index 000000000..bfc3bd01b --- /dev/null +++ b/src/macosx/classes/sun/awt/resources/awtosx.properties @@ -0,0 +1,71 @@ +# +# OS X specific AWT properties +# + +# Modifier names +AWT.shift=\u21e7 +AWT.control=\u2303 +AWT.alt=\u2325 +AWT.meta=\u2318 +AWT.altGraph=\u2325 + +# Key names +AWT.enter=\u23ce +AWT.backSpace=\u232b +AWT.tab=\u21e5 +AWT.cancel=\u238b +AWT.clear=\u2327 +AWT.capsLock=\u21ea +AWT.escape=\u238b +AWT.space=\u2423 +AWT.pgup=\u21de +AWT.pgdn=\u21df +AWT.end=\u2198 +AWT.home=\u2196 +AWT.left=\u2190 +AWT.up=\u2191 +AWT.right=\u2192 +AWT.down=\u2193 +AWT.comma=, +AWT.period=. +AWT.slash=/ +AWT.semicolon=; +AWT.equals=\u003d +AWT.openBracket=[ +AWT.backSlash=\\ +AWT.closeBracket=] +AWT.multiply=\u2328 * +AWT.add=\u2328 + +AWT.separator=\u2328 , +AWT.separater=\u2328 , +AWT.subtract=\u2328 - +AWT.decimal=\u2328 . +AWT.divide=\u2328 / +AWT.delete=\u2326 +AWT.printScreen=\u2399 +AWT.backQuote=` +AWT.quote=' +AWT.ampersand=& +AWT.asterisk=* +AWT.quoteDbl=" +AWT.Less=< +AWT.greater=> +AWT.braceLeft=[ +AWT.braceRight=] +AWT.at=@ +AWT.colon=: +AWT.circumflex=^ +AWT.dollar=$ +AWT.euro=\u20ac +AWT.exclamationMark=! +AWT.invertedExclamationMark=\u00a1 +AWT.leftParenthesis=( +AWT.numberSign=# +AWT.plus=+ +AWT.minus=- +AWT.rightParenthesis=) +AWT.underscore=_ + +# Numeric Keypad +AWT.numpad=\u2328 + diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index cf395f3ab..d698845e5 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -44,6 +44,8 @@ import sun.lwawt.*; import sun.lwawt.LWWindowPeer.PeerType; import sun.security.action.GetBooleanAction; +import sun.util.CoreResourceBundleControl; + class NamedCursor extends Cursor { NamedCursor(String name) { super(name); @@ -67,13 +69,28 @@ public final class LWCToolkit extends LWToolkit { static { System.err.flush(); - java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { - public Object run() { + + ResourceBundle platformResources = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public ResourceBundle run() { + ResourceBundle platformResources = null; + try { + platformResources = + ResourceBundle.getBundle("sun.awt.resources.awtosx", + CoreResourceBundleControl.getRBControlInstance()); + } catch (MissingResourceException e) { + // No resource file; defaults will be used. + } + System.loadLibrary("awt"); System.loadLibrary("fontmanager"); - return null; + + return platformResources; } }); + + AWTAccessor.getToolkitAccessor().setPlatformResources(platformResources); + if (!GraphicsEnvironment.isHeadless()) { initIDs(); } -- cgit v1.2.3 From cecdb70d3ebda41391ce603be7080fcc33651442 Mon Sep 17 00:00:00 2001 From: serb Date: Mon, 23 Sep 2013 16:17:26 +0400 Subject: 8005255: [macosx] Cleanup warnings in sun.lwawt Reviewed-by: alexsch, anthony --- src/macosx/classes/sun/lwawt/LWButtonPeer.java | 9 ++- src/macosx/classes/sun/lwawt/LWCanvasPeer.java | 6 +- src/macosx/classes/sun/lwawt/LWCheckboxPeer.java | 12 ++- src/macosx/classes/sun/lwawt/LWChoicePeer.java | 7 +- src/macosx/classes/sun/lwawt/LWComponentPeer.java | 90 +++++++++++++--------- src/macosx/classes/sun/lwawt/LWContainerPeer.java | 89 +++++++++++---------- src/macosx/classes/sun/lwawt/LWCursorManager.java | 6 +- src/macosx/classes/sun/lwawt/LWLabelPeer.java | 4 +- src/macosx/classes/sun/lwawt/LWListPeer.java | 16 ++-- src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java | 9 +-- src/macosx/classes/sun/lwawt/LWPanelPeer.java | 8 +- src/macosx/classes/sun/lwawt/LWRepaintArea.java | 25 +++--- src/macosx/classes/sun/lwawt/LWScrollBarPeer.java | 8 +- src/macosx/classes/sun/lwawt/LWScrollPanePeer.java | 20 +++-- src/macosx/classes/sun/lwawt/LWTextAreaPeer.java | 13 ++-- .../classes/sun/lwawt/LWTextComponentPeer.java | 11 ++- src/macosx/classes/sun/lwawt/LWTextFieldPeer.java | 11 ++- src/macosx/classes/sun/lwawt/LWToolkit.java | 14 ++-- src/macosx/classes/sun/lwawt/LWWindowPeer.java | 41 ++++++---- .../classes/sun/lwawt/SelectionClearListener.java | 34 -------- 20 files changed, 233 insertions(+), 200 deletions(-) delete mode 100644 src/macosx/classes/sun/lwawt/SelectionClearListener.java (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWButtonPeer.java b/src/macosx/classes/sun/lwawt/LWButtonPeer.java index e5f8838c8..f4b46c763 100644 --- a/src/macosx/classes/sun/lwawt/LWButtonPeer.java +++ b/src/macosx/classes/sun/lwawt/LWButtonPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,10 @@ import java.awt.peer.ButtonPeer; import javax.swing.JButton; +/** + * Lightweight implementation of {@link ButtonPeer}. Delegates most of the work + * to the {@link JButton}. + */ final class LWButtonPeer extends LWComponentPeer implements ButtonPeer, ActionListener { @@ -42,7 +46,7 @@ final class LWButtonPeer extends LWComponentPeer } @Override - protected JButton createDelegate() { + JButton createDelegate() { return new JButtonDelegate(); } @@ -74,6 +78,7 @@ final class LWButtonPeer extends LWComponentPeer return true; } + @SuppressWarnings("serial")// Safe: outer class is non-serializable. private final class JButtonDelegate extends JButton { // Empty non private constructor was added because access to this diff --git a/src/macosx/classes/sun/lwawt/LWCanvasPeer.java b/src/macosx/classes/sun/lwawt/LWCanvasPeer.java index 0c80ff0af..c7559c216 100644 --- a/src/macosx/classes/sun/lwawt/LWCanvasPeer.java +++ b/src/macosx/classes/sun/lwawt/LWCanvasPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,10 @@ import java.awt.peer.CanvasPeer; import javax.swing.JComponent; +/** + * Lightweight implementation of {@link CanvasPeer}. This peer is empty, because + * all the components in lwawt use graphic object from the top level window. + */ class LWCanvasPeer extends LWComponentPeer implements CanvasPeer { diff --git a/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java b/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java index de1c378b8..c3b91a2fa 100644 --- a/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java +++ b/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,11 @@ import javax.swing.JRadioButton; import javax.swing.JToggleButton; import javax.swing.SwingUtilities; +/** + * Lightweight implementation of {@link CheckboxPeer}. Delegates most of the + * work to the {@link JCheckBox} and {@link JRadioButton}, which are placed + * inside an empty {@link JComponent}. + */ final class LWCheckboxPeer extends LWComponentPeer implements CheckboxPeer, ItemListener { @@ -51,12 +56,12 @@ final class LWCheckboxPeer } @Override - protected CheckboxDelegate createDelegate() { + CheckboxDelegate createDelegate() { return new CheckboxDelegate(); } @Override - protected Component getDelegateFocusOwner() { + Component getDelegateFocusOwner() { return getDelegate().getCurrentButton(); } @@ -137,6 +142,7 @@ final class LWCheckboxPeer return true; } + @SuppressWarnings("serial")// Safe: outer class is non-serializable. final class CheckboxDelegate extends JComponent { private final JCheckBox cb; diff --git a/src/macosx/classes/sun/lwawt/LWChoicePeer.java b/src/macosx/classes/sun/lwawt/LWChoicePeer.java index c90300e8d..5b78e74b6 100644 --- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java +++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java @@ -34,6 +34,10 @@ import java.awt.peer.ChoicePeer; import javax.accessibility.Accessible; import javax.swing.*; +/** + * Lightweight implementation of {@link ChoicePeer}. Delegates most of the work + * to the {@link JComboBox}. + */ final class LWChoicePeer extends LWComponentPeer> implements ChoicePeer, ItemListener { @@ -50,7 +54,7 @@ final class LWChoicePeer extends LWComponentPeer> } @Override - protected JComboBox createDelegate() { + JComboBox createDelegate() { return new JComboBoxDelegate(); } @@ -128,6 +132,7 @@ final class LWChoicePeer extends LWComponentPeer> return true; } + @SuppressWarnings("serial")// Safe: outer class is non-serializable. private final class JComboBoxDelegate extends JComboBox { // Empty non private constructor was added because access to this diff --git a/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/src/macosx/classes/sun/lwawt/LWComponentPeer.java index 5b081b1f2..f6adcda7f 100644 --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,19 +72,23 @@ public abstract class LWComponentPeer { private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWComponentPeer"); - // State lock is to be used for modifications to this - // peer's fields (e.g. bounds, background, font, etc.) - // It should be the last lock in the lock chain - private final Object stateLock = - new StringBuilder("LWComponentPeer.stateLock"); + /** + * State lock is to be used for modifications to this peer's fields (e.g. + * bounds, background, font, etc.) It should be the last lock in the lock + * chain + */ + private final Object stateLock = new Object(); - // The lock to operate with the peers hierarchy. AWT tree - // lock is not used as there are many peers related ops - // to be done on the toolkit thread, and we don't want to - // depend on a public lock on this thread - private static final Object peerTreeLock = - new StringBuilder("LWComponentPeer.peerTreeLock"); + /** + * The lock to operate with the peers hierarchy. AWT tree lock is not used + * as there are many peers related ops to be done on the toolkit thread, and + * we don't want to depend on a public lock on this thread + */ + private static final Object peerTreeLock = new Object(); + /** + * The associated AWT object. + */ private final T target; /** @@ -95,7 +99,7 @@ public abstract class LWComponentPeer * the hierarchy. The exception is LWWindowPeers: their containers are * always null */ - private final LWContainerPeer containerPeer; + private final LWContainerPeer containerPeer; /** * Handy reference to the top-level window peer. Window peer is borrowed @@ -147,11 +151,18 @@ public abstract class LWComponentPeer */ private Image backBuffer; + /** + * All Swing delegates use delegateContainer as a parent. This container + * intentionally do not use parent of the peer. + */ + @SuppressWarnings("serial")// Safe: outer class is non-serializable. private final class DelegateContainer extends Container { { enableEvents(0xFFFFFFFF); } + // Empty non private constructor was added because access to this + // class shouldn't be emulated by a synthetic accessor method. DelegateContainer() { super(); } @@ -182,7 +193,7 @@ public abstract class LWComponentPeer } } - public LWComponentPeer(T target, PlatformComponent platformComponent) { + LWComponentPeer(final T target, final PlatformComponent platformComponent) { targetPaintArea = new LWRepaintArea(); this.target = target; this.platformComponent = platformComponent; @@ -276,15 +287,18 @@ public abstract class LWComponentPeer * This method is called under getDelegateLock(). * Overridden in subclasses. */ - protected D createDelegate() { + D createDelegate() { return null; } - protected final D getDelegate() { + final D getDelegate() { return delegate; } - protected Component getDelegateFocusOwner() { + /** + * This method should be called under getDelegateLock(). + */ + Component getDelegateFocusOwner() { return getDelegate(); } @@ -356,7 +370,7 @@ public abstract class LWComponentPeer } // Just a helper method - protected final LWContainerPeer getContainerPeer() { + protected final LWContainerPeer getContainerPeer() { return containerPeer; } @@ -390,7 +404,7 @@ public abstract class LWComponentPeer protected void disposeImpl() { destroyBuffers(); - LWContainerPeer cp = getContainerPeer(); + LWContainerPeer cp = getContainerPeer(); if (cp != null) { cp.removeChildPeer(this); } @@ -462,12 +476,13 @@ public abstract class LWComponentPeer sg2d.constrain(size.x, size.y, size.width, size.height, getVisibleRegion()); } - public Region getVisibleRegion() { + Region getVisibleRegion() { return computeVisibleRect(this, getRegion()); } - static final Region computeVisibleRect(LWComponentPeer c, Region region) { - final LWContainerPeer p = c.getContainerPeer(); + static final Region computeVisibleRect(final LWComponentPeer c, + Region region) { + final LWContainerPeer p = c.getContainerPeer(); if (p != null) { final Rectangle r = c.getBounds(); region = region.getTranslatedRegion(r.x, r.y); @@ -612,7 +627,7 @@ public abstract class LWComponentPeer * @param p Point relative to the peer. * @return Cursor of the peer or null if default cursor should be used. */ - protected Cursor getCursor(final Point p) { + Cursor getCursor(final Point p) { return getTarget().getCursor(); } @@ -717,7 +732,7 @@ public abstract class LWComponentPeer @Override public void setEnabled(final boolean e) { boolean status = e; - final LWComponentPeer cp = getContainerPeer(); + final LWComponentPeer cp = getContainerPeer(); if (cp != null) { status &= cp.isEnabled(); } @@ -802,12 +817,12 @@ public abstract class LWComponentPeer } @Override - public void setZOrder(ComponentPeer above) { - LWContainerPeer cp = getContainerPeer(); + public void setZOrder(final ComponentPeer above) { + LWContainerPeer cp = getContainerPeer(); // Don't check containerPeer for null as it can only happen // for windows, but this method is overridden in // LWWindowPeer and doesn't call super() - cp.setChildPeerZOrder(this, (LWComponentPeer) above); + cp.setChildPeerZOrder(this, (LWComponentPeer) above); } @Override @@ -923,7 +938,9 @@ public abstract class LWComponentPeer LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget()); return false; } - LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer(); + final LWWindowPeer parentPeer = + (LWWindowPeer) AWTAccessor.getComponentAccessor() + .getPeer(parentWindow); if (parentPeer == null) { focusLog.fine("request rejected, parentPeer is null"); LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget()); @@ -1138,7 +1155,7 @@ public abstract class LWComponentPeer } protected final void repaintParent(final Rectangle oldB) { - final LWContainerPeer cp = getContainerPeer(); + final LWContainerPeer cp = getContainerPeer(); if (cp != null) { // Repaint unobscured part of the parent cp.repaintPeer(cp.getContentSize().intersection(oldB)); @@ -1275,7 +1292,7 @@ public abstract class LWComponentPeer /** * Handler for FocusEvents. */ - protected void handleJavaFocusEvent(FocusEvent e) { + void handleJavaFocusEvent(final FocusEvent e) { // Note that the peer receives all the FocusEvents from // its lightweight children as well KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); @@ -1311,7 +1328,7 @@ public abstract class LWComponentPeer * Finds a top-most visible component for the given point. The location is * specified relative to the peer's parent. */ - public LWComponentPeer findPeerAt(final int x, final int y) { + LWComponentPeer findPeerAt(final int x, final int y) { final Rectangle r = getBounds(); final Region sh = getRegion(); final boolean found = isVisible() && sh.contains(x - r.x, y - r.y); @@ -1328,7 +1345,7 @@ public abstract class LWComponentPeer } public Point windowToLocal(Point p, LWWindowPeer wp) { - LWComponentPeer cp = this; + LWComponentPeer cp = this; while (cp != wp) { Rectangle cpb = cp.getBounds(); p.x -= cpb.x; @@ -1349,7 +1366,7 @@ public abstract class LWComponentPeer } public Point localToWindow(Point p) { - LWComponentPeer cp = getContainerPeer(); + LWComponentPeer cp = getContainerPeer(); Rectangle r = getBounds(); while (cp != null) { p.x += r.x; @@ -1370,7 +1387,7 @@ public abstract class LWComponentPeer repaintPeer(getSize()); } - public void repaintPeer(final Rectangle r) { + void repaintPeer(final Rectangle r) { final Rectangle toPaint = getSize().intersection(r); if (!isShowing() || toPaint.isEmpty()) { return; @@ -1389,7 +1406,7 @@ public abstract class LWComponentPeer protected final boolean isShowing() { synchronized (getPeerTreeLock()) { if (isVisible()) { - final LWContainerPeer container = getContainerPeer(); + final LWContainerPeer container = getContainerPeer(); return (container == null) || container.isShowing(); } } @@ -1397,8 +1414,7 @@ public abstract class LWComponentPeer } /** - * Paints the peer. Overridden in subclasses to delegate the actual painting - * to Swing components. + * Paints the peer. Delegate the actual painting to Swing components. */ protected final void paintPeer(final Graphics g) { final D delegate = getDelegate(); diff --git a/src/macosx/classes/sun/lwawt/LWContainerPeer.java b/src/macosx/classes/sun/lwawt/LWContainerPeer.java index c213664b8..3069d3c2a 100644 --- a/src/macosx/classes/sun/lwawt/LWContainerPeer.java +++ b/src/macosx/classes/sun/lwawt/LWContainerPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,32 +41,25 @@ import java.util.List; import javax.swing.JComponent; abstract class LWContainerPeer - extends LWCanvasPeer - implements ContainerPeer -{ - // List of child peers sorted by z-order from bottom-most - // to top-most - private List childPeers = - new LinkedList(); - - LWContainerPeer(T target, PlatformComponent platformComponent) { - super(target, platformComponent); - } + extends LWCanvasPeer implements ContainerPeer { - void addChildPeer(LWComponentPeer child) { - synchronized (getPeerTreeLock()) { - addChildPeer(child, childPeers.size()); - } + /** + * List of child peers sorted by z-order from bottom-most to top-most. + */ + private final List> childPeers = new LinkedList<>(); + + LWContainerPeer(final T target, final PlatformComponent platformComponent) { + super(target, platformComponent); } - void addChildPeer(LWComponentPeer child, int index) { + final void addChildPeer(final LWComponentPeer child) { synchronized (getPeerTreeLock()) { - childPeers.add(index, child); + childPeers.add(childPeers.size(), child); + // TODO: repaint } - // TODO: repaint } - void removeChildPeer(LWComponentPeer child) { + final void removeChildPeer(final LWComponentPeer child) { synchronized (getPeerTreeLock()) { childPeers.remove(child); } @@ -74,7 +67,8 @@ abstract class LWContainerPeer } // Used by LWComponentPeer.setZOrder() - void setChildPeerZOrder(LWComponentPeer peer, LWComponentPeer above) { + final void setChildPeerZOrder(final LWComponentPeer peer, + final LWComponentPeer above) { synchronized (getPeerTreeLock()) { childPeers.remove(peer); int index = (above != null) ? childPeers.indexOf(above) : childPeers.size(); @@ -98,25 +92,27 @@ abstract class LWContainerPeer } @Override - public void beginValidate() { + public final void beginValidate() { // TODO: it seems that begin/endValidate() is only useful // for heavyweight windows, when a batch movement for // child windows occurs. That's why no-op } + @Override - public void endValidate() { + public final void endValidate() { // TODO: it seems that begin/endValidate() is only useful // for heavyweight windows, when a batch movement for // child windows occurs. That's why no-op } @Override - public void beginLayout() { + public final void beginLayout() { // Skip all painting till endLayout() setLayouting(true); } + @Override - public void endLayout() { + public final void endLayout() { setLayouting(false); // Post an empty event to flush all the pending target paints @@ -125,18 +121,19 @@ abstract class LWContainerPeer // ---- PEER NOTIFICATIONS ---- // - /* + /** * Returns a copy of the childPeer collection. */ - protected List getChildren() { + @SuppressWarnings("unchecked") + final List> getChildren() { synchronized (getPeerTreeLock()) { - Object copy = ((LinkedList)childPeers).clone(); - return (List)copy; + Object copy = ((LinkedList) childPeers).clone(); + return (List>) copy; } } @Override - public final Region getVisibleRegion() { + final Region getVisibleRegion() { return cutChildren(super.getVisibleRegion(), null); } @@ -144,9 +141,9 @@ abstract class LWContainerPeer * Removes bounds of children above specific child from the region. If above * is null removes all bounds of children. */ - protected final Region cutChildren(Region r, final LWComponentPeer above) { + final Region cutChildren(Region r, final LWComponentPeer above) { boolean aboveFound = above == null; - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { if (!aboveFound && child == above) { aboveFound = true; continue; @@ -170,8 +167,8 @@ abstract class LWContainerPeer * specified relative to the peer's parent. */ @Override - public final LWComponentPeer findPeerAt(int x, int y) { - LWComponentPeer peer = super.findPeerAt(x, y); + final LWComponentPeer findPeerAt(int x, int y) { + LWComponentPeer peer = super.findPeerAt(x, y); final Rectangle r = getBounds(); // Translate to this container's coordinates to pass to children x -= r.x; @@ -179,7 +176,7 @@ abstract class LWContainerPeer if (peer != null && getContentSize().contains(x, y)) { synchronized (getPeerTreeLock()) { for (int i = childPeers.size() - 1; i >= 0; --i) { - LWComponentPeer p = childPeers.get(i).findPeerAt(x, y); + LWComponentPeer p = childPeers.get(i).findPeerAt(x, y); if (p != null) { peer = p; break; @@ -195,7 +192,7 @@ abstract class LWContainerPeer * peers should be repainted */ @Override - public final void repaintPeer(final Rectangle r) { + final void repaintPeer(final Rectangle r) { final Rectangle toPaint = getSize().intersection(r); if (!isShowing() || toPaint.isEmpty()) { return; @@ -208,13 +205,13 @@ abstract class LWContainerPeer repaintChildren(toPaint); } - /* - * Paints all the child peers in the straight z-order, so the - * bottom-most ones are painted first. - */ + /** + * Paints all the child peers in the straight z-order, so the + * bottom-most ones are painted first. + */ private void repaintChildren(final Rectangle r) { final Rectangle content = getContentSize(); - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { final Rectangle childBounds = child.getBounds(); Rectangle toPaint = r.intersection(childBounds); toPaint = toPaint.intersection(content); @@ -223,21 +220,21 @@ abstract class LWContainerPeer } } - protected Rectangle getContentSize() { + Rectangle getContentSize() { return getSize(); } @Override public void setEnabled(final boolean e) { super.setEnabled(e); - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { child.setEnabled(e && child.getTarget().isEnabled()); } } @Override public void setBackground(final Color c) { - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { if (!child.getTarget().isBackgroundSet()) { child.setBackground(c); } @@ -247,7 +244,7 @@ abstract class LWContainerPeer @Override public void setForeground(final Color c) { - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { if (!child.getTarget().isForegroundSet()) { child.setForeground(c); } @@ -257,7 +254,7 @@ abstract class LWContainerPeer @Override public void setFont(final Font f) { - for (final LWComponentPeer child : getChildren()) { + for (final LWComponentPeer child : getChildren()) { if (!child.getTarget().isFontSet()) { child.setFont(f); } diff --git a/src/macosx/classes/sun/lwawt/LWCursorManager.java b/src/macosx/classes/sun/lwawt/LWCursorManager.java index de1b53785..ee9d0dd57 100644 --- a/src/macosx/classes/sun/lwawt/LWCursorManager.java +++ b/src/macosx/classes/sun/lwawt/LWCursorManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import java.awt.Point; import java.util.concurrent.atomic.AtomicBoolean; +import sun.awt.AWTAccessor; import sun.awt.SunToolkit; public abstract class LWCursorManager { @@ -109,7 +110,8 @@ public abstract class LWCursorManager { cursorPos.y - p.y); } while (c != null) { - if (c.isVisible() && c.isEnabled() && (c.getPeer() != null)) { + final Object p = AWTAccessor.getComponentAccessor().getPeer(c); + if (c.isVisible() && c.isEnabled() && p != null) { break; } c = c.getParent(); diff --git a/src/macosx/classes/sun/lwawt/LWLabelPeer.java b/src/macosx/classes/sun/lwawt/LWLabelPeer.java index 19743da74..68af14af3 100644 --- a/src/macosx/classes/sun/lwawt/LWLabelPeer.java +++ b/src/macosx/classes/sun/lwawt/LWLabelPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ final class LWLabelPeer extends LWComponentPeer } @Override - protected JLabel createDelegate() { + JLabel createDelegate() { return new JLabel(); } diff --git a/src/macosx/classes/sun/lwawt/LWListPeer.java b/src/macosx/classes/sun/lwawt/LWListPeer.java index 5edb8e16c..e6e1ec38c 100644 --- a/src/macosx/classes/sun/lwawt/LWListPeer.java +++ b/src/macosx/classes/sun/lwawt/LWListPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,8 @@ import java.awt.peer.ListPeer; import java.util.Arrays; /** - * Lightweight implementation of {@link ListPeer}. + * Lightweight implementation of {@link ListPeer}. Delegates most of the work to + * the {@link JList}, which is placed inside {@link JScrollPane}. */ final class LWListPeer extends LWComponentPeer implements ListPeer { @@ -56,7 +57,7 @@ final class LWListPeer extends LWComponentPeer } @Override - protected ScrollableJList createDelegate() { + ScrollableJList createDelegate() { return new ScrollableJList(); } @@ -78,7 +79,7 @@ final class LWListPeer extends LWComponentPeer } @Override - protected Component getDelegateFocusOwner() { + Component getDelegateFocusOwner() { return getDelegate().getView(); } @@ -193,6 +194,7 @@ final class LWListPeer extends LWComponentPeer } } + @SuppressWarnings("serial")// Safe: outer class is non-serializable. final class ScrollableJList extends JScrollPane implements ListSelectionListener { private boolean skipStateChangedEvent; @@ -234,9 +236,10 @@ final class LWListPeer extends LWComponentPeer } @Override + @SuppressWarnings("unchecked") public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !isSkipStateChangedEvent()) { - final JList source = (JList) e.getSource(); + final JList source = (JList) e.getSource(); for(int i = 0 ; i < source.getModel().getSize(); i++) { final boolean wasSelected = Arrays.binarySearch(oldSelectedIndices, i) >= 0; @@ -255,6 +258,7 @@ final class LWListPeer extends LWComponentPeer } } + @SuppressWarnings("unchecked") public JList getView() { return (JList) getViewport().getView(); } @@ -289,7 +293,7 @@ final class LWListPeer extends LWComponentPeer private final class JListDelegate extends JList { JListDelegate() { - super(ScrollableJList.this.model); + super(model); } @Override diff --git a/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java b/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java index 2cce1b172..1920a73d3 100644 --- a/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java +++ b/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,9 @@ import java.awt.Window; import java.awt.peer.MouseInfoPeer; -public class LWMouseInfoPeer implements MouseInfoPeer { +import sun.awt.AWTAccessor; - public LWMouseInfoPeer() { - } +public class LWMouseInfoPeer implements MouseInfoPeer { @Override public int fillPointWithCoords(Point point) { @@ -52,7 +51,7 @@ public class LWMouseInfoPeer implements MouseInfoPeer { return false; } - LWWindowPeer windowPeer = (LWWindowPeer)w.getPeer(); + final Object windowPeer = AWTAccessor.getComponentAccessor().getPeer(w); return LWWindowPeer.getWindowUnderCursor() == windowPeer; } diff --git a/src/macosx/classes/sun/lwawt/LWPanelPeer.java b/src/macosx/classes/sun/lwawt/LWPanelPeer.java index 6b1f48b08..ef1e93e8b 100644 --- a/src/macosx/classes/sun/lwawt/LWPanelPeer.java +++ b/src/macosx/classes/sun/lwawt/LWPanelPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,10 @@ import java.awt.peer.PanelPeer; import javax.swing.JPanel; +/** + * Lightweight implementation of {@link PanelPeer}. Delegates most of the work + * to the {@link JPanel}. + */ final class LWPanelPeer extends LWContainerPeer implements PanelPeer { @@ -39,7 +43,7 @@ final class LWPanelPeer extends LWContainerPeer } @Override - public JPanel createDelegate() { + JPanel createDelegate() { return new JPanel(); } } diff --git a/src/macosx/classes/sun/lwawt/LWRepaintArea.java b/src/macosx/classes/sun/lwawt/LWRepaintArea.java index e67b2fa43..7b7c7e8b6 100644 --- a/src/macosx/classes/sun/lwawt/LWRepaintArea.java +++ b/src/macosx/classes/sun/lwawt/LWRepaintArea.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,39 +26,38 @@ package sun.lwawt; -import sun.awt.RepaintArea; - import java.awt.Component; import java.awt.Graphics; +import sun.awt.AWTAccessor; +import sun.awt.RepaintArea; + /** + * Emulates appearance of heavyweight components before call of the user code. + * * @author Sergey Bylokhov */ final class LWRepaintArea extends RepaintArea { @Override protected void updateComponent(final Component comp, final Graphics g) { + // We shouldn't paint native component as a result of UPDATE events, + // just flush onscreen back-buffer. if (comp != null) { super.updateComponent(comp, g); - flushBuffers((LWComponentPeer) comp.getPeer()); + LWComponentPeer.flushOnscreenGraphics(); } } @Override protected void paintComponent(final Component comp, final Graphics g) { if (comp != null) { - final LWComponentPeer peer = (LWComponentPeer) comp.getPeer(); + Object peer = AWTAccessor.getComponentAccessor().getPeer(comp); if (peer != null) { - peer.paintPeer(g); + ((LWComponentPeer) peer).paintPeer(g); } super.paintComponent(comp, g); - flushBuffers(peer); - } - } - - private static void flushBuffers(final LWComponentPeer peer) { - if (peer != null) { - peer.flushOnscreenGraphics(); + LWComponentPeer.flushOnscreenGraphics(); } } } diff --git a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java index f5cb0d576..6fce0d584 100644 --- a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java +++ b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java @@ -34,10 +34,14 @@ import java.awt.peer.ScrollbarPeer; import javax.swing.JScrollBar; +/** + * Lightweight implementation of {@link ScrollbarPeer}. Delegates most of the + * work to the {@link JScrollBar}. + */ final class LWScrollBarPeer extends LWComponentPeer implements ScrollbarPeer, AdjustmentListener { - //JScrollBar fires two changes with firePropertyChange (one for old value + // JScrollBar fires two changes with firePropertyChange (one for old value // and one for new one. // We save the last value and don't fire event if not changed. private int currentValue; @@ -48,7 +52,7 @@ final class LWScrollBarPeer extends LWComponentPeer } @Override - protected JScrollBar createDelegate() { + JScrollBar createDelegate() { return new JScrollBar(); } diff --git a/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java b/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java index 723a9dd8d..4db7cac12 100644 --- a/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java +++ b/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,10 @@ import java.awt.event.MouseWheelEvent; import java.awt.peer.ScrollPanePeer; import java.util.List; +/** + * Lightweight implementation of {@link ScrollPanePeer}. Delegates most of the + * work to the {@link JScrollPane}. + */ final class LWScrollPanePeer extends LWContainerPeer implements ScrollPanePeer, ChangeListener { @@ -41,7 +45,8 @@ final class LWScrollPanePeer extends LWContainerPeer super(target, platformComponent); } - protected JScrollPane createDelegate() { + @Override + JScrollPane createDelegate() { final JScrollPane sp = new JScrollPane(); final JPanel panel = new JPanel(); panel.setOpaque(false); @@ -72,7 +77,7 @@ final class LWScrollPanePeer extends LWContainerPeer SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - final LWComponentPeer viewPeer = getViewPeer(); + final LWComponentPeer viewPeer = getViewPeer(); if (viewPeer != null) { final Rectangle r; synchronized (getDelegateLock()) { @@ -96,14 +101,13 @@ final class LWScrollPanePeer extends LWContainerPeer } } - LWComponentPeer getViewPeer() { - List peerList = getChildren(); + LWComponentPeer getViewPeer() { + final List> peerList = getChildren(); return peerList.isEmpty() ? null : peerList.get(0); } - @Override - protected Rectangle getContentSize() { + Rectangle getContentSize() { Rectangle viewRect = getDelegate().getViewport().getViewRect(); return new Rectangle(viewRect.width, viewRect.height); } @@ -112,7 +116,7 @@ final class LWScrollPanePeer extends LWContainerPeer public void layout() { super.layout(); synchronized (getDelegateLock()) { - LWComponentPeer viewPeer = getViewPeer(); + final LWComponentPeer viewPeer = getViewPeer(); if (viewPeer != null) { Component view = getDelegate().getViewport().getView(); view.setBounds(viewPeer.getBounds()); diff --git a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java index 98032e20c..5db1b6ca2 100644 --- a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java +++ b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ import javax.swing.text.JTextComponent; /** * Lightweight implementation of {@link TextAreaPeer}. Delegates most of the - * work to the {@link JTextArea} inside JScrollPane. + * work to the {@link JTextArea} inside {@link JScrollPane}. */ final class LWTextAreaPeer extends LWTextComponentPeer @@ -66,7 +66,7 @@ final class LWTextAreaPeer } @Override - protected ScrollableJTextArea createDelegate() { + ScrollableJTextArea createDelegate() { return new ScrollableJTextArea(); } @@ -85,7 +85,7 @@ final class LWTextAreaPeer } @Override - protected Cursor getCursor(final Point p) { + Cursor getCursor(final Point p) { final boolean isContains; synchronized (getDelegateLock()) { isContains = getDelegate().getViewport().getBounds().contains(p); @@ -94,7 +94,7 @@ final class LWTextAreaPeer } @Override - protected Component getDelegateFocusOwner() { + Component getDelegateFocusOwner() { return getTextComponent(); } @@ -200,7 +200,7 @@ final class LWTextAreaPeer } } - @SuppressWarnings("serial") + @SuppressWarnings("serial")// Safe: outer class is non-serializable. final class ScrollableJTextArea extends JScrollPane { ScrollableJTextArea() { @@ -218,7 +218,6 @@ final class LWTextAreaPeer super.setEnabled(enabled); } - @SuppressWarnings("serial") private final class JTextAreaDelegate extends JTextArea { // Empty non private constructor was added because access to this diff --git a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java index aab0baf43..860aa5466 100644 --- a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java +++ b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,11 +44,14 @@ import javax.swing.event.DocumentListener; import javax.swing.text.Document; import javax.swing.text.JTextComponent; +/** + * Lightweight implementation of {@link TextComponentPeer}. Provides useful + * methods for {@link LWTextAreaPeer} and {@link LWTextFieldPeer} + */ abstract class LWTextComponentPeer extends LWComponentPeer implements DocumentListener, TextComponentPeer, InputMethodListener { - private volatile boolean firstChangeSkipped; LWTextComponentPeer(final T target, @@ -218,14 +221,14 @@ abstract class LWTextComponentPeer implements TextFieldPeer, ActionListener { @@ -47,7 +51,7 @@ final class LWTextFieldPeer } @Override - protected JPasswordField createDelegate() { + JPasswordField createDelegate() { return new JPasswordFieldDelegate(); } @@ -107,7 +111,7 @@ final class LWTextFieldPeer * @param e the focus event */ @Override - protected void handleJavaFocusEvent(final FocusEvent e) { + void handleJavaFocusEvent(final FocusEvent e) { if (e.getID() == FocusEvent.FOCUS_LOST) { // In order to de-select the selection setCaretPosition(0); @@ -115,6 +119,7 @@ final class LWTextFieldPeer super.handleJavaFocusEvent(e); } + @SuppressWarnings("serial")// Safe: outer class is non-serializable. private final class JPasswordFieldDelegate extends JPasswordField { // Empty non private constructor was added because access to this diff --git a/src/macosx/classes/sun/lwawt/LWToolkit.java b/src/macosx/classes/sun/lwawt/LWToolkit.java index 9765066d9..f98dffbf3 100644 --- a/src/macosx/classes/sun/lwawt/LWToolkit.java +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java @@ -557,16 +557,18 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { } @Override - public void grab(Window w) { - if (w.getPeer() != null) { - ((LWWindowPeer)w.getPeer()).grab(); + public void grab(final Window w) { + final Object peer = AWTAccessor.getComponentAccessor().getPeer(w); + if (peer != null) { + ((LWWindowPeer) peer).grab(); } } @Override - public void ungrab(Window w) { - if (w.getPeer() != null) { - ((LWWindowPeer)w.getPeer()).ungrab(false); + public void ungrab(final Window w) { + final Object peer = AWTAccessor.getComponentAccessor().getPeer(w); + if (peer != null) { + ((LWWindowPeer) peer).ungrab(false); } } diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java index 600001630..632fe844e 100644 --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -43,7 +43,7 @@ public class LWWindowPeer extends LWContainerPeer implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener, PlatformEventNotifier { - public static enum PeerType { + public enum PeerType { SIMPLEWINDOW, FRAME, DIALOG, @@ -83,15 +83,15 @@ public class LWWindowPeer // A peer where the last mouse event came to. Used by cursor manager to // find the component under cursor - private static volatile LWComponentPeer lastCommonMouseEventPeer = null; + private static volatile LWComponentPeer lastCommonMouseEventPeer; // A peer where the last mouse event came to. Used to generate // MOUSE_ENTERED/EXITED notifications - private volatile LWComponentPeer lastMouseEventPeer; + private volatile LWComponentPeer lastMouseEventPeer; // Peers where all dragged/released events should come to, // depending on what mouse button is being dragged according to Cocoa - private static LWComponentPeer mouseDownTarget[] = new LWComponentPeer[3]; + private static final LWComponentPeer[] mouseDownTarget = new LWComponentPeer[3]; // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events // on MOUSE_RELEASE. Click events are only generated if there were no drag @@ -129,7 +129,8 @@ public class LWWindowPeer this.peerType = peerType; Window owner = target.getOwner(); - LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null; + LWWindowPeer ownerPeer = owner == null ? null : + (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner); PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null; // The delegate.initialize() needs a non-null GC on X11. @@ -163,10 +164,10 @@ public class LWWindowPeer // Init warning window(for applets) SecurityWarningWindow warn = null; - if (((Window)target).getWarningString() != null) { + if (target.getWarningString() != null) { // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip // and TrayIcon balloon windows without a warning window. - if (!AWTAccessor.getWindowAccessor().isTrayIconWindow((Window)target)) { + if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) { LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit(); warn = toolkit.createSecurityWarning(target, this); } @@ -210,6 +211,7 @@ public class LWWindowPeer } // Just a helper method + @Override public PlatformWindow getPlatformWindow() { return platformWindow; } @@ -391,7 +393,8 @@ public class LWWindowPeer @Override public void setModalBlocked(Dialog blocker, boolean blocked) { synchronized (getPeerTreeLock()) { - this.blocker = blocked ? (LWWindowPeer)blocker.getPeer() : null; + this.blocker = !blocked ? null : + (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(blocker); } platformWindow.setModalBlocked(blocked); @@ -458,6 +461,7 @@ public class LWWindowPeer textured = isTextured; } + @Override public final boolean isTranslucent() { synchronized (getStateLock()) { /* @@ -537,7 +541,8 @@ public class LWWindowPeer public void blockWindows(List windows) { //TODO: LWX will probably need some collectJavaToplevels to speed this up for (Window w : windows) { - WindowPeer wp = (WindowPeer)w.getPeer(); + WindowPeer wp = + (WindowPeer) AWTAccessor.getComponentAccessor().getPeer(w); if (wp != null) { wp.setModalBlocked((Dialog)getTarget(), true); } @@ -694,7 +699,7 @@ public class LWWindowPeer // TODO: fill "bdata" member of AWTEvent Rectangle r = getBounds(); // findPeerAt() expects parent coordinates - LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); + LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); if (id == MouseEvent.MOUSE_EXITED) { isMouseOver = false; @@ -743,7 +748,7 @@ public class LWWindowPeer screenX, screenY, modifiers, clickCount, popupTrigger, targetPeer); } else { - LWComponentPeer topmostTargetPeer = + LWComponentPeer topmostTargetPeer = topmostWindowPeer != null ? topmostWindowPeer.findPeerAt(r.x + x, r.y + y) : null; topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y, screenX, screenY, modifiers, clickCount, popupTrigger, @@ -840,7 +845,7 @@ public class LWWindowPeer private void generateMouseEnterExitEventsForComponents(long when, int button, int x, int y, int screenX, int screenY, int modifiers, int clickCount, boolean popupTrigger, - LWComponentPeer targetPeer) { + final LWComponentPeer targetPeer) { if (!isMouseOver || targetPeer == lastMouseEventPeer) { return; @@ -899,7 +904,7 @@ public class LWWindowPeer // TODO: could we just use the last mouse event target here? Rectangle r = getBounds(); // findPeerAt() expects parent coordinates - final LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); + final LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); if (targetPeer == null || !targetPeer.isEnabled()) { return; } @@ -1157,8 +1162,9 @@ public class LWWindowPeer if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { focusLog.fine("requesting native focus to the owner " + owner); } - LWWindowPeer currentActivePeer = (currentActive != null ? - (LWWindowPeer)currentActive.getPeer() : null); + LWWindowPeer currentActivePeer = currentActive == null ? null : + (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer( + currentActive); // Ensure the opposite is natively active and suppress sending events. if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) { @@ -1270,7 +1276,8 @@ public class LWWindowPeer while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { owner = owner.getOwner(); } - return owner != null ? (LWWindowPeer)owner.getPeer() : null; + return owner == null ? null : + (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner); } /** @@ -1289,11 +1296,13 @@ public class LWWindowPeer } } + @Override public void enterFullScreenMode() { platformWindow.enterFullScreenMode(); updateSecurityWarningVisibility(); } + @Override public void exitFullScreenMode() { platformWindow.exitFullScreenMode(); updateSecurityWarningVisibility(); diff --git a/src/macosx/classes/sun/lwawt/SelectionClearListener.java b/src/macosx/classes/sun/lwawt/SelectionClearListener.java deleted file mode 100644 index 4b3784842..000000000 --- a/src/macosx/classes/sun/lwawt/SelectionClearListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.lwawt; - -/* - * Every time the TextField (or TextArea) change selection, every other text components - * must immediately clear their selections. - */ -interface SelectionClearListener { - void clearSelection(); -} -- cgit v1.2.3 From d60ba2b03a9c387ed92820d83545a6831cfe7abf Mon Sep 17 00:00:00 2001 From: leonidr Date: Tue, 24 Sep 2013 18:24:03 +0400 Subject: 8022555: [macosx] AppleScriptEngine.jar MUST call java.awt.Toolkit.getDefaultToolkit() lazily Reviewed-by: anthony, serb --- .../applescript/AppleScriptEngineFactory.java | 41 ++++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/apple/applescript/AppleScriptEngineFactory.java b/src/macosx/classes/apple/applescript/AppleScriptEngineFactory.java index 564dfe063..8c50b9d93 100644 --- a/src/macosx/classes/apple/applescript/AppleScriptEngineFactory.java +++ b/src/macosx/classes/apple/applescript/AppleScriptEngineFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,9 @@ import java.util.*; import javax.script.*; public class AppleScriptEngineFactory implements ScriptEngineFactory { - private static native void initNative(); + private static volatile boolean initialized = false; - static { - java.awt.Toolkit.getDefaultToolkit(); - System.loadLibrary("AppleScriptEngine"); - initNative(); - TRACE(""); - } + private static native void initNative(); static void TRACE(final String str) { // System.out.println(AppleScriptEngineFactory.class.getName() + "." + str); @@ -80,6 +75,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return full name of the ScriptEngine */ + @Override public String getEngineName() { TRACE("getEngineName()"); return ENGINE_NAME; @@ -90,6 +86,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return version of the ScriptEngine */ + @Override public String getEngineVersion() { TRACE("getEngineVersion()"); return ENGINE_VERSION; @@ -100,6 +97,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return name of the language supported by the ScriptEngine(Factory) */ + @Override public String getLanguageName() { TRACE("getLanguageName()"); return LANGUAGE; @@ -110,11 +108,12 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return language version supported by the ScriptEngine(Factory) */ + @Override public String getLanguageVersion() { TRACE("getLanguageVersion()"); return AccessController.doPrivileged(new PrivilegedAction() { public String run() { - final AppleScriptEngine engine = new AppleScriptEngine(AppleScriptEngineFactory.this); + final AppleScriptEngine engine = getScriptEngine(); return engine.getLanguageVersion(); } }); @@ -126,6 +125,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return ArrayList of file extensions AppleScript associates with */ + @Override public List getExtensions() { TRACE("getExtensions()"); return Arrays.asList("scpt", "applescript", "app"); @@ -137,6 +137,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return ArrayList of mimetypes that AppleScript associates with */ + @Override public List getMimeTypes() { TRACE("getMimeTypes()"); return Arrays.asList("application/x-applescript", "text/plain", "text/applescript"); @@ -148,6 +149,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return */ + @Override public List getNames() { TRACE("getNames()"); return Arrays.asList("AppleScriptEngine", "AppleScript", "OSA"); @@ -165,6 +167,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * arguments to the function * @return the AppleScript string calling the method */ + @Override public String getMethodCallSyntax(final String obj, final String fname, final String ... args) { // StringBuilder builder = new StringBuilder(); // builder.append("my " + fname + "("); @@ -181,6 +184,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * @param toDisplay * @return */ + @Override public String getOutputStatement(final String toDisplay) { // TODO -- this might even be good enough? XD return getMethodCallSyntax(null, "print", toDisplay); @@ -193,8 +197,9 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * the key to look up * @return the static preseeded value for the key in the ScriptEngine, if it exists, otherwise null */ + @Override public Object getParameter(final String key) { - final AppleScriptEngine engine = new AppleScriptEngine(this); + final AppleScriptEngine engine = getScriptEngine(); if (!engine.getBindings(ScriptContext.ENGINE_SCOPE).containsKey(key)) return null; return engine.getBindings(ScriptContext.ENGINE_SCOPE).get(key); } @@ -205,6 +210,7 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * @param statements * @return */ + @Override public String getProgram(final String ... statements) { final StringBuilder program = new StringBuilder(); for (final String statement : statements) { @@ -218,8 +224,21 @@ public class AppleScriptEngineFactory implements ScriptEngineFactory { * * @return new AppleScriptEngine with this factory as it's parent */ - public ScriptEngine getScriptEngine() { + @Override + public AppleScriptEngine getScriptEngine() { AppleScriptEngine.checkSecurity(); + ensureInitialized(); + return new AppleScriptEngine(this); } + + private static synchronized void ensureInitialized() { + if (!initialized) { + initialized = true; + + java.awt.Toolkit.getDefaultToolkit(); + System.loadLibrary("AppleScriptEngine"); + initNative(); + } + } } -- cgit v1.2.3 From 0c655412dce90012a12d46bfcc432acec039c593 Mon Sep 17 00:00:00 2001 From: mfang Date: Tue, 24 Sep 2013 14:17:42 -0700 Subject: 8025215: jdk8 l10n resource file translation update 4 Reviewed-by: naoto, yhuang --- src/macosx/classes/com/apple/laf/resources/aqua_ko.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/com/apple/laf/resources/aqua_ko.properties b/src/macosx/classes/com/apple/laf/resources/aqua_ko.properties index 3fbfbe7e7..82c4ce2f2 100644 --- a/src/macosx/classes/com/apple/laf/resources/aqua_ko.properties +++ b/src/macosx/classes/com/apple/laf/resources/aqua_ko.properties @@ -46,7 +46,7 @@ FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5 FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30 FileChooser.saveDialogTitle.textAndMnemonic=\uC800\uC7A5 FileChooser.openDialogTitle.textAndMnemonic=\uC5F4\uAE30 -FileChooser.updateButton.textAndMnemonic=\uAC31\uC2E0 +FileChooser.updateButton.textAndMnemonic=\uC5C5\uB370\uC774\uD2B8 FileChooser.helpButton.textAndMnemonic=\uB3C4\uC6C0\uB9D0 FileChooser.directoryOpenButton.textAndMnemonic=\uC5F4\uAE30 -- cgit v1.2.3 From 7756f594a3014875e6726979dba52bfb1cc6bca1 Mon Sep 17 00:00:00 2001 From: alexsch Date: Wed, 25 Sep 2013 16:17:42 +0400 Subject: 8007155: [macosx] Disabled panel takes mouse input in JLayeredPane Reviewed-by: serb, anthony --- src/macosx/classes/sun/lwawt/LWCursorManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/macosx/classes') diff --git a/src/macosx/classes/sun/lwawt/LWCursorManager.java b/src/macosx/classes/sun/lwawt/LWCursorManager.java index ee9d0dd57..e17cced70 100644 --- a/src/macosx/classes/sun/lwawt/LWCursorManager.java +++ b/src/macosx/classes/sun/lwawt/LWCursorManager.java @@ -106,8 +106,9 @@ public abstract class LWCursorManager { c = peer.getTarget(); if (c instanceof Container) { final Point p = peer.getLocationOnScreen(); - c = ((Container) c).findComponentAt(cursorPos.x - p.x, - cursorPos.y - p.y); + c = AWTAccessor.getContainerAccessor().findComponentAt( + (Container) c, cursorPos.x - p.x, cursorPos.y - p.y, false); + } while (c != null) { final Object p = AWTAccessor.getComponentAccessor().getPeer(c); -- cgit v1.2.3