private void asyncClose() { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=152010 getShell().getDisplay().asyncExec(new Runnable() { public void run() { close(); } }); }
private void asyncClose() { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=152010 Shell shell = getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(() -> close()); } }
public void handleEvent(Event event) { /* * Close if we are deactivating and have no child shells. If we * have child shells, we are deactivating due to their opening. * On X, we receive this when a menu child (such as the system * menu) of the shell opens, but I have not found a way to * distinguish that case here. Hence bug #113577 still exists. */ if (listenToDeactivate && event.widget == getShell() && getShell().getShells().length == 0) { asyncClose(); } else { /* * We typically ignore deactivates to work around * platform-specific event ordering. Now that we've ignored * whatever we were supposed to, start listening to * deactivates. Example issues can be found in * https://bugs.eclipse.org/bugs/show_bug.cgi?id=123392 */ listenToDeactivate = true; } } });
/** * Return the default background color used for popup dialogs. * * @return the default background color */ private Color getDefaultBackground() { return getShell().getDisplay() .getSystemColor(SWT.COLOR_INFO_BACKGROUND); }
public void handleEvent(Event event) { // ignore this event if we have launched a child if (event.widget == getShell() && getShell().getShells().length == 0) { listenToDeactivate = true; // Typically we start listening for parent deactivate after // we are activated, except on the Mac, where the deactivate // is received after activate. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=100668 listenToParentDeactivate = !Util.isMac(); } } });
private void asyncClose() { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=152010 Shell shell = getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(() -> close()); } }
/** * Return the default foreground color used for popup dialogs. * * @return the default foreground color. */ private Color getDefaultForeground() { return getShell().getDisplay() .getSystemColor(SWT.COLOR_INFO_FOREGROUND); }
/** * Return the default foreground color used for popup dialogs. * * @return the default foreground color. */ private Color getDefaultForeground() { return getShell().getDisplay() .getSystemColor(SWT.COLOR_INFO_FOREGROUND); }
/** * Return the default background color used for popup dialogs. * * @return the default background color */ private Color getDefaultBackground() { return getShell().getDisplay() .getSystemColor(SWT.COLOR_INFO_BACKGROUND); }
/** * Show the dialog's menu. This message has no effect if the receiver was * not configured to show a menu. Clients may call this method in order to * trigger the menu via keystrokes or other gestures. Subclasses typically * do not override method. */ protected void showDialogMenu() { if (!showDialogMenu) { return; } if (menuManager == null) { menuManager = new MenuManager(); fillDialogMenu(menuManager); } // Setting this flag works around a problem that remains on X only, // whereby activating the menu deactivates our shell. listenToDeactivate = !Util.isGtk(); Menu menu = menuManager.createContextMenu(getShell()); Rectangle bounds = toolBar.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = getShell().toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
/** * Show the dialog's menu. This message has no effect if the receiver was * not configured to show a menu. Clients may call this method in order to * trigger the menu via keystrokes or other gestures. Subclasses typically * do not override method. */ protected void showDialogMenu() { if (!showDialogMenu) { return; } if (menuManager == null) { menuManager = new MenuManager(); fillDialogMenu(menuManager); } // Setting this flag works around a problem that remains on X only, // whereby activating the menu deactivates our shell. listenToDeactivate = !Util.isGtk(); Menu menu = menuManager.createContextMenu(getShell()); Rectangle bounds = toolBar.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = getShell().toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
/** * Show the dialog's menu. This message has no effect if the receiver was * not configured to show a menu. Clients may call this method in order to * trigger the menu via keystrokes or other gestures. Subclasses typically * do not override method. */ protected void showDialogMenu() { if (!showDialogMenu) { return; } if (menuManager == null) { menuManager = new MenuManager(); fillDialogMenu(menuManager); } // Setting this flag works around a problem that remains on X only, // whereby activating the menu deactivates our shell. listenToDeactivate = !Util.isGtk(); Menu menu = menuManager.createContextMenu(getShell()); Rectangle bounds = toolBar.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = getShell().toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
/** * Perform the requested tracker action (resize or move). * * @param style * The track style (resize or move). */ private void performTrackerAction(int style) { Shell shell = getShell(); if (shell == null || shell.isDisposed()) { return; } Tracker tracker = new Tracker(shell.getDisplay(), style); tracker.setStippled(true); Rectangle[] r = new Rectangle[] { shell.getBounds() }; tracker.setRectangles(r); // Ignore any deactivate events caused by opening the tracker. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=120656 boolean oldListenToDeactivate = listenToDeactivate; listenToDeactivate = false; if (tracker.open()) { if (!shell.isDisposed()) { shell.setBounds(tracker.getRectangles()[0]); } } tracker.dispose(); listenToDeactivate = oldListenToDeactivate; }
/** * Perform the requested tracker action (resize or move). * * @param style * The track style (resize or move). */ private void performTrackerAction(int style) { Shell shell = getShell(); if (shell == null || shell.isDisposed()) { return; } Tracker tracker = new Tracker(shell.getDisplay(), style); tracker.setStippled(true); Rectangle[] r = new Rectangle[] { shell.getBounds() }; tracker.setRectangles(r); // Ignore any deactivate events caused by opening the tracker. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=120656 boolean oldListenToDeactivate = listenToDeactivate; listenToDeactivate = false; if (tracker.open()) { if (!shell.isDisposed()) { shell.setBounds(tracker.getRectangles()[0]); } } tracker.dispose(); listenToDeactivate = oldListenToDeactivate; }
@Override public Object execute(ExecutionEvent event) { if (popupDialog != null && popupDialog.getShell() != null && !popupDialog.getShell().isDisposed()) { popupDialog.close(); } Shell shell = HandlerUtil.getActiveShell(event); if (shell != null) { Display display = shell.getDisplay(); display.addFilter(SWT.Selection, this); display.addFilter(SWT.KeyDown, this); display.addFilter(SWT.Show, this); if (display.getActiveShell() != null) { defaultCursor = display.getActiveShell().getCursor(); Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_MENUSPY_OBJ); spyCursor = new Cursor(display, image.getImageData(), 7, 7); display.getActiveShell().setCursor(spyCursor); } } return null; }