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

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

Introduction

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

Prototype

public static ImageDescriptor createFromFile(Class<?> location, String filename) 

Source Link

Document

Creates and returns a new image descriptor from a file.

Usage

From source file:org.jboss.tools.common.gef.outline.xpl.DiagramContentOutlinePage.java

License:Open Source License

protected void configureOutlineViewer() {
    IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
    IMenuManager mm = getSite().getActionBars().getMenuManager();
    showOutlineAction = new Action() {
        public void run() {
            showPage(ID_OUTLINE);/*from  ww  w. jav a  2s.c om*/
        }
    };
    showOutlineAction.setImageDescriptor(ImageDescriptor.createFromFile(getClass(), OUTLINE_ICON_PATH));
    showOutlineAction.setToolTipText(GEFUIMessages.TREE);
    tbm.add(showOutlineAction);
    showOutlineAction.setText(GEFUIMessages.SHOW_TREE);
    mm.add(showOutlineAction);

    showOverviewAction = new Action() {
        public void run() {
            showPage(ID_OVERVIEW);
        }
    };
    showOverviewAction.setToolTipText(GEFUIMessages.DIAGRAM_NAVIGATOR);
    showOverviewAction.setImageDescriptor(ImageDescriptor.createFromFile(getClass(), OVERVIEW_ICON_PATH));
    tbm.add(showOverviewAction);

    showOverviewAction.setText(GEFUIMessages.SHOW_DIAGRAM_NAVIGATOR);
    mm.add(showOverviewAction);

    showPage(ID_OUTLINE);
}

From source file:org.jboss.tools.common.text.xml.xpl.ToggleOccurencesMarkUpAction.java

License:Open Source License

protected void initialize(ResourceBundle bundle, String prefix) {
    String labelKey = "label"; //$NON-NLS-1$
    String tooltipKey = "tooltip"; //$NON-NLS-1$
    String imageKey = "image"; //$NON-NLS-1$
    String disabledImageKey = "disabledImage"; //$NON-NLS-1$
    String descriptionKey = "description"; //$NON-NLS-1$

    if (prefix != null && prefix.length() > 0) {
        labelKey = prefix + labelKey;// w ww  .  j  a  v  a  2 s.c  o m
        tooltipKey = prefix + tooltipKey;
        imageKey = prefix + imageKey;
        disabledImageKey = prefix + disabledImageKey;
        descriptionKey = prefix + descriptionKey;
    }

    setText(getString(bundle, labelKey, labelKey));
    setToolTipText(getString(bundle, tooltipKey, null));
    setDescription(getString(bundle, descriptionKey, null));

    String relPath = getString(bundle, imageKey, null);
    ImageDescriptor id = ImageDescriptor.createFromFile(ToggleOccurencesMarkUpAction.class, relPath); //$NON-NLS-1$
    if (id != null) {
        setImageDescriptor(id);
    }

    relPath = getString(bundle, disabledImageKey, null);
    id = ImageDescriptor.createFromFile(ToggleOccurencesMarkUpAction.class, relPath); //$NON-NLS-1$
    if (id != null) {
        setDisabledImageDescriptor(id);
    }
}

From source file:org.jboss.tools.esb.ui.wizard.newfile.NewESBFileWizard.java

License:Open Source License

public NewESBFileWizard() {
    setDefaultPageImageDescriptor(/*from  www . j  a v  a2  s . c  o  m*/
            ImageDescriptor.createFromFile(NewESBFileWizard.class, "EclipseCreateNewProject.png")); //$NON-NLS-1$
}

From source file:org.jboss.tools.forge.ui.internal.ext.dialog.ForgeProgressMonitorPart.java

License:Open Source License

/**
 * Creates the progress monitor's UI parts and layouts them according to the
 * given layout. If the layout is <code>null</code> the part's default
 * layout is used./*from ww w. ja v a  2 s.  co m*/
 * 
 * @param layout
 *            The layout for the receiver.
 * @param progressIndicatorHeight
 *            The suggested height of the indicator
 */
