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

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

Introduction

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

Prototype

public static Image getImage(String key) 

Source Link

Document

Returns the image in JFace's image registry with the given key, or null if none.

Usage

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.AspectPresentationTooltip.java

License:Open Source License

@Override
protected final Composite createToolTipContentArea(final Event event, final Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);

    GridLayout gl = new GridLayout(1, false);
    gl.marginBottom = 0;/*w ww .  ja  va  2s.c  om*/
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    gl.verticalSpacing = 1;
    comp.setLayout(gl);

    Composite topArea = new Composite(comp, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.widthHint = 200;
    topArea.setLayoutData(data);
    topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 2;
    gl.marginTop = 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 5;
    gl.marginRight = 2;

    topArea.setLayout(gl);

    Label l = new Label(topArea, SWT.NONE);
    l.setText(_aspect.getDisplayNameWithID());
    l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT));
    l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR));
    l.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite iconComp = new Composite(topArea, SWT.NONE);
    iconComp.setLayoutData(new GridData());
    iconComp.setLayout(new GridLayout(2, false));
    iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    iconComp.setLayout(gl);

    Label helpIcon = new Label(iconComp, SWT.NONE);
    helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    helpIcon.setImage(_imageReg.get(IconsInternal.CANCEL));
    helpIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            hide();
            // MarkupTooltip.this.dispose();
            openHelp();
        }
    });

    Label closeIcon = new Label(iconComp, SWT.NONE);
    closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON));
    closeIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            _parentShell.setFocus();
            hide();
            // MarkupTooltip.this.dispose();
        }
    });

    createContentArea(comp).setLayoutData(new GridData(GridData.FILL_BOTH));

    return comp;
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.MarkupTooltip.java

License:Open Source License

@Override
protected final Composite createToolTipContentArea(final Event event, final Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);

    GridLayout gl = new GridLayout(1, false);
    gl.marginBottom = 0;//ww  w  .  j ava  2  s .c o m
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    gl.verticalSpacing = 1;
    comp.setLayout(gl);

    Composite topArea = new Composite(comp, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.widthHint = 200;
    topArea.setLayoutData(data);
    topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 2;
    gl.marginTop = 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 5;
    gl.marginRight = 2;

    topArea.setLayout(gl);

    Label l = new Label(topArea, SWT.NONE);
    l.setText(_headerText);
    l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT));
    l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR));
    l.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite iconComp = new Composite(topArea, SWT.NONE);
    iconComp.setLayoutData(new GridData());
    iconComp.setLayout(new GridLayout(2, false));
    iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    iconComp.setLayout(gl);

    Label helpIcon = new Label(iconComp, SWT.NONE);
    helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    helpIcon.setImage(_imageReg.get(IconsInternal.MARKUP));
    helpIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            hide();
            // MarkupTooltip.this.dispose();
            openHelp();
        }
    });

    Label closeIcon = new Label(iconComp, SWT.NONE);
    closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON));
    closeIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            _parentShell.setFocus();
            hide();
            // MarkupTooltip.this.dispose();
        }
    });

    createContentArea(comp).setLayoutData(new GridData(GridData.FILL_BOTH));

    return comp;
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.ReferenceEditorAddFieldToolTip.java

License:Open Source License

@Override
protected final Composite createToolTipContentArea(final Event event, final Composite parent) {
    _mainComp = new Composite(parent, SWT.NONE);

    GridLayout gl = new GridLayout(1, false);
    gl.marginBottom = 0;//from   w  w w . j ava2 s. c  o m
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    gl.verticalSpacing = 1;
    _mainComp.setLayout(gl);

    Composite topArea = new Composite(_mainComp, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.widthHint = 370;
    topArea.setLayoutData(data);
    topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 2;
    gl.marginTop = 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 5;
    gl.marginRight = 2;

    topArea.setLayout(gl);

    Label l = new Label(topArea, SWT.NONE);
    l.setText(_headerText);
    l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT));
    l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR));
    l.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite iconComp = new Composite(topArea, SWT.NONE);
    iconComp.setLayoutData(new GridData());
    iconComp.setLayout(new GridLayout(2, false));
    iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    iconComp.setLayout(gl);

    Label helpIcon = new Label(iconComp, SWT.NONE);
    helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    helpIcon.setImage(_imageReg.get(IconsInternal.CANCEL));
    helpIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            hide();
            // openHelp();
        }
    });

    Label closeIcon = new Label(iconComp, SWT.NONE);
    closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON));
    closeIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            _parentShell.setFocus();
            hide();
        }
    });

    createContentArea().setLayoutData(new GridData(GridData.FILL_BOTH));

    return _mainComp;
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.RevisionHistoryToolTip.java

License:Open Source License

@Override
protected final Composite createToolTipContentArea(final Event event, final Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);

    GridLayout gl = new GridLayout(1, false);
    gl.marginBottom = 0;//from  w w  w. j  ava 2  s .c o m
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    gl.verticalSpacing = 1;
    comp.setLayout(gl);

    Composite topArea = new Composite(comp, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.widthHint = 200;
    topArea.setLayoutData(data);
    topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 2;
    gl.marginTop = 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 5;
    gl.marginRight = 2;

    topArea.setLayout(gl);

    Label l = new Label(topArea, SWT.NONE);
    l.setText(_headerText);
    l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT));
    l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR));
    l.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite iconComp = new Composite(topArea, SWT.NONE);
    iconComp.setLayoutData(new GridData());
    iconComp.setLayout(new GridLayout(2, false));
    iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));

    gl = new GridLayout(2, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    iconComp.setLayout(gl);

    Label helpIcon = new Label(iconComp, SWT.NONE);
    helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    helpIcon.setImage(_imageReg.get(IconsInternal.USER));
    helpIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            hide();
        }
    });

    Label closeIcon = new Label(iconComp, SWT.NONE);
    closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR));
    closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON));
    closeIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            _parentShell.setFocus();
            hide();
        }
    });

    createContentArea(comp).setLayoutData(new GridData(GridData.FILL_BOTH));

    return comp;
}

