aboutsummaryrefslogtreecommitdiff
path: root/src/macosx/classes
diff options
context:
space:
mode:
authorchegar <none@none>2013-10-03 19:06:43 +0100
committerchegar <none@none>2013-10-03 19:06:43 +0100
commitb2ba5fb7b9dc0f3296388d54cef67b90a5b1026a (patch)
tree1f835abcc1604ece6073c132a47aa7036adcbd59 /src/macosx/classes
parent7e24648b618df6c5f7905bfd293718b70dded745 (diff)
parent7bdfeae8000856c03eb2411ddab292e2b1101f02 (diff)
Merge
Diffstat (limited to 'src/macosx/classes')
-rw-r--r--src/macosx/classes/apple/applescript/AppleScriptEngineFactory.java41
-rw-r--r--src/macosx/classes/com/apple/laf/AquaFileChooserUI.java62
-rw-r--r--src/macosx/classes/com/apple/laf/resources/aqua_ko.properties2
-rw-r--r--src/macosx/classes/sun/awt/resources/awtosx.properties71
-rw-r--r--src/macosx/classes/sun/lwawt/LWButtonPeer.java9
-rw-r--r--src/macosx/classes/sun/lwawt/LWCanvasPeer.java6
-rw-r--r--src/macosx/classes/sun/lwawt/LWCheckboxPeer.java12
-rw-r--r--src/macosx/classes/sun/lwawt/LWChoicePeer.java42
-rw-r--r--src/macosx/classes/sun/lwawt/LWComponentPeer.java92
-rw-r--r--src/macosx/classes/sun/lwawt/LWContainerPeer.java89
-rw-r--r--src/macosx/classes/sun/lwawt/LWCursorManager.java11
-rw-r--r--src/macosx/classes/sun/lwawt/LWLabelPeer.java4
-rw-r--r--src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java12
-rw-r--r--src/macosx/classes/sun/lwawt/LWListPeer.java16
-rw-r--r--src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java9
-rw-r--r--src/macosx/classes/sun/lwawt/LWPanelPeer.java8
-rw-r--r--src/macosx/classes/sun/lwawt/LWRepaintArea.java25
-rw-r--r--src/macosx/classes/sun/lwawt/LWScrollBarPeer.java8
-rw-r--r--src/macosx/classes/sun/lwawt/LWScrollPanePeer.java20
-rw-r--r--src/macosx/classes/sun/lwawt/LWTextAreaPeer.java13
-rw-r--r--src/macosx/classes/sun/lwawt/LWTextComponentPeer.java11
-rw-r--r--src/macosx/classes/sun/lwawt/LWTextFieldPeer.java11
-rw-r--r--src/macosx/classes/sun/lwawt/LWToolkit.java17
-rw-r--r--src/macosx/classes/sun/lwawt/LWWindowPeer.java48
-rw-r--r--src/macosx/classes/sun/lwawt/SelectionClearListener.java34
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CMenu.java16
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CMenuItem.java17
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CMouseInfoPeer.java45
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java5
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java34
30 files changed, 447 insertions, 343 deletions
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("<static-init>");
- }
+ 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<String>() {
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<String> 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<String> 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<String> 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 <code>null</code>
*/
+ @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();
+ }
+ }
}
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();
}
}
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
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/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<Button, JButton>
implements ButtonPeer, ActionListener {
@@ -42,7 +46,7 @@ final class LWButtonPeer extends LWComponentPeer<Button, JButton>
}
@Override
- protected JButton createDelegate() {
+ JButton createDelegate() {
return new JButtonDelegate();
}
@@ -74,6 +78,7 @@ final class LWButtonPeer extends LWComponentPeer<Button, JButton>
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<T extends Component, D extends JComponent>
extends LWComponentPeer<T, D> 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<Checkbox, LWCheckboxPeer.CheckboxDelegate>
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 dc781d3d6..5b78e74b6 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,14 +26,18 @@
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.*;
+/**
+ * Lightweight implementation of {@link ChoicePeer}. Delegates most of the work
+ * to the {@link JComboBox}.
+ */
final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
implements ChoicePeer, ItemListener {
@@ -50,7 +54,7 @@ final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
}
@Override
- protected JComboBox<String> createDelegate() {
+ JComboBox<String> createDelegate() {
return new JComboBoxDelegate();
}
@@ -128,6 +132,7 @@ final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
return true;
}
+ @SuppressWarnings("serial")// Safe: outer class is non-serializable.
private final class JComboBoxDelegate extends JComboBox<String> {
// Empty non private constructor was added because access to this
@@ -159,5 +164,32 @@ final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
}
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;
+ }
}
}
diff --git a/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/src/macosx/classes/sun/lwawt/LWComponentPeer.java
index 05d1d5d1f..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<T extends Component, D extends JComponent>
{
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<T extends Component, D extends JComponent>
* 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<T extends Component, D extends JComponent>
*/
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<T extends Component, D extends JComponent>
}
}
- 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<T extends Component, D extends JComponent>
* 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<T extends Component, D extends JComponent>
}
// Just a helper method
- protected final LWContainerPeer getContainerPeer() {
+ protected final LWContainerPeer<?, ?> getContainerPeer() {
return containerPeer;
}
@@ -390,7 +404,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
protected void disposeImpl() {
destroyBuffers();
- LWContainerPeer cp = getContainerPeer();
+ LWContainerPeer<?, ?> cp = getContainerPeer();
if (cp != null) {
cp.removeChildPeer(this);
}
@@ -462,12 +476,13 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
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<T extends Component, D extends JComponent>
* @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<T extends Component, D extends JComponent>
@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<T extends Component, D extends JComponent>
}
@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<T extends Component, D extends JComponent>
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<T extends Component, D extends JComponent>
}
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));
@@ -1254,6 +1271,8 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
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());
@@ -1273,7 +1292,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
/**
* 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();
@@ -1309,7 +1328,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* 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);
@@ -1326,7 +1345,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
public Point windowToLocal(Point p, LWWindowPeer wp) {
- LWComponentPeer cp = this;
+ LWComponentPeer<?, ?> cp = this;
while (cp != wp) {
Rectangle cpb = cp.getBounds();
p.x -= cpb.x;
@@ -1347,7 +1366,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
public Point localToWindow(Point p) {
- LWComponentPeer cp = getContainerPeer();
+ LWComponentPeer<?, ?> cp = getContainerPeer();
Rectangle r = getBounds();
while (cp != null) {
p.x += r.x;
@@ -1368,7 +1387,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
repaintPeer(getSize());
}
- public void repaintPeer(final Rectangle r) {
+ void repaintPeer(final Rectangle r) {
final Rectangle toPaint = getSize().intersection(r);
if (!isShowing() || toPaint.isEmpty()) {
return;
@@ -1387,7 +1406,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
protected final boolean isShowing() {
synchronized (getPeerTreeLock()) {
if (isVisible()) {
- final LWContainerPeer container = getContainerPeer();
+ final LWContainerPeer<?, ?> container = getContainerPeer();
return (container == null) || container.isShowing();
}
}
@@ -1395,8 +1414,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
/**
- * 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<T extends Container, D extends JComponent>
- extends LWCanvasPeer<T, D>
- implements ContainerPeer
-{
- // List of child peers sorted by z-order from bottom-most
- // to top-most
- private List<LWComponentPeer> childPeers =
- new LinkedList<LWComponentPeer>();
-
- LWContainerPeer(T target, PlatformComponent platformComponent) {
- super(target, platformComponent);
- }
+ extends LWCanvasPeer<T, D> 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<LWComponentPeer<?, ?>> 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<T extends Container, D extends JComponent>
}
// 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<T extends Container, D extends JComponent>
}
@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<T extends Container, D extends JComponent>
// ---- PEER NOTIFICATIONS ---- //
- /*
+ /**
* Returns a copy of the childPeer collection.
*/
- protected List<LWComponentPeer> getChildren() {
+ @SuppressWarnings("unchecked")
+ final List<LWComponentPeer<?, ?>> getChildren() {
synchronized (getPeerTreeLock()) {
- Object copy = ((LinkedList)childPeers).clone();
- return (List<LWComponentPeer>)copy;
+ Object copy = ((LinkedList<?>) childPeers).clone();
+ return (List<LWComponentPeer<?, ?>>) copy;
}
}
@Override
- public final Region getVisibleRegion() {
+ final Region getVisibleRegion() {
return cutChildren(super.getVisibleRegion(), null);
}
@@ -144,9 +141,9 @@ abstract class LWContainerPeer<T extends Container, D extends JComponent>
* 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<T extends Container, D extends JComponent>
* 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<T extends Container, D extends JComponent>
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<T extends Container, D extends JComponent>
* 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<T extends Container, D extends JComponent>
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<T extends Container, D extends JComponent>
}
}
- 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<T extends Container, D extends JComponent>
@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<T extends Container, D extends JComponent>
@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..e17cced70 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 {
@@ -105,11 +106,13 @@ 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) {
- 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<Label, JLabel>
}
@Override
- protected JLabel createDelegate() {
+ JLabel createDelegate() {
return new JLabel();
}
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 {
@@ -91,11 +93,6 @@ public class LWLightweightFramePeer extends LWWindowPeer {
}
@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());
+ }
}
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<List, LWListPeer.ScrollableJList>
implements ListPeer {
@@ -56,7 +57,7 @@ final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
}
@Override
- protected ScrollableJList createDelegate() {
+ ScrollableJList createDelegate() {
return new ScrollableJList();
}
@@ -78,7 +79,7 @@ final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
}
@Override
- protected Component getDelegateFocusOwner() {
+ Component getDelegateFocusOwner() {
return getDelegate().getView();
}
@@ -193,6 +194,7 @@ final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
}
}
+ @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<List, LWListPeer.ScrollableJList>
}
@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<List, LWListPeer.ScrollableJList>
}
}
+ @SuppressWarnings("unchecked")
public JList<String> getView() {
return (JList<String>) getViewport().getView();
}
@@ -289,7 +293,7 @@ final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
private final class JListDelegate extends JList<String> {
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<Panel, JPanel>
implements PanelPeer {
@@ -39,7 +43,7 @@ final class LWPanelPeer extends LWContainerPeer<Panel, JPanel>
}
@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<Scrollbar, JScrollBar>
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<Scrollbar, JScrollBar>
}
@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<ScrollPane, JScrollPane>
implements ScrollPanePeer, ChangeListener {
@@ -41,7 +45,8 @@ final class LWScrollPanePeer extends LWContainerPeer<ScrollPane, JScrollPane>
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<ScrollPane, JScrollPane>
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<ScrollPane, JScrollPane>
}
}
- LWComponentPeer getViewPeer() {
- List<LWComponentPeer> peerList = getChildren();
+ LWComponentPeer<?, ?> getViewPeer() {
+ final List<LWComponentPeer<?, ?>> 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<ScrollPane, JScrollPane>
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<TextArea, LWTextAreaPeer.ScrollableJTextArea>
@@ -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<T extends TextComponent, D extends JComponent>
extends LWComponentPeer<T, D>
implements DocumentListener, TextComponentPeer, InputMethodListener {
-
private volatile boolean firstChangeSkipped;
LWTextComponentPeer(final T target,
@@ -218,14 +221,14 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent
}
@Override
- public void inputMethodTextChanged(InputMethodEvent event) {
+ public void inputMethodTextChanged(final InputMethodEvent event) {
synchronized (getDelegateLock()) {
AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
}
}
@Override
- public void caretPositionChanged(InputMethodEvent event) {
+ public void caretPositionChanged(final InputMethodEvent event) {
synchronized (getDelegateLock()) {
AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
}
diff --git a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java
index ef2b4d087..fb3c43d5d 100644
--- a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java
+++ b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.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
@@ -37,6 +37,10 @@ import java.awt.peer.TextFieldPeer;
import javax.swing.*;
import javax.swing.text.JTextComponent;
+/**
+ * Lightweight implementation of {@link TextFieldPeer}. Delegates most of the
+ * work to the {@link JPasswordField}.
+ */
final class LWTextFieldPeer
extends LWTextComponentPeer<TextField, JPasswordField>
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 fb7032f0b..f98dffbf3 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) {
@@ -556,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 2be41cf3b..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<Window, JComponent>
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<Window> 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;
}
@@ -933,7 +938,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 ---- //
@@ -1152,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()) {
@@ -1265,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);
}
/**
@@ -1284,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();
-}
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);
}
@@ -41,6 +43,20 @@ public class CMenu extends CMenuItem implements MenuPeer {
}
@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)
LWCToolkit.targetToPeer(getTarget().getParent());
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/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/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();
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
index 943dbe2fe..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<Object>() {
- public Object run() {
+
+ ResourceBundle platformResources = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<ResourceBundle>() {
+ 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();
}
@@ -207,9 +224,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
@@ -303,11 +320,6 @@ public final class LWCToolkit extends LWToolkit {
}
@Override
- protected MouseInfoPeer createMouseInfoPeerImpl() {
- return new CMouseInfoPeer();
- }
-
- @Override
protected int getScreenHeight() {
return GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration().getBounds().height;