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

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

Introduction

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

Prototype

public static Font getFont(String symbolicName) 

Source Link

Document

Returns the font in JFace's font registry with the given symbolic font name.

Usage

From source file:org.eclipse.ant.internal.ui.preferences.AntPreviewerUpdater.java

License:Open Source License

/**
 * Creates a source preview updater for the given viewer, configuration and preference store.
 * //ww w .j a  va2  s  .c o  m
 * @param viewer
 *            the viewer
 * @param configuration
 *            the configuration
 * @param preferenceStore
 *            the preference store
 */
public AntPreviewerUpdater(final SourceViewer viewer, final AntSourceViewerConfiguration configuration,
        final IPreferenceStore preferenceStore) {

    initializeViewerColors(viewer, preferenceStore);

    final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {
        /*
         * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
         */
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(JFaceResources.TEXT_FONT)) {
                Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
                viewer.getTextWidget().setFont(font);
            }
        }
    };
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
        /*
         * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
         */
        @Override
        public void propertyChange(PropertyChangeEvent event) {

            String property = event.getProperty();

            if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT
                            .equals(property)) {
                initializeViewerColors(viewer, preferenceStore);
            }

            if (configuration.affectsTextPresentation(event)) {
                configuration.adaptToPreferenceChange(event);
                viewer.invalidateTextPresentation();
            }

            if (FormattingPreferences.affectsFormatting(event)) {
                format(viewer, preferenceStore);
            }
        }

        /**
         * @param viewer
         * @param preferenceStore
         */
        private void format(final SourceViewer sourceViewer, final IPreferenceStore store) {
            String contents = sourceViewer.getDocument().get();
            FormattingPreferences prefs = new FormattingPreferences();
            prefs.setPreferenceStore(store);
            contents = XmlFormatter.format(contents, prefs);
            viewer.getDocument().set(contents);
        }
    };
    viewer.getTextWidget().addDisposeListener(new DisposeListener() {
        /*
         * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
         */
        @Override
        public void widgetDisposed(DisposeEvent e) {
            preferenceStore.removePropertyChangeListener(propertyChangeListener);
            JFaceResources.getFontRegistry().removeListener(fontChangeListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
}

From source file:org.eclipse.birt.report.designer.ui.ide.preferences.ExpressionSyntaxColoringPage.java

License:Open Source License

protected Control createContents(final Composite parent) {
    initializeDialogUnits(parent);/*from w w  w. ja  v a2s. co  m*/

    fDefaultForeground = UIUtil.getEclipseEditorForeground();
    fDefaultBackground = UIUtil.getEclipseEditorBackground();
    Composite pageComponent = createComposite(parent, 2);
    UIUtil.bindHelp(getControl(), IHelpContextIds.PREFERENCE_BIRT_EXPRESSION_SYNTAX_COLOR_ID);

    Link link = new Link(pageComponent, SWT.WRAP);
    link.setText(Messages.getString("ExpressionSyntaxColoringPage.Link.ColorAndFont")); //$NON-NLS-1$
    link.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
        }
    });

    GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
    linkData.widthHint = 150; // only expand further if anyone else requires
    // it
    link.setLayoutData(linkData);

    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());

    SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
    GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData2.horizontalSpan = 2;
    editor.setLayoutData(gridData2);
    SashForm top = new SashForm(editor, SWT.HORIZONTAL);
    Composite styleEditor = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginRight = 5;
    ((GridLayout) styleEditor.getLayout()).marginLeft = 0;
    createLabel(styleEditor, Messages.getString("ExpressionSyntaxColoringPage.Label.SyntaxElement")); //$NON-NLS-1$
    fStylesViewer = createStylesViewer(styleEditor);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalIndent = 0;
    Iterator iterator = fStyleToDescriptionMap.values().iterator();
    while (iterator.hasNext()) {
        gridData.widthHint = Math.max(gridData.widthHint,
                convertWidthInCharsToPixels(iterator.next().toString().length()));
    }
    gridData.heightHint = convertHeightInCharsToPixels(5);
    fStylesViewer.getControl().setLayoutData(gridData);

    Composite editingComposite = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginLeft = 5;
    createLabel(editingComposite, ""); //$NON-NLS-1$
    Button enabler = createCheckbox(editingComposite,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Enable")); //$NON-NLS-1$
    enabler.setEnabled(false);
    enabler.setSelection(true);
    Composite editControls = createComposite(editingComposite, 2);
    ((GridLayout) editControls.getLayout()).marginLeft = 20;

    fForegroundLabel = createLabel(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Label.Foreground")); //$NON-NLS-1$
    ((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    fForegroundLabel.setEnabled(false);

    fForegroundColorEditor = new ColorSelector(editControls);
    Button fForegroundColor = fForegroundColorEditor.getButton();
    GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fForegroundColor.setLayoutData(gd);
    fForegroundColorEditor.setEnabled(false);
    fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(final AccessibleEvent e) {
            e.result = Messages.getString("ExpressionSyntaxColoringPage.Accessible.Name.Foreground"); //$NON-NLS-1$
        }
    });

    fBackgroundLabel = createLabel(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Label.Background")); //$NON-NLS-1$
    ((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    fBackgroundLabel.setEnabled(false);

    fBackgroundColorEditor = new ColorSelector(editControls);
    Button fBackgroundColor = fBackgroundColorEditor.getButton();
    gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fBackgroundColor.setLayoutData(gd);
    fBackgroundColorEditor.setEnabled(false);
    fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(final AccessibleEvent e) {
            e.result = Messages.getString("ExpressionSyntaxColoringPage.Accessible.Name.Background"); //$NON-NLS-1$
        }
    });

    fBold = createCheckbox(editControls, Messages.getString("ExpressionSyntaxColoringPage.Button.Bold")); //$NON-NLS-1$
    fBold.setEnabled(false);
    ((GridData) fBold.getLayoutData()).horizontalSpan = 2;
    fItalic = createCheckbox(editControls, Messages.getString("ExpressionSyntaxColoringPage.Button.Italic")); //$NON-NLS-1$
    fItalic.setEnabled(false);
    ((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
    fStrike = createCheckbox(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Strikethrough")); //$NON-NLS-1$
    fStrike.setEnabled(false);
    ((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
    fUnderline = createCheckbox(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Underline")); //$NON-NLS-1$
    fUnderline.setEnabled(false);
    ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
    fClearStyle = new Button(editingComposite, SWT.PUSH);
    fClearStyle.setText(Messages.getString("ExpressionSyntaxColoringPage.Button.Restore")); //$NON-NLS-1$
    fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
    ((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
    fClearStyle.setEnabled(false);

    Composite sampleArea = createComposite(editor, 1);

    ((GridLayout) sampleArea.getLayout()).marginLeft = 5;
    ((GridLayout) sampleArea.getLayout()).marginTop = 5;
    createLabel(sampleArea, Messages.getString("ExpressionSyntaxColoringPage.Label.SampleText")); //$NON-NLS-1$
    fPreviewViewer = new SourceViewer(sampleArea, null,
            SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    fPreviewViewer.configure(new JSSourceViewerConfiguration());
    fText = fPreviewViewer.getTextWidget();
    GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData3.widthHint = convertWidthInCharsToPixels(20);
    gridData3.heightHint = convertHeightInCharsToPixels(5);
    gridData3.horizontalSpan = 2;
    fText.setLayoutData(gridData3);
    fText.setEditable(false);
    fText.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    fText.addKeyListener(getTextKeyListener());
    fText.addSelectionListener(getTextSelectionListener());
    fText.addMouseListener(getTextMouseListener());
    fText.addTraverseListener(getTraverseListener());
    setAccessible(fText, Messages.getString("ExpressionSyntaxColoringPage.Label.SampleText")); //$NON-NLS-1$

    JSEditorInput editorInput = new JSEditorInput(loadPreviewContentFromFile());
    JSDocumentProvider documentProvider = new JSDocumentProvider();

    try {
        documentProvider.connect(editorInput);
    } catch (CoreException e) {
        ExceptionHandler.handle(e);
    }

    fDocument = documentProvider.getDocument(editorInput);

    initializeSourcePreviewColors(fPreviewViewer);

    fPreviewViewer.setDocument(fDocument);

    top.setWeights(new int[] { 1, 1 });
    editor.setWeights(new int[] { 1, 1 });

    fStylesViewer.setInput(getStylePreferenceKeys());

    applyStyles();

    fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                activate(namedStyle);
                if (namedStyle == null)
                    return;
            }
        }
    });

    fForegroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[0];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue());

                    if (!newValue.equals(oldValue)) {
                        stylePrefs[0] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        fText.redraw();
                    }
                }
            }
        }
    });

    fBackgroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[1];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue());

                    if (!newValue.equals(oldValue)) {
                        stylePrefs[1] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        fText.redraw();
                        activate(namedStyle);
                    }
                }
            }
        }
    });

    fBold.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[2];
                String newValue = String.valueOf(fBold.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[2] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fItalic.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[3];
                String newValue = String.valueOf(fItalic.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[3] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fStrike.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[4];
                String newValue = String.valueOf(fStrike.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[4] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fUnderline.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[5];
                String newValue = String.valueOf(fUnderline.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[5] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fClearStyle.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (fStylesViewer.getSelection().isEmpty())
                return;
            String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement()
                    .toString();
            getOverlayStore().setToDefault(namedStyle);
            applyStyles();
            fText.redraw();
            activate(namedStyle);
        }
    });

    return pageComponent;
}

