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

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

Introduction

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

Prototype

public Image createImage() 

Source Link

Document

Creates and returns a new SWT image for this image descriptor.

Usage

From source file:com.collabnet.subversion.merge.Activator.java

License:Open Source License

public static IMergeInputProvider[] getMergeInputProviders() throws Exception {
    if (mergeInputProviders == null) {
        ArrayList inputProviderList = new ArrayList();

        if (!getDefault().isDesktopInstalled()) {
            DesktopDownloadMergeInputProvider desktopDownloadMergeInputProvider = new DesktopDownloadMergeInputProvider();
            inputProviderList.add(desktopDownloadMergeInputProvider);
        }//w w w  .  jav a2s  . c om

        IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
        IConfigurationElement[] configurationElements = extensionRegistry
                .getConfigurationElementsFor(MERGE_INPUT_PROVIDERS);
        for (int i = 0; i < configurationElements.length; i++) {
            IConfigurationElement configurationElement = configurationElements[i];
            IMergeInputProvider inputProvider = (IMergeInputProvider) configurationElement
                    .createExecutableExtension("class"); //$NON-NLS-1$
            inputProvider.setText(configurationElement.getAttribute("name")); //$NON-NLS-1$
            inputProvider.setDescription(configurationElement.getAttribute("description").replaceAll("%NL%", //$NON-NLS-1$//$NON-NLS-2$
                    System.getProperty("line.separator"))); //$NON-NLS-1$
            String imageKey = configurationElement.getAttribute("image"); //$NON-NLS-1$
            if (imageKey != null) {
                ImageDescriptor imageDescriptor = imageDescriptorFromPlugin(PLUGIN_ID, "icons/" + imageKey); //$NON-NLS-1$
                Image image = imageDescriptor.createImage();
                mergeInputImages.add(image);
                inputProvider.setImage(image);
            }
            String seq = configurationElement.getAttribute("sequence"); //$NON-NLS-1$
            if (seq != null)
                inputProvider.setSequence(Integer.parseInt(seq));
            inputProviderList.add(inputProvider);
        }
        mergeInputProviders = new IMergeInputProvider[inputProviderList.size()];
        inputProviderList.toArray(mergeInputProviders);
        Arrays.sort(mergeInputProviders);
    }
    return mergeInputProviders;
}

From source file:com.dadabeatnik.codemap.ui.ImageFactory.java

License:Open Source License

