org.eclipse.swt.widgets.ToolTip Java Examples
The following examples show how to use
org.eclipse.swt.widgets.ToolTip.
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: RESTRequestReconnectionValidation.java From tesb-studio-se with Apache License 2.0 | 7 votes |
@Override public boolean canConnectToSource(INode oldSource, INode newSource, INode target, EConnectionType lineStyle, String connectorName, String connectionName) { if (oldSource != null && newSource != null && (T_REST_REQUEST.equals(newSource.getComponent().getName()) || T_REST_REQUEST .equals(oldSource.getComponent().getName()))) { ToolTip tooltip = new ToolTip(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), SWT.ICON_WARNING); tooltip.setText(Messages.RESTRequestReconnectionValidation_WarningMsg); // tooltip.setMessage("It's not allowed to reconnect to or from a tRESTRequest component"); tooltip.setAutoHide(true); tooltip.setVisible(true); return false; } return true; }
Example #2
Source File: SwtGatewayTray.java From davmail with GNU General Public License v2.0 | 6 votes |
/** * Log and display balloon message according to log level. * * @param message text message * @param level log level */ public void displayMessage(final String message, final Level level) { if (trayItem != null) { display.asyncExec(() -> { int messageType = 0; if (level.equals(Level.INFO)) { messageType = SWT.ICON_INFORMATION; } else if (level.equals(Level.WARN)) { messageType = SWT.ICON_WARNING; } else if (level.equals(Level.ERROR)) { messageType = SWT.ICON_ERROR; } if (messageType != 0) { final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | messageType); toolTip.setText(BundleMessage.format("UI_DAVMAIL_GATEWAY")); toolTip.setMessage(message); trayItem.setToolTip(toolTip); // Wait for tray init 1 second on first message if (firstMessage) { firstMessage = false; try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } toolTip.setVisible(true); } trayItem.setToolTipText(BundleMessage.format("UI_DAVMAIL_GATEWAY") + '\n' + message); }); } }
Example #3
Source File: Utils.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
private static void showToolTipSWTwidget(Control control, int style, String title, String message) { ToolTip tooltip = new ToolTip(control.getShell(), /*SWT.BALLOON | */ style); tooltip.setAutoHide(true); tooltip.setLocation(control.toDisplay(control.getSize().x/2, control.getSize().y + 5)); tooltip.setText(title); tooltip.setMessage(message); tooltip.setVisible(true); }
Example #4
Source File: Utils.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
private static void showToolTipSWTJface(Control control, int style, String title, String message) { DefaultToolTip tooltip = new DefaultToolTip(control, org.eclipse.jface.window.ToolTip.NO_RECREATE, true); tooltip.setHideDelay(TOOLTIP_HIDE_DELAY); tooltip.setText("[" + title+ "]\n\n" + message); tooltip.setImage(control.getDisplay().getSystemImage(/*SWT.ICON_INFORMATION*/ style)); tooltip.show(control.toDisplay(control.getSize().x/2, 5)); }
Example #5
Source File: AsyncExecApplicationMain.java From logbook with MIT License | 5 votes |
@Override public void run() { // 現在時刻 Date now = Calendar.getInstance().getTime(); List<String> notice = new ArrayList<String>(); boolean visibleHome = false; // 遠征を更新する if (this.updateDeck(now, notice)) { PlayerThread.randomExpeditionSoundPlay(); visibleHome |= AppConfig.get().isVisibleOnReturnMission(); } // 入渠を更新する if (this.updateNdock(now, notice)) { PlayerThread.randomDockSoundPlay(); visibleHome |= AppConfig.get().isVisibleOnReturnBathwater(); } if (visibleHome) { this.main.getTabFolder().setSelection(0); } if (AppConfig.get().isUseBalloon()) { // バルーンツールチップを表示する try { // 遠征・入渠のお知らせ if (notice.size() > 0) { ToolTip tip = new ToolTip(this.main.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION); tip.setText("遠征・入渠"); tip.setMessage(StringUtils.join(notice, "\r\n")); this.main.getTrayItem().setToolTip(tip); tip.setVisible(true); } } catch (Exception e) { LoggerHolder.LOG.warn("お知らせの表示に失敗しました", e); } } }
Example #6
Source File: FleetComposite.java From logbook with MIT License | 5 votes |
/** * 艦隊が出撃中で大破した場合に警告を行います */ private void postFatal() { if (this.badlyDamage && GlobalContext.isSortie(this.dock.getId())) { if (AppConfig.get().isBalloonBybadlyDamage()) { List<ShipDto> ships = this.dock.getShips(); StringBuilder sb = new StringBuilder(); sb.append(AppConstants.MESSAGE_STOP_SORTIE); sb.append("\n"); for (ShipDto shipDto : ships) { if (shipDto.isBadlyDamage()) { sb.append(shipDto.getName()); sb.append("(" + shipDto.getLv() + ")"); sb.append(" : "); List<ItemDto> items = shipDto.getItem(); List<String> names = new ArrayList<String>(); for (ItemDto itemDto : items) { if (itemDto != null) { names.add(itemDto.getName()); } } sb.append(StringUtils.join(names, ",")); sb.append("\n"); } } ToolTip tip = new ToolTip(this.getShell(), SWT.BALLOON | SWT.ICON_ERROR); tip.setText("大破警告"); tip.setMessage(sb.toString()); this.main.getTrayItem().setToolTip(tip); tip.setVisible(true); } // 大破時にサウンドを再生する PlayerThread.randomBadlySoundPlay(); } }
Example #7
Source File: HorizontalSpinnerSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void createSpinnerGroup(final Shell shell) { final Group group = new Group(shell, SWT.NONE); group.setLayout(new GridLayout(1, false)); final Label lbl1 = new Label(group, SWT.NONE); lbl1.setText("Simple vertical spinner :"); final Spinner spinner1 = new Spinner(group, SWT.BORDER); spinner1.setMinimum(0); spinner1.setMaximum(1000); spinner1.setSelection(500); spinner1.setIncrement(1); spinner1.setPageIncrement(100); final Label lbl2 = new Label(group, SWT.NONE); lbl2.setText("Floating point values in Spinner :"); final Spinner spinner2 = new Spinner(group, SWT.NONE); // allow 3 decimal places spinner2.setDigits(3); // set the minimum value to 0.001 spinner2.setMinimum(1); // set the maximum value to 20 spinner2.setMaximum(20000); // set the increment value to 0.010 spinner2.setIncrement(10); // set the seletion to 3.456 spinner2.setSelection(3456); spinner2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final int selection = spinner2.getSelection(); final int digits = spinner2.getDigits(); System.out.println("Selection is " + selection / Math.pow(10, digits)); } }); final Label lbl3 = new Label(group, SWT.NONE); lbl3.setText("Validate input in a spinner widget :"); final Spinner spinner3 = new Spinner(group, SWT.BORDER); spinner3.setValues(0, -100, 100, 0, 1, 10); spinner3.setLayoutData(new GridData(200, SWT.DEFAULT)); final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_WARNING); spinner3.addModifyListener(e -> { final String string = spinner3.getText(); String message = null; try { final int value = Integer.parseInt(string); final int maximum = spinner3.getMaximum(); final int minimum = spinner3.getMinimum(); if (value > maximum) { message = "Current input is greater than the maximum limit (" + maximum + ")"; } else if (value < minimum) { message = "Current input is less than the minimum limit (" + minimum + ")"; } } catch (final Exception ex) { message = "Current input is not numeric"; } if (message != null) { spinner3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_RED)); final Rectangle rect = spinner3.getBounds(); final GC gc = new GC(spinner3); final Point pt = gc.textExtent(string); gc.dispose(); toolTip.setLocation(shell.getDisplay().map(shell, null, rect.x + pt.x, rect.y + rect.height)); toolTip.setMessage(message); toolTip.setVisible(true); } else { toolTip.setVisible(false); spinner3.setForeground(null); } }); }
Example #8
Source File: HorizontalSpinnerSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void createHorizontalSpinnerGroup(final Shell shell, final String title, final int style) { final Group group = new Group(shell, SWT.NONE); group.setLayout(new GridLayout(1, false)); group.setText(title); final Label lbl1 = new Label(group, SWT.NONE); lbl1.setText("Simple horizontal spinner :"); final HorizontalSpinner spinner1 = new HorizontalSpinner(group, SWT.BORDER | style); spinner1.setMinimum(0); spinner1.setMaximum(1000); spinner1.setSelection(500); spinner1.setIncrement(1); spinner1.setPageIncrement(100); final Label lbl2 = new Label(group, SWT.NONE); lbl2.setText("Floating point values in Spinner :"); final HorizontalSpinner spinner2 = new HorizontalSpinner(group, style); // allow 3 decimal places spinner2.setDigits(3); // set the minimum value to 0.001 spinner2.setMinimum(1); // set the maximum value to 20 spinner2.setMaximum(20000); // set the increment value to 0.010 spinner2.setIncrement(10); // set the seletion to 3.456 spinner2.setSelection(3456); spinner2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final int selection = spinner2.getSelection(); final int digits = spinner2.getDigits(); System.out.println("Selection is " + selection / Math.pow(10, digits)); } }); final Label lbl3 = new Label(group, SWT.NONE); lbl3.setText("Validate input in a spinner widget :"); final HorizontalSpinner spinner3 = new HorizontalSpinner(group, SWT.BORDER | style); spinner3.setValues(0, -100, 100, 0, 1, 10); spinner3.setLayoutData(new GridData(200, SWT.DEFAULT)); final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_WARNING); spinner3.addModifyListener(e -> { final String string = spinner3.getText(); String message = null; try { final int value = Integer.parseInt(string); final int maximum = spinner3.getMaximum(); final int minimum = spinner3.getMinimum(); if (value > maximum) { message = "Current input is greater than the maximum limit (" + maximum + ")"; } else if (value < minimum) { message = "Current input is less than the minimum limit (" + minimum + ")"; } } catch (final Exception ex) { message = "Current input is not numeric"; } if (message != null) { spinner3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_RED)); final Rectangle rect = spinner3.getBounds(); final GC gc = new GC(spinner3); final Point pt = gc.textExtent(string); gc.dispose(); toolTip.setLocation(shell.getDisplay().map(group, null, rect.x + pt.x, rect.y + rect.height)); toolTip.setMessage(message); toolTip.setVisible(true); } else { toolTip.setVisible(false); spinner3.setForeground(null); } }); }