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

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

Introduction

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

Prototype

public static Font getDefaultFont() 

Source Link

Document

Returns JFace's standard font.

Usage

From source file:org.springsource.ide.eclipse.gradle.ui.taskview.TaskLabelProvider.java

License:Open Source License

@Override
public Font getFont(Object element, int columnIndex) {
    if (columnIndex == 0) {
        return getTaskNameFont();
    } else {//from  w  w w .j a v  a  2s.  co  m
        return JFaceResources.getDefaultFont();
    }
}

From source file:org.talend.commons.ui.swt.listviewer.ControlListViewer.java

License:Open Source License

/**
 * Create a new instance of the receiver with a control that is a child of parent with style style.
 * /*from www  . j  a  v  a  2s .  co  m*/
 * @param parent
 * @param style
 */
public ControlListViewer(Composite parent, int style) {
    scrolled = new ScrolledComposite(parent, style | SWT.VERTICAL);
    int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight();
    scrolled.getVerticalBar().setIncrement(height * 2);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    // bug 311276: can cause unintended scrolling of viewer
    // scrolled.setShowFocusedControl(true);

    control = new Composite(scrolled, SWT.NONE) {
        // @Override
        // public boolean setFocus() {
        // forceFocus();
        // return true;
        // }

        @Override
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            if (visible) {
                updateSize(control);
            }
        }
    };
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    control.setLayout(layout);
    control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    control.setBackgroundMode(SWT.INHERIT_FORCE);
    control.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
            updateVisibleItems();
        }

        @Override
        public void controlResized(ControlEvent e) {
            updateVisibleItems();
        }
    });

    scrolled.setContent(control);
    hookControl(control);

    noEntryArea = new Composite(scrolled, SWT.NONE);
    doCreateNoEntryArea(noEntryArea);

    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    scrolled.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            updateSize(scrolled.getContent());
        }
    });
    control.addTraverseListener(new TraverseListener() {

        private boolean handleEvent = true;

        @Override
        public void keyTraversed(TraverseEvent event) {
            if (!handleEvent) {
                return;
            }
            switch (event.detail) {
            case SWT.TRAVERSE_ARROW_PREVIOUS: {
                Control[] children = control.getChildren();
                if (children.length > 0) {
                    boolean selected = false;
                    for (int i = 0; i < children.length; i++) {
                        ControlListItem<?> item = (ControlListItem<?>) children[i];
                        if (item.isSelected()) {
                            selected = true;
                            if (i > 0) {
                                setSelection(new StructuredSelection(children[i - 1].getData()), true);
                            }
                            break;
                        }
                    }
                    if (!selected) {
                        setSelection(new StructuredSelection(children[children.length - 1].getData()), true);
                    }
                }
                break;
            }
            case SWT.TRAVERSE_ARROW_NEXT: {
                Control[] children = control.getChildren();
                if (children.length > 0) {
                    boolean selected = false;
                    for (int i = 0; i < children.length; i++) {
                        ControlListItem<?> item = (ControlListItem<?>) children[i];
                        if (item.isSelected()) {
                            selected = true;
                            if (i < children.length - 1) {
                                setSelection(new StructuredSelection(children[i + 1].getData()), true);
                            }
                            break;
                        }
                    }
                    if (!selected) {
                        setSelection(new StructuredSelection(children[0].getData()), true);
                    }
                }
                break;
            }
            default:
                handleEvent = false;
                event.doit = true;
                Control control = ControlListViewer.this.control;
                Shell shell = control.getShell();
                while (control != null) {
                    if (control.traverse(event.detail)) {
                        break;
                    }
                    if (!event.doit || control == shell) {
                        break;
                    }
                    control = control.getParent();
                }
                handleEvent = true;
                break;
            }
        }
    });
}

From source file:org.talend.designer.business.diagram.custom.figures.BusinessTooltipFigure.java

License:Open Source License

public void buildFigures(List<Label> labels) {
    if (labels != null) {
        removeAll();//ww w.j  a v  a 2s. co  m
        Label label = new Label(Messages.getString("BusinessTooltipFigure.assignedMeta", labels.size())); //$NON-NLS-1$
        String fontName = JFaceResources.getDefaultFont().getFontData()[0].getName();
        if (label.getFont() != null) {
            fontName = label.getFont().getFontData()[0].getName();
        }
        label.setFont(JFaceResources.getFontRegistry().getBold(fontName));
        add(label);
        for (int i = 0; i < labels.size(); i++) {
            add(labels.get(i));
        }
    }
    // setPreferredSize(computePreferedSize());
}

From source file:org.testng.eclipse.ui.JUnitProgressBar.java

License:Open Source License