public static Image getFileIcon(Object element) {
    ImageRegistry imageRegistry = CodeMapPlugin.getDefault().getImageRegistry();

    Image image = null;/*w ww.j  ava2 s  .c o m*/
    IEditorDescriptor editorDescriptor = null;

    if (element instanceof FileModel) {
        try {
            editorDescriptor = CodeMapEditor.getDefaultEditor(((FileModel) element).getFile());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    if (editorDescriptor != null) {
        image = imageRegistry.get(editorDescriptor.getId()); // cached?
        if (image == null) {
            ImageDescriptor imageDescriptor = editorDescriptor.getImageDescriptor();
            if (imageDescriptor != null) {
                image = imageDescriptor.createImage();
                if (image != null) {
                    imageRegistry.put(editorDescriptor.getId(), image); // cache it
                }
            }
        }
    }

    if (image == null) {
        image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
    }

    return image;
}

From source file:com.ebmwebsourcing.petals.common.croquis.internal.provisional.CroquisNewWizardPage.java

License:Open Source License

/**
 * Constructor.//  ww  w . ja  v  a 2s .  c  om
 */
public CroquisNewWizardPage() {
    super("Main Page");

    try {
        ImageDescriptor desc = PetalsCommonPlugin.getImageDescriptor("icons/screenshots/question-mark.png");
        this.defaultImage = desc.createImage();

    } catch (Exception e) {
        PetalsCommonPlugin.log(e, IStatus.WARNING);
    }
}

From source file:com.ebmwebsourcing.petals.common.croquis.internal.provisional.CroquisNewWizardPage.java

License:Open Source License

public void createControl(Composite parent) {

    // The top composite
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, true);
    layout.horizontalSpacing = 8;/*from   w w  w .  j  a v a2s .c o  m*/
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    setControl(container);

    // Update the page settings
    setTitle("New Petals Croquis");
    getShell().setText("New Petals Croquis");
    setDescription("Create a new croquis for Petals ESB.");

    // The left part
    final Composite leftContainer = new Composite(container, SWT.NONE);
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginTop = 2;
    leftContainer.setLayout(layout);
    leftContainer.setLayoutData(new GridData(GridData.FILL_BOTH));

    final Label l = new Label(leftContainer, SWT.NONE);
    l.setText("Croquis Type:");
    l.setToolTipText("Select the kind of croquis to create");

    final ComboViewer croquisViewer = new ComboViewer(leftContainer,
            SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
    croquisViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    croquisViewer.setContentProvider(new ArrayContentProvider());
    croquisViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return element instanceof String ? (String) element : ((ICroquisExtension) element).getTitle();
        }
    });

    // The right part
    Composite rightContainer = new Composite(container, SWT.BORDER);
    rightContainer.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
    layout = new GridLayout();
    layout.marginWidth = 12;
    layout.marginHeight = 12;
    rightContainer.setLayout(layout);
    rightContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final Label screenshotLabel = new Label(rightContainer, SWT.NONE);
    screenshotLabel.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));

    final Label descriptionLabel = new Label(rightContainer, SWT.NONE);
    GridData layoutData = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
    layoutData.verticalIndent = 7;
    descriptionLabel.setLayoutData(layoutData);
    descriptionLabel.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));

    // The selection change listener
    croquisViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {

            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (!(o instanceof ICroquisExtension))
                return;

            if (o.equals(CroquisNewWizardPage.this.selectedExtension))
                return;

            CroquisNewWizardPage.this.selectedExtension = (ICroquisExtension) o;
            String text = ((ICroquisExtension) o).getDescription();
            descriptionLabel.setText(text);

            ImageDescriptor desc = ((ICroquisExtension) o).getScreenshot();
            if (CroquisNewWizardPage.this.currentImage != null
                    && CroquisNewWizardPage.this.currentImage != CroquisNewWizardPage.this.defaultImage) {
                CroquisNewWizardPage.this.currentImage.dispose();
                CroquisNewWizardPage.this.currentImage = null;
            }

            if (desc != null) {
                try {
                    CroquisNewWizardPage.this.currentImage = desc.createImage();
                } catch (Exception e) {
                    PetalsCommonPlugin.log(e, IStatus.ERROR);
                }
            } else {
                CroquisNewWizardPage.this.currentImage = CroquisNewWizardPage.this.defaultImage;
            }

            screenshotLabel.setImage(CroquisNewWizardPage.this.currentImage);
            screenshotLabel.getParent().layout();

            for (Control c : leftContainer.getChildren()) {
                if (c != l && c != croquisViewer.getCombo())
                    c.dispose();
            }

            ((ICroquisExtension) o).createControl(leftContainer, CroquisNewWizardPage.this);
            leftContainer.layout();
        }
    });

    // Initialize the rest
    List<ICroquisExtension> ext = CroquisContributionManager.INSTANCE.getCroquisData();
    if (ext.size() > 0) {
        croquisViewer.setInput(ext);
        croquisViewer.getCombo().select(0);
        croquisViewer.getCombo().notifyListeners(SWT.Selection, new Event());

    } else {
        croquisViewer.setInput("-- No Croquis Available --");
    }
}

From source file:com.ebmwebsourcing.petals.common.internal.provisional.ui.LibrariesExportWizardPage.java

License:Open Source License

/**
 * @param pageName//  w w w  . j  av a 2 s  . com
 */
