Example usage for org.eclipse.jface.resource ImageDescriptor createFromURL

List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createFromURL.

Prototype

public static ImageDescriptor createFromURL(URL url) 

Source Link

Document

Creates and returns a new image descriptor from a URL.

Usage

From source file:eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetLabelProvider.java

License:Open Source License

@Override
public Image getImage(Object element) {
    if (element instanceof SchemaPreset) {
        SchemaPreset schema = (SchemaPreset) element;
        URL iconURL = schema.getIconURL();
        if (iconURL != null) {
            String key = iconURL.toString();
            Image image = urlImages.get(key);
            if (image == null) {
                image = ImageDescriptor.createFromURL(iconURL).createImage();
                urlImages.put(key, image);
            }//from w  ww . j  a va  2 s.  com
            return image;
        }

        return defImage;
    }
    if (element instanceof SchemaCategory) {
        return categoryImage;
    }
    return null;
}

From source file:eu.esdihumboldt.hale.ui.templates.contribution.LoadTemplateAction.java

License:Open Source License

/**
 * Create an action to load the given template.
 * /*from   w  ww  .j a v  a  2s .  c  om*/
 * @param template the project template
 */
public LoadTemplateAction(ProjectTemplate template) {
    super(template.getName(), AS_PUSH_BUTTON);

    this.template = template;

    URL iconUrl = template.getIconURL();
    if (iconUrl != null) {
        setImageDescriptor(ImageDescriptor.createFromURL(iconUrl));
    }
}

From source file:eu.esdihumboldt.hale.ui.views.data.internal.compare.DefinitionMetaCompareLabelProvider.java

License:Open Source License

/**
 * @see eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider#getImage(java.lang.Object)
 *//*  w  w w.j a v a2s . c om*/
@Override
public Image getImage(Object element) {
    if (element instanceof Set<?>) {
        return CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_META);
    }
    if (element instanceof String) {
        MetadataInfo meta = MetadataInfoExtension.getInstance().get((String) element);
        if (meta != null) {
            if (metaimages.containsKey(element)) {
                return metaimages.get(element);
            } else {
                URL icon = meta.getIconURL();
                if (icon != null) {
                    Image img = ImageDescriptor.createFromURL(icon).createImage();
                    metaimages.put((String) element, img);
                    return img;
                }
            }

        }
    }
    return super.getImage(element);
}

From source file:eu.esdihumboldt.hale.ui.views.data.internal.explore.DefinitionMetaLabelProvider.java

License:Open Source License

/**
 * Returns an adjusted image depending on the type of the object passed in.
 * //  w w w.  j  av  a2s  .  c o m
 * @return an Image
 */
@Override
public Image getImage(Object element) {
    if (element == Metadata.METADATA) {
        return CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_META);
    }
    if (element instanceof String) {
        MetadataInfo meta = MetadataInfoExtension.getInstance().get((String) element);
        if (meta != null) {
            if (metaimages.containsKey(element)) {
                return metaimages.get(element);
            } else {
                URL icon = meta.getIconURL();
                if (icon != null) {
                    Image img = ImageDescriptor.createFromURL(icon).createImage();
                    metaimages.put((String) element, img);
                    return img;
                }
            }

        }
    }

    return super.getImage(element);
}

From source file:eu.esdihumboldt.hale.ui.views.data.internal.MetadataActionProvider.java

License:Open Source License

/**
 * Adds the action to the certain TreeViewer cell
 *//*ww w  .ja  va 2s .  co  m*/
public void setup() {

    final TreeEditor metaEditor = new TreeEditor(treeViewer.getTree());
    metaEditor.horizontalAlignment = SWT.LEFT;
    metaEditor.verticalAlignment = SWT.TOP;

    treeViewer.getTree().addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent e) {
            final ViewerCell cell = treeViewer.getCell(new Point(e.x, e.y));

            // Selected cell changed?
            if (cell == null || metaEditor.getItem() != cell.getItem()
                    || metaEditor.getColumn() != cell.getColumnIndex()) {
                // Clean up any previous editor control
                Control oldmetaEditor = metaEditor.getEditor();
                if (oldmetaEditor != null) {
                    oldmetaEditor.dispose();
                    metaEditor.setEditor(null, null, 0);
                }
            }

            // No selected cell or selected cell didn't change.
            if (cell == null || cell.getColumnIndex() == 0 || (metaEditor.getItem() == cell.getItem()
                    && metaEditor.getColumn() == cell.getColumnIndex())) {
                return;
            }

            // Initiate the extension-point
            MetadataActionExtension mae = MetadataActionExtension.getInstance();
            final Pair<Object, Object> data = retrieveMetadata(cell);
            if (data == null) {
                return;
            }

            // get all defined actions
            final List<MetadataActionFactory> actionSources = mae
                    .getMetadataActions(data.getFirst().toString());

            if (actionSources == null || actionSources.isEmpty()) {
                return;
            }
            // Tool-bar used to view and trigger the different possible
            // actions
            ToolBar tooli = new ToolBar(treeViewer.getTree(), SWT.NONE);

            for (final MetadataActionFactory source : actionSources) {
                ToolItem actionItem = new ToolItem(tooli, SWT.PUSH);

                // get the Icon of the action
                URL iconURL = source.getIconURL();
                Image image = ImageDescriptor.createFromURL(iconURL).createImage();
                actionItem.setImage(image);
                actionItem.setToolTipText(source.getDisplayName());

                actionItem.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {

                        try {
                            source.createExtensionObject().execute(data.getFirst(), data.getSecond());
                        } catch (Exception e1) {
                            _log.userError("error creating metadata action", e1);
                        }
                    }
                });
            }
            metaEditor.setEditor(tooli, (TreeItem) cell.getItem(), cell.getColumnIndex());
            tooli.pack();
        }
    });

}

