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.xmind.ui.internal.dialogs.ProgressDialogPart.java

License:LGPL

@Override
protected void createContent(Composite parent) {
    resources = new LocalResourceManager(JFaceResources.getResources(), parent);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setBackground((Color) resources.get(ColorUtils.toDescriptor("#ffffff"))); //$NON-NLS-1$

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;/* w ww. j  a v a 2s .c  o  m*/
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);

    createContentsSection(composite);
    createBottomSection(composite);

    this.control = composite;
}

From source file:org.xmind.ui.internal.dialogs.ShareDialog.java

License:Open Source License

@Override
protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    resources = new LocalResourceManager(JFaceResources.getResources(), newShell);
}

From source file:org.xmind.ui.internal.editor.MindMapEditor.java

License:Open Source License

private void updateMessages(boolean layout) {
    for (Control messageItem : messageContainer.getChildren()) {
        messageItem.dispose();/*  www  .  ja  va 2 s.co  m*/
    }
    List<IInteractiveMessage> messages = workbookRef.getMessages();
    if (messages != null && !messages.isEmpty()) {
        for (IInteractiveMessage message : new ArrayList<IInteractiveMessage>(messages)) {

            Image icon;
            Color lineColor;
            Color textColor;
            int type = message.getMessageType();
            if (type == IInteractiveMessage.WARNING) {
                ///TODO use a dedicated icon
                icon = null;
                lineColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#fff6ae")); //$NON-NLS-1$
                textColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#1e1e1e")); //$NON-NLS-1$
            } else if (type == IInteractiveMessage.ERROR) {
                ///TODO use a dedicated icon
                icon = null;
                lineColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#fff6ae")); //$NON-NLS-1$
                textColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#1e1e1e")); //$NON-NLS-1$
            } else {
                ///TODO use a dedicated icon
                icon = Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION);
                lineColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#fff6ae")); //$NON-NLS-1$
                textColor = (Color) JFaceResources.getResources().get(ColorUtils.toDescriptor("#1e1e1e")); //$NON-NLS-1$
            }

            String text = message.getMessage();
            if (text == null) {
                text = ""; //$NON-NLS-1$
            }

            List<IAction> actions = message.getActions();

            final Composite line = new Composite(messageContainer, SWT.NONE);
            line.setBackground(lineColor);
            GridData lineData = new GridData(SWT.CENTER, SWT.FILL, true, false);
            lineData.widthHint = 500;
            line.setLayoutData(lineData);
            line.setLayout(new GridLayout(2, false));

            Composite leftComposite = new Composite(line, SWT.NONE);
            leftComposite.setBackground(line.getBackground());
            GridData lineBodyData = new GridData(SWT.CENTER, SWT.FILL, true, false);
            leftComposite.setLayoutData(lineBodyData);
            int numColumns = 0;
            GridLayout leftCompositeLayout = new GridLayout(numColumns, false);
            leftCompositeLayout.marginLeft = 16;
            leftCompositeLayout.marginHeight = 5;
            leftCompositeLayout.horizontalSpacing = 3;
            leftCompositeLayout.verticalSpacing = 0;
            leftComposite.setLayout(leftCompositeLayout);

            if (icon != null) {
                numColumns++;
                Label iconLabel = new Label(leftComposite, SWT.NONE);
                iconLabel.setBackground(line.getBackground());
                iconLabel.setImage(icon);
                iconLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true));
            }

            numColumns++;
            Label textLabel = new Label(leftComposite, SWT.WRAP | SWT.CENTER);
            textLabel.setText(text);
            textLabel.setBackground(line.getBackground());
            textLabel.setForeground(textColor);
            textLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
            Font textFont = textLabel.getFont();
            if (textFont != null) {
                FontData[] fontData = textFont.getFontData();
                FontData[] newFontData = FontUtils.newHeight(fontData, Util.isMac() ? 12 : 10);
                textLabel.setFont(
                        (Font) JFaceResources.getResources().get(FontDescriptor.createFrom(newFontData)));
            }

            if (!actions.isEmpty()) {
                numColumns++;
                Composite actionBar = new Composite(leftComposite, SWT.NONE);
                actionBar.setBackground(line.getBackground());
                actionBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
                GridLayout actionLayout = new GridLayout(actions.size(), false);
                actionLayout.marginWidth = 0;
                actionLayout.marginHeight = 0;
                actionLayout.horizontalSpacing = 3;
                actionLayout.verticalSpacing = 0;
                actionBar.setLayout(actionLayout);

                for (final IAction action : actions) {
                    final Button actionButton = new Button(actionBar, SWT.PUSH);
                    actionButton.setBackground(actionBar.getBackground());
                    actionButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
                    String actionText = action.getText();
                    if (actionText == null) {
                        actionButton.setText(actionText);
                    } else {
                        ImageDescriptor actionImageDescriptor = action.getImageDescriptor();
                        if (actionImageDescriptor != null) {
                            final Image actionImage = actionImageDescriptor.createImage(Display.getCurrent());
                            actionButton.addDisposeListener(new DisposeListener() {

                                @Override
                                public void widgetDisposed(DisposeEvent e) {
                                    actionImage.dispose();
                                }
                            });
                            actionButton.setImage(actionImage);
                        }
                    }
                    actionButton.setToolTipText(action.getToolTipText());
                    actionButton.addListener(SWT.Selection, new Listener() {

                        @Override
                        public void handleEvent(Event event) {
                            action.runWithEvent(event);
                        }
                    });
                }
            }

            leftCompositeLayout.numColumns = numColumns;

            final Label closeImageLabel = new Label(line, SWT.NONE);
            closeImageLabel.setBackground(line.getBackground());
            closeImageLabel.setImage(
                    (Image) JFaceResources.getResources().get(MindMapUI.getImages().get("close.png", true))); //$NON-NLS-1$
            closeImageLabel.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
            closeImageLabel.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseDown(MouseEvent e) {
                    if (messageContainer != null && !messageContainer.isDisposed()) {
                        if (line != null && !line.isDisposed()) {
                            line.dispose();
                        }
                        Control[] children = messageContainer.getChildren();
                        if (children == null || children.length == 0) {
                            messageContainer.setVisible(false);
                        }
                        messageContainer.getParent().layout(true);
                    }
                }
            });
            closeImageLabel.addMouseTrackListener(new MouseTrackListener() {

                @Override
                public void mouseHover(MouseEvent e) {
                    closeImageLabel.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND));
                }

                @Override
                public void mouseExit(MouseEvent e) {
                    closeImageLabel.setCursor(null);
                }

                @Override
                public void mouseEnter(MouseEvent e) {
                    closeImageLabel.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND));
                }
            });
        }
        org.eclipse.swt.graphics.Point size = messageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        FormData messageFormData = new FormData();
        messageFormData.left = new FormAttachment(50, -size.x / 2);
        messageFormData.right = new FormAttachment(50, size.x / 2);
        messageFormData.top = new FormAttachment(0, 0);
        //can't set bottom
        //            messageFormData.bottom = new FormAttachment(100, -size.y);
        messageContainer.setLayoutData(messageFormData);
        messageContainer.setVisible(true);
    }

    if (layout) {
        messageContainer.getParent().layout(true, true);
    }
}

