Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-07-24 19:57:11 +0000
committerAlexander Kurtakov2016-07-24 19:57:11 +0000
commit1fb36aa4b6acb0358844d2c2090bdcdd60d0836b (patch)
tree6837dae6582893a65c9a443c529092eef526d2ed /bundles/org.eclipse.swt/Eclipse SWT AWT
parent16f51f88dad9396bc46d985696a4f65ae53b2f76 (diff)
downloadeclipse.platform.swt-1fb36aa4b6acb0358844d2c2090bdcdd60d0836b.tar.gz
eclipse.platform.swt-1fb36aa4b6acb0358844d2c2090bdcdd60d0836b.tar.xz
eclipse.platform.swt-1fb36aa4b6acb0358844d2c2090bdcdd60d0836b.zip
Bug 497962 - Use lambdas where possible
Enable convert to lambdas and run initial conversion to not interfere with later commits. Slightly smaller and faster code is worth it at SWT level. Change-Id: Ia94b6c25beb09555626eaa455b9e9f43e329f7e6 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT AWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java132
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java153
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java239
3 files changed, 200 insertions, 324 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java
index 746b05ec7d..ae3257927f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java
@@ -204,27 +204,14 @@ public static Frame new_Frame(final Composite parent) {
parent.setData(EMBEDDED_FRAME_KEY, frame);
/* Forward the iconify and deiconify events */
- final Listener shellListener = new Listener () {
- @Override
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
+ final Listener shellListener = e -> {
+ switch (e.type) {
+ case SWT.Deiconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED)));
+ break;
+ case SWT.Iconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED)));
+ break;
}
};
Shell shell = parent.getShell ();
@@ -268,42 +255,33 @@ public static Frame new_Frame(final Composite parent) {
shell.removeListener (SWT.Deactivate, this);
}
parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- try {
- frame.dispose ();
- } catch (Throwable e) {}
- }
+ EventQueue.invokeLater(() -> {
+ try {
+ frame.dispose ();
+ } catch (Throwable e1) {}
});
break;
case SWT.Activate:
if (!parent.isFocusControl()) return;
case SWT.FocusIn:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- if (frame.isActive()) return;
- try {
- Class<?> clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
- if (method != null) method.invoke(frame, Boolean.TRUE);
- } catch (Throwable e) {e.printStackTrace();}
- }
+ EventQueue.invokeLater(() -> {
+ if (frame.isActive()) return;
+ try {
+ Class<?> clazz1 = frame.getClass();
+ Method method = clazz1.getMethod("synthesizeWindowActivation", boolean.class);
+ if (method != null) method.invoke(frame, Boolean.TRUE);
+ } catch (Throwable e1) {e1.printStackTrace();}
});
break;
case SWT.Deactivate:
case SWT.FocusOut:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- if (!frame.isActive()) return;
- try {
- Class<?> clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
- if (method != null) method.invoke(frame, Boolean.FALSE);
- } catch (Throwable e) {e.printStackTrace();}
- }
+ EventQueue.invokeLater(() -> {
+ if (!frame.isActive()) return;
+ try {
+ Class<?> clazz1 = frame.getClass();
+ Method method = clazz1.getMethod("synthesizeWindowActivation", boolean.class);
+ if (method != null) method.invoke(frame, Boolean.FALSE);
+ } catch (Throwable e1) {e1.printStackTrace();}
});
break;
}
@@ -321,30 +299,24 @@ public static Frame new_Frame(final Composite parent) {
}
parent.addListener (SWT.Dispose, listener);
- display.asyncExec(new Runnable() {
- @Override
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
- if (isJDK17) {
- try {
- Method method = frame.getClass().getMethod("validateWithBounds", int.class, int.class, int.class, int.class);
- if (method != null) method.invoke(frame, Integer.valueOf(clientArea.x), Integer.valueOf(clientArea.y), Integer.valueOf(clientArea.width), Integer.valueOf(clientArea.height));
- } catch (Throwable e) {e.printStackTrace();}
- } else {
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.setSize(clientArea.width, clientArea.height);
- frame.validate();
+ display.asyncExec(() -> {
+ if (parent.isDisposed()) return;
+ final Rectangle clientArea = parent.getClientArea();
+ if (isJDK17) {
+ try {
+ Method method = frame.getClass().getMethod("validateWithBounds", int.class, int.class, int.class, int.class);
+ if (method != null) method.invoke(frame, Integer.valueOf(clientArea.x), Integer.valueOf(clientArea.y), Integer.valueOf(clientArea.width), Integer.valueOf(clientArea.height));
+ } catch (Throwable e) {e.printStackTrace();}
+ } else {
+ EventQueue.invokeLater(() -> {
+ frame.setSize(clientArea.width, clientArea.height);
+ frame.validate();
- // Bug in Cocoa AWT? For some reason the frame isn't showing up on first draw.
- // Toggling visibility seems to be the only thing that works.
- frame.setVisible(false);
- frame.setVisible(true);
- }
- });
- }
+ // Bug in Cocoa AWT? For some reason the frame isn't showing up on first draw.
+ // Toggling visibility seems to be the only thing that works.
+ frame.setVisible(false);
+ frame.setVisible(true);
+ });
}
});
@@ -384,23 +356,15 @@ public static Shell new_Shell(final Display display, final Canvas parent) {
final ComponentListener listener = new ComponentAdapter () {
@Override
public void componentResized (ComponentEvent e) {
- display.asyncExec (new Runnable () {
- @Override
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
- }
+ display.asyncExec (() -> {
+ if (shell.isDisposed()) return;
+ Dimension dim = parent.getSize ();
+ shell.setSize (dim.width, dim.height);
});
}
};
parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- @Override
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
+ shell.addListener(SWT.Dispose, event -> parent.removeComponentListener(listener));
shell.setVisible (true);
return shell;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
index b3b0d42c97..abd0347f01 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
@@ -25,7 +25,6 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
/**
@@ -177,106 +176,70 @@ public static Frame new_Frame (final Composite parent) {
Method method = clazz.getMethod("registerListeners");
if (method != null) method.invoke(value);
} catch (Throwable e) {}
- final AWTEventListener awtListener = new AWTEventListener() {
- @Override
- public void eventDispatched(AWTEvent event) {
- if (event.getID() == WindowEvent.WINDOW_OPENED) {
- final Window window = (Window) event.getSource();
- if (window.getParent() == frame) {
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (parent.isDisposed()) return;
- Shell shell = parent.getShell();
- loadLibrary();
- long /*int*/ awtHandle = getAWTHandle(window);
- if (awtHandle == 0) return;
- long /*int*/ xWindow;
- if (OS.GTK3) {
- xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shell.handle));
- } else {
- xWindow = OS.gdk_x11_drawable_get_xid(OS.gtk_widget_get_window(OS.gtk_widget_get_toplevel(shell.handle)));
- }
- OS.XSetTransientForHint(OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()), awtHandle, xWindow);
- }
- });
- }
+ final AWTEventListener awtListener = event -> {
+ if (event.getID() == WindowEvent.WINDOW_OPENED) {
+ final Window window = (Window) event.getSource();
+ if (window.getParent() == frame) {
+ parent.getDisplay().asyncExec(() -> {
+ if (parent.isDisposed()) return;
+ Shell shell = parent.getShell();
+ loadLibrary();
+ long /*int*/ awtHandle = getAWTHandle(window);
+ if (awtHandle == 0) return;
+ long /*int*/ xWindow;
+ if (OS.GTK3) {
+ xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shell.handle));
+ } else {
+ xWindow = OS.gdk_x11_drawable_get_xid(OS.gtk_widget_get_window(OS.gtk_widget_get_toplevel(shell.handle)));
+ }
+ OS.XSetTransientForHint(OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()), awtHandle, xWindow);
+ });
}
}
};
frame.getToolkit().addAWTEventListener(awtListener, AWTEvent.WINDOW_EVENT_MASK);
- final Listener shellListener = new Listener () {
- @Override
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
+ final Listener shellListener = e -> {
+ switch (e.type) {
+ case SWT.Deiconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED)));
+ break;
+ case SWT.Iconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED)));
+ break;
}
};
Shell shell = parent.getShell ();
shell.addListener (SWT.Deiconify, shellListener);
shell.addListener (SWT.Iconify, shellListener);
- Listener listener = new Listener () {
- @Override
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Dispose:
- Shell shell = parent.getShell ();
- shell.removeListener (SWT.Deiconify, shellListener);
- shell.removeListener (SWT.Iconify, shellListener);
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.getToolkit().removeAWTEventListener(awtListener);
- frame.dispose ();
- }
- });
- break;
- case SWT.Resize:
- final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- }
- });
- break;
- }
+ Listener listener = e -> {
+ switch (e.type) {
+ case SWT.Dispose:
+ Shell shell1 = parent.getShell ();
+ shell1.removeListener (SWT.Deiconify, shellListener);
+ shell1.removeListener (SWT.Iconify, shellListener);
+ parent.setVisible(false);
+ EventQueue.invokeLater(() -> {
+ frame.getToolkit().removeAWTEventListener(awtListener);
+ frame.dispose ();
+ });
+ break;
+ case SWT.Resize:
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
+ EventQueue.invokeLater(() -> frame.setSize (clientArea.width, clientArea.height));
+ break;
}
};
parent.addListener (SWT.Dispose, listener);
parent.addListener (SWT.Resize, listener);
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- frame.validate ();
- }
- });
- }
+ parent.getDisplay().asyncExec(() -> {
+ if (parent.isDisposed()) return;
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
+ EventQueue.invokeLater(() -> {
+ frame.setSize (clientArea.width, clientArea.height);
+ frame.validate ();
+ });
});
return frame;
}
@@ -313,23 +276,15 @@ public static Shell new_Shell (final Display display, final Canvas parent) {
final ComponentListener listener = new ComponentAdapter () {
@Override
public void componentResized (ComponentEvent e) {
- display.syncExec (new Runnable () {
- @Override
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize (DPIUtil.autoScaleDown(new Point(dim.width, dim.height)));
- }
+ display.syncExec (() -> {
+ if (shell.isDisposed()) return;
+ Dimension dim = parent.getSize ();
+ shell.setSize (DPIUtil.autoScaleDown(new Point(dim.width, dim.height)));
});
}
};
parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- @Override
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
+ shell.addListener(SWT.Dispose, event -> parent.removeComponentListener(listener));
shell.setVisible (true);
return shell;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
index 35cc62c76b..bb50999c3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
@@ -24,7 +24,6 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
/**
* This class provides a bridge between SWT and AWT, so that it
@@ -130,59 +129,56 @@ public static Frame new_Frame (final Composite parent) {
final long /*int*/ handle = parent.handle;
final Frame[] result = new Frame[1];
final Throwable[] exception = new Throwable[1];
- Runnable runnable = new Runnable () {
- @Override
- public void run () {
+ Runnable runnable = () -> {
+ try {
+ /*
+ * Some JREs have implemented the embedded frame constructor to take an integer
+ * and other JREs take a long. To handle this binary incompatibility, use
+ * reflection to create the embedded frame.
+ */
+ Class<?> clazz = null;
+ try {
+ String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.windows.WEmbeddedFrame";
+ clazz = Class.forName(className);
+ } catch (Throwable e3) {
+ exception[0] = e3;
+ return;
+ }
+ initializeSwing ();
+ Object value = null;
+ Constructor<?> constructor = null;
try {
- /*
- * Some JREs have implemented the embedded frame constructor to take an integer
- * and other JREs take a long. To handle this binary incompatibility, use
- * reflection to create the embedded frame.
- */
- Class<?> clazz = null;
+ constructor = clazz.getConstructor (int.class);
+ value = constructor.newInstance (new Integer ((int)/*64*/handle));
+ } catch (Throwable e1) {
try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.windows.WEmbeddedFrame";
- clazz = Class.forName(className);
- } catch (Throwable e) {
- exception[0] = e;
+ constructor = clazz.getConstructor (long.class);
+ value = constructor.newInstance (new Long (handle));
+ } catch (Throwable e2) {
+ exception[0] = e2;
return;
}
- initializeSwing ();
- Object value = null;
- Constructor<?> constructor = null;
- try {
- constructor = clazz.getConstructor (int.class);
- value = constructor.newInstance (new Integer ((int)/*64*/handle));
- } catch (Throwable e1) {
- try {
- constructor = clazz.getConstructor (long.class);
- value = constructor.newInstance (new Long (handle));
- } catch (Throwable e2) {
- exception[0] = e2;
- return;
- }
- }
- final Frame frame = (Frame) value;
+ }
+ final Frame frame = (Frame) value;
- /*
- * TEMPORARY CODE
- *
- * For some reason, the graphics configuration of the embedded
- * frame is not initialized properly. This causes an exception
- * when the depth of the screen is changed.
- */
- try {
- clazz = Class.forName("sun.awt.windows.WComponentPeer");
- Field field = clazz.getDeclaredField("winGraphicsConfig");
- field.setAccessible(true);
- field.set(frame.getPeer(), frame.getGraphicsConfiguration());
- } catch (Throwable e) {}
+ /*
+ * TEMPORARY CODE
+ *
+ * For some reason, the graphics configuration of the embedded
+ * frame is not initialized properly. This causes an exception
+ * when the depth of the screen is changed.
+ */
+ try {
+ clazz = Class.forName("sun.awt.windows.WComponentPeer");
+ Field field = clazz.getDeclaredField("winGraphicsConfig");
+ field.setAccessible(true);
+ field.set(frame.getPeer(), frame.getGraphicsConfiguration());
+ } catch (Throwable e4) {}
- result[0] = frame;
- } finally {
- synchronized(result) {
- result.notify();
- }
+ result[0] = frame;
+ } finally {
+ synchronized(result) {
+ result.notify();
}
}
};
@@ -216,27 +212,14 @@ public static Frame new_Frame (final Composite parent) {
parent.setData(EMBEDDED_FRAME_KEY, frame);
/* Forward the iconify and deiconify events */
- final Listener shellListener = new Listener () {
- @Override
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
+ final Listener shellListener = e -> {
+ switch (e.type) {
+ case SWT.Deiconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED)));
+ break;
+ case SWT.Iconify:
+ EventQueue.invokeLater(() -> frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED)));
+ break;
}
};
Shell shell = parent.getShell ();
@@ -248,71 +231,53 @@ public static Frame new_Frame (final Composite parent) {
* the embedded frame. This is needed in order to make keyboard
* focus work properly for lightweights.
*/
- Listener listener = new Listener () {
- @Override
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Dispose:
- Shell shell = parent.getShell ();
- shell.removeListener (SWT.Deiconify, shellListener);
- shell.removeListener (SWT.Iconify, shellListener);
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- try {
- frame.dispose ();
- } catch (Throwable e) {}
- }
- });
- break;
- case SWT.FocusIn:
- case SWT.Activate:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- if (frame.isActive()) return;
- try {
- Class<?> clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
- if (method != null) method.invoke(frame, Boolean.TRUE);
- } catch (Throwable e) {}
- }
- });
- break;
- case SWT.Deactivate:
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- if (!frame.isActive()) return;
- try {
- Class<?> clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
- if (method != null) method.invoke(frame, Boolean.FALSE);
- } catch (Throwable e) {}
- }
- });
- break;
- }
+ Listener listener = e -> {
+ switch (e.type) {
+ case SWT.Dispose:
+ Shell shell1 = parent.getShell ();
+ shell1.removeListener (SWT.Deiconify, shellListener);
+ shell1.removeListener (SWT.Iconify, shellListener);
+ parent.setVisible(false);
+ EventQueue.invokeLater(() -> {
+ try {
+ frame.dispose ();
+ } catch (Throwable e1) {}
+ });
+ break;
+ case SWT.FocusIn:
+ case SWT.Activate:
+ EventQueue.invokeLater(() -> {
+ if (frame.isActive()) return;
+ try {
+ Class<?> clazz = frame.getClass();
+ Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
+ if (method != null) method.invoke(frame, Boolean.TRUE);
+ } catch (Throwable e1) {}
+ });
+ break;
+ case SWT.Deactivate:
+ EventQueue.invokeLater(() -> {
+ if (!frame.isActive()) return;
+ try {
+ Class<?> clazz = frame.getClass();
+ Method method = clazz.getMethod("synthesizeWindowActivation", boolean.class);
+ if (method != null) method.invoke(frame, Boolean.FALSE);
+ } catch (Throwable e1) {}
+ });
+ break;
}
};
parent.addListener (SWT.FocusIn, listener);
parent.addListener (SWT.Deactivate, listener);
parent.addListener (SWT.Dispose, listener);
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); // To Pixels
- EventQueue.invokeLater(new Runnable () {
- @Override
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- frame.validate ();
- }
- });
- }
+ parent.getDisplay().asyncExec(() -> {
+ if (parent.isDisposed()) return;
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); // To Pixels
+ EventQueue.invokeLater(() -> {
+ frame.setSize (clientArea.width, clientArea.height);
+ frame.validate ();
+ });
});
return frame;
}
@@ -349,23 +314,15 @@ public static Shell new_Shell (final Display display, final Canvas parent) {
final ComponentListener listener = new ComponentAdapter () {
@Override
public void componentResized (ComponentEvent e) {
- display.syncExec (new Runnable () {
- @Override
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize(DPIUtil.autoScaleDown(new Point(dim.width, dim.height))); // To Points
- }
+ display.syncExec (() -> {
+ if (shell.isDisposed()) return;
+ Dimension dim = parent.getSize ();
+ shell.setSize(DPIUtil.autoScaleDown(new Point(dim.width, dim.height))); // To Points
});
}
};
parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- @Override
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
+ shell.addListener(SWT.Dispose, event -> parent.removeComponentListener(listener));
shell.setVisible (true);
return shell;
}

Back to the top