8031090: [macosx] LWToolkit should not depends from the macosx
Reviewed-by: anthony, pchelko
This commit is contained in:
parent
0d1b63f4cb
commit
b9b2db0eea
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, 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
|
||||
@ -28,18 +28,17 @@ package sun.lwawt;
|
||||
import java.awt.*;
|
||||
import java.awt.List;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.dnd.*;
|
||||
import java.awt.dnd.peer.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.peer.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.awt.*;
|
||||
import sun.lwawt.macosx.*;
|
||||
import sun.print.*;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
import static sun.lwawt.LWWindowPeer.PeerType;
|
||||
|
||||
public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
|
||||
private final static int STATE_NONE = 0;
|
||||
@ -115,7 +114,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
/*
|
||||
* Sends a request to stop the message pump.
|
||||
*/
|
||||
public void shutdown() {
|
||||
public final void shutdown() {
|
||||
setRunState(STATE_SHUTDOWN);
|
||||
platformShutdown();
|
||||
}
|
||||
@ -146,7 +145,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
public boolean isTerminating() {
|
||||
public final boolean isTerminating() {
|
||||
return getRunState() >= STATE_SHUTDOWN;
|
||||
}
|
||||
|
||||
@ -163,7 +162,8 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
@Override
|
||||
public final void run() {
|
||||
setRunState(STATE_INIT);
|
||||
platformInit();
|
||||
AWTAutoShutdown.notifyToolkitThreadFree();
|
||||
@ -215,80 +215,51 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
* Note that LWWindowPeer implements WindowPeer, FramePeer
|
||||
* and DialogPeer interfaces.
|
||||
*/
|
||||
private LWWindowPeer createDelegatedPeer(Window target, PlatformComponent platformComponent,
|
||||
PlatformWindow platformWindow, LWWindowPeer.PeerType peerType)
|
||||
{
|
||||
protected LWWindowPeer createDelegatedPeer(Window target,
|
||||
PlatformComponent platformComponent,
|
||||
PlatformWindow platformWindow,
|
||||
PeerType peerType) {
|
||||
LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow, peerType);
|
||||
targetCreatedPeer(target, peer);
|
||||
peer.initialize();
|
||||
return peer;
|
||||
}
|
||||
|
||||
private LWLightweightFramePeer createDelegatedLwPeer(LightweightFrame target,
|
||||
PlatformComponent platformComponent,
|
||||
PlatformWindow platformWindow)
|
||||
{
|
||||
LWLightweightFramePeer peer = new LWLightweightFramePeer(target, platformComponent, platformWindow);
|
||||
@Override
|
||||
public final FramePeer createLightweightFrame(LightweightFrame target) {
|
||||
PlatformComponent platformComponent = createLwPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.LW_FRAME);
|
||||
LWLightweightFramePeer peer = new LWLightweightFramePeer(target,
|
||||
platformComponent,
|
||||
platformWindow);
|
||||
targetCreatedPeer(target, peer);
|
||||
peer.initialize();
|
||||
return peer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FramePeer createLightweightFrame(LightweightFrame target) {
|
||||
PlatformComponent platformComponent = createLwPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.LW_FRAME);
|
||||
return createDelegatedLwPeer(target, platformComponent, platformWindow);
|
||||
public final WindowPeer createWindow(Window target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.SIMPLEWINDOW);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.SIMPLEWINDOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowPeer createWindow(Window target) {
|
||||
public final FramePeer createFrame(Frame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.SIMPLEWINDOW);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.SIMPLEWINDOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FramePeer createFrame(Frame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.FRAME);
|
||||
}
|
||||
|
||||
public LWWindowPeer createEmbeddedFrame(CEmbeddedFrame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.EMBEDDED_FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.EMBEDDED_FRAME);
|
||||
}
|
||||
|
||||
public LWWindowPeer createEmbeddedFrame(CViewEmbeddedFrame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.VIEW_EMBEDDED_FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.VIEW_EMBEDDED_FRAME);
|
||||
}
|
||||
|
||||
|
||||
CPrinterDialogPeer createCPrinterDialog(CPrinterDialog target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG);
|
||||
CPrinterDialogPeer peer = new CPrinterDialogPeer(target, platformComponent, platformWindow);
|
||||
targetCreatedPeer(target, peer);
|
||||
return peer;
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.FRAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogPeer createDialog(Dialog target) {
|
||||
if (target instanceof CPrinterDialog) {
|
||||
return createCPrinterDialog((CPrinterDialog)target);
|
||||
}
|
||||
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(LWWindowPeer.PeerType.DIALOG);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, LWWindowPeer.PeerType.DIALOG);
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.DIALOG);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.DIALOG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileDialogPeer createFileDialog(FileDialog target) {
|
||||
public final FileDialogPeer createFileDialog(FileDialog target) {
|
||||
FileDialogPeer peer = createFileDialogPeer(target);
|
||||
targetCreatedPeer(target, peer);
|
||||
return peer;
|
||||
@ -297,7 +268,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
// ---- LIGHTWEIGHT COMPONENT PEERS ---- //
|
||||
|
||||
@Override
|
||||
public ButtonPeer createButton(Button target) {
|
||||
public final ButtonPeer createButton(Button target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWButtonPeer peer = new LWButtonPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -306,7 +277,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckboxPeer createCheckbox(Checkbox target) {
|
||||
public final CheckboxPeer createCheckbox(Checkbox target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWCheckboxPeer peer = new LWCheckboxPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -315,12 +286,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChoicePeer createChoice(Choice target) {
|
||||
public final ChoicePeer createChoice(Choice target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWChoicePeer peer = new LWChoicePeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -329,7 +295,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelPeer createLabel(Label target) {
|
||||
public final LabelPeer createLabel(Label target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWLabelPeer peer = new LWLabelPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -338,7 +304,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanvasPeer createCanvas(Canvas target) {
|
||||
public final CanvasPeer createCanvas(Canvas target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -347,7 +313,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPeer createList(List target) {
|
||||
public final ListPeer createList(List target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWListPeer peer = new LWListPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -356,22 +322,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuPeer createMenu(Menu target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuBarPeer createMenuBar(MenuBar target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItemPeer createMenuItem(MenuItem target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PanelPeer createPanel(Panel target) {
|
||||
public final PanelPeer createPanel(Panel target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWPanelPeer peer = new LWPanelPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -380,12 +331,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PopupMenuPeer createPopupMenu(PopupMenu target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollPanePeer createScrollPane(ScrollPane target) {
|
||||
public final ScrollPanePeer createScrollPane(ScrollPane target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWScrollPanePeer peer = new LWScrollPanePeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -394,7 +340,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollbarPeer createScrollbar(Scrollbar target) {
|
||||
public final ScrollbarPeer createScrollbar(Scrollbar target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWScrollBarPeer peer = new LWScrollBarPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -403,7 +349,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAreaPeer createTextArea(TextArea target) {
|
||||
public final TextAreaPeer createTextArea(TextArea target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWTextAreaPeer peer = new LWTextAreaPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -412,7 +358,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextFieldPeer createTextField(TextField target) {
|
||||
public final TextFieldPeer createTextField(TextField target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWTextFieldPeer peer = new LWTextFieldPeer(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
@ -423,56 +369,51 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
// ---- NON-COMPONENT PEERS ---- //
|
||||
|
||||
@Override
|
||||
public ColorModel getColorModel() throws HeadlessException {
|
||||
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getColorModel();
|
||||
public final ColorModel getColorModel() throws HeadlessException {
|
||||
return GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice()
|
||||
.getDefaultConfiguration().getColorModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDesktopSupported() {
|
||||
public final boolean isDesktopSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DesktopPeer createDesktopPeer(Desktop target) {
|
||||
return new CDesktopPeer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) {
|
||||
DragSourceContextPeer dscp = CDragSourceContextPeer.createDragSourceContextPeer(dge);
|
||||
|
||||
return dscp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
|
||||
public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
|
||||
return LWKeyboardFocusManagerPeer.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
public final synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
if (mouseInfoPeer == null) {
|
||||
mouseInfoPeer = createMouseInfoPeerImpl();
|
||||
}
|
||||
return mouseInfoPeer;
|
||||
}
|
||||
|
||||
protected MouseInfoPeer createMouseInfoPeerImpl() {
|
||||
protected final MouseInfoPeer createMouseInfoPeerImpl() {
|
||||
return new LWMouseInfoPeer();
|
||||
}
|
||||
|
||||
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props) {
|
||||
@Override
|
||||
public final PrintJob getPrintJob(Frame frame, String doctitle,
|
||||
Properties props) {
|
||||
return getPrintJob(frame, doctitle, null, null);
|
||||
}
|
||||
|
||||
public PrintJob getPrintJob(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes) {
|
||||
@Override
|
||||
public final PrintJob getPrintJob(Frame frame, String doctitle,
|
||||
JobAttributes jobAttributes,
|
||||
PageAttributes pageAttributes) {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
PrintJob2D printJob = new PrintJob2D(frame, doctitle, jobAttributes, pageAttributes);
|
||||
|
||||
if (printJob.printDialog() == false) {
|
||||
if (!printJob.printDialog()) {
|
||||
printJob = null;
|
||||
}
|
||||
|
||||
@ -480,27 +421,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTraySupported() {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemTrayPeer createSystemTray(SystemTray target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrayIconPeer createTrayIcon(TrayIcon target) {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard getSystemClipboard() {
|
||||
public final Clipboard getSystemClipboard() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
|
||||
@ -514,7 +435,8 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
protected abstract SecurityWarningWindow createSecurityWarning(Window ownerWindow, LWWindowPeer ownerPeer);
|
||||
protected abstract SecurityWarningWindow createSecurityWarning(
|
||||
Window ownerWindow, LWWindowPeer ownerPeer);
|
||||
|
||||
// ---- DELEGATES ---- //
|
||||
|
||||
@ -523,7 +445,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
/*
|
||||
* Creates a delegate for the given peer type (window, frame, dialog, etc.)
|
||||
*/
|
||||
protected abstract PlatformWindow createPlatformWindow(LWWindowPeer.PeerType peerType);
|
||||
protected abstract PlatformWindow createPlatformWindow(PeerType peerType);
|
||||
|
||||
protected abstract PlatformComponent createPlatformComponent();
|
||||
|
||||
@ -557,7 +479,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grab(final Window w) {
|
||||
public final void grab(final Window w) {
|
||||
final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (peer != null) {
|
||||
((LWWindowPeer) peer).grab();
|
||||
@ -565,7 +487,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ungrab(final Window w) {
|
||||
public final void ungrab(final Window w) {
|
||||
final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (peer != null) {
|
||||
((LWWindowPeer) peer).ungrab(false);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, 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
|
||||
@ -23,17 +23,15 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
import sun.lwawt.LWToolkit;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
import sun.lwawt.macosx.CocoaConstants;
|
||||
import sun.lwawt.macosx.event.NSEvent;
|
||||
import java.awt.AWTKeyStroke;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import sun.awt.EmbeddedFrame;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
|
||||
public class CEmbeddedFrame extends EmbeddedFrame {
|
||||
|
||||
@ -48,7 +46,7 @@ public class CEmbeddedFrame extends EmbeddedFrame {
|
||||
|
||||
public void addNotify() {
|
||||
if (getPeer() == null) {
|
||||
LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
|
||||
LWCToolkit toolkit = (LWCToolkit)Toolkit.getDefaultToolkit();
|
||||
LWWindowPeer peer = toolkit.createEmbeddedFrame(this);
|
||||
setPeer(peer);
|
||||
responder = new CPlatformResponder(peer, true);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
@ -22,14 +22,17 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
import java.awt.AWTKeyStroke;
|
||||
import java.awt.Toolkit;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.lwawt.LWToolkit;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
|
||||
/*
|
||||
* The CViewEmbeddedFrame class is used in the SWT_AWT bridge.
|
||||
* This is a part of public API and should not be renamed or moved
|
||||
@ -48,7 +51,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
|
||||
@Override
|
||||
public void addNotify() {
|
||||
if (getPeer() == null) {
|
||||
LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
|
||||
LWCToolkit toolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
|
||||
setPeer(toolkit.createEmbeddedFrame(this));
|
||||
}
|
||||
super.addNotify();
|
||||
|
@ -33,6 +33,7 @@ import java.awt.event.InputEvent;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.im.InputMethodHighlight;
|
||||
import java.awt.im.spi.InputMethodDescriptor;
|
||||
import java.awt.peer.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.URL;
|
||||
@ -50,7 +51,7 @@ import sun.awt.image.MultiResolutionImage;
|
||||
|
||||
import sun.util.CoreResourceBundleControl;
|
||||
|
||||
class NamedCursor extends Cursor {
|
||||
final class NamedCursor extends Cursor {
|
||||
NamedCursor(String name) {
|
||||
super(name);
|
||||
}
|
||||
@ -76,6 +77,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
|
||||
ResourceBundle platformResources = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ResourceBundle>() {
|
||||
@Override
|
||||
public ResourceBundle run() {
|
||||
ResourceBundle platformResources = null;
|
||||
try {
|
||||
@ -133,18 +135,20 @@ public final class LWCToolkit extends LWToolkit {
|
||||
|
||||
private native void loadNativeColors(final int[] systemColors, final int[] appleColors);
|
||||
|
||||
@Override
|
||||
protected void loadSystemColors(final int[] systemColors) {
|
||||
if (systemColors == null) return;
|
||||
loadNativeColors(systemColors, appleColors);
|
||||
}
|
||||
|
||||
private static class AppleSpecificColor extends Color {
|
||||
int index;
|
||||
public AppleSpecificColor(int index) {
|
||||
private final int index;
|
||||
AppleSpecificColor(int index) {
|
||||
super(appleColors[index]);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGB() {
|
||||
return appleColors[index];
|
||||
}
|
||||
@ -152,7 +156,6 @@ public final class LWCToolkit extends LWToolkit {
|
||||
|
||||
/**
|
||||
* Returns Apple specific colors that we may expose going forward.
|
||||
*
|
||||
*/
|
||||
public static Color getAppleColor(int color) {
|
||||
return new AppleSpecificColor(color);
|
||||
@ -192,13 +195,44 @@ public final class LWCToolkit extends LWToolkit {
|
||||
} else if (peerType == PeerType.LW_FRAME) {
|
||||
return new CPlatformLWWindow();
|
||||
} else {
|
||||
assert (peerType == PeerType.SIMPLEWINDOW || peerType == PeerType.DIALOG || peerType == PeerType.FRAME);
|
||||
assert (peerType == PeerType.SIMPLEWINDOW
|
||||
|| peerType == PeerType.DIALOG
|
||||
|| peerType == PeerType.FRAME);
|
||||
return new CPlatformWindow();
|
||||
}
|
||||
}
|
||||
|
||||
LWWindowPeer createEmbeddedFrame(CEmbeddedFrame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.EMBEDDED_FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.EMBEDDED_FRAME);
|
||||
}
|
||||
|
||||
LWWindowPeer createEmbeddedFrame(CViewEmbeddedFrame target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.VIEW_EMBEDDED_FRAME);
|
||||
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.VIEW_EMBEDDED_FRAME);
|
||||
}
|
||||
|
||||
private CPrinterDialogPeer createCPrinterDialog(CPrinterDialog target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
PlatformWindow platformWindow = createPlatformWindow(PeerType.DIALOG);
|
||||
CPrinterDialogPeer peer = new CPrinterDialogPeer(target, platformComponent, platformWindow);
|
||||
targetCreatedPeer(target, peer);
|
||||
return peer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SecurityWarningWindow createSecurityWarning(Window ownerWindow, LWWindowPeer ownerPeer) {
|
||||
public DialogPeer createDialog(Dialog target) {
|
||||
if (target instanceof CPrinterDialog) {
|
||||
return createCPrinterDialog((CPrinterDialog)target);
|
||||
}
|
||||
return super.createDialog(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SecurityWarningWindow createSecurityWarning(Window ownerWindow,
|
||||
LWWindowPeer ownerPeer) {
|
||||
return new CWarningWindow(ownerWindow, ownerPeer);
|
||||
}
|
||||
|
||||
@ -250,13 +284,11 @@ public final class LWCToolkit extends LWToolkit {
|
||||
PopupMenuPeer peer = new CPopupMenu(target);
|
||||
targetCreatedPeer(target, peer);
|
||||
return peer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemTrayPeer createSystemTray(SystemTray target) {
|
||||
SystemTrayPeer peer = new CSystemTray();
|
||||
return peer;
|
||||
return new CSystemTray();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,57 +298,64 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return peer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DesktopPeer createDesktopPeer(Desktop target) {
|
||||
return new CDesktopPeer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LWCursorManager getCursorManager() {
|
||||
return CCursorManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor createCustomCursor(final Image cursor, final Point hotSpot, final String name) throws IndexOutOfBoundsException, HeadlessException {
|
||||
public Cursor createCustomCursor(final Image cursor, final Point hotSpot,
|
||||
final String name)
|
||||
throws IndexOutOfBoundsException, HeadlessException {
|
||||
return new CCustomCursor(cursor, hotSpot, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getBestCursorSize(final int preferredWidth, final int preferredHeight) throws HeadlessException {
|
||||
public Dimension getBestCursorSize(final int preferredWidth,
|
||||
final int preferredHeight)
|
||||
throws HeadlessException {
|
||||
return CCustomCursor.getBestCursorSize(preferredWidth, preferredHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void platformCleanup() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void platformInit() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void platformRunMessage() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void platformShutdown() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
class OSXPlatformFont extends sun.awt.PlatformFont
|
||||
{
|
||||
public OSXPlatformFont(String name, int style)
|
||||
OSXPlatformFont(String name, int style)
|
||||
{
|
||||
super(name, style);
|
||||
}
|
||||
@Override
|
||||
protected char getMissingGlyphCharacter()
|
||||
{
|
||||
// Follow up for real implementation
|
||||
return (char)0xfff8; // see http://developer.apple.com/fonts/LastResortFont/
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public FontPeer getFontPeer(String name, int style) {
|
||||
return new OSXPlatformFont(name, style);
|
||||
}
|
||||
@ -336,7 +375,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
@Override
|
||||
protected void initializeDesktopProperties() {
|
||||
super.initializeDesktopProperties();
|
||||
Map <Object, Object> fontHints = new HashMap<Object, Object>();
|
||||
Map <Object, Object> fontHints = new HashMap<>();
|
||||
fontHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
fontHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, fontHints);
|
||||
@ -357,14 +396,8 @@ public final class LWCToolkit extends LWToolkit {
|
||||
desktopProperties.put("DnD.Cursor.CopyNoDrop", new NamedCursor("DnD.Cursor.CopyNoDrop"));
|
||||
desktopProperties.put("DnD.Cursor.MoveNoDrop", new NamedCursor("DnD.Cursor.MoveNoDrop"));
|
||||
desktopProperties.put("DnD.Cursor.LinkNoDrop", new NamedCursor("DnD.Cursor.LinkNoDrop"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The method returns true if some events were processed during that timeout.
|
||||
* @see sun.awt.SunToolkit#syncNativeQueue(long)
|
||||
*/
|
||||
@Override
|
||||
protected boolean syncNativeQueue(long timeout) {
|
||||
return nativeSyncQueue(timeout);
|
||||
@ -388,7 +421,6 @@ public final class LWCToolkit extends LWToolkit {
|
||||
@Override
|
||||
public void sync() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -408,6 +440,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
* as Num Lock on PC keyboards is called Clear, doesn't lock
|
||||
* anything and is used for entirely different purpose.
|
||||
*/
|
||||
@Override
|
||||
public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.VK_NUM_LOCK:
|
||||
@ -427,10 +460,12 @@ public final class LWCToolkit extends LWToolkit {
|
||||
//Set to true by default.
|
||||
private static boolean areExtraMouseButtonsEnabled = true;
|
||||
|
||||
@Override
|
||||
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
|
||||
return areExtraMouseButtonsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfButtons(){
|
||||
return BUTTONS;
|
||||
}
|
||||
@ -489,6 +524,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
* @see java.awt.MenuShortcut
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@Override
|
||||
public int getMenuShortcutKeyMask() {
|
||||
return Event.META_MASK;
|
||||
}
|
||||
@ -522,8 +558,8 @@ public final class LWCToolkit extends LWToolkit {
|
||||
? getImageWithResolutionVariant(url, url2x) : super.getImage(url);
|
||||
}
|
||||
|
||||
static final String nsImagePrefix = "NSImage://";
|
||||
protected Image checkForNSImage(final String imageName) {
|
||||
private static final String nsImagePrefix = "NSImage://";
|
||||
private Image checkForNSImage(final String imageName) {
|
||||
if (imageName == null) return null;
|
||||
if (!imageName.startsWith(nsImagePrefix)) return null;
|
||||
return CImage.getCreator().createImageFromName(imageName.substring(nsImagePrefix.length()));
|
||||
@ -542,8 +578,9 @@ public final class LWCToolkit extends LWToolkit {
|
||||
synchronized(ret) { return ret[0]; }
|
||||
}
|
||||
|
||||
public static <T> T invokeAndWait(final Callable<T> callable, Component component) throws Exception {
|
||||
final CallableWrapper<T> wrapper = new CallableWrapper<T>(callable);
|
||||
public static <T> T invokeAndWait(final Callable<T> callable,
|
||||
Component component) throws Exception {
|
||||
final CallableWrapper<T> wrapper = new CallableWrapper<>(callable);
|
||||
invokeAndWait(wrapper, component);
|
||||
return wrapper.getResult();
|
||||
}
|
||||
@ -553,10 +590,11 @@ public final class LWCToolkit extends LWToolkit {
|
||||
T object;
|
||||
Exception e;
|
||||
|
||||
public CallableWrapper(final Callable<T> callable) {
|
||||
CallableWrapper(final Callable<T> callable) {
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
object = callable.call();
|
||||
@ -571,12 +609,16 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
}
|
||||
|
||||
// Kicks an event over to the appropriate eventqueue and waits for it to finish
|
||||
// To avoid deadlocking, we manually run the NSRunLoop while waiting
|
||||
// Any selector invoked using ThreadUtilities performOnMainThread will be processed in doAWTRunLoop
|
||||
// The InvocationEvent will call LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual runloop
|
||||
// Does not dispatch native events while in the loop
|
||||
public static void invokeAndWait(Runnable runnable, Component component) throws InvocationTargetException {
|
||||
/**
|
||||
* Kicks an event over to the appropriate eventqueue and waits for it to
|
||||
* finish To avoid deadlocking, we manually run the NSRunLoop while waiting
|
||||
* Any selector invoked using ThreadUtilities performOnMainThread will be
|
||||
* processed in doAWTRunLoop The InvocationEvent will call
|
||||
* LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual
|
||||
* runloop Does not dispatch native events while in the loop
|
||||
*/
|
||||
public static void invokeAndWait(Runnable runnable, Component component)
|
||||
throws InvocationTargetException {
|
||||
final long mediator = createAWTRunLoopMediator();
|
||||
|
||||
InvocationEvent invocationEvent =
|
||||
@ -611,7 +653,8 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
}
|
||||
|
||||
public static void invokeLater(Runnable event, Component component) throws InvocationTargetException {
|
||||
public static void invokeLater(Runnable event, Component component)
|
||||
throws InvocationTargetException {
|
||||
final InvocationEvent invocationEvent =
|
||||
new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);
|
||||
|
||||
@ -640,16 +683,18 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return getSystemEventQueueImpl();
|
||||
}
|
||||
|
||||
|
||||
// DnD support
|
||||
|
||||
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
|
||||
DragSourceContextPeer dscp = CDragSourceContextPeer.createDragSourceContextPeer(dge);
|
||||
|
||||
return dscp;
|
||||
@Override
|
||||
public DragSourceContextPeer createDragSourceContextPeer(
|
||||
DragGestureEvent dge) throws InvalidDnDOperationException {
|
||||
return CDragSourceContextPeer.createDragSourceContextPeer(dge);
|
||||
}
|
||||
|
||||
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) {
|
||||
@Override
|
||||
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
|
||||
Class<T> abstractRecognizerClass, DragSource ds, Component c,
|
||||
int srcActions, DragGestureListener dgl) {
|
||||
DragGestureRecognizer dgr = null;
|
||||
|
||||
// Create a new mouse drag gesture recognizer if we have a class match:
|
||||
@ -663,6 +708,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
/**
|
||||
* Returns the default keyboard locale of the underlying operating system
|
||||
*/
|
||||
@Override
|
||||
public Locale getDefaultKeyboardLocale() {
|
||||
Locale locale = CInputMethod.getNativeLocale();
|
||||
|
||||
@ -673,7 +719,8 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public java.awt.im.spi.InputMethodDescriptor getInputMethodAdapterDescriptor() {
|
||||
@Override
|
||||
public InputMethodDescriptor getInputMethodAdapterDescriptor() {
|
||||
if (sInputMethodDescriptor == null)
|
||||
sInputMethodDescriptor = new CInputMethodDescriptor();
|
||||
|
||||
@ -689,12 +736,14 @@ public final class LWCToolkit extends LWToolkit {
|
||||
* @return style attribute map, or null
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
|
||||
return CInputMethod.mapInputMethodHighlight(highlight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns key modifiers used by Swing to set up a focus accelerator key stroke.
|
||||
* Returns key modifiers used by Swing to set up a focus accelerator key
|
||||
* stroke.
|
||||
*/
|
||||
@Override
|
||||
public int getFocusAcceleratorKeyMask() {
|
||||
@ -702,8 +751,8 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether specified key modifiers mask can be used to enter a printable
|
||||
* character.
|
||||
* Tests whether specified key modifiers mask can be used to enter a
|
||||
* printable character.
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrintableCharacterModifiersMask(int mods) {
|
||||
@ -724,15 +773,14 @@ public final class LWCToolkit extends LWToolkit {
|
||||
* Returns the value of "sun.awt.disableCALayers" property. Default
|
||||
* value is {@code false}.
|
||||
*/
|
||||
public synchronized static boolean getSunAwtDisableCALayers() {
|
||||
public static synchronized boolean getSunAwtDisableCALayers() {
|
||||
if (sunAwtDisableCALayers == null) {
|
||||
sunAwtDisableCALayers = AccessController.doPrivileged(
|
||||
new GetBooleanAction("sun.awt.disableCALayers"));
|
||||
}
|
||||
return sunAwtDisableCALayers.booleanValue();
|
||||
return sunAwtDisableCALayers;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns true if the application (one of its windows) owns keyboard focus.
|
||||
*/
|
||||
@ -757,7 +805,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
static void doAWTRunLoop(long mediator, boolean processEvents) {
|
||||
doAWTRunLoopImpl(mediator, processEvents, inAWT);
|
||||
}
|
||||
static private native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
|
||||
private static native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
|
||||
static native void stopAWTRunLoop(long mediator);
|
||||
|
||||
private native boolean nativeSyncQueue(long timeout);
|
||||
@ -801,6 +849,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSwingBackbufferTranslucencySupported() {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user