From source file:org.xmind.ui.internal.mindmap.LegendItemPart.java

License:Open Source License

public LocalResourceManager getResourceManager() {
    if (resourceManager == null)
        resourceManager = new LocalResourceManager(JFaceResources.getResources());
    return resourceManager;
}

From source file:org.xmind.ui.internal.mindmap.MarkerPart.java

License:Open Source License

@Override
protected void onActivated() {
    this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
    super.onActivated();
}

From source file:org.xmind.ui.internal.mindmap.MarkerPart.java

License:Open Source License

private SVGReference createSVGReference() {
    preferredSize = calculateSVGPreferredSize();

    String resourcePath = MarkerImageDescriptor.RESOURCE_URL_PREFIX + getMarker().getSVGPath();
    SVGReference ref = new SVGReference(resourcePath);
    if (this.resourceManager == null)
        this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
    return ref;//  w w  w .j  a v a  2 s  . c o  m
}

From source file:org.xmind.ui.internal.print.multipage.MultipageImagePreviewViewer.java

License:Open Source License

public void createControl(Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    resources = new LocalResourceManager(JFaceResources.getResources(), composite);

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;//  w  ww .ja v a 2  s. co m
    layout.marginWidth = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);

    Composite composite2 = new Composite(composite, SWT.NONE);
    GridLayout layout2 = new GridLayout();
    layout2.marginHeight = 0;
    layout2.marginWidth = 0;
    layout2.horizontalSpacing = 0;
    layout2.verticalSpacing = 10;
    composite2.setLayout(layout2);
    //        composite2.setLayoutData(
    //                new GridData(fill ? GridData.FILL : GridData.CENTER,
    //                        fill ? GridData.FILL : GridData.CENTER, true, true));
    composite2.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));

    createCanvas(composite2);
    createBarControls(composite2);
}

