Java Code Examples for org.eclipse.jface.resource.JFaceResources#getImage()

The following examples show how to use org.eclipse.jface.resource.JFaceResources#getImage() . 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: StatusLabelProvider.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the image for the given {@link MergeUnitStatus}.
 * 
 * @param status the status
 * @return the image
 */
private static Image getImage(final MergeUnitStatus status) {
	final Image image = JFaceResources.getImage(status.toString());
	if (image == null) {
		final URL imageClockUrl = FileLocator.find(Activator.getDefault().getBundle(),
				new Path(IMAGE_PATH_MAPPING.get(status)));
		if (imageClockUrl != null) {
			JFaceResources.getImageRegistry().put(status.toString(), ImageDescriptor.createFromURL(imageClockUrl));
			return JFaceResources.getImage(status.toString());
		} else {
			return null;
		}
	} else {
		return image;
	}
}
 
Example 2
Source File: SWTUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private static Image getImage(String bundleSymbolicName, String path, ImageDescriptor id)
{
	String computedName = bundleSymbolicName + path;
	Image image = JFaceResources.getImage(computedName);
	if (image != null)
	{
		return image;
	}

	if (id == null)
	{
		id = AbstractUIPlugin.imageDescriptorFromPlugin(bundleSymbolicName, path);
	}

	if (id != null)
	{
		JFaceResources.getImageRegistry().put(computedName, id);
		return JFaceResources.getImage(computedName);
	}
	return null;
}
 
Example 3
Source File: RepositoryLabelProvider.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the image for the given {@link VersionControlSystem}.
 * 
 * @param system the system
 * @return the image
 */
private static Image getImage(final VersionControlSystem system) {
	final Image image = JFaceResources.getImage(system.toString());
	if (image == null) {
		final URL imageClockUrl = FileLocator.find(Activator.getDefault().getBundle(),
				new Path(IMAGE_PATH_MAPPING.get(system)));
		if (imageClockUrl != null) {
			JFaceResources.getImageRegistry().put(system.toString(), ImageDescriptor.createFromURL(imageClockUrl));
			return JFaceResources.getImage(system.toString());
		} else {
			return null;
		}
	} else {
		return image;
	}
}
 
Example 4
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Composite createImportComposite(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 0).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    createHeader(composite);
    
    
    Composite viewerComposite = new Composite(composite, SWT.None);
    viewerComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    
    CLabel previewDescLabel = new CLabel(viewerComposite, SWT.None);
    previewDescLabel.setLayoutData(GridDataFactory.fillDefaults().create());
    Image icon = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
    previewDescLabel.setImage(icon);
    previewDescLabel.setText(Messages.previewDesc);
    
    createMergeViewer(viewerComposite);

    return composite;
}
 
Example 5
Source File: CheckboxCellContentProvider.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Provides a checkbox <code>Image</code> depending on whether the cell is
 * enabled/disabled and selected/unselected.
 */
@Override
public Image getImage(Object element) {
	Image image = null;

	// Depending on whether or not the element is checked and enabled, set
	// its image.
	if (isEnabled(element)) {
		if (isSelected(element)) {
			image = JFaceResources.getImage(ENABLED_CHECKED);
		} else {
			image = JFaceResources.getImage(ENABLED_UNCHECKED);
		}
	} else if (isSelected(element)) {
		image = JFaceResources.getImage(DISABLED_CHECKED);
	} else {
		image = JFaceResources.getImage(DISABLED_UNCHECKED);
	}

	return image;
}
 
Example 6
Source File: StyleBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setTitleMessage( String newMessage, int newType )
{
	Image newImage = null;
	if ( newMessage != null )
	{
		switch ( newType )
		{
			case IMessageProvider.NONE :
				break;
			case IMessageProvider.INFORMATION :
				newImage = JFaceResources.getImage( DLG_IMG_MESSAGE_INFO );
				break;
			case IMessageProvider.WARNING :
				newImage = JFaceResources.getImage( DLG_IMG_MESSAGE_WARNING );
				break;
			case IMessageProvider.ERROR :
				newImage = JFaceResources.getImage( DLG_IMG_MESSAGE_ERROR );
				break;
		}
	}
	showTitleMessage( newMessage, newImage );
}
 
Example 7
Source File: StatusWidget.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private Image imageFor(int type) {
	switch (type) {
		case IMessageProvider.NONE:
			return null;
		case IMessageProvider.INFORMATION:
			return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
		case IMessageProvider.WARNING:
			return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
		case IMessageProvider.ERROR:
			return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
		default:
			return null;
	}
}
 
Example 8
Source File: GUIHelper.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static Image getImage(String key) {
	Image image = JFaceResources.getImage(key);
	if (image == null) {
		URL imageUrl = getImageUrl(key);
		if (imageUrl != null) {
			ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imageUrl);
			JFaceResources.getImageRegistry().put(key, imageDescriptor.createImage());
			image = JFaceResources.getImage(key);
		}
	}
	return image;
}
 
Example 9
Source File: GUIHelper.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public static Image getImage(String key) {
	Image image = JFaceResources.getImage(key);
	if (image == null) {
		URL imageUrl = getImageUrl(key);
		if (imageUrl != null) {
			ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imageUrl);
			JFaceResources.getImageRegistry().put(key, imageDescriptor.createImage());
			image = JFaceResources.getImage(key);
		}
	}
	return image;
}
 
Example 10
Source File: WidgetMessageDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Image getStatusImage(IStatus status) {
    if (status == null) {
        return null;
    }
    switch (status.getSeverity()) {
        case IStatus.INFO:
            return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        case IStatus.WARNING:
            return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        case IStatus.ERROR:
            return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        default:
            return null;
    }
}
 
