List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferencePage.java
License:Open Source License
private Button createButton(final Composite parent, final String label, final SelectionListener selectionListener) { ((GridLayout) parent.getLayout()).numColumns++; final Button button = new Button(parent, SWT.PUSH); button.setText(label);/* w ww .ja v a2 s . c o m*/ button.setFont(JFaceResources.getDialogFont()); button.addSelectionListener(selectionListener); setButtonLayoutData(button); return button; }
From source file:de.walware.ecommons.ui.dialogs.ToolPopup.java
License:Open Source License
private void create(final Shell parent) { if (UIAccess.isOkToUse(fShell)) { if (fShell.getParent() == parent) { return; }//from w w w . j a v a 2s . c o m dispose(); } fToolTabs.clear(); fShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); // SWT.RESIZE fShell.setText("Color"); fShell.setFont(JFaceResources.getDialogFont()); fShell.setSize(320, 300); { final GridLayout gl = new GridLayout(); gl.marginHeight = 0; gl.marginWidth = 0; gl.horizontalSpacing = 0; gl.verticalSpacing = 0; fShell.setLayout(gl); } final SWTListener listener = new SWTListener(); parent.addListener(SWT.Dispose, listener); fShell.addListener(SWT.Deactivate, listener); fShell.setBackground(fShell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); fShell.setBackgroundMode(SWT.INHERIT_FORCE); fTabFolder = new CTabFolder(fShell, SWT.BOTTOM | SWT.FLAT); fTabFolder.setSimple(true); fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); fTabFolder.setSelectionBackground(G_BACKGROUND); addTabs(fTabFolder); final Composite commonBar = new Composite(fShell, SWT.NONE); commonBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); commonBar.setLayout(LayoutUtil.createContentGrid(3)); // final Composite status = new Composite(commonBar, SWT.NONE); // status.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); addStatusControls(commonBar); fOKButton = new Button(commonBar, SWT.PUSH | SWT.FLAT); fOKButton.setText(IDialogConstants.OK_LABEL); fOKButton.setFont(fShell.getFont()); fOKButton.addListener(SWT.Selection, listener); fCancelButton = new Button(commonBar, SWT.PUSH | SWT.FLAT); fCancelButton.setText(IDialogConstants.CANCEL_LABEL); fCancelButton.setFont(fShell.getFont()); fCancelButton.addListener(SWT.Selection, listener); { final Point size = fOKButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); size.x = Math.max(size.x, fCancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); { final GridData gd = new GridData(SWT.FILL, SWT.FILL); gd.widthHint = size.x; gd.heightHint = size.y - 2; fOKButton.setLayoutData(gd); } { final GridData gd = new GridData(SWT.FILL, SWT.FILL); gd.widthHint = size.x; gd.heightHint = size.y - 2; fCancelButton.setLayoutData(gd); } } fTabFolder.addListener(SWT.Selection, listener); fShell.setDefaultButton(fOKButton); fShell.pack(); }
From source file:de.walware.rj.eclient.graphics.RGraphicsPreferencePage.java
License:Open Source License
protected void set(final FontPref pref, final String value) { if (value.equals(pref.currentName)) { return;//from ww w . j a v a 2 s . c o m } pref.valueLabel.setText(""); Font font; try { font = new Font(pref.valueLabel.getDisplay(), value, fSize, SWT.NONE); if (pref != fSymbolFontPref) { pref.valueLabel.setFont(font); } pref.valueLabel.setText(value); } catch (final SWTError e) { font = JFaceResources.getDialogFont(); pref.valueLabel.setFont(font); pref.valueLabel.setText(value + " (not available)"); } if (pref.currentFont != null && !pref.currentFont.isDisposed()) { pref.currentFont.dispose(); } pref.currentName = value; pref.currentFont = font; }
From source file:de.walware.statet.r.internal.ui.rhelp.RHelpInfoHoverCreator.java
License:Open Source License
@Override protected void createContent(final Composite parent) { fContentComposite = new Composite(parent, SWT.NONE) { @Override//from w ww . j a v a 2s . co m public Point computeSize(final int width, final int height, final boolean changed) { return super.computeSize(width, height, changed || width != getSize().x); } }; fContentComposite.setBackgroundMode(SWT.INHERIT_FORCE); final GridLayout gridLayout = LayoutUtil.createCompositeGrid(2); gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5); fContentComposite.setLayout(gridLayout); final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4); final int hIndent = Math.max(3, LayoutUtil.defaultHSpacing() / 3); { // Title image fTitleImage = new Label(fContentComposite, SWT.NULL); final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID); fTitleImage.setImage(image); final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false); fTitleText = new StyledText(fContentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) { @Override public Point computeSize(int width, final int height, final boolean changed) { if (!fLayoutHint && width <= 0 && fContentComposite.getSize().x > 0) { width = fContentComposite.getSize().x - LayoutUtil.defaultHMargin() - fTitleImage.getSize().x - LayoutUtil.defaultHSpacing() - 10; } final Point size = super.computeSize(width, -1, true); // if (width >= 0) { // size.x = Math.min(size.x, width); // } return size; } }; fTitleText.setFont(JFaceResources.getDialogFont()); final GC gc = new GC(fTitleText); final FontMetrics fontMetrics = gc.getFontMetrics(); final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false); imageGd.horizontalIndent = hIndent - 2; final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading(); final int imageHeight = image.getBounds().height; final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5)); if (textHeight + shift < imageHeight) { imageGd.verticalIndent = vIndent + shift; textGd.verticalIndent = vIndent + (imageHeight - textHeight); } else { imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift; textGd.verticalIndent = vIndent; } fTitleImage.setLayoutData(imageGd); fTitleText.setLayoutData(textGd); fLayoutWorkaround = true; gc.dispose(); } fInfoBrowser = new Browser(fContentComposite, SWT.NONE); fInfoBrowser.addOpenWindowListener(this); fInfoBrowser.addLocationListener(this); fInfoBrowser.addProgressListener(this); fInfoBrowser.addTitleListener(this); fInfoBrowser.addOpenWindowListener(new OpenWindowListener() { @Override public void open(final WindowEvent event) { event.required = true; } }); // Disable context menu fInfoBrowser.setMenu(new Menu(getShell(), SWT.NONE)); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); // gd.widthHint = LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50); fInfoBrowser.setLayoutData(gd); fInfoBrowser.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.character == SWT.ESC) { dispose(); } } @Override public void keyReleased(final KeyEvent e) { } }); setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); if ((fMode & MODE_FOCUS) != 0) { initActions(fHandlerCollection); final ToolBarManager toolBarManager = getToolBarManager(); contributeToActionBars(PlatformUI.getWorkbench(), toolBarManager, fHandlerCollection); toolBarManager.update(true); } updateInput(); }
From source file:de.walware.statet.r.internal.ui.rhelp.RHelpInfoHoverCreator.java
License:Open Source License
@Override public Point computeSizeHint() { updateInput();//from ww w . j ava 2 s .c o m final Point sizeConstraints = getSizeConstraints(); final Rectangle trim = computeTrim(); fTitleText.setFont(JFaceResources.getDialogFont()); final PixelConverter converter = new PixelConverter(fTitleText); int widthHint = converter.convertWidthInCharsToPixels(60); final GC gc = new GC(fContentComposite); gc.setFont(JFaceResources.getTextFont()); widthHint = Math.max(widthHint, gc.getFontMetrics().getAverageCharWidth() * 60); gc.dispose(); final int heightHint = fTitleText.getLineHeight() * 12; final int widthMax = ((sizeConstraints != null && sizeConstraints.x != SWT.DEFAULT) ? sizeConstraints.x : widthHint + 100) - trim.width; final int heightMax = ((sizeConstraints != null && sizeConstraints.y != SWT.DEFAULT) ? sizeConstraints.y : fTitleText.getLineHeight() * 12) - trim.height; final Point size = new Point(widthHint, heightHint); size.y += LayoutUtil.defaultVSpacing(); size.x = Math.max(Math.min(size.x, widthMax), 200) + trim.width; size.y = Math.max(Math.min(size.y, heightMax), 100) + trim.height; return size; }
From source file:de.walware.statet.r.internal.ui.rhelp.RHelpSearchResultPage.java
License:Open Source License
@Override protected void configureTableViewer(final TableViewer viewer) { super.configureTableViewer(viewer); final TableColumnLayout layout = new TableColumnLayout(); viewer.getControl().getParent().setLayout(layout); viewer.getTable().setHeaderVisible(true); {/*www . j a v a 2s . c o m*/ final TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT); column.getColumn().setText("Page"); layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.setLabelProvider(new DecoratingStyledLabelProvider(new RHelpLabelProvider(), TextSearchLabelUtil.DEFAULT_SEARCH_LABEL_PROPERTIES)); } { final TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT); column.getColumn().setText("Package"); layout.setColumnData(column.getColumn(), new ColumnPixelData( new PixelConverter(JFaceResources.getDialogFont()).convertWidthInCharsToPixels(10), true, true)); column.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { final Object element = cell.getElement(); String text = ""; //$NON-NLS-1$ if (element instanceof RHelpSearchMatch) { final IRHelpSearchMatch match = ((RHelpSearchMatch) element).getRHelpMatch(); text = match.getPage().getPackage().getName(); } cell.setText(text); } }); } { final TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT); column.getColumn().setText("Best Match"); layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.setLabelProvider(new MatchLabelProvider()); } ColumnViewerToolTipSupport.enableFor(viewer); updateSorter(); }
From source file:de.walware.statet.r.ui.graphics.RFontFamilyChooser.java
License:Open Source License
public static Font createFont(final Device device, final String fontName, int height) { FontData fontData = getFontData(device, fontName); if (fontData == null) { return null; }// w w w . j a va 2 s. co m if (height < 0) { height = JFaceResources.getDialogFont().getFontData()[0].getHeight(); } if (fontData.getHeight() != height) { fontData = new FontData(fontData.getName(), height, fontData.getStyle()); } return new Font(device, fontData); }
From source file:de.walware.statet.r.ui.rtool.RElementInfoHoverCreator.java
License:Open Source License
@Override protected void createContent(final Composite parent) { fContentComposite = new Composite(parent, SWT.NONE) { @Override/*from w w w. j a v a 2s. c om*/ public Point computeSize(final int width, final int height, final boolean changed) { return super.computeSize(width, height, changed || width != getSize().x); } }; fContentComposite.setBackgroundMode(SWT.INHERIT_FORCE); final GridLayout gridLayout = LayoutUtil.applyCompositeDefaults(new GridLayout(), 2); gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5); fContentComposite.setLayout(gridLayout); final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4); final int hIndent = Math.max(3, LayoutUtil.defaultHSpacing() / 2); { // Title image fTitleImage = new Label(fContentComposite, SWT.NULL); final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID); fTitleImage.setImage(image); final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false); fTitleText = new StyledText(fContentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) { @Override public Point computeSize(int width, final int height, final boolean changed) { if (!fLayoutHint && width <= 0 && fContentComposite.getSize().x > 0) { width = fContentComposite.getSize().x - LayoutUtil.defaultHMargin() - fTitleImage.getSize().x - LayoutUtil.defaultHSpacing() - 10; } final Point size = super.computeSize(width, -1, true); // if (width >= 0) { // size.x = Math.min(size.x, width); // } return size; } }; fTitleText.setFont(JFaceResources.getDialogFont()); final GC gc = new GC(fTitleText); final FontMetrics fontMetrics = gc.getFontMetrics(); final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false); imageGd.horizontalIndent = hIndent; final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading(); final int imageHeight = image.getBounds().height; final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5)); if (textHeight + shift < imageHeight) { imageGd.verticalIndent = vIndent + shift; textGd.verticalIndent = vIndent + (imageHeight - textHeight); } else { imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift; textGd.verticalIndent = vIndent; } fTitleImage.setLayoutData(imageGd); fTitleText.setLayoutData(textGd); fLayoutWorkaround = true; gc.dispose(); } fInfoText = new StyledText(fContentComposite, fMode == MODE_FOCUS ? (SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL) : (SWT.MULTI | SWT.READ_ONLY)); fInfoText.setIndent(hIndent); fInfoText.setFont(JFaceResources.getFont(PREF_DETAIL_PANE_FONT)); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); // gd.widthHint = LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50); fInfoText.setLayoutData(gd); setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); updateInput(); }
From source file:descent.internal.ui.preferences.AppearancePreferencePage.java
License:Open Source License
protected Control createContents(Composite parent) { initializeDialogUnits(parent);/*w ww . jav a 2 s .c om*/ int nColumns = 1; Composite result = new Composite(parent, SWT.NONE); result.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = 0; layout.numColumns = nColumns; result.setLayout(layout); fShowMethodReturnType.doFillIntoGrid(result, nColumns); fShowMethodTypeParameters.doFillIntoGrid(result, nColumns); fShowCategory.doFillIntoGrid(result, nColumns); fShowMembersInPackageView.doFillIntoGrid(result, nColumns); fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns); new Separator().doFillIntoGrid(result, nColumns); fCompressPackageNames.doFillIntoGrid(result, nColumns); fPackageNamePattern.doFillIntoGrid(result, 2); LayoutUtil.setHorizontalGrabbing(fPackageNamePattern.getTextControl(null)); LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null), convertWidthInCharsToPixels(65)); new Separator().doFillIntoGrid(result, nColumns); fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns); String noteTitle = PreferencesMessages.AppearancePreferencePage_note; String noteMessage = PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives; Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; noteControl.setLayoutData(gd); initFields(); Dialog.applyDialogFont(result); return result; }
From source file:descent.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent, int widthHint, SelectionListener listener) { ControlData data = new ControlData(key, values); GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false); gd.horizontalSpan = 3;//from ww w . ja va2 s .c om gd.horizontalIndent = indent; Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 2; composite.setLayout(layout); composite.setLayoutData(gd); Button checkBox = new Button(composite, SWT.CHECK); checkBox.setFont(JFaceResources.getDialogFont()); checkBox.setData(data); checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); checkBox.addSelectionListener(getSelectionListener()); gd = new GridData(GridData.FILL, GridData.CENTER, true, false); gd.widthHint = widthHint; Link link = new Link(composite, SWT.NONE); link.setText(label); link.setLayoutData(gd); if (listener != null) { link.addSelectionListener(listener); } makeScrollableCompositeAware(link); makeScrollableCompositeAware(checkBox); String currValue = getValue(key); checkBox.setSelection(data.getSelection(currValue) == 0); fCheckBoxes.add(checkBox); return checkBox; }