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

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

Introduction

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

Prototype

public static FontRegistry getFontRegistry() 

Source Link

Document

Returns the font registry for JFace itself.

Usage

From source file:org.eclipse.tcf.internal.debug.ui.model.TCFDetailPane.java

License:Open Source License

public Control createControl(Composite parent) {
    assert source_viewer == null;
    source_viewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL);
    source_viewer.configure(new SourceViewerConfiguration());
    source_viewer.setDocument(document);
    source_viewer.setEditable(false);/*from   w  w w  .j a  va2 s  .  c  o m*/
    source_viewer.addTextPresentationListener(presentation_listener);
    Control control = source_viewer.getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(gd);
    display = control.getDisplay();
    createActions();
    // Add the selection listener so selection dependent actions get updated.
    document.addDocumentListener(new IDocumentListener() {
        public void documentAboutToBeChanged(DocumentEvent event) {
        }

        public void documentChanged(DocumentEvent event) {
            updateSelectionDependentActions();
        }
    });
    // Add the selection listener so selection dependent actions get updated.
    source_viewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelectionDependentActions();
        }
    });
    // Add a focus listener to update actions when details area gains focus
    source_viewer.getControl().addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            if (part_site != null)
                part_site.setSelectionProvider(source_viewer.getSelectionProvider());
            setGlobalAction(IDebugView.SELECT_ALL_ACTION, getAction(DETAIL_SELECT_ALL_ACTION));
            setGlobalAction(IDebugView.COPY_ACTION, getAction(DETAIL_COPY_ACTION));
            if (part_site instanceof IViewSite)
                ((IViewSite) part_site).getActionBars().updateActionBars();
        }

        public void focusLost(FocusEvent e) {
            if (part_site != null)
                part_site.setSelectionProvider(null);
            setGlobalAction(IDebugView.SELECT_ALL_ACTION, null);
            setGlobalAction(IDebugView.COPY_ACTION, null);
            if (part_site instanceof IViewSite)
                ((IViewSite) part_site).getActionBars().updateActionBars();
        }
    });
    // Add a context menu to the detail area
    createDetailContextMenu(source_viewer.getTextWidget());
    // Add font registry listener
    JFaceResources.getFontRegistry().addListener(this);
    return control;
}

From source file:org.eclipse.tcf.internal.debug.ui.model.TCFDetailPane.java

License:Open Source License

public void dispose() {
    JFaceResources.getFontRegistry().removeListener(this);
    if (mono_font != null) {
        mono_font.dispose();//w  ww .  ja  v a2s  .  co m
        mono_font = null;
    }
    for (Color c : colors.values())
        c.dispose();
    colors.clear();
    if (source_viewer == null)
        return;
    generation++;
    if (source_viewer.getControl() != null) {
        source_viewer.getControl().dispose();
    }
    source_viewer = null;
    selection_actions.clear();
    action_map.clear();
}

From source file:org.eclipse.tcf.internal.debug.ui.model.TCFModelFonts.java

License:Open Source License

public static FontData getNormalFontData(String view_id) {
    FontData fd = fd_normal.get(view_id);
    if (fd == null) {
        if (listener == null) {
            listener = new IPropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    Protocol.invokeLater(new Runnable() {
                        public void run() {
                            fd_normal.clear();
                            fd_italic.clear();
                            fd_monospaced.clear();
                        }/*ww w  .  j  a  va 2  s.co m*/
                    });
                }
            };
            JFaceResources.getFontRegistry().addListener(listener);
        }
        if (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id)) {
            fd = JFaceResources.getFontDescriptor(JFaceResources.DEFAULT_FONT).getFontData()[0];
        } else if (TCFDetailPane.ID.equals(view_id)) {
            FontData ff = JFaceResources.getFontDescriptor(JFaceResources.DEFAULT_FONT).getFontData()[0];
            FontData fp = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_DETAIL_PANE_FONT)
                    .getFontData()[0];
            fd = new FontData(fp.getName(), ff.getHeight(), SWT.NORMAL);
        } else {
            fd = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0];
        }
        fd_normal.put(view_id, fd);
    }
    return fd;
}

From source file:org.eclipse.tcf.te.tcf.ui.console.AbstractConsole.java

License:Open Source License

@Override
protected void dispose() {
    // Do not disconnect the partitioner yet. Dispose is called
    // if the console is removed from the console view. This does
    // not mean the user does not want to show the console again later
    // with the full content preserved. The console will be destroyed
    // if shutdown() is called.
    synchronized (buffer) {
        visible = false;/* w ww .j  av  a  2s  . c om*/
        JFaceResources.getFontRegistry().removeListener(this);
    }
}

From source file:org.eclipse.tcf.te.tcf.ui.console.AbstractConsole.java

License:Open Source License

@Override
protected void init() {
    // Called when console is added to the console view
    super.init();

    initConsoleOutputLimitSettings();/*from ww w  . j a  v a2  s.c om*/
    initConsoleWidthSetting();

    //   Ensure that initialization occurs in the UI thread
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            JFaceResources.getFontRegistry().addListener(AbstractConsole.this);
            initializeStreams();
            flushBuffer();
        }
    });
}

From source file:org.eclipse.tcf.te.ui.forms.CustomFormToolkit.java

License:Open Source License

/**
 * Creates a composite with a highlighted note entry and a message text.
 * This is designed to take up the full width of the page.
 *
* @param parent The parent composite. Must not be <code>null</code>.
 * @param title The note title. Must not be <code>null</code>.
 * @param message The note message Must not be <code>null</code>.
 * @param widthHint The note message width hint in pixel or <code>SWT.DEFAULT</code>.
* @param overwriteBackground If <code>true</code>, the parent background color and image are applied to the note composite.
 *
 * @return The note composite./*  ww  w.  j a v a 2  s . c  o  m*/
 */