Example 11
Source File: ConstraintEditorWizardDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Image getHelpImage() {
    return JFaceResources.getImage(DLG_IMG_HELP);
}
 
Example 12
Source File: LegacyStoreModel.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Image getImage() {
    return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
}
 
Example 13
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createHeader(Composite parent) {
    Group composite = new Group(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x, 2).extendedMargins(0, 0, -5, 0).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    CLabel warning = new CLabel(composite, SWT.WRAP);
    warning.setLayoutData(GridDataFactory.fillDefaults().exclude(true).create());
    Image warningIcon = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    warning.setImage(warningIcon);

    CLabel info1 = new CLabel(composite, SWT.WRAP);
    info1.setLayoutData(GridDataFactory.fillDefaults().exclude(true).create());
    info1.setImage(BusinessObjectPlugin.getImage("icons/arrow16.png"));

    CLabel info2 = new CLabel(composite, SWT.WRAP);
    info2.setLayoutData(GridDataFactory.fillDefaults().exclude(true).create());
    info2.setImage(BusinessObjectPlugin.getImage("icons/arrow16.png"));

    importBdmModelObservable.addValueChangeListener(e -> {
        SmartImportBdmModel newModel = e.diff.getNewValue();
        if (newModel == null) {
            updateCLabel(warning, "", false);
            updateCLabel(info1, "", false);
            updateCLabel(info2, "", false);
        } else if (bdmFileStore == null) {
            updateCLabel(warning, "", false);
            updateCLabel(info1, "", false);
            updateCLabel(info2, Messages.newBdmImport, true);
        } else if (isSameContent(newModel)) {
            updateCLabel(warning, "", false);
            updateCLabel(info1, "", false);
            updateCLabel(info2, Messages.globalSkipped, true);
        } else if (isConflicting(newModel)) {
            if (newModel instanceof OverwriteImportBdmModel) {
                updateCLabel(warning, Messages.smartImportImpossible, true);
                updateCLabel(info1, Messages.overwriteImportDesc, true);
                updateCLabel(info2, "", false);
            } else {
                updateCLabel(warning, Messages.smartImportConflict, true);
                updateCLabel(info1, Messages.selectPackageToKeep, true);
                updateCLabel(info2, Messages.smartImportDesc, true);
            }
        } else {
            updateCLabel(warning, "", false);
            updateCLabel(info1, "", false);
            updateCLabel(info2, Messages.smartImportDesc, true);
        }
        parent.layout(true);
    });
}
 
Example 14
Source File: ProcedureFlagNode.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Image getImage( )
{
	return JFaceResources.getImage( PROCEDURE_FLAG_ICON );
}
 
Example 15
Source File: TableColumnNode.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Image getImage( )
{
	return JFaceResources.getImage( COLUMN_ICON );
}
 
Example 16
Source File: TableNode.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Image getImage( )
{
	return isView ? JFaceResources.getImage( VIEW_ICON ) : JFaceResources.getImage( TABLE_ICON );
}
 
Example 17
Source File: TSTitleAreaDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the message for this dialog with an indication of what type of
 * message it is.
 * <p>
 * The valid message types are one of <code>NONE</code>,
 * <code>INFORMATION</code>,<code>WARNING</code>, or
 * <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type
 * <code>ERROR</code> is different than an error message (set using
 * <code>setErrorMessage</code>). An error message overrides the current
 * message until the error message is cleared. This method replaces the
 * current message and does not affect the error message.
 * </p>
 * 
 * @param newMessage
 *            the message, or <code>null</code> to clear the message
 * @param newType
 *            the message type
 * @since 2.0
 */
public void setMessage(String newMessage, int newType) {
	Image newImage = null;
	if (newMessage != null) {
		switch (newType) {
		case IMessageProvider.NONE:
			break;
		case IMessageProvider.INFORMATION:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO);
			break;
		case IMessageProvider.WARNING:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING);
			break;
		case IMessageProvider.ERROR:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR);
			break;
		}
	}
	showMessage(newMessage, newImage);
}
 
Example 18
Source File: TSTitleAreaDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the message for this dialog with an indication of what type of
 * message it is.
 * <p>
 * The valid message types are one of <code>NONE</code>,
 * <code>INFORMATION</code>,<code>WARNING</code>, or
 * <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type
 * <code>ERROR</code> is different than an error message (set using
 * <code>setErrorMessage</code>). An error message overrides the current
 * message until the error message is cleared. This method replaces the
 * current message and does not affect the error message.
 * </p>
 * 
 * @param newMessage
 *            the message, or <code>null</code> to clear the message
 * @param newType
 *            the message type
 * @since 2.0
 */
public void setMessage(String newMessage, int newType) {
	Image newImage = null;
	if (newMessage != null) {
		switch (newType) {
		case IMessageProvider.NONE:
			break;
		case IMessageProvider.INFORMATION:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO);
			break;
		case IMessageProvider.WARNING:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING);
			break;
		case IMessageProvider.ERROR:
			newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR);
			break;
		}
	}
	showMessage(newMessage, newImage);
}
 
Example 19
Source File: AbstractPopupSheet.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new help control that provides access to context help.
 * <p>
 * The <code>TrayDialog</code> implementation of this method creates the
 * control, registers it for selection events including selection, Note that
 * the parent's layout is assumed to be a <code>GridLayout</code> and the
 * number of columns in this layout is incremented. Subclasses may override.
 * </p>
 * 
 * @param parent
 *            the parent composite
 * @return the help control
 */
private Control createHelpControl( Composite parent )
{
	Image helpImage = JFaceResources.getImage( Dialog.DLG_IMG_HELP );
	if ( helpImage != null )
	{
		return createHelpImageButton( parent, helpImage );
	}
	return createHelpLink( parent );
}