public LibrariesExportWizardPage(String pageName) {
    super(pageName);

    this.dependencies = new HashMap<IJavaProject, Set<JavaProjectLibrary>>();
    this.librariesToImport = new HashSet<File>();

    ImageDescriptor desc = PetalsCommonPlugin.getImageDescriptor("icons/obj16/jar_l_obj.gif");
    if (desc != null)
        this.jarImage = desc.createImage();
}

From source file:com.ebmwebsourcing.petals.common.internal.provisional.utils.ImageRegistry.java

License:Open Source License

/**
 * @param descriptor/*from  w w  w  .  j a va2 s . c om*/
 * @return
 */
public Image getBaseImage(ImageDescriptor descriptor) {

    Image img = this.baseImages.get(descriptor);
    if (img == null) {
        img = descriptor.createImage();
        this.baseImages.put(descriptor, img);
    }

    return img;
}

From source file:com.ebmwebsourcing.petals.services.eip.designer.EipDesignerImageStore.java

License:Open Source License

/**
 * Constructor./*w w  w  .  ja va  2  s .  com*/
 * <p>
 * It is in charge of creating the images.
 * </p>
 */
private EipDesignerImageStore() {

    // Create the EIP images
    for (EIPtype type : EIPtype.values()) {

        String path = "icons/obj64/d_" + type.toString().toLowerCase() + "_64x64.png";
        try {
            ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
            this.disabledEipToImage.put(type, desc.createImage());

            path = "icons/obj64/e_" + type.toString().toLowerCase() + "_64x64.png";
            desc = PetalsEipPlugin.getImageDescriptor(path);
            this.enabledEipToImage.put(type, desc.createImage());

        } catch (Exception e) {
            PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
        }
    }

    // Create the end-point image
    String path = "icons/obj32/d_endpoint_32x32.png";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.disabledEdptImage = desc.createImage();

        path = "icons/obj32/e_endpoint_32x32.png";
        desc = PetalsEipPlugin.getImageDescriptor(path);
        this.enabledEdptImage = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }

    // Create the 16x16 image
    path = "icons/obj16/eip_1_16x16.png";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.eip_16x16_image = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }

    // Create the other images
    path = "icons/obj16/documentation.gif";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.docImage = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }

    path = "icons/obj16/export.gif";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.exportImage = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }

    path = "icons/obj16/error.gif";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.errorIcon = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }

    path = "icons/obj16/warning.gif";
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor(path);
        this.warningIcon = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log("The image " + path + " could not be found.", IStatus.WARNING);
    }
}

From source file:com.ebmwebsourcing.petals.services.eip.designer.tabbedproperties.EndpointInterfaceSection.java

License:Open Source License

/**
 * Constructor.//from   ww w  .j  a  v a  2s  . com
 */
public EndpointInterfaceSection() {

    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor("icons/obj16/smartmode_co.gif");
        this.ideaImg = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log(e, IStatus.WARNING);
    }
}

From source file:com.ebmwebsourcing.petals.services.eip.su.EipWizardPage.java

License:Open Source License

