List of usage examples for org.eclipse.jface.resource JFaceResources getDefaultFont
public static Font getDefaultFont()
From source file:org.eclipse.jpt.common.ui.internal.swt.widgets.TableTools.java
License:Open Source License
public static int calculateHeightHint(Table table, int rowCount) { if (table.getFont().equals(JFaceResources.getDefaultFont())) { table.setFont(JFaceResources.getDialogFont()); }/*from w w w . j av a2s .c o m*/ int hint = table.getHeaderHeight() + (table.getItemHeight() * rowCount); if (table.getLinesVisible()) { hint += table.getGridLineWidth() * (rowCount - 1); } return hint; }
From source file:org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * @param button //from w w w .j a va 2 s. c om * @return the hint value */ static int getButtonWidthHint(Button button) { if (button.getFont().equals(JFaceResources.getDefaultFont())) button.setFont(JFaceResources.getDialogFont()); GC gc = new GC(button); gc.setFont(button.getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); int length = button.getText().length(); int widthHint = Dialog.convertWidthInCharsToPixels(fontMetrics, length < 2 ? 2 : length); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.jst.jsf.facesconfig.ui.preference.ColorFontFieldEditor.java
License:Open Source License
/** * // www . jav a 2 s. c o m * Returns the change button for this field editor. * * * @param parent * @return the change button * */ protected Button getChangeControl(Composite parent) { if (changeFontButton == null) { changeFontButton = new Button(parent, SWT.PUSH); if (changeButtonText != null) changeFontButton.setText(changeButtonText); changeFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog fontDialog = new FontDialog(changeFontButton.getShell()); if (chosenFont != null) fontDialog.setFontList(chosenFont); if (fontRGB != null) fontDialog.setRGB(fontRGB); FontData font = fontDialog.open(); if (font != null) { FontData[] oldFont = chosenFont; if (oldFont == null) oldFont = JFaceResources.getDefaultFont().getFontData(); setPresentsDefaultValue(false); FontData[] newData = new FontData[1]; newData[0] = font; fontRGB = fontDialog.getRGB(); updateFont(newData); fireValueChanged(VALUE, oldFont[0], font); } } }); changeFontButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { changeFontButton = null; } }); changeFontButton.setFont(parent.getFont()); setButtonLayoutData(changeFontButton); } else checkParent(changeFontButton, parent); return changeFontButton; }
From source file:org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.attach.LuaAttachMainTab.java
License:Open Source License
private Font getInformationFont() { Font textFont = JFaceResources.getTextFont(); if (textFont == null) return JFaceResources.getDefaultFont(); if (textFont.getFontData().length > 0) { Font italic = JFaceResources.getFontRegistry().getItalic(textFont.getFontData()[0].getName()); if (italic != null) return italic; }//from www . ja v a 2 s .c o m return textFont; }
From source file:org.eclipse.mat.ui.internal.views.NavigatorViewPage.java
License:Open Source License
private void initializeFont() { Font defaultFont = JFaceResources.getDefaultFont(); FontDescriptor fontDescriptor = FontDescriptor.createFrom(defaultFont); fontDescriptor = fontDescriptor.setStyle(SWT.ITALIC); this.font = fontDescriptor.createFont(treeViewer.getTree().getDisplay()); Color foreground = treeViewer.getTree().getForeground(); Color background = treeViewer.getTree().getBackground(); RGB grey = ColorUtil.blend(foreground.getRGB(), background.getRGB()); this.greyColor = new Color(treeViewer.getTree().getDisplay(), grey); }
From source file:org.eclipse.mat.ui.snapshot.views.inspector.InspectorView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { SashForm form = new SashForm(parent, SWT.VERTICAL); GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(1, 1).applyTo(form); top = new Composite(form, SWT.TOP); GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(1, 1).applyTo(top); IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); mgr.add(createSyncAction());/*from w ww .jav a 2 s.co m*/ FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDefaultFont()); fontDescriptor = fontDescriptor.setStyle(SWT.BOLD); this.font = fontDescriptor.createFont(top.getDisplay()); createTopTable(top); createTabFolder(top); createVisualViewer(form); form.setWeights(new int[] { 95, 5 }); // add page listener getSite().getPage().addPartListener(this); hookContextMenu(); showBootstrapPart(); }
From source file:org.eclipse.mylar.zest.core.internal.graphmodel.GraphModelNode.java
License:Open Source License
protected void initModel(GraphModel graphModel, Object externalNode) { this.setData(externalNode); ZestPlugin plugin = ZestPlugin.getDefault(); this.sourceConnections = new ArrayList(); this.targetConnections = new ArrayList(); this.preferredLocation = false; this.foreColor = plugin.getColor(IZestColorConstants.BLACK); this.backColor = plugin.getColor(IZestColorConstants.LIGHT_BLUE); this.highlightColor = plugin.getColor(IZestColorConstants.YELLOW); this.unhighlightColor = this.backColor; this.highlightAdjacentColor = plugin.getColor(IZestColorConstants.ORANGE); this.nodeStyle = IZestGraphDefaults.NODE_STYLE; this.borderColor = plugin.getColor(IZestColorConstants.BLACK); this.borderHighlightColor = plugin.getColor(IZestColorConstants.BLUE); this.borderUnhighlightColor = plugin.getColor(IZestColorConstants.BLACK); this.borderWidth = 1; this.currentLocation = new Point(10, 10); this.size = new Dimension(20, 20); this.font = Display.getDefault().getSystemFont(); this.graphModel = graphModel; if (font == null) { font = JFaceResources.getDefaultFont(); }/*from www . j a v a 2 s . c o m*/ }
From source file:org.eclipse.mylar.zest.core.internal.graphmodel.GraphModelNode.java
License:Open Source License
private Dimension calculateTextExtents() { Dimension dim = new Dimension(0, 0); String text = getText();/*from w ww .j a va2s .c o m*/ if (text != null) { if (font == null) { font = JFaceResources.getDefaultFont(); } dim.setSize(FigureUtilities.getTextExtents(text + " ", font)); } return dim; }
From source file:org.eclipse.mylar.zest.core.internal.graphmodel.NonNestedProxyNode.java
License:Open Source License
private Dimension calculateTextExtents() { Dimension dim = new Dimension(0, 0); String text = getText();//from w w w . ja va 2 s .c o m if (text != null) { Font font = getFont(); if (font == null) { font = JFaceResources.getDefaultFont(); } dim.setSize(FigureUtilities.getTextExtents(text + " ", font)); } return dim; }
From source file:org.eclipse.mylyn.commons.ui.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. * /*w w w . jav a 2 s . c o m*/ * @param parent * @param style */ public ControlListViewer(Composite parent, int style) { scrolled = new ScrolledComposite(parent, style); int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); scrolled.getVerticalBar().setIncrement(height * 2); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(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 = 1; control.setLayout(layout); control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { updateVisibleItems(); } 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; 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; } } }); }