From source file:org.bonitasoft.studio.common.jface.CellEditorValidationStatusListener.java

License:Open Source License

@Override
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
    if (!newValidState) {
        statusControl.setText(editor.getErrorMessage());
        statusControl.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
    } else {/*from w ww.  j a  v a2s  .  c  o m*/
        statusControl.setText("");
        statusControl.setImage(null);
    }
}

From source file:org.bonitasoft.studio.common.properties.TogglePropertyHelpContributionItem.java

License:Open Source License

@Override
public void fill(final ToolBar toolbar, final int arg1) {
    final ToolItem toolItem = new ToolItem(toolbar, SWT.LEFT | SWT.PUSH | SWT.NO_FOCUS);
    toolItem.setToolTipText(Messages.toggleHelp);
    toolItem.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP));
    toolItem.addSelectionListener(new SelectionAdapter() {

        @Override/*from w  w w  .  j ava 2  s. c o m*/
        public void widgetSelected(final SelectionEvent e) {
            toggleHelp();
        }
    });
    if (propertySectionHistory.isDescriptionVisible()) {
        toggleHelp();
    }
}

From source file:org.bonitasoft.studio.contract.ui.property.constraint.edit.editor.ConstraintEditorWizardDialog.java

License:Open Source License

protected Image getHelpImage() {
    return JFaceResources.getImage(DLG_IMG_HELP);
}

From source file:org.bonitasoft.studio.engine.ui.dialog.ProcessEnablementProblemsDialog.java

License:Open Source License

@Override
protected Control createCustomArea(Composite parent) {
    if (processResolutionProblems.isEmpty()) {
        return super.createCustomArea(parent);
    }//from  w w  w.j  ava2 s .c o  m
    TableViewer problemsViewer = new TableViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    problemsViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(300, 100).indent(0, 10).create());
    problemsViewer.setContentProvider(new ArrayContentProvider());
    problemsViewer.setLabelProvider(new LabelProvider() {

        /*
         * (non-Javadoc)
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        @Override
        public String getText(Object element) {
            return ((Problem) element).getDescription();
        }

        /*
         * (non-Javadoc)
         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
         */
        @Override
        public Image getImage(Object element) {
            return ((Problem) element).getLevel() == Level.ERROR
                    ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)
                    : JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        }
    });
    problemsViewer.setInput(processResolutionProblems);
    return problemsViewer.getControl();
}

From source file:org.bonitasoft.studio.expression.editor.viewer.PatternExpressionViewer.java

License:Open Source License

protected void createTextViewer() {
    viewer = createViewer(mc);//ww w.j av  a  2s  . com
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    configureTextViewer();

    helpDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.RIGHT, this);
    helpDecoration.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP));
    helpDecoration.setDescriptionText(Messages.patternViewerHelp);
    helpDecoration.setMarginWidth(2);
    helpDecoration.hide();

    hintDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.LEFT, this);
    hintDecoration.setImage(Pics.getImage(PicsConstants.hint));
    hintDecoration.setMarginWidth(2);
    hintDecoration.setShowHover(true);
    hintDecoration.setShowOnlyOnFocus(true);
    hintDecoration.hide();

    viewer.addTextListener(new ITextListener() {

        @Override
        public void textChanged(TextEvent event) {
            viewer.getTextWidget().notifyListeners(SWT.Modify, new Event());
        }
    });

    contentAssisProcessor = new ExpressionContentAssistProcessor(viewer.getDocument());
    final ContentAssistant assistant = new ContentAssistant();
    assistant.setContentAssistProcessor(contentAssisProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    assistant.setShowEmptyList(true);
    assistant.enableAutoActivation(true);
    assistant.install(viewer);

    viewer.getTextWidget().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {

            switch (e.keyCode) {
            case SWT.F1:
                assistant.showPossibleCompletions();
                break;
            default:
                //ignore everything else
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if ((e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND) && e.keyCode == SWT.SPACE) {
                assistant.showPossibleCompletions();
            }
        }
    });

    ISWTObservableValue observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(getTextControl(), SWT.Modify));
    observable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            if (!expressionMode()) {
                updateExpressionDependencies();
            }
        }
    });

    helpDecoration.show();
}

From source file:org.bonitasoft.studio.migration.ui.view.CheckboxLabelProvider.java

License:Open Source License

@Override
protected void paint(Event event, Object element) {
    super.paint(event, element);
    Image image = null;//from  www .  java  2s.  co  m
    Change change = (Change) element;
    if (change.isReviewed()) {
        image = JFaceResources.getImage(CHECKED_KEY);
    } else {
        image = JFaceResources.getImage(UNCHECK_KEY);
    }
    Rectangle bounds = ((TableItem) event.item).getBounds(event.index);
    Rectangle imgBounds = image.getBounds();
    bounds.width /= 2;
    bounds.width -= imgBounds.width / 2;
    bounds.height /= 2;
    bounds.height -= imgBounds.height / 2;

    int x = bounds.width > 0 ? bounds.x + bounds.width : bounds.x;
    int y = bounds.height > 0 ? bounds.y + bounds.height : bounds.y;

    event.gc.drawImage(image, x, y);
}