From source file:org.eclipse.buildship.ui.console.GradleConsole.java

License:Open Source License

private GradleConsole(String name, Optional<ProcessDescription> processDescription) {
    super(name, PluginImages.TASK.withState(PluginImages.ImageState.ENABLED).getImageDescriptor());

    this.processDescription = processDescription;
    this.configurationStream = newOutputStream();
    this.outputStream = newOutputStream();
    this.errorStream = newOutputStream();
    this.inputStream = super.getInputStream();

    // decorate console output such that URLs are presented as clickable links
    addPatternMatchListener(new UrlPatternMatchListener());

    // collect build scan URL
    addPatternMatchListener(new BuildScanPatternMatchListener());

    // set proper colors on output/error streams (needs to happen in the UI thread)
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

        @SuppressWarnings("restriction")
        @Override/*from w  w  w  .  j  a v a 2  s  . c  om*/
        public void run() {
            Font consoleFont = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT);
            GradleConsole.this.setFont(consoleFont);

            Color backgroundColor = DebugUIPlugin
                    .getPreferenceColor(IDebugPreferenceConstants.CONSOLE_BAKGROUND_COLOR);
            GradleConsole.this.setBackground(backgroundColor);

            Color inputColor = DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.CONSOLE_SYS_IN_COLOR);
            GradleConsole.this.inputStream.setColor(inputColor);

            Color outputColor = DebugUIPlugin
                    .getPreferenceColor(IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR);
            GradleConsole.this.outputStream.setColor(outputColor);

            Color errorColor = DebugUIPlugin
                    .getPreferenceColor(IDebugPreferenceConstants.CONSOLE_SYS_ERR_COLOR);
            GradleConsole.this.errorStream.setColor(errorColor);

            // assign a static color to the configuration output stream
            Color configurationColor = PlatformUI.getWorkbench().getDisplay()
                    .getSystemColor(SWT.COLOR_DARK_GRAY);
            GradleConsole.this.configurationStream.setColor(configurationColor);
        }
    });
}