@Override
protected void initialize(Layout layout, int progressIndicatorHeight) {
    if (layout == null) {
        GridLayout l = new GridLayout();
        l.marginWidth = 0;
        l.marginHeight = 0;
        layout = l;
    }
    int numColumns = 2;
    setLayout(layout);

    if (layout instanceof GridLayout)
        ((GridLayout) layout).numColumns = numColumns;

    fLabel = new Label(this, SWT.LEFT);
    fLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 1));

    if (progressIndicatorHeight == SWT.DEFAULT) {
        GC gc = new GC(fLabel);
        FontMetrics fm = gc.getFontMetrics();
        gc.dispose();
        progressIndicatorHeight = fm.getHeight();
    }

    fProgressIndicator = new ProgressIndicator(this);
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;
    gd.verticalAlignment = GridData.CENTER;
    gd.heightHint = progressIndicatorHeight;
    fProgressIndicator.setLayoutData(gd);

    fToolBar = new ToolBar(this, SWT.FLAT);

    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    gd.grabExcessVerticalSpace = false;
    gd.verticalAlignment = GridData.CENTER;
    fToolBar.setLayoutData(gd);
    fStopButton = new ToolItem(fToolBar, SWT.PUSH);
    // It would have been nice to use the fCancelListener, but that
    // listener operates on the fCancelComponent which must be a control.
    fStopButton.addListener(SWT.Selection, new CancelListener());
    final Image stopImage = ImageDescriptor.createFromFile(ForgeProgressMonitorPart.class, "images/stop.gif") //$NON-NLS-1$
            .createImage(getDisplay());
    final Cursor arrowCursor = new Cursor(this.getDisplay(), SWT.CURSOR_ARROW);
    fToolBar.setCursor(arrowCursor);
    fStopButton.setImage(stopImage);
    fStopButton.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            stopImage.dispose();
            arrowCursor.dispose();
        }
    });
    fStopButton.setEnabled(false);
    fStopButton.setToolTipText(JFaceResources.getString("ProgressMonitorPart.cancelToolTip")); //$NON-NLS-1$
}

From source file:org.jboss.tools.hibernate.ui.diagram.editors.DiagramContentOutlinePage.java

License:Open Source License

/**
 * Outline viewer configuration/*  ww  w .  j a v  a  2s  .co m*/
 * 
 */
protected void configureOutlineViewer() {
    getViewer().setEditDomain(editor.getDefaultEditDomain());
    getViewer().setEditPartFactory(new TreePartFactory());
    MenuManager provider = new PopupMenuProvider(getViewer(), getActionRegistry());
    //getViewer().setContextMenu(provider);
    getViewer().setContextMenu(provider);
    getSite().registerContextMenu("org.jboss.tools.hibernate.ui.diagram.editors.popup.outline.contextmenu", //$NON-NLS-1$
            provider, getSite().getSelectionProvider());
    IToolBarManager tbm = getSite().getActionBars().getToolBarManager();

    tbm.add(editor.getLexicalSortingAction());

    showOutlineAction = new Action() {
        public void run() {
            showPage(ID_OUTLINE);
        }
    };
    showOutlineAction.setToolTipText(DiagramViewerMessages.DiagramContentOutlinePage_Outline);
    showOutlineAction
            .setImageDescriptor(ImageDescriptor.createFromFile(DiagramViewer.class, "icons/outline.gif")); //$NON-NLS-1$
    tbm.add(showOutlineAction);
    showOverviewAction = new Action() {
        public void run() {
            showPage(ID_OVERVIEW);
        }
    };
    showOverviewAction.setToolTipText(DiagramViewerMessages.DiagramContentOutlinePage_Overview);
    showOverviewAction
            .setImageDescriptor(ImageDescriptor.createFromFile(DiagramViewer.class, "icons/overview.gif")); //$NON-NLS-1$
    tbm.add(showOverviewAction);
    showPage(ID_OVERVIEW);
}

