Java Code Examples for org.eclipse.swt.SWT#TOOL
The following examples show how to use
org.eclipse.swt.SWT#TOOL .
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: GridToolTip.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Creates an inplace tooltip. * * @param parent parent control. */ public GridToolTip(final Control parent) { super(parent, SWT.NONE); shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); parent.addListener(SWT.Dispose, new Listener() { public void handleEvent(Event arg0) { shell.dispose(); dispose(); } }); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { onPaint(e.gc); } }); }
Example 2
Source File: SWTUtil.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) */ @Override public void mouseDown(MouseEvent e) { Control theControl = (Control) e.widget; Display display = theControl.getDisplay(); Shell tip = new Shell(theControl.getShell(), SWT.ON_TOP | SWT.TOOL); tip.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); FillLayout layout = new FillLayout(); layout.marginHeight = 1; layout.marginWidth = 2; tip.setLayout(layout); Label label = new Label(tip, SWT.NONE); label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label.setText(theControl.getToolTipText()); label.addMouseTrackListener(this); Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rect = theControl.getBounds(); Point pt = theControl.getParent().toDisplay(rect.x, rect.y); tip.setBounds(pt.x, pt.y, size.x, size.y); tip.setVisible(true); }
Example 3
Source File: PopOverShell.java From swt-bling with MIT License | 6 votes |
/** * Provides the backbone for Custom Widgets that need a <code>Shell</code> popped over a <code>Control</code> or * <code>CustomElementDataProvider</code>. If you're using a <code>CustomElementDataProvider</code>, pass the * <code>CustomElementDataProvider.getPaintedElement()</code> as the parentControl. * @param parentControl The control you want the PopOverShell to appear above. In the case of * <code>CustomElementDataProvider</code>, pass * <code>CustomElementDataProvider.getPaintedElement()</code>. * @param customElementDataProvider The <code>CustomElementDataProvider</code> you want the PopOverShell to appear * above (or null if you're using a Control) */ public PopOverShell(Control parentControl, CustomElementDataProvider customElementDataProvider) { super(parentControl, SWT.NONE); displaySafe = new DisplaySafe(); if (customElementDataProvider != null) { poppedOverItem = new PoppedOverItem(customElementDataProvider); } else { poppedOverItem = new PoppedOverItem(parentControl); } this.parentControl = parentControl; parentShell = AncestryHelper.getShellFromControl(poppedOverItem.getControl()); backgroundColor = ColorFactory.getColor(getDisplay(), BACKGROUND_COLOR); // SWT.TOOL adds a drop shadow on supported platforms popOverShell = new Shell(parentShell, SWT.NO_TRIM | SWT.TOOL); popOverShell.setBackground(backgroundColor); popOverShell.setLayout(new FillLayout()); attachListeners(); }
Example 4
Source File: ToolTipHandler.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new tooltip handler * * @param parent the parent Shell */ public ToolTipHandler(Shell parent) { final Display display = parent.getDisplay(); this.parentShell = parent; tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.marginWidth = 2; gridLayout.marginHeight = 2; tipShell.setLayout(gridLayout); tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); tipLabelImage = new Label(tipShell, SWT.NONE); tipLabelImage.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); tipLabelImage.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); tipLabelImage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); tipLabelText = new Label(tipShell, SWT.NONE); tipLabelText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); tipLabelText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); tipLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); }
Example 5
Source File: GridToolTip.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Creates an inplace tooltip. * * @param parent parent control. */ public GridToolTip(final Control parent) { super(parent, SWT.NONE); shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); parent.addListener(SWT.Dispose, new Listener() { public void handleEvent(Event arg0) { shell.dispose(); dispose(); } }); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { onPaint(e.gc); } }); }
Example 6
Source File: GridToolTip.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Creates an inplace tooltip. * * @param parent parent control. */ public GridToolTip(final Control parent) { super(parent, SWT.NONE); shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); parent.addListener(SWT.Dispose, new Listener() { public void handleEvent(Event arg0) { shell.dispose(); dispose(); } }); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { onPaint(e.gc); } }); }
Example 7
Source File: AbstractCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Creates the popup that will be displayed when the button is selected. * Popup is a new Shell containing a unique Control. The content is specific * to each implementation of the Combo and is created overriding the * createPopupContent method. */ protected void createPopup() { popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP); popupContent = createPopupContent(popup); popupContent.setFont(text.getFont()); popupContent.setBackground(text.getBackground()); popupContent.setForeground(text.getForeground()); popup.pack(); popup.addListener(SWT.Close, listener); popup.addListener(SWT.Deactivate, listener); popupContent.addListener(SWT.FocusIn, listener); popupContent.addListener(SWT.Selection, listener); }
Example 8
Source File: BufferDialog.java From e4macs with Eclipse Public License 1.0 | 5 votes |
void showTip(String txt, ItemPkg tp, Table table) { tip = new Shell((Shell) null, SWT.ON_TOP | SWT.TOOL); tip.setLayout(new FillLayout()); tip.setBackground(table.getBackground()); createBufferTip(tip, (IEditorReference)getSelectables().get(txt)); Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rect = tp.getBounds(); Point pt = table.toDisplay(rect.x + getSizeAdjustment(), rect.y - size.y); tip.setBounds(pt.x, pt.y, size.x, size.y); tip.setVisible(true); }
Example 9
Source File: MetaXDialog.java From e4macs with Eclipse Public License 1.0 | 5 votes |
void showTip(String txt, ItemPkg tp, Table table) { tip = new Shell((Shell) null, SWT.ON_TOP | SWT.TOOL); tip.setLayout(new FillLayout()); tip.setBackground(table.getBackground()); createCommandTip(tip, (Command) getSelectables().get(txt)); Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rect = tp.getBounds(); Point pt = table.toDisplay(rect.x + getSizeAdjustment(), rect.y - size.y); tip.setBounds(pt.x, pt.y, size.x, size.y); tip.setVisible(true); }
Example 10
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void open() { // Must cache here, since editor context is not available in menu from popup shell: fOpenDialogBinding= getOpenDialogBinding(); Shell workbenchShell= fEditor.getSite().getShell(); final Display display= workbenchShell.getDisplay(); fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL); fPopupLayout= new GridLayout(2, false); fPopupLayout.marginWidth= 1; fPopupLayout.marginHeight= 1; fPopupLayout.marginLeft= 4; fPopupLayout.horizontalSpacing= 0; fPopup.setLayout(fPopupLayout); createContent(fPopup); updatePopupLocation(true); new PopupVisibilityManager().start(); // Leave linked mode when popup loses focus // (except when focus goes back to workbench window or menu is open): fPopup.addShellListener(new ShellAdapter() { @Override public void shellDeactivated(ShellEvent e) { if (fIsMenuUp) return; final Shell editorShell= fEditor.getSite().getShell(); display.asyncExec(new Runnable() { // post to UI thread since editor shell only gets activated after popup has lost focus public void run() { Shell activeShell= display.getActiveShell(); if (activeShell != editorShell) { fRenameLinkedMode.cancel(); } } }); } }); if (! MAC) { // carbon and cocoa draw their own border... fPopup.addPaintListener(new PaintListener() { public void paintControl(PaintEvent pe) { pe.gc.drawPolygon(getPolygon(true)); } }); } // fPopup.moveBelow(null); // make sure hovers are on top of the info popup // XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774 // fPopup.moveBelow(workbenchShell.getShells()[0]); UIJob delayJob= new UIJob(display, ReorgMessages.RenameInformationPopup_delayJobName) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { fDelayJobFinished= true; if (fPopup != null && ! fPopup.isDisposed()) { updateVisibility(); } return Status.OK_STATUS; } }; delayJob.setSystem(true); delayJob.setPriority(Job.INTERACTIVE); delayJob.schedule(POPUP_VISIBILITY_DELAY); }
Example 11
Source File: RenameInformationPopup.java From typescript.java with MIT License | 4 votes |
public void open() { // Must cache here, since editor context is not available in menu from popup shell: fOpenDialogBinding= getOpenDialogBinding(); Shell workbenchShell= fEditor.getSite().getShell(); final Display display= workbenchShell.getDisplay(); fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL); fPopupLayout= new GridLayout(3, false); fPopupLayout.marginWidth= 1; fPopupLayout.marginHeight= 1; fPopupLayout.marginLeft= 4; fPopupLayout.horizontalSpacing= 0; fPopup.setLayout(fPopupLayout); createContent(fPopup); updatePopupLocation(true); new PopupVisibilityManager().start(); // Leave linked mode when popup loses focus // (except when focus goes back to workbench window or menu is open): fPopup.addShellListener(new ShellAdapter() { @Override public void shellDeactivated(ShellEvent e) { if (fIsMenuUp) return; final Shell editorShell= fEditor.getSite().getShell(); display.asyncExec(new Runnable() { // post to UI thread since editor shell only gets activated after popup has lost focus @Override public void run() { Shell activeShell= display.getActiveShell(); if (activeShell != editorShell) { fRenameLinkedMode.cancel(); } } }); } }); if (! MAC) { // carbon and cocoa draw their own border... fPopup.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent pe) { pe.gc.drawPolygon(getPolygon(true)); } }); } // fPopup.moveBelow(null); // make sure hovers are on top of the info popup // XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774 // fPopup.moveBelow(workbenchShell.getShells()[0]); UIJob delayJob= new UIJob(display, RefactoringMessages.RenameInformationPopup_delayJobName) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { fDelayJobFinished= true; if (fPopup != null && ! fPopup.isDisposed()) { updateVisibility(); } return Status.OK_STATUS; } }; delayJob.setSystem(true); delayJob.setPriority(Job.INTERACTIVE); delayJob.schedule(POPUP_VISIBILITY_DELAY); }
Example 12
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(); }
Example 13
Source File: RenameRefactoringPopup.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void open() { // Must cache here, since editor context is not available in menu from popup shell: openDialogBinding = getOpenDialogBinding(); Shell workbenchShell = editor.getSite().getShell(); final Display display = workbenchShell.getDisplay(); popup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL); popupLayout = new GridLayout(2, false); popupLayout.marginWidth = 1; popupLayout.marginHeight = 1; popupLayout.marginLeft = 4; popupLayout.horizontalSpacing = 0; popup.setLayout(popupLayout); createContent(popup); updatePopupLocation(); new PopupVisibilityManager().start(); // Leave linked mode when popup loses focus // (except when focus goes back to workbench window or menu is open): popup.addShellListener(new ShellAdapter() { @Override public void shellDeactivated(ShellEvent e) { if (iSMenuUp) return; final Shell editorShell = editor.getSite().getShell(); display.asyncExec(new Runnable() { // post to UI thread since editor shell only gets activated after popup has lost focus @Override public void run() { Shell activeShell = display.getActiveShell(); if (activeShell != editorShell) { controller.cancelLinkedMode(); } } }); } }); if (!MAC) { // carbon and cocoa draw their own border... popup.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent pe) { pe.gc.drawPolygon(getPolygon(true)); } }); } UIJob delayJob = new UIJob(display, "Delayed RenameInformationPopup") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { delayJobFinished = true; if (popup != null && !popup.isDisposed()) { updateVisibility(); } return Status.OK_STATUS; } }; delayJob.setSystem(true); delayJob.setPriority(Job.INTERACTIVE); delayJob.schedule(POPUP_VISIBILITY_DELAY); }
Example 14
Source File: TypeScriptSourceViewerConfiguration.java From typescript.java with MIT License | 3 votes |
/** * Returns the information presenter control creator. The creator is a * factory creating the presenter controls for the given source viewer. * This implementation always returns a creator for * <code>DefaultInformationControl</code> instances. * * @param sourceViewer * the source viewer to be configured by this configuration * @return an information control creator * */ private IInformationControlCreator getInformationPresenterControlCreator(final ISourceViewer sourceViewer) { return new IInformationControlCreator() { public IInformationControl createInformationControl(final Shell parent) { int shellStyle = SWT.RESIZE | SWT.TOOL; int style = SWT.V_SCROLL | SWT.H_SCROLL; return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false)); } }; }
Example 15
Source File: CustomAbstractInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates an abstract information control with the given shell as parent. The control will be resizable and * optionally show a tool bar managed by the given tool bar manager. * <p> * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> * </p> * * @param parentShell * the parent of this control's shell * @param toolBarManager * the manager or <code>null</code> if toolbar is not desired */ public CustomAbstractInformationControl(Shell parentShell, ToolBarManager toolBarManager) { this(parentShell, SWT.TOOL | SWT.ON_TOP | SWT.RESIZE, null, toolBarManager); }
Example 16
Source File: CustomAbstractInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates an abstract information control with the given shell as parent. * <p> * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> * </p> * * @param parentShell * the parent of this control's shell * @param isResizable * <code>true</code> if the control should be resizable */ public CustomAbstractInformationControl(Shell parentShell, boolean isResizable) { this(parentShell, SWT.TOOL | SWT.ON_TOP | (isResizable ? SWT.RESIZE : 0), null, null); }
Example 17
Source File: SourceViewerInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates a source viewer information control with the given shell as * parent and the given font. * * @param parent the parent shell * @param symbolicFontName the symbolic font name */ public SourceViewerInformationControl(Shell parent, String symbolicFontName) { this(parent, SWT.NO_TRIM | SWT.TOOL, SWT.NONE, symbolicFontName, null); }
Example 18
Source File: CustomAbstractInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates an abstract information control with the given shell as parent. The control will not be resizable and * optionally show a status line with the given status field text. * <p> * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> * </p> * * @param parentShell * the parent of this control's shell * @param statusFieldText * the text to be used in the status field or <code>null</code> to hide the status field */ public CustomAbstractInformationControl(Shell parentShell, String statusFieldText) { this(parentShell, SWT.TOOL | SWT.ON_TOP, statusFieldText, null); }
Example 19
Source File: InformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates a default information control with the given shell as parent. The given * information presenter is used to process the information to be displayed. The given * styles are applied to the created styled text widget. * * @param parent the parent shell * @param style the additional styles for the styled text widget * @param presenter the presenter to be used * @param statusFieldText the text to be used in the optional status field * or <code>null</code> if the status field should be hidden * @since 3.0 */ public InformationControl(Shell parent, int style, IInformationPresenter presenter, String statusFieldText) { this(parent, SWT.TOOL | SWT.NO_TRIM, style, presenter, statusFieldText); }
Example 20
Source File: InformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Creates a default information control with the given shell as parent. The given * information presenter is used to process the information to be displayed. The given * styles are applied to the created styled text widget. * * @param parent the parent shell * @param style the additional styles for the styled text widget * @param presenter the presenter to be used */ public InformationControl(Shell parent,int style, IInformationPresenter presenter) { this(parent, SWT.TOOL | SWT.NO_TRIM, style, presenter); }