Java Code Examples for org.eclipse.swt.widgets.Display#getSystemImage()

The following examples show how to use org.eclipse.swt.widgets.Display#getSystemImage() . 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: ExceptionDetailsDialog.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Answer the image based on the provided image and details object.
 * 
 * @param image
 *            the image
 * @param details
 *            the details
 * 
 * @return the image
 */
private static Image getImage(final Image image, final Object details) {
	if (image != null) { return image; }
	final Display display = WorkbenchHelper.getDisplay();
	if (details instanceof IStatus) {
		switch (((IStatus) details).getSeverity()) {
			case IStatus.ERROR:
				return display.getSystemImage(SWT.ICON_ERROR);
			case IStatus.WARNING:
				return display.getSystemImage(SWT.ICON_WARNING);
			case IStatus.INFO:
				return display.getSystemImage(SWT.ICON_INFORMATION);
			case IStatus.OK:
				return null;
		}
	}
	return display.getSystemImage(SWT.ICON_ERROR);
}
 
Example 2
Source File: CreateContractInputFromBusinessObjectWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createReminderText(final EMFDataBindingContext dbc, final Composite composite) {
    final CLabel reminder = new CLabel(composite, SWT.NONE);
    final Display d = Display.getCurrent();
    final Image img = d.getSystemImage(SWT.ICON_WARNING);
    reminder.setImage(img);
    reminder.setLayoutData(GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).create());
    final Button autoGeneratedOperationButton = new Button(composite, SWT.RADIO);
    final Button manuallyDefinedOperationButton = new Button(composite, SWT.RADIO);
    actionObservable = new SelectObservableValue<>(Boolean.class);
    actionObservable.addOption(Boolean.TRUE, WidgetProperties.selection().observe(autoGeneratedOperationButton));
    actionObservable.addOption(Boolean.FALSE, WidgetProperties.selection().observe(manuallyDefinedOperationButton));
    if (contract.eContainer() instanceof Task) {
        reminder.setText(Messages.reminderForStepMessage);
        autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationStepButton);
        manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationStepButton);
    } else {
        reminder.setText(Messages.reminderForProcessMessage);
        autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationProcessButton);
        manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationProcessButton);
    }
    dbc.bindValue(actionObservable, generationOptions.getAutoGeneratedScriptObservable());
}
 
Example 3
Source File: CustomWidgetBubbleExample.java    From swt-bling with MIT License 6 votes vote down vote up
public void run(Display display, final Shell shell) {
  shell.setLayout(new FillLayout());
  parentComposite = new Composite(shell, SWT.NONE);
  parentComposite.setLayout(new FillLayout());

  widget = new CustomImageWidget(parentComposite, display.getSystemImage(SWT.ICON_QUESTION));

  parentComposite.addPaintListener(new PaintListener() {
    public void paintControl(PaintEvent e) {
      Point shellSize = shell.getSize();
      Point centered = new Point((shellSize.x / 2) - (widget.getSize().x / 2),
                                 (shellSize.y / 2) - (widget.getSize().y / 2));
      widget.setLocation(centered);
      e.gc.drawImage(widget.getImage(), centered.x, centered.y);
    }
  });

  Bubble.createBubbleForCustomWidget(widget, "Here's some info about the custom icon. This item is drawn with a GC," +
          " and would traditionally have un-tooltip-able");

  shell.setSize(200, 200);
  shell.open();
}
 
Example 4
Source File: BrowserEnvironmentWarningDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setWarningIcon( Display display ) {
  warningIcon = new Label( shell, SWT.NONE );
  Image image = display.getSystemImage( SWT.ICON_WARNING );
  warningIcon.setImage( image );
  props.setLook( warningIcon );
  FormData fdIcon = new FormData();
  fdIcon.left = new FormAttachment( 0, 0 );
  fdIcon.top = new FormAttachment( 0, 0 );
  fdIcon.right = new FormAttachment( 0, image.getBounds().width );
  fdIcon.bottom = new FormAttachment( 0, image.getBounds().height ); //icon should be at the top left corner
  warningIcon.setLayoutData( fdIcon );
}
 
Example 5
Source File: ApplicationMain.java    From logbook with MIT License 5 votes vote down vote up
/**
 * トレイアイコンを追加します
 *
 * @param display
 * @return
 */
private TrayItem addTrayItem(final Display display) {
    // トレイアイコンを追加します
    Tray tray = display.getSystemTray();
    TrayItem item = new TrayItem(tray, SWT.NONE);
    Image image = display.getSystemImage(SWT.ICON_INFORMATION);
    item.setImage(image);
    item.setToolTipText(AppConstants.NAME + AppConstants.VERSION);
    item.addListener(SWT.Selection, new TraySelectionListener(this.shell));
    item.addMenuDetectListener(new TrayItemMenuListener(this.getShell()));
    return item;
}
 
Example 6
Source File: BrowserEnvironmentWarningDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void setWarningIcon( Display display ) {
  warningIcon = new Label( shell, SWT.NONE );
  Image image = display.getSystemImage( SWT.ICON_WARNING );
  warningIcon.setImage( image );
  props.setLook( warningIcon );
  FormData fdIcon = new FormData();
  fdIcon.left = new FormAttachment( 0, 0 );
  fdIcon.top = new FormAttachment( 0, 0 );
  fdIcon.right = new FormAttachment( 0, image.getBounds().width );
  fdIcon.bottom = new FormAttachment( 0, image.getBounds().height ); //icon should be at the top left corner
  warningIcon.setLayoutData( fdIcon );
}
 
Example 7
Source File: PopOverCompositeExample.java    From swt-bling with MIT License 4 votes vote down vote up
public void run(Display display, Shell shell) {
  shell.setLayout(new FillLayout());
  Button button = new Button(shell, SWT.PUSH);
  button.setText("Open PopOverComposite");

  final PopOverComposite popOverComposite = PopOverComposite.createPopOverComposite(button);
  button.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent e) {
      popOverComposite.toggle();
    }
  });

  Composite composite = new Composite(popOverComposite.getPopOverCompositeShell(), SWT.NONE);
  composite.setLayout(new GridLayout(2, false));

  Image iconInformation = display.getSystemImage(SWT.ICON_INFORMATION);
  Image iconError = display.getSystemImage(SWT.ICON_ERROR);
  Image iconWarning = display.getSystemImage(SWT.ICON_WARNING);

  new SquareButton.SquareButtonBuilder()
          .setImage(iconInformation)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button provides you with some information.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconWarning)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("You should be cautious clicking this button.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconError)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button will produce an error.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconError)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button is bad news.")
          .setParent(composite)
          .build();

  popOverComposite.setComposite(composite);

  shell.pack();
  shell.open();
}
 
Example 8
Source File: ReportDocumentEditor.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
private Image getImage( )
{
	Display d = Display.getCurrent( );

	return d.getSystemImage( SWT.ICON_ERROR );

}