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.osee.framework.ui.swt.DynamicWizard.java

License:Open Source License

/**
 * The <code>Wizard</code> implementation of this <code>IWizard</code> method disposes all the pages controls using
 * <code>DialogPage.dispose</code>. Subclasses should extend this method if the wizard instance maintains addition
 * SWT resource that need to be disposed.
 *//*from w w w .  j  av  a2s.c om*/
@Override
public void dispose() {
    // notify pages
    Set<String> keys = pages.keySet();
    for (String key : keys) {
        pages.get(key).dispose();
    }
    // dispose of image
    if (defaultImage != null) {
        JFaceResources.getResources().destroyImage(defaultImageDescriptor);
        defaultImage = null;
    }
}

From source file:org.eclipse.osee.framework.ui.swt.DynamicWizard.java

License:Open Source License

@Override
public Image getDefaultPageImage() {
    if (defaultImage == null) {
        defaultImage = JFaceResources.getResources().createImageWithDefault(defaultImageDescriptor);
    }//w  ww . j av a2 s.  c o m
    return defaultImage;
}

From source file:org.eclipse.papyrus.diagram.common.figure.node.HTMLCornerBentFigure.java

License:Open Source License

/**
 * Generates code from a node representing a text.
 * /*  w  w  w . j  ava  2s.c om*/
 * @param node
 *        the node from which to generate belowk flows
 * @param parentFlow
 *        the parent block flow which will contain the block created
 */
protected void generateTextFromTextNode(Node node, BlockFlow parentFlow) {
    // node has type: TEXT_NODE
    String text = HTMLCleaner.cleanHTMLTags(node.getNodeValue());
    TextFlowEx textFlow = new TextFlowEx(text);
    textFlow.setTextUnderline(false);

    boolean italic = false;
    boolean strong = false;
    boolean quote = false;
    boolean codeSample = false;
    String fontName = "Arial";
    int fontSize = 2;

    // calculate the font to apply
    for (Styles style : textProperties) {
        switch (style) {
        case italic:
            italic = true;
            break;
        case strong:
            strong = true;
            break;
        case underline:
            textFlow.setTextUnderline(true);
            break;
        case quote:
            quote = true;
            break;
        case code:
            codeSample = true;
            break;
        case font:
            fontName = (Styles.font.getData().get(FONT_NAME) != null)
                    ? (String) Styles.font.getData().get(FONT_NAME)
                    : "Arial";
            fontSize = (Styles.font.getData().get(FONT_SIZE) != null)
                    ? ((Integer) Styles.font.getData().get(FONT_SIZE))
                    : 2;
            break;
        default:
            break;
        }

    }

    int style = SWT.NORMAL;

    if (italic) {
        style = style | SWT.ITALIC;
    }

    if (strong) {
        style = style | SWT.BOLD;
    }

    FontData fontData;
    if (codeSample) {
        fontData = new FontData("Lucida Console", 8, style);
    } else if (quote) {
        fontData = new FontData("Monotype Corsiva", 10, style);
        textFlow.setBackgroundColor(DisplayUtils.getDisplay().getSystemColor(SWT.COLOR_RED));
    } else {
        // font size = [1..7] in html, but does not correspond to system size... 2 by default => 8 in real size.
        // so: real size = (html font size)+6
        fontData = new FontData(fontName, 2 * fontSize + 4, style);
    }

    Font font = (Font) JFaceResources.getResources().get(FontDescriptor.createFrom(fontData));
    textFlow.setFont(font);

    parentFlow.add(textFlow);
}

From source file:org.eclipse.papyrus.infra.widgets.toolbox.notification.dialogs.AbstractNotificationPopup.java

License:Open Source License

public AbstractNotificationPopup(Display display, int style, FormToolkit toolkit) {
    super(new Shell(display));
    this.toolkit = toolkit;
    setShellStyle(style);/*from w w  w  . ja  v  a2  s.  co m*/

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

    closeJob.setSystem(true);
}

From source file:org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure.java

License:Open Source License

