Example usage for org.eclipse.jface.resource JFaceResources getResources

List of usage examples for org.eclipse.jface.resource JFaceResources getResources

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getResources.

Prototype

public static ResourceManager getResources() 

Source Link

Document

Returns the ResourceManager for the current display.

Usage

From source file:org.eclipse.ui.views.bookmarkexplorer.BookmarkLabelProvider.java

License:Open Source License

public void dispose() {
    if (image != null) {
        JFaceResources.getResources().destroyImage(desc);
        image = null;
    }
}

From source file:org.eclipse.ui.views.markers.internal.FieldDone.java

License:Open Source License

/**
 * Get the image at path./*from  w  w w.  jav  a  2 s . c  om*/
 * @param path
 * @return Image
 */
private Image getImage(String path) {
    return JFaceResources.getResources().createImageWithDefault(IDEWorkbenchPlugin.getIDEImageDescriptor(path));

}

From source file:org.eclipse.ui.views.markers.internal.FieldSeverityAndMessage.java

License:Open Source License

public Image getImage(Object obj) {
    if (obj == null || !(obj instanceof MarkerNode)) {
        return null;
    }/* ww w  . j  a v  a2  s . co m*/

    MarkerNode node = (MarkerNode) obj;
    if (node.isConcrete()) {
        if (node instanceof ProblemMarker) {
            return Util.getImage(((ProblemMarker) obj).getSeverity());
        }
        return null;
    }

    try {
        return JFaceResources.getResources().createImageWithDefault(IDEInternalWorkbenchImages
                .getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY));
    } catch (DeviceResourceException e) {
        return null;
    }
}

From source file:org.eclipse.ui.views.markers.internal.MarkerResolutionDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    initializeDialogUnits(parent);//from   w ww .ja v  a2 s .  c  om

    setTitleImage(JFaceResources.getResources().createImageWithDefault(
            IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG)));

    Composite mainArea = (Composite) super.createDialogArea(parent);

    // Create a new composite as there is the title bar seperator
    // to deal with
    Composite control = new Composite(mainArea, SWT.NONE);
    control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    FormLayout layout = new FormLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    control.setLayout(layout);

    Label resolutionsLabel = new Label(control, SWT.NONE);
    resolutionsLabel.setText(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title);

    resolutionsLabel.setLayoutData(new FormData());

    resolutionsList = new ListViewer(control, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    resolutionsList.setContentProvider(new IStructuredContentProvider() {
        public Object[] getElements(Object inputElement) {
            return resolutions;
        }

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.jface.viewers.IContentProvider#dispose()
         */
        public void dispose() {

        }

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
         *      java.lang.Object, java.lang.Object)
         */
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

        }
    });

    resolutionsList.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            return ((IMarkerResolution) element).getLabel();
        }
    });

    resolutionsList.addSelectionChangedListener(new ISelectionChangedListener() {
        /*
        * (non-Javadoc)
        * 
        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
        */
        public void selectionChanged(SelectionChangedEvent event) {

            WorkbenchMarkerResolution resolution = getSelectedWorkbenchResolution();
            if (resolution == null || markerMap.containsKey(resolution))
                addMatching.setEnabled(false);
            else
                addMatching.setEnabled(true);
            markersTable.refresh();
        }
    });

    resolutionsList.setInput(this);

    resolutionsList.setComparator(resolutionsComparator);

    FormData listData = new FormData();
    listData.top = new FormAttachment(resolutionsLabel, 0);
    listData.left = new FormAttachment(0);
    listData.right = new FormAttachment(100, 0);
    listData.height = convertHeightInCharsToPixels(10);
    resolutionsList.getControl().setLayoutData(listData);

    Label title = new Label(control, SWT.NONE);
    title.setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Title);
    FormData labelData = new FormData();
    labelData.top = new FormAttachment(resolutionsList.getControl(), 0);
    labelData.left = new FormAttachment(0);
    title.setLayoutData(labelData);

    Composite buttons = createTableButtons(control);
    FormData buttonData = new FormData();
    buttonData.top = new FormAttachment(title, 0);
    buttonData.right = new FormAttachment(100);
    buttonData.height = convertHeightInCharsToPixels(10);
    buttons.setLayoutData(buttonData);

    createMarkerTable(control);

    FormData tableData = new FormData();
    tableData.top = new FormAttachment(buttons, 0, SWT.TOP);
    tableData.left = new FormAttachment(0);
    tableData.right = new FormAttachment(buttons, 0);
    tableData.height = convertHeightInCharsToPixels(10);
    markersTable.getControl().setLayoutData(tableData);

    progressPart = new ProgressMonitorPart(control, new GridLayout());

    FormData progressData = new FormData();
    progressData.top = new FormAttachment(markersTable.getControl(), 0);
    progressData.left = new FormAttachment(0);
    progressData.right = new FormAttachment(100, 0);
    progressPart.setLayoutData(progressData);

    Dialog.applyDialogFont(control);

    String message = NLS.bind(MarkerMessages.MarkerResolutionDialog_Description,
            Util.getProperty(IMarker.MESSAGE, originalMarker));
    if (message.length() > 50) {
        // Add a carriage return in the middle if we can
        int insertionIndex = chooseWhitespace(message);
        if (insertionIndex > 0) {
            StringBuffer buffer = new StringBuffer();
            buffer.append(message.substring(0, insertionIndex));
            buffer.append("\n"); //$NON-NLS-1$
            buffer.append(message.substring(insertionIndex, message.length()));
            message = buffer.toString();
        }
    }

    setMessage(message);
    return mainArea;

}