From source file:org.jboss.tools.jsf.ui.editor.JSFEditor.java

License:Open Source License

protected PaletteContainer createControlGroup(PaletteRoot root) {
    PaletteGroup controlGroup = new PaletteGroup("control"); //$NON-NLS-1$

    List<PaletteEntry> entries = new ArrayList<PaletteEntry>();

    ToolEntry tool = new SelectionToolEntry();
    tool.setDescription(FacesConfigEditorMessages.JSFDIAGRAM_SELECT);
    entries.add(tool);/*from   w ww  .j  a  v  a  2  s.  c o m*/
    root.setDefaultEntry(tool);

    tool = new MarqueeToolEntry();
    tool.setDescription(FacesConfigEditorMessages.JSFDIAGRAM_MARQUEE);
    entries.add(tool);

    PaletteSeparator sep = new PaletteSeparator("separator"); //$NON-NLS-1$
    sep.setUserModificationPermission(PaletteSeparator.PERMISSION_NO_MODIFICATION);
    entries.add(sep);

    connectionCreationTool = new GEFConnectionCreationToolEntry(
            FacesConfigEditorMessages.JSFDIAGRAM_CREATE_NEW_CONNECTION,
            FacesConfigEditorMessages.JSFDIAGRAM_CREATE_NEW_CONNECTION, null,
            ImageDescriptor.createFromFile(JSFEditor.class, "icons/transition.gif"), //$NON-NLS-1$
            null) {
        protected void dragFinished() {
            XModelTransferBuffer.getInstance().disable();
        }
    };
    connectionCreationTool.setUnloadWhenFinished(switchToSelectionTool);
    entries.add(connectionCreationTool);

    entries.add(sep);

    CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
            FacesConfigEditorMessages.JSFDIAGRAM_VIEW_TEMPLATE,
            FacesConfigEditorMessages.JSFDIAGRAM_VIEW_TEMPLATE, TemplateConstants.TEMPLATE_VIEW,
            new SimpleFactory(String.class), ImageDescriptor.createFromFile(JSFEditor.class, "icons/view.gif"), //$NON-NLS-1$
            null);
    entries.add(combined);

    controlGroup.addAll(entries);
    return controlGroup;
}

From source file:org.jboss.tools.jst.angularjs.internal.ExpressionsProposalProcessor.java

License:Open Source License

@Override
public TextProposal[] getProposals(KbQuery query, IPageContext context) {
    List<TextProposal> proposals = new ArrayList<TextProposal>();
    String qValue = query.getValue();
    int startEl = qValue.lastIndexOf("{{");
    if (startEl < 0) {
        qValue = query.getRegionValuePrefix();
        if (qValue != null) {
            startEl = qValue.lastIndexOf("{{");
        }/*from w  w  w . ja  v  a  2 s . com*/
    }
    if (startEl > -1) {
        String value = qValue.substring(startEl + 2);
        if (!value.contains("\n") && !value.contains("}") && (new AngularJSRecognizer()).isUsed(context)) {
            // Create a JS
            String js = generateJs(value, context);
            Collection<Object> results = BrowserDataProviderManager.getInstance().evaluate(js, context);
            // Convert the data to a list of proposals
            if (!results.isEmpty()) {
                if (image == null) {
                    image = ImageDescriptor.createFromFile(AngularJsPlugin.class, "angular.png");
                }
                for (Object object : results) {
                    if (object == BrowserDataProviderManager.DATA_LOADING) {
                        ReplacementString rs = getReplacementString(query, "", qValue, "");
                        TextProposal proposal = new TextProposal();
                        proposal.setLabel(AngularMessages.dataLoading);
                        proposal.setReplacementString(rs.string);
                        proposal.setPosition(rs.position);
                        proposal.setImageDescriptor(image);
                        proposal.setAutoActivationContentAssistantAfterApplication(true);
                        proposal.setRelevance(Integer.MAX_VALUE);
                        proposals.add(proposal);
                    } else {
                        String result = object.toString();
                        StringTokenizer st = new StringTokenizer(result, ";", false);
                        int dotIndex = value.lastIndexOf('.');
                        String remove = value;
                        if (dotIndex > -1) {
                            remove = value.substring(dotIndex + 1);
                        }
                        while (st.hasMoreElements()) {
                            String label = st.nextToken().trim();
                            if (!label.matches("\\d+")) { // Ignore numbers
                                ReplacementString rs = getReplacementString(query, label, qValue, remove);
                                TextProposal proposal = new TextProposal();
                                proposal.setRelevance(TextProposal.R_TAG_TEMPLATE + 10);
                                proposal.setLabel(label);
                                proposal.setReplacementString(rs.string);
                                proposal.setPosition(rs.position);
                                proposal.setImageDescriptor(image);
                                proposal.setAutoActivationContentAssistantAfterApplication(false);
                                proposals.add(proposal);
                            }
                        }
                    }
                }
            }
        }
    }
    return proposals.toArray(new TextProposal[proposals.size()]);
}

From source file:org.jboss.tools.jst.web.kb.internal.proposal.FacetNameProposalType.java

License:Open Source License

@Override
public TextProposal[] getProposals(KbQuery query) {
    String[] parentTags = query.getParentTags();
    Set<String> facetNames = new HashSet<String>();
    if (parentTags.length > 1) {
        String parentTag = parentTags[parentTags.length - 2];
        KbQuery newQuery = new KbQuery();
        newQuery.setMask(false);//from   www .  j a  v  a2 s  .com
        newQuery.setType(KbQuery.Type.TAG_NAME);
        newQuery.setValue(parentTag);
        newQuery.setOffset(query.getOffset());
        IComponent[] components = PageProcessor.getInstance().getComponents(newQuery, context);
        Set<String> types = new HashSet<String>();
        for (int i = 0; i < components.length; i++) {
            String type = components[i].getComponentType();
            if (type != null) {
                types.add(type.trim());
            }
        }
        if (!types.isEmpty()) {
            ITagLibrary[] libs = TagLibraryManager.getLibraries(context.getResource().getProject());
            for (ITagLibrary lib : libs) {
                if (lib instanceof IFacesConfigTagLibrary) {
                    for (String type : types) {
                        IComponent comp = lib.getComponentByType(type);
                        if (comp != null) {
                            Facet[] facets = comp.getFacets();
                            if (facets != null) {
                                for (int i = 0; i < facets.length; i++) {
                                    facetNames.add(facets[i].getName());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    List<TextProposal> proposals = new ArrayList<TextProposal>();
    for (String facetName : facetNames) {
        if (facetName.startsWith(query.getValue())) {
            TextProposal proposal = new TextProposal();
            proposal.setLabel(facetName);
            proposal.setReplacementString(facetName);
            proposal.setPosition(facetName.length());
            if (ICON == null) {
                ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME);
            }
            proposal.setImageDescriptor(ICON);
            proposals.add(proposal);
        }
    }
    return proposals.toArray(new TextProposal[0]);
}

From source file:org.jboss.tools.jst.web.kb.WebKbPlugin.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(Class<?> baseClass, String imageName) {
    return ImageDescriptor.createFromFile(baseClass, imageName);
}

From source file:org.jboss.tools.jst.web.kb.WebKbPlugin.java

License:Open Source License

public static Image getImage(Class<?> baseClass, String imageName) {
    ImageRegistry registry = getDefault().getImageRegistry();
    Image result = registry.get(imageName);
    if (result == null || result.isDisposed()) {
        result = ImageDescriptor.createFromFile(baseClass, imageName).createImage();
        if (result != null) {
            registry.put(imageName, result);
        }/*from  w ww .ja v  a2s.  c  o  m*/
    }
    return result;
}