/**
 * Generates code from a node representing a text.
 * // w  w w  .  java 2s.c  o m
 * @param node
 *        the node from which to generate belowk flows
 * @param parentFlow
 *        the parent block flow which will contain the block created
 */
protected void generateTextFromTextNode(Node node, BlockFlow parentFlow) {
    // node has type: TEXT_NODE
    String text = HTMLCleaner.cleanHTMLTags(node.getNodeValue());
    TextFlowEx textFlow = new TextFlowEx(text);
    textFlow.setTextUnderline(false);

    boolean italic = false;
    boolean strong = false;
    boolean quote = false;
    boolean codeSample = false;
    String fontName = "Arial";
    int fontSize = 2;

    // calculate the font to apply
    for (Styles style : textProperties) {
        switch (style) {
        case italic:
            italic = true;
            break;
        case strong:
            strong = true;
            break;
        case underline:
            textFlow.setTextUnderline(true);
            break;
        case quote:
            quote = true;
            break;
        case code:
            codeSample = true;
            break;
        case font:
            fontName = (Styles.font.getData().get(FONT_NAME) != null)
                    ? (String) Styles.font.getData().get(FONT_NAME)
                    : "Arial";
            fontSize = (Styles.font.getData().get(FONT_SIZE) != null)
                    ? ((Integer) Styles.font.getData().get(FONT_SIZE))
                    : 2;
            break;
        default:
            break;
        }

    }

    int style = SWT.NORMAL;

    if (italic) {
        style = style | SWT.ITALIC;
    }

    if (strong) {
        style = style | SWT.BOLD;
    }

    FontData fontData;
    if (codeSample) {
        fontData = new FontData("Lucida Console", 8, style);
    } else if (quote) {
        fontData = new FontData("Monotype Corsiva", 10, style);
        textFlow.setBackgroundColor(DisplayUtils.getDisplay().getSystemColor(SWT.COLOR_RED));
    } else {
        // font size = [1..7] in html, but does not correspond to system
        // size... 2 by default => 8 in real size.
        // so: real size = (html font size)+6
        fontData = new FontData(fontName, 2 * fontSize + 4, style);
    }

    Font font = (Font) JFaceResources.getResources().get(FontDescriptor.createFrom(fontData));
    textFlow.setFont(font);

    parentFlow.add(textFlow);
}

From source file:org.eclipse.pde.internal.ui.compare.PluginStructureCreator.java

License:Open Source License

protected IStructureComparator createStructureComparator(Object input, IDocument document,
        ISharedDocumentAdapter adapter, IProgressMonitor monitor) throws CoreException {
    final boolean isEditable;
    if (input instanceof IEditableContent)
        isEditable = ((IEditableContent) input).isEditable();
    else// w ww.  ja  v  a  2  s.  co  m
        isEditable = false;

    // Create a label provider to provide the text of the elements
    final PDELabelProvider labelProvider = new PDELabelProvider();
    // Create a resource manager to manage the images.
    // We can't use the label provider because an image could be disposed that is still in use.
    // By using a resource manager, we ensure that the image is not disposed until no resource 
    // managers reference it.
    final ResourceManager resources = new LocalResourceManager(JFaceResources.getResources());
    DocumentRangeNode rootNode = new StructureRootNode(document, input, this, adapter) {
        public boolean isEditable() {
            return isEditable;
        }

        public void dispose() {
            // Dispose the label provider and the local resource manager
            labelProvider.dispose();
            resources.dispose();
            super.dispose();
        }
    };
    try {
        parsePlugin(input, rootNode, document, labelProvider, resources, monitor);
    } catch (CoreException ex) {
        if (adapter != null)
            adapter.disconnect(input);
        throw ex;
    }

    return rootNode;
}

From source file:org.eclipse.php.internal.ui.editor.PHPStructuredEditor.java

License:Open Source License