From source file:eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider.java

License:Open Source License

@Override
public Image getImage(Object element) {
    if (element instanceof IOAction) {
        IOAction action = (IOAction) element;
        Image actionImage = actionImages.get(action.getId());
        if (actionImage == null) {
            ActionUI actionUI = ActionUIExtension.getInstance().findActionUI(action.getId());
            URL iconUrl = actionUI.getIconURL();
            if (iconUrl != null) {
                actionImage = ImageDescriptor.createFromURL(iconUrl).createImage();
                actionImages.put(action.getId(), actionImage);
            }/*  w w  w . j av  a 2 s . co  m*/
        }

        if (actionImage != null) {
            return actionImage;
        }

        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
    }

    if (element instanceof Resource) {
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
    }

    if (element instanceof ProjectToken) {
        return projectImage;
    }

    return null;
}

From source file:eu.geclipse.aws.ec2.ui.wizards.AddAttributeWizardPage.java

License:Open Source License

/**
 * Create a new {@link WizardPage} and define title, description and image.
 *///from w w w.  ja  v a2  s .  c om
protected AddAttributeWizardPage() {
    super(AddAttributeWizardPage.WIZARD_PAGE_ID, Messages.getString("AddAttributeWizardPage.wizard_page_title"), //$NON-NLS-1$
            null);
    setDescription(Messages.getString("AddAttributeWizardPage.wizard_page_description")); //$NON-NLS-1$
    URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/wizban/service_wiz.gif"); //$NON-NLS-1$
    setImageDescriptor(ImageDescriptor.createFromURL(imgUrl));
    setPageComplete(false);
}

From source file:eu.geclipse.aws.ec2.ui.wizards.CIDRPermissionWizardPage.java

License:Open Source License

/**
 * The constructor creates the {@link WizardPage} and sets title, description
 * and page image.//  w ww  . j av  a  2  s. c o  m
 * 
 * @param securityGroup the security group to add the cidr entry to
 */
public CIDRPermissionWizardPage(final GroupDescription securityGroup) {
    super(CIDRPermissionWizardPage.WIZARD_PAGE_ID,
            Messages.getString("CIDRPermissionWizardPage.page_title") + securityGroup.getName(), //$NON-NLS-1$
            null);
    setDescription(Messages.getString("CIDRPermissionWizardPage.page_description") //$NON-NLS-1$
            + securityGroup.getName());
    URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/wizban/security_wiz.gif"); //$NON-NLS-1$
    setImageDescriptor(ImageDescriptor.createFromURL(imgUrl));
    setPageComplete(false);
}

From source file:eu.geclipse.aws.ec2.ui.wizards.CreateKeypairWizardPage.java

License:Open Source License

/**
 * Creates a new {@link WizardPage} with the aws access id in the aws vo.
 * //  ww w  .ja  va2s  .  c o m
 * @param awsVo the container of the aws access id
 */
public CreateKeypairWizardPage(final AWSVirtualOrganization awsVo) {
    super(CreateKeypairWizardPage.WIZARD_PAGE_ID, Messages.getString("CreateKeypairWizardPage.page_title"), //$NON-NLS-1$
            null);
    String awsAccessId = null;
    try {
        awsAccessId = awsVo.getProperties().getAwsAccessId();
        setDescription(Messages.getString("CreateKeypairWizardPage.page_description1") + awsAccessId //$NON-NLS-1$
                + Messages.getString("CreateKeypairWizardPage.page_description2")); //$NON-NLS-1$
    } catch (ProblemException problemEx) {
        Activator.log("Could not read aws vo properties", problemEx); //$NON-NLS-1$
    }
    URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/wizban/security_wiz.gif"); //$NON-NLS-1$
    setImageDescriptor(ImageDescriptor.createFromURL(imgUrl));

    setPageComplete(false);

}

From source file:eu.geclipse.aws.ec2.ui.wizards.CreateSecurityGroupWizardPage.java

License:Open Source License

/**
 * Creates a new {@link WizardPage} with the aws access id in the aws vo.
 * //  ww w .  j  a v  a2 s . c  om
 * @param awsVo the container of the aws access id
 */
public CreateSecurityGroupWizardPage(final AWSVirtualOrganization awsVo) {
    super(CreateSecurityGroupWizardPage.WIZARD_PAGE_ID,
            Messages.getString("CreateSecurityGroupWizardPage.page_title"), //$NON-NLS-1$
            null);
    String awsAccessId = null;
    try {
        awsAccessId = awsVo.getProperties().getAwsAccessId();
        setDescription(Messages.getString("CreateSecurityGroupWizardPage.page_description1") + awsAccessId //$NON-NLS-1$
                + Messages.getString("CreateSecurityGroupWizardPage.page_description2")); //$NON-NLS-1$
    } catch (ProblemException problemEx) {
        Activator.log("Could not read aws vo properties", problemEx); //$NON-NLS-1$
    }
    URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/wizban/security_wiz.gif"); //$NON-NLS-1$
    setImageDescriptor(ImageDescriptor.createFromURL(imgUrl));

    setPageComplete(false);

}