public void createControl(Composite parent) {

    // Create the main structure
    Composite container = new Composite(parent, SWT.BORDER);
    container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    GridLayout layout = new GridLayout(2, false);
    layout.verticalSpacing = 23;//from  ww  w . j a va2 s  . c  om
    layout.horizontalSpacing = 12;
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    setControl(container);

    FormText ft = new FormText(container, SWT.WRAP);
    ft.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    ft.marginWidth = 7;

    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 2;
    layoutData.verticalIndent = 12;
    layoutData.widthHint = 380;
    ft.setLayoutData(layoutData);

    // Load images
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor("icons/obj16/smartmode_co.gif");
        this.tipImage = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log(e, IStatus.WARNING);
    }

    ft.setImage("tip", this.tipImage);

    // Add some text
    StringBuilder sb = new StringBuilder();
    sb.append("<form>");
    sb.append("<p><img href=\"tip\" /> <b>EIP Wizard</b></p>");
    sb.append("<p>The Petals EIP component cannot be configured using this wizard anymore.<br />");
    sb.append("Instead, <b>croquis</b> must be used. Croquis allow to design graphically an EIP chain.");
    sb.append(
            "An EIP croquis can be exported either as Petals projects or directly as a service assembly.</p>");
    sb.append("</form>");
    ft.setText(sb.toString(), true, false);

    // Add the image and a link
    try {
        ImageDescriptor desc = PetalsEipPlugin.getImageDescriptor("icons/screenshots/overview.png");
        this.screenshotImg = desc.createImage();

    } catch (Exception e) {
        PetalsEipPlugin.log(e, IStatus.WARNING);
    }

    new Label(container, SWT.NONE).setImage(this.screenshotImg);
    ft = new FormText(container, SWT.NONE);
    ft.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    ft.setLayoutData(new GridData(SWT.DEFAULT, SWT.TOP, false, false));

    sb = new StringBuilder();
    sb.append("<form>");
    sb.append("<p>The picture on the left shows an example of EIP croquis.</p>");
    sb.append("<p>Click <a href=\"croquis\">here to open the croquis wizard</a>.</p>");
    sb.append("<p vspace=\"false\">Or click the <b>Cancel</b> button to close this wizard.</p>");
    sb.append("</form>");
    ft.setText(sb.toString(), true, false);

    // React to link activation
    ft.addHyperlinkListener(new PetalsHyperlinkListener() {
        @Override
        public void linkActivated(HyperlinkEvent e) {

            // Close the wizard, which does nothing anyway
            getWizard().getContainer().getShell().close();

            // Open the croquis wizard in a new dialog
            ICommandService cmdService = (ICommandService) PlatformUI.getWorkbench()
                    .getService(ICommandService.class);
            Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.FILE_NEW);
            try {
                IParameter paramId = cmd.getParameter(IWorkbenchCommandConstants.FILE_NEW_PARM_WIZARDID);
                Parameterization param = new Parameterization(paramId,
                        "com.ebmwebsourcing.petals.common.croquisWizard");

                ParameterizedCommand parmCommand = new ParameterizedCommand(cmd,
                        new Parameterization[] { param });
                IHandlerService ds = (IHandlerService) PlatformUI.getWorkbench()
                        .getService(IHandlerService.class);
                ds.executeCommand(parmCommand, null);

            } catch (Exception e1) {
                PetalsEipPlugin.log(e1, IStatus.ERROR);
            }
        }
    });
}

From source file:com.ebmwebsourcing.petals.services.explorer.ServiceExplorerLabelProvider.java

License:Open Source License

/**
 * Constructor./*from  ww w. j av a2s .c o m*/
 */
public ServiceExplorerLabelProvider() {

    ImageDescriptor desc;
    try {
        desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/Endpoint_3.gif");
        if (desc != null)
            this.edptImg = desc.createImage();

    } catch (Exception e) {
        PetalsServicesPlugin.log(e, IStatus.WARNING);
    }

    try {
        desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/EndpointFolderClosed.gif");
        if (desc != null)
            this.closedFolderImg = desc.createImage();

    } catch (Exception e) {
        PetalsServicesPlugin.log(e, IStatus.WARNING);
    }

    try {
        desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/EndpointProjectOpen.gif");
        if (desc != null)
            this.openProjectImg = desc.createImage();

    } catch (Exception e) {
        PetalsServicesPlugin.log(e, IStatus.WARNING);
    }

    try {
        desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/EndpointProjectClosed.gif");
        if (desc != null)
            this.closedProjectImg = desc.createImage();

    } catch (Exception e) {
        PetalsServicesPlugin.log(e, IStatus.WARNING);
    }

    try {
        desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/service_unit.png");
        if (desc != null)
            this.suImg = desc.createImage();

    } catch (Exception e) {
        PetalsServicesPlugin.log(e, IStatus.WARNING);
    }
}