From source file:org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyPane.java

License:Open Source License

protected VirtualSourceViewer createViewer(Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) {
    int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
    VirtualSourceViewer viewer = new VirtualSourceViewer(parent, fVerticalRuler, fOverviewRuler, true, styles);
    viewer.getControl().setLayoutData(parent.getLayoutData());
    viewer.setEditable(false);/*from  w ww .  j av  a2 s  .  co m*/
    viewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT));
    viewer.setRangeIndicator(new DefaultRangeIndicator());
    getSourceViewerDecorationSupport(viewer);
    viewer.configure(new SourceViewerConfiguration());
    JFaceResources.getFontRegistry().addListener(this);
    JFaceResources.getColorRegistry().addListener(this);
    getEditorPreferenceStore().addPropertyChangeListener(this);
    return viewer;
}

From source file:org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getProperty();
    if (IInternalCDebugUIConstants.DISASSEMBLY_SOURCE_LINE_COLOR.equals(propertyName)) {
        IEditorInput input = getInput();
        if (input instanceof DisassemblyEditorInput)
            getSourceViewer().changeTextPresentation(
                    createTextPresentation(((DisassemblyEditorInput) input).getSourceRegions()), true);
    } else if (IInternalCDebugUIConstants.DISASSEMBLY_FONT.equals(propertyName)) {
        getSourceViewer().getTextWidget()
                .setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT));
    }//from  w  ww  .jav  a 2s .co m
}

From source file:org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyViewer.java

License:Open Source License

/**
 * Constructor for DisassemblyViewer./*from  ww  w .j a  v  a 2 s. c o  m*/
 * 
 * @param parent
 * @param ruler
 * @param styles
 */
public DisassemblyViewer(Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) {
    super(parent, vertRuler, ovRuler, true,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT));
    setEditable(false);
    GridData gd = new GridData(GridData.FILL_BOTH);
    getControl().setLayoutData(gd);
}

From source file:org.eclipse.cdt.debug.internal.ui.views.modules.ModuleDetailPane.java

License:Open Source License

/**
 * Creates the source viewer in the given parent composite
 * //from   w w w .  ja va  2 s  . co  m
 * @param parent Parent composite to create the source viewer in
 */