private void paintStep(int startX, int endX) {
    GC gc = new GC(this);
    setStatusColor(gc);//from  w  w w  . j av a  2  s . co  m
    Rectangle rect = getClientArea();
    startX = Math.max(1, startX);
    gc.fillRectangle(startX, 1, endX - startX, rect.height - 2);
    String string = getCurrentMessage();
    m_currentMessage = string;
    gc.setFont(JFaceResources.getDefaultFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    int stringWidth = fontMetrics.getAverageCharWidth() * string.length();
    int stringHeight = fontMetrics.getHeight();
    gc.setForeground(m_messageColor);
    gc.drawString(string, (rect.width - stringWidth) / 2, (rect.height - stringHeight) / 2, true);

    gc.dispose();
}

From source file:org.testng.eclipse.ui.JUnitProgressBar.java

License:Open Source License

private void paint(PaintEvent event) {
    GC gc = event.gc;/*www. j av a  2 s  .c o  m*/
    Display disp = getDisplay();

    Rectangle rect = getClientArea();
    gc.fillRectangle(rect);
    drawBevelRect(gc, rect.x, rect.y, rect.width - 1, rect.height - 1,
            disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));

    setStatusColor(gc);
    fColorBarWidth = Math.min(rect.width - 2, fColorBarWidth);
    gc.fillRectangle(1, 1, fColorBarWidth, rect.height - 2);

    gc.setFont(JFaceResources.getDefaultFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    final String msg = getCurrentMessage();
    int stringWidth = fontMetrics.getAverageCharWidth() * msg.length();
    int stringHeight = fontMetrics.getHeight();
    gc.setForeground(m_messageColor);
    gc.drawString(msg, (rect.width - stringWidth) / 2, (rect.height - stringHeight) / 2, true);
}

From source file:org.testng.eclipse.ui.ProgressBar.java

License:Open Source License

private void paint(PaintEvent event) {
    GC gc = event.gc;/*from  ww w  . j av  a  2 s.co  m*/
    Display disp = getDisplay();

    Rectangle rect = getClientArea();
    gc.fillRectangle(rect);
    drawBevelRect(gc, rect.x, rect.y, rect.width - 1, rect.height - 1,
            disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));

    setStatusColor(gc);
    m_colorBarWidth = Math.min(rect.width - 2, m_colorBarWidth);
    gc.fillRectangle(1, 1, m_colorBarWidth, rect.height - 2);

    gc.setFont(JFaceResources.getDefaultFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    final String msg = getCurrentMessage();
    int stringWidth = fontMetrics.getAverageCharWidth() * msg.length();
    int stringHeight = fontMetrics.getHeight();
    gc.setForeground(m_messageColor);
    gc.drawString(msg, (rect.width - stringWidth) / 2, (rect.height - stringHeight) / 2, true);
}

From source file:org.webcat.eclipse.importer.SWTUtil.java

License:Open Source License

/**
 * Returns an estimate of the height in pixels of a table with the
 * specified number of rows.//  w w w.  ja  va  2 s. c o  m
 * 
 * @param table the Table whose height should be calculated
 * @param rows the number of rows that should be used to estimate the
 *     height of the table
 * @return the estimated height of the table, in pixels
 */
public static int getTableHeightHint(Table table, int rows) {
    if (table.getFont().equals(JFaceResources.getDefaultFont())) {
        table.setFont(JFaceResources.getDialogFont());
    }

    int result = table.getItemHeight() * rows + table.getHeaderHeight();

    if (table.getLinesVisible()) {
        result += table.getGridLineWidth() * (rows - 1);
    }

    return result;
}

From source file:org.webcat.oda.designer.ognl.OgnlExpressionBuilder.java

License:Open Source License

/**
 *
 * @param parentShell//www.j av a 2  s  .c  o m
 * @param rootClass
 * @param initialExpr
 */
public OgnlExpressionBuilder(Shell parentShell, String rootClass, String initialExpr) {
    super(parentShell);

    expression = initialExpr;
    rootClassName = rootClass;
    keyProvider = new WebCATKeyProvider();

    Font font = JFaceResources.getDefaultFont();
    FontData[] fd = font.getFontData();
    fd[0].setStyle(fd[0].getStyle() | SWT.BOLD);

    boldFont = new Font(parentShell.getDisplay(), fd[0]);
}

From source file:org.xmind.ui.font.FontDialog.java

License:Open Source License

protected static String getDefaultFontName() {
    if (DEFAULT_FONT_NAME == null)
        DEFAULT_FONT_NAME = JFaceResources.getDefaultFont().getFontData()[0].getName();
    return DEFAULT_FONT_NAME;
}

From source file:org.xmind.ui.font.FontDialog.java

License:Open Source License

protected static int getDefaultFontHeight() {
    if (DEFAULT_FONT_HEIGHT < 0)
        DEFAULT_FONT_HEIGHT = JFaceResources.getDefaultFont().getFontData()[0].getHeight();
    return DEFAULT_FONT_HEIGHT;
}