@Override
protected void doSetInput(IEditorInput input) throws CoreException {
    IFile resource = null;//from   w ww  . ja v a2  s  . c  o  m
    isExternal = false;

    if (input instanceof IFileEditorInput) {
        // This is the existing workspace file
        final IFileEditorInput fileInput = (IFileEditorInput) input;
        resource = fileInput.getFile();
        if (getRefactorableFileEditorInput() != null
                && ((RefactorableFileEditorInput) getRefactorableFileEditorInput()).isRefactor()) {
            getRefactorableFileEditorInput().setRefactor(false);
            getDocumentProvider().disconnect(getRefactorableFileEditorInput());
            getRefactorableFileEditorInput().setFile(fileInput.getFile());
            input = getRefactorableFileEditorInput();
        } else {
            input = new RefactorableFileEditorInput(fileInput.getFile());
        }

    }

    if (resource != null) {
        if (PHPToolkitUtil.isPhpFile((IFile) resource)) {

            PhpSourceParser.editFile.set(resource);

            super.doSetInput(input);

            initPHPVersionsListener();

        } else {
            super.doSetInput(input);
        }
    } else {
        isExternal = true;
        super.doSetInput(input);
    }

    ImageDescriptor imageDescriptor = input.getImageDescriptor();
    if (imageDescriptor != null) {
        setTitleImage(JFaceResources.getResources().createImageWithDefault(imageDescriptor));
    }
    if (isShowingOverrideIndicators()) {
        installOverrideIndicator(true);
    }

    if (fProjectionModelUpdater != null)
        updateProjectionSupport();
}

From source file:org.eclipse.php.smarty.ui.editor.SmartyStructuredEditor.java

License:Open Source License

@SuppressWarnings({ "restriction", "unchecked" })
@Override/* w w w .  ja v a2  s. c o  m*/
protected void doSetInput(IEditorInput input) throws CoreException {
    IResource resource = null;
    isExternal = false;

    if (input instanceof IFileEditorInput) {
        // This is the existing workspace file
        final IFileEditorInput fileInput = (IFileEditorInput) input;
        resource = fileInput.getFile();
    } else if (input instanceof IStorageEditorInput) {
        // This kind of editor input usually means non-workspace file, like
        // PHP file which comes from include path, remote file which comes
        // from
        // Web server while debugging, file from ZIP archive, etc...

        //         final IStorageEditorInput editorInput = (IStorageEditorInput) input;
        //         final IStorage storage = editorInput.getStorage();

        //         if (storage instanceof ZipEntryStorage) {
        //            resource = ((ZipEntryStorage) storage).getProject();
        //         }
    }

    if (resource instanceof IFile) {
        if (PHPToolkitUtil.isPhpFile((IFile) resource)
                || "tpl".equals(resource.getFullPath().getFileExtension())) {

            SmartySourceParser.editFile.set(resource);

            super.doSetInput(input);

        } else {
            super.doSetInput(input);
        }
    } else {
        isExternal = true;
        super.doSetInput(input);
    }

    ImageDescriptor imageDescriptor = input.getImageDescriptor();
    if (imageDescriptor != null) {
        setTitleImage(JFaceResources.getResources().createImageWithDefault(imageDescriptor));
    }
    if (isShowingOverrideIndicators()) {
        installOverrideIndicator(true);
    }
}

From source file:org.eclipse.sapphire.ui.forms.swt.SapphireWizard.java

License:Open Source License

@Override
public final Image getDefaultPageImage() {
    if (this.defaultPageImage == null) {
        this.defaultPageImage = JFaceResources.getResources()
                .createImageWithDefault(this.defaultPageImageDescriptor);
    }//from   w  w  w.  j a v  a  2  s. c  om

    return this.defaultPageImage;
}

From source file:org.eclipse.sapphire.ui.forms.swt.SapphireWizard.java

License:Open Source License

private final void refreshImage() {
    if (this.defaultPageImage != null) {
        JFaceResources.getResources().destroyImage(this.defaultPageImageDescriptor);
        this.defaultPageImage = null;
    }/*from   ww  w.ja va  2 s  .c o m*/

    this.defaultPageImageDescriptor = toImageDescriptor(this.part.getImage());

    if (this.defaultPageImageDescriptor == null) {
        this.defaultPageImageDescriptor = JFaceResources.getImageRegistry().getDescriptor(Wizard.DEFAULT_IMAGE);
    }
}