From source file:org.xmind.ui.internal.print.multipage.MultipageImagePreviewViewer.java

License:Open Source License

private void createFeedbackFigure(FigureCanvas canvas) {
    canvas.setViewport(new Viewport(true));

    feedbackLayer = new Layer();
    canvas.getViewport().setContents(feedbackLayer);

    borderFigure = new Layer();
    borderFigure.setBorder(new LineBorder(
            new LocalResourceManager(JFaceResources.getResources(), canvas)
                    .createColor(ColorUtils.toRGB("#959595")), //$NON-NLS-1$
            1));// w ww .j  a  va2 s  .c o m
    feedbackLayer.add(borderFigure);

    textLayer = new Layer();
    textLayer.setLayoutManager(new PreviewTextLayout());
    feedbackLayer.add(textLayer);

    headerFigure = new RotatableWrapLabel(RotatableWrapLabel.NORMAL);
    headerFigure.setForegroundColor(canvas.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    textLayer.add(headerFigure);

    footerFigure = new RotatableWrapLabel(RotatableWrapLabel.NORMAL);
    footerFigure.setForegroundColor(canvas.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    textLayer.add(footerFigure);

    pageNumberLayer = new Layer();
    textLayer.add(pageNumberLayer);

    org.eclipse.draw2d.GridLayout gridLayout = new org.eclipse.draw2d.GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    pageNumberLayer.setLayoutManager(gridLayout);

    pageNumberFigure = new RotatableWrapLabel(RotatableWrapLabel.NORMAL);
    pageNumberFigure.setForegroundColor(canvas.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    org.eclipse.draw2d.GridData gridData = new org.eclipse.draw2d.GridData(SWT.FILL, SWT.FILL, true, true);
    pageNumberLayer.add(pageNumberFigure, gridData);
}

From source file:org.xmind.ui.internal.print.multipage.MultipageSetupDialog.java

License:Open Source License

protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    resources = new LocalResourceManager(JFaceResources.getResources(), newShell);
    newShell.setText(DialogMessages.PageSetupDialog_windowTitle);
}

From source file:org.xmind.ui.internal.spelling.SpellingCheckPrefPage.java

License:Open Source License

private void addSpellingSettings(Composite composite) {
    resources = new LocalResourceManager(JFaceResources.getResources(), composite);

    settingsParent = createSettingsParent(composite);
    addSettingField(Configuration.SPELL_IGNOREUPPERCASE, Messages.ignoreAllCapital);
    addSettingField(Configuration.SPELL_IGNOREMIXEDCASE, Messages.ignoreMultiCapital);
    addSettingField(Configuration.SPELL_IGNOREINTERNETADDRESSES, Messages.ignoreWebAddress);
    addSettingField(Configuration.SPELL_IGNOREDIGITWORDS, Messages.ignoreNumberousAppendix);
    addSettingField(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, Messages.ignoreFirstLowercaseSentences);
}