From source file:org.eclipse.wb.internal.discovery.ui.WBDiscoveryUiPlugin.java

License:Open Source License

public static Image getImage(ImageDescriptor imageDescriptor) {
    if (resourceManager == null) {
        resourceManager = new LocalResourceManager(JFaceResources.getResources());
    }/*from w  w w.jav a  2 s . c  o m*/
    return resourceManager.createImage(imageDescriptor);
}

From source file:org.eclipsetrader.ui.internal.NotificationPopup.java

License:Open Source License

public NotificationPopup(Display display, int style) {
    super(new Shell(display));
    setShellStyle(style);/*ww  w  . j ava  2  s  .  c  o  m*/

    this.display = display;
    resources = new LocalResourceManager(JFaceResources.getResources());
    initResources();

    closeJob.setSystem(true);
}

From source file:org.fusesource.ide.branding.wizards.project.WorkingSetGroup.java

License:Open Source License

private void createControl(Composite container) {
    addToWorkingSetButton = new Button(container, SWT.CHECK);
    GridData gd_addToWorkingSetButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
    gd_addToWorkingSetButton.verticalIndent = 12;
    addToWorkingSetButton.setLayoutData(gd_addToWorkingSetButton);
    addToWorkingSetButton.setSelection(true);
    addToWorkingSetButton.setData("name", "addToWorkingSetButton"); //$NON-NLS-1$ //$NON-NLS-2$
    addToWorkingSetButton.setText(WizardMessages.WorkingSetGroup_btnAddSet);
    addToWorkingSetButton.setSelection(false);

    final Label workingsetLabel = new Label(container, SWT.NONE);
    GridData gd_workingsetLabel = new GridData();
    gd_workingsetLabel.horizontalIndent = 10;
    workingsetLabel.setLayoutData(gd_workingsetLabel);
    workingsetLabel.setEnabled(false);//from   www .jav a  2 s  .  c  o m
    workingsetLabel.setData("name", "workingsetLabel"); //$NON-NLS-1$ //$NON-NLS-2$
    workingsetLabel.setText(WizardMessages.WorkingSetGroup_lblSet);

    Combo workingsetCombo = new Combo(container, SWT.READ_ONLY);
    workingsetCombo.setEnabled(false);
    workingsetCombo.setData("name", "workingsetCombo"); //$NON-NLS-1$ //$NON-NLS-2$
    workingsetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    workingsetComboViewer = new ComboViewer(workingsetCombo);
    workingsetComboViewer.setContentProvider(new IStructuredContentProvider() {
        @Override
        public Object[] getElements(Object input) {
            if (input instanceof IWorkingSet[]) {
                return (IWorkingSet[]) input;
            } else if (input instanceof List<?>) {
                return new Object[] { input };
            } else if (input instanceof Set<?>) {
                return ((Set<?>) input).toArray();
            }
            return new IWorkingSet[0];
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }
    });
    workingsetComboViewer.setLabelProvider(new LabelProvider() {
        private ResourceManager images = new LocalResourceManager(JFaceResources.getResources());

        @Override
        public Image getImage(Object element) {
            if (element instanceof IWorkingSet) {
                ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImageDescriptor();
                if (imageDescriptor != null) {
                    try {
                        return (Image) images.create(imageDescriptor);
                    } catch (DeviceResourceException ex) {
                        return null;
                    }
                }
            }
            return super.getImage(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IWorkingSet) {
                return ((IWorkingSet) element).getLabel();
            } else if (element instanceof List<?>) {
                StringBuilder sb = new StringBuilder();
                for (Object o : (List<?>) element) {
                    if (o instanceof IWorkingSet) {
                        if (sb.length() > 0) {
                            sb.append(", "); //$NON-NLS-1$
                        }
                        sb.append(((IWorkingSet) o).getLabel());
                    }
                }
                return sb.toString();
            }
            return super.getText(element);
        }

        @Override
        public void dispose() {
            images.dispose();
            super.dispose();
        }
    });

    workingsetComboViewer.setComparator(new ViewerComparator());

    final Button newWorkingSetButton = new Button(container, SWT.NONE);
    newWorkingSetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    newWorkingSetButton.setData("name", "configureButton"); //$NON-NLS-1$ //$NON-NLS-2$
    newWorkingSetButton.setText(WizardMessages.WorkingSetGroup_btnMore);
    newWorkingSetButton.setEnabled(false);
    newWorkingSetButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
            IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(shell, true,
                    WORKING_SET_IDS.toArray(new String[0]));
            if (dialog.open() == Window.OK) {
                IWorkingSet[] workingSets = dialog.getSelection();
                selectWorkingSets(Arrays.asList(workingSets));
            }
        }
    });

    if (selectWorkingSets(workingSets)) {
        addToWorkingSetButton.setSelection(true);
        workingsetLabel.setEnabled(true);
        workingsetComboViewer.getCombo().setEnabled(true);
        newWorkingSetButton.setEnabled(true);
    }

    addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
            workingsetLabel.setEnabled(addToWorkingingSet);
            workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
            newWorkingSetButton.setEnabled(addToWorkingingSet);
            if (addToWorkingingSet) {
                updateConfiguration();
            } else {
                workingSets.clear();
            }
        }
    });

    workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateConfiguration();
        }
    });
}

From source file:org.hibernate.eclipse.console.workbench.xpl.AnyAdaptableLabelProvider.java

License:Open Source License

/**
 * Creates a new workbench label provider.
 *//*from  w  ww  . java2s . co  m*/
public AnyAdaptableLabelProvider() {
    PlatformUI.getWorkbench().getEditorRegistry().addPropertyListener(editorRegistryListener);
    this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
}

From source file:org.jboss.ide.eclipse.archives.webtools.filesets.FilesetLabelProvider.java

License:Open Source License

public FilesetLabelProvider() {
    super();//from  w ww  .j  a  v  a2s  .c o  m
    this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
    ImageDescriptor des = ImageDescriptor
            .createFromURL(IntegrationPlugin.getDefault().getBundle().getEntry("icons/multiple_files.gif")); //$NON-NLS-1$
    rootImage = des.createImage();
}

From source file:org.jcryptool.fileexplorer.views.FileExplorerLabelProvider.java

License:Open Source License

/**
 * Creates a new workbench label provider.
 *///w w  w. j  a v  a 2s .  c o  m
public FileExplorerLabelProvider() {
    PlatformUI.getWorkbench().getEditorRegistry().addPropertyListener(editorRegistryListener);
    this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
}