Java Code Examples for org.eclipse.swt.widgets.Display#getFocusControl()
The following examples show how to use
org.eclipse.swt.widgets.Display#getFocusControl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentAssistText.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void paintControlBorder(final PaintEvent e) { final GC gc = e.gc; final Display display = e.display; if (display != null && gc != null && !gc.isDisposed()) { final Control focused = display.getFocusControl(); final GC parentGC = gc; parentGC.setAdvanced(true); final Rectangle r = ContentAssistText.this.getBounds(); if (focused == null || focused.getParent() != null && !focused.getParent().equals(ContentAssistText.this)) { parentGC.setForeground(display.getSystemColor(SWT.COLOR_GRAY)); } else { parentGC.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BORDER)); } parentGC.setLineWidth(1); parentGC.drawRectangle(0, 0, r.width - 1, r.height - 1); } }
Example 2
Source File: InformationPresenterControlManager.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void setInitiallyActiveShell(Shell activeShell) { this.fInitiallyActiveShell = activeShell; this.fFocusControl = null; if (activeShell != null) { Display display = activeShell.getDisplay(); if (display != null) { this.fFocusControl = display.getFocusControl(); } } }
Example 3
Source File: EditableControlWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void drawBorder(final Composite container, Event e) { final GC gc = e.gc; final Display display = e.display; if (display != null && gc != null && !gc.isDisposed()) { final Control focused = display.getFocusControl(); gc.setAdvanced(true); gc.setForeground(getBorderColor(focused, container)); gc.setLineWidth(1); final Rectangle r = container.getBounds(); gc.drawRectangle(0, 0, r.width - 1, r.height - 1); } }
Example 4
Source File: BonitaSashForm.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected boolean isFocusAncestorA (Control control) { Display display = getDisplay (); Control focusControl = display.getFocusControl (); while (focusControl != null && focusControl != control) { focusControl = focusControl. getParent(); } return control == focusControl; }
Example 5
Source File: BalloonNotification.java From saros with GNU General Public License v2.0 | 4 votes |
/** * Opens a notification window next to a control. The notification window will show the given * title as the title of the balloon, The given text as the description. * * <p>The window will be hidden automatically after the value specified in the timeout expires * * <p><b>Note:</b> The balloon window is always anchored to the given control at position (0,0). * Specifying the balloon window anchor is relative to this point. * * <p>TODO wrap the contents so the balloon notification does not expand across two screens for a * long text. OR even better: do not show long notifications. users tend to ignore them anyway! * * @param control the control, next to where the widget will appear * @param anchor the anchor of the balloon window * @param title the title of the balloon * @param text the text to display as contents */ public static void showNotification(Control control, int anchor, String title, String text) { if (control != null && control.isDisposed()) { control = null; } /* * show message at least 8 secs, but show it longer for longer messages * Referenced by wikipedia, a user can read 2,5 words per second so we * approximate 400ms per word */ int timeout = Math.max(8000, text.split("\\s").length * 400); // close all previous balloon notifications like it is done in // windows to prevent overlapping of multiple balloons... BalloonNotification.removeAllActiveNotifications(); final BalloonWindow window = new BalloonWindow( control != null ? control.getShell() : null, SWT.NO_FOCUS | SWT.TOOL | SWT.TITLE); window.setAnchor(anchor); windows.add(window); /* * Note: if you add SWT.CLOSE to the style of the BalloonWindow, it will * only be closed when directly clicking on the close icon (x) and * therefore break user expectations. FIXME: find out a way to display * the closing X AND make the bubble close on any click anywhere on it. */ window.setText(title); /* * Adding the text to the contents. Pack() is required so the size of * the composite is recalculated, else the contents won't show */ Composite content = window.getContents(); content.setLayout(new FillLayout()); Label message = new Label(content, SWT.NONE); message.setText(text); content.pack(true); message.setBackground(WHITE); message.setForeground(BLACK); // make window close when clicking on balloon text, too window.addSelectionControl(message); // Locate the balloon to the widget location if (control != null) { Point widgetLocation = control.toDisplay(new Point(0, 0)); window.setLocation(widgetLocation); } // Runnable that will close the window after time has been expired final Runnable closeWindow = ThreadUtils.wrapSafe( log, new Runnable() { @Override public void run() { final Shell shell = window.getShell(); if (shell.isDisposed()) return; window.close(); } }); window.getShell().getDisplay().timerExec(timeout, closeWindow); Display display = control != null ? control.getDisplay() : Display.getCurrent(); Control lastControlWithFocus = display != null ? display.getFocusControl() : null; window.open(); if (lastControlWithFocus != null) lastControlWithFocus.setFocus(); }