public final Composite createNoteComposite(Composite parent, String title, String message, int widthHint,
        boolean overwriteBackground) {
    Assert.isNotNull(parent);
    Assert.isNotNull(title);
    Assert.isNotNull(message);

    Composite composite = getFormToolkit().createComposite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    composite.setFont(parent.getFont());

    Label noteLabel = getFormToolkit().createLabel(composite, title, SWT.BOLD);
    noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    Label messageLabel = getFormToolkit().createLabel(composite, message);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.widthHint = widthHint;
    messageLabel.setLayoutData(layoutData);
    messageLabel.setFont(parent.getFont());

    // Overwrite background color and image if requested
    if (overwriteBackground) {
        composite.setBackground(parent.getBackground());
        composite.setBackgroundImage(parent.getBackgroundImage());

        noteLabel.setBackground(parent.getBackground());
        noteLabel.setBackgroundImage(parent.getBackgroundImage());

        messageLabel.setBackground(parent.getBackground());
        messageLabel.setBackgroundImage(parent.getBackgroundImage());
    }

    return composite;
}

From source file:org.eclipse.tcf.te.ui.notifications.delegates.DefaultFormTextFactoryDelegate.java

License:Open Source License

/**
 * Set the fonts used by the form.//  w ww  .  j a va2 s  . c om
 *
 * @param toolkit The form toolkit. Must not be <code>null</code>.
 * @param widget The form text widget. Must not be <code>null</code>.
 */
protected void setFormTextFonts(FormToolkit toolkit, FormText widget) {
    Assert.isNotNull(toolkit);
    Assert.isNotNull(widget);

    widget.setFont("header", JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); //$NON-NLS-1$
    widget.setFont("text", JFaceResources.getTextFont()); //$NON-NLS-1$
}

From source file:org.eclipse.tcf.te.ui.notifications.internal.popup.AbstractNotificationPopup.java

License:Open Source License

/**
 * Override to customize the title bar/*w w w  .  j  ava 2  s.  c o m*/
 */
protected void createTitleArea(Composite parent) {
    ((GridData) parent.getLayoutData()).heightHint = TITLE_HEIGHT;

    Label titleImageLabel = new Label(parent, SWT.NONE);
    titleImageLabel.setImage(getPopupShellImage(TITLE_HEIGHT));

    Label titleTextLabel = new Label(parent, SWT.NONE);
    titleTextLabel.setText(getPopupShellTitle());
    titleTextLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    titleTextLabel.setForeground(getTitleForeground());
    titleTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    titleTextLabel.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND));

    final Label button = new Label(parent, SWT.NONE);
    button.setImage(UIPlugin.getImage(ImageConsts.NOTIFICATION_CLOSE));
    button.addMouseTrackListener(new MouseTrackAdapter() {
        @Override
        public void mouseEnter(MouseEvent e) {
            button.setImage(UIPlugin.getImage(ImageConsts.NOTIFICATION_CLOSE_HOVER));
        }

        @Override
        public void mouseExit(MouseEvent e) {
            button.setImage(UIPlugin.getImage(ImageConsts.NOTIFICATION_CLOSE));
        }
    });
    button.addMouseListener(new MouseAdapter() {

        @SuppressWarnings("synthetic-access")
        @Override
        public void mouseUp(MouseEvent e) {
            close();
            setReturnCode(CANCEL);
        }

    });
}

From source file:org.eclipse.tcf.te.ui.swt.widgets.NoteCompositeHelper.java

License:Open Source License

/**
 * Creates a composite with a highlighted Note entry and a message text.
 * This is designed to take up the full width of the page.
 *
 * @see PreferencePage#createNoteComposite, this is a plain copy of that!
 * @param font/*from  w  w w. j a  va 2 s . c  o m*/
 *            the font to use
 * @param composite
 *            the parent composite
 * @param title
 *            the title of the note
 * @param message
 *            the message for the note
 * @param minCharsPerLine
 *            the minimum number of characters per line. Defaults to '65' if less than '20'.
 *
 * @return the composite for the note
 */
public static Composite createNoteComposite(Font font, Composite composite, String title, String message,
        int minCharsPerLine) {
    Composite messageComposite = new NoteComposite(composite, SWT.NONE);

    GridLayout messageLayout = new GridLayout();
    messageLayout.numColumns = 2;
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    messageComposite.setLayout(messageLayout);

    GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    if (composite.getLayout() instanceof GridLayout) {
        layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns;
    }
    messageComposite.setLayoutData(layoutData);
    messageComposite.setFont(font);

    final Label noteLabel = new Label(messageComposite, SWT.BOLD);
    noteLabel.setText(title);
    noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            // Note: This is actually wrong but the same as in platforms
            // PreferencePage
            if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
                noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
            }
        }
    };
    JFaceResources.getFontRegistry().addListener(fontListener);
    noteLabel.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
        }
    });

    Label messageLabel = new Label(messageComposite, SWT.WRAP);
    messageLabel.setText(message);
    messageLabel.setFont(font);

    /**
     * Set the controls style to FILL_HORIZONTAL making it multi-line if
     * needed
     */
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(messageLabel,
            minCharsPerLine >= 20 ? minCharsPerLine : 65);
    messageLabel.setLayoutData(layoutData);

    return messageComposite;
}

From source file:org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole.java

License:Open Source License

protected void init() {
    // Called when console is added to the console view
    super.init();

    initLimitOutput();//w  w w .  j a va  2s .  com
    initWrapSetting();

    //   Ensure that initialization occurs in the ui thread
    CVSUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
        public void run() {
            JFaceResources.getFontRegistry().addListener(CVSOutputConsole.this);
            initializeStreams();
            dump();
        }
    });
}