private void createSourceViewer(Composite parent) {

    // Create & configure a SourceViewer
    fSourceViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL);
    fSourceViewer.setDocument(getDetailDocument());
    fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT));
    fSourceViewer.setEditable(false);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fSourceViewer.getTextWidget(),
            ICDebugHelpContextIds.MODULES_DETAIL_PANE);
    Control control = fSourceViewer.getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(gd);
}

From source file:org.eclipse.cdt.debug.internal.ui.views.modules.ModuleDetailPane.java

License:Open Source License

@Override
public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getProperty();
    if (propertyName.equals(IInternalCDebugUIConstants.DETAIL_PANE_FONT)) {
        fSourceViewer.getTextWidget()// w ww .java2s .  c  o  m
                .setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT));
    }

}

From source file:org.eclipse.cdt.debug.ui.memory.floatingpoint.FPRendering.java

License:Open Source License

public FPRendering(String id) {
    super(id);//from   w ww  .  j  a v a 2  s. c o  m

    JFaceResources.getFontRegistry().addListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(IInternalDebugUIConstants.FONT_NAME)) {
                FPRendering.this.fRendering.handleFontPreferenceChange(
                        JFaceResources.getFont(IInternalDebugUIConstants.FONT_NAME));
            }
        }
    });

    this.addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            IMemoryRendering sourceRendering = (IMemoryRendering) event.getSource();
            if (!sourceRendering.getMemoryBlock().equals(getMemoryBlock()))
                return;

            Object address = event.getNewValue();

            if (event.getProperty().equals(AbstractTableRendering.PROPERTY_SELECTED_ADDRESS)
                    && address instanceof BigInteger) {
                FPRendering.this.fRendering.ensureVisible((BigInteger) address);
            }
        }
    });

    FPRenderingPlugin.getDefault().getPreferenceStore()
            .addPropertyChangeListener(new IPropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent event) {
                    disposeColors();
                    allocateColors();
                    applyPreferences();
                }
            });

    DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(IDebugUIConstants.PREF_PADDED_STR)) {
                if (FPRendering.this.fRendering != null) {
                    setRenderingPadding((String) event.getNewValue());
                    FPRendering.this.fRendering.redrawPanes();
                }
            }
        }
    });
}

From source file:org.eclipse.cdt.debug.ui.memory.floatingpoint.Rendering.java

License:Open Source License

public Rendering(Composite parent, FPRendering renderingParent) {
    super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL);
    this.setFont(JFaceResources.getFont(IInternalDebugUIConstants.FONT_NAME)); // TODO: internal?
    this.fParent = renderingParent;

    // Initialize the viewport start

    if (fParent.getMemoryBlock() != null) {
        fViewportAddress = fParent.getMemoryBlockStartAddress();

        // The viewport address will be null if memory may be retrieved at any
        // address less than this memory block's base.  If so use the base address.

        if (fViewportAddress == null)
            fViewportAddress = fParent.getBigBaseAddress();

        fBaseAddress = fViewportAddress;
    }/* w  ww.ja v a 2  s  .c om*/

    // Instantiate the panes, TODO default visibility from state or plugin.xml?

    this.fAddressPane = createAddressPane();
    this.fDataPane = createDataPane();

    fAddressBar = new GoToAddressComposite();
    fAddressBarControl = fAddressBar.createControl(parent);
    Button button = fAddressBar.getButton(IDialogConstants.OK_ID);

    if (button != null) {
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                doGoToAddress();
            }
        });

        button = fAddressBar.getButton(IDialogConstants.CANCEL_ID);
        if (button != null) {
            button.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    setVisibleAddressBar(false);
                }
            });
        }
    }

    fAddressBar.getExpressionWidget().addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            doGoToAddress();
        }
    });

    fAddressBar.getExpressionWidget().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.ESC)
                setVisibleAddressBar(false);
            super.keyPressed(e);
        }
    });

    this.fAddressBarControl.setVisible(false);

    getHorizontalBar().addSelectionListener(createHorizontalBarSelectionListener());
    getVerticalBar().addSelectionListener(createVerticalBarSelectinListener());

    this.addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent pe) {
            pe.gc.setBackground(Rendering.this.getFPRendering().getColorBackground());
            pe.gc.fillRectangle(0, 0, Rendering.this.getBounds().width, Rendering.this.getBounds().height);
        }
    });

    setLayout();

    this.addControlListener(new ControlListener() {
        @Override
        public void controlMoved(ControlEvent ce) {
        }

        @Override
        public void controlResized(ControlEvent ce) {
            packColumns();
        }
    });

    DebugPlugin.getDefault().addDebugEventListener(this);
}