List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.daveware.passwordmakerapp.gui.GuiMain.java
License:Open Source License
protected void setupFonts() { // Clone the font of the accountFilterText widget Font stockFont = accountFilterText.getFont(); FontData[] fdItalics = display.getSystemFont().getFontData(); // Default OSX font doesn't support italics (on my system) if (Utilities.isMac()) { italicsSearchFont = new Font(display, fdItalics[0].getName(), fdItalics[0].getHeight(), 0); } else {// ww w . ja v a2 s .c o m italicsSearchFont = new Font(display, fdItalics[0].getName(), fdItalics[0].getHeight(), SWT.ITALIC); } regularSearchFont = new Font(display, stockFont.getFontData()); accountFilterText.setFont(italicsSearchFont); int fontSize = cmdLineSettings.fontSize > 0 ? cmdLineSettings.fontSize : 14; if (cmdLineSettings.pwFont != null) { passwordFont = new Font(Display.getCurrent(), cmdLineSettings.pwFont, fontSize, SWT.BOLD); } else { passwordFont = new Font(Display.getCurrent(), JFaceResources.getFont(JFaceResources.TEXT_FONT).getFontData()[0].getName(), fontSize, SWT.BOLD); } }
From source file:org.deidentifier.arx.gui.view.impl.menu.DialogDebug.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { parent.setLayout(new GridLayout()); // License/*from w ww . j a v a 2s.c o m*/ data = new Text(parent, SWT.NONE | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); data.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); data.setText(controller.getDebugData()); final GridData d = SWTUtil.createFillGridData(); d.heightHint = 200; d.grabExcessVerticalSpace = true; data.setLayoutData(d); return parent; }
From source file:org.deved.antlride.internal.ui.views.interpreter.AntlrFigure.java
License:Open Source License
public AntlrFigure(IEvalElement evalElement, int x, int y) { //setStyle(Clickable.STYLE_BUTTON); setCursor(Cursors.HAND);/*from www.j a va2 s. c om*/ this.element = evalElement; setLayoutManager(new BorderLayout()); Font font = JFaceResources.getFont("Monospaced"); Label label = new Label(); Label tooltip = new Label(); EvalElementKind kind = evalElement.getElementKind(); String labelText = null; String labelToolTipText = null; Color foregroundColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); switch (kind) { case RULE: { labelText = evalElement.getElementName(); labelToolTipText = String.format(RULE_TOOL_TIP_PATTERN, labelText); if (!((IRuleEvalElement) evalElement).isLexerRule()) { foregroundColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_RULE_COLOR); } } break; case TOKEN: { ITokenEvalElement token = (ITokenEvalElement) evalElement; labelText = "'" + evalElement.getElementName() + "'"; labelToolTipText = String.format(LOCATION_TOOL_TIP_PATTERN, evalElement.getElementName(), token.getLine(), token.getColumn() + 1); foregroundColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_STRING_COLOR); } break; case EXCEPTION: { IExceptionEvalElement exception = (IExceptionEvalElement) evalElement; labelText = evalElement.getElementName(); // labelToolTipText = String.format(LOCATION_TOOL_TIP_PATTERN, // labelText, exception.getLine(), exception.getColumn() + 1); labelToolTipText = exception.getMessage(); foregroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED); } break; } // text label.setFont(font); label.setText(labelText); label.setForegroundColor(foregroundColor); // tooltip tooltip.setText(labelToolTipText); setToolTip(tooltip); // add text label add(label, BorderLayout.CENTER); //setBorder(new SimpleRaisedBorder()); setBorder(new LineBorder(ColorConstants.black, 1)); Dimension size = FigureUtilities.getTextExtents(labelText + " ", font); this.x = x; this.y = y; this.width = size.width + (size.width * 2 / 10); this.height = size.height + (size.height * 2 / 5); }
From source file:org.deved.antlride.ui.text.AntlrInputSourceViewer.java
License:Open Source License
private static Font getDefaultFont() { return JFaceResources.getFont("Monospaced"); }
From source file:org.eclipse.andmore.android.codesnippets.AndroidSnippetsTooltip.java
License:Apache License
/** * Display the snippet preview by using a JAVA Source Viewer, which is used * to highlight the code/*w w w . j av a2s.c o m*/ * * @see org.eclipse.jface.window.ToolTip#createToolTipContentArea(org.eclipse.swt.widgets.Event, * org.eclipse.swt.widgets.Composite) */ @Override protected Composite createToolTipContentArea(Event event, Composite parent) { // the main composite Composite mainComposite = new Composite(parent, SWT.NULL); mainComposite.setLayout(new GridLayout(1, true)); /* * snippet preview label */ Label textElem = new Label(mainComposite, SWT.LEFT); textElem.setText(AndroidSnippetsNLS.UI_Snippet_Preview); textElem.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); /* * JAVA source viewer */ final ScrolledComposite scroll = new ScrolledComposite(mainComposite, SWT.H_SCROLL | SWT.V_SCROLL); scroll.setLayout(new FillLayout()); // create scroll layout which receives values to limit its area of // display GridData scrollLayoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); Rectangle visibleArea = parent.getDisplay().getActiveShell().getMonitor().getClientArea(); scrollLayoutData.heightHint = visibleArea.height / 3; scrollLayoutData.widthHint = visibleArea.width / 3; scroll.setLayoutData(scrollLayoutData); final Composite javaSourceViewerComposite = new Composite(scroll, SWT.NULL); javaSourceViewerComposite.setLayout(new FillLayout()); int styles = SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; Document document = new Document(item.getContentString()); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaTextTools javaTextTools = JavaPlugin.getDefault().getJavaTextTools(); SourceViewer javaSourceViewer = new JavaSourceViewer(javaSourceViewerComposite, null, null, false, styles, store); javaSourceViewer .configure(new JavaSourceViewerConfiguration(javaTextTools.getColorManager(), store, null, null)); javaSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); javaTextTools.setupJavaDocumentPartitioner(document); javaSourceViewer.setDocument(document); javaSourceViewer.setEditable(false); // set up scroll scroll.setContent(javaSourceViewerComposite); scroll.setExpandHorizontal(true); scroll.setExpandVertical(true); scroll.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { scroll.setMinSize(javaSourceViewerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }); return mainComposite; }
From source file:org.eclipse.angularjs.internal.ui.preferences.html.HTMLAngularEditorSyntaxColoringPreferencePage.java
License:Open Source License
protected Control createContents(final Composite parent) { initializeDialogUnits(parent);//w w w .jav a2 s.co m fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); Composite pageComponent = createComposite(parent, 2); PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); Link link = new Link(pageComponent, SWT.WRAP); link.setText(SSEUIMessages.SyntaxColoring_Link); 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, HTMLUIMessages.SyntaxColoringPage_0); 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, HTMLUIMessages.SyntaxColoringPage_2); enabler.setEnabled(false); enabler.setSelection(true); Composite editControls = createComposite(editingComposite, 2); ((GridLayout) editControls.getLayout()).marginLeft = 20; fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_); ((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 = SSEUIMessages.Foreground_Color_Selector_Button; } }); fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_); ((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 = SSEUIMessages.Background_Color_Selector_Button; } }); fBold = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_3); fBold.setEnabled(false); ((GridData) fBold.getLayoutData()).horizontalSpan = 2; fItalic = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_4); fItalic.setEnabled(false); ((GridData) fItalic.getLayoutData()).horizontalSpan = 2; fStrike = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_5); fStrike.setEnabled(false); ((GridData) fStrike.getLayoutData()).horizontalSpan = 2; fUnderline = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_6); fUnderline.setEnabled(false); ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2; fClearStyle = new Button(editingComposite, SWT.PUSH); fClearStyle.setText(SSEUIMessages.Restore_Default_UI_); //$NON-NLS-1$ = "Restore Default" 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, SSEUIMessages.Sample_text__UI_); //$NON-NLS-1$ = "&Sample text:" fPreviewViewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); 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("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ fText.addKeyListener(getTextKeyListener()); fText.addSelectionListener(getTextSelectionListener()); fText.addMouseListener(getTextMouseListener()); fText.addTraverseListener(getTraverseListener()); setAccessible(fText, SSEUIMessages.Sample_text__UI_); initializeSourcePreviewColors(fPreviewViewer); IStructuredModel model = null; try { model = getDomModel(); fPreviewViewer.setDocument(getDomModel().getStructuredDocument()); } catch (IOException e) { Trace.trace(Trace.SEVERE, "Error while loading DOM", e); } finally { if (model != null) { model.releaseFromRead(); } } top.setWeights(new int[] { 1, 1 }); editor.setWeights(new int[] { 1, 1 }); PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); 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.ant.internal.ui.editor.AntSourceViewerInformationControl.java
License:Open Source License
private SourceViewer createViewer(Composite parent) { SourceViewer viewer = new SourceViewer(parent, null, SWT.NONE); SourceViewerConfiguration configuration = new AntSourceViewerConfiguration(); viewer.configure(configuration);/*w w w. j av a2 s . co m*/ viewer.setEditable(false); Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); return viewer; }
From source file:org.eclipse.ant.internal.ui.editor.templates.AntTemplatePreferencePage.java
License:Open Source License
@Override protected SourceViewer createViewer(Composite parent) { SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); SourceViewerConfiguration configuration = new AntTemplateViewerConfiguration(); IDocument document = new Document(); new AntDocumentSetupParticipant().setup(document); viewer.configure(configuration);/*from www.j a va 2 s. c om*/ viewer.setDocument(document); viewer.setEditable(false); Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); return viewer; }
From source file:org.eclipse.ant.internal.ui.preferences.AntCodeFormatterPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); AntSourceViewerConfiguration configuration = new AntSourceViewerConfiguration(); fPreviewViewer.configure(configuration); fPreviewViewer.setEditable(false);/* w w w .ja va2 s. c om*/ Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() }); fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store); String content = loadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$ content = formatContent(content, store); IDocument document = new Document(content); new AntDocumentSetupParticipant().setup(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
From source file:org.eclipse.ant.internal.ui.preferences.AntEditorPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); AntSourceViewerConfiguration configuration = new AntSourceViewerConfiguration(); fPreviewViewer.configure(configuration); fPreviewViewer.setEditable(false);// ww w .j a v a 2 s. c o m Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() }); fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store); String content = loadPreviewContentFromFile("SyntaxPreviewCode.txt"); //$NON-NLS-1$ IDocument document = new Document(content); new AntDocumentSetupParticipant().setup(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }