List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:com.nokia.carbide.cpp.sysdoc.internal.hover.view.BrowserInformationControl.java
License:Open Source License
public Point computeSizeConstraints(int widthInChars, int heightInChars) { if (fSymbolicFontName == null) return null; GC gc = new GC(fBrowser); Font font = fSymbolicFontName == null ? JFaceResources.getDialogFont() : JFaceResources.getFont(fSymbolicFontName); gc.setFont(font);//from w w w .ja v a 2s.co m int width = gc.getFontMetrics().getAverageCharWidth(); int height = gc.getFontMetrics().getHeight(); gc.dispose(); return new Point(widthInChars * width, heightInChars * (height)); }
From source file:com.nokia.testfw.codegen.ui.preferences.TESTFWTemplatePreferencePage.java
License:Open Source License
private SourceViewer createViewer(Composite parent, int nColumns) { Label label = new Label(parent, 0); label.setText(Messages.getString("TemplatePreferencePage_preview")); GridData data = new GridData(); data.horizontalSpan = nColumns;/*ww w .jav a 2 s . c om*/ label.setLayoutData(data); IDocument document = new Document(); CTextTools tools = CUIPlugin.getDefault().getTextTools(); tools.setupCDocumentPartitioner(document, "___c_partitioning", null); org.eclipse.jface.preference.IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new CSourceViewer(parent, null, null, false, 2816, store); CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration( tools.getColorManager(), store, null, iTemplateProcessor); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); org.eclipse.swt.graphics.Font font = JFaceResources.getFont("org.eclipse.cdt.ui.editors.textfont"); viewer.getTextWidget().setFont(font); new CSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); data = new GridData(1296); data.horizontalSpan = nColumns; data.heightHint = new PixelConverter(parent).convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; }
From source file:com.patrick_vane.unrealscript.editor.default_classes.HoverInformationControl.java
License:Open Source License
/** * Initialize the font to the editor font. * /*from ww w . j a v a2 s . c o m*/ * @since 3.2 */ private void initializeFont() { fTextFont = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); StyledText styledText = getViewer().getTextWidget(); styledText.setFont(fTextFont); }
From source file:com.redhat.ceylon.eclipse.code.browser.BrowserInformationControl.java
License:Open Source License
@Override public Point computeSizeConstraints(int widthInChars, int heightInChars) { if (fSymbolicFontName == null) return null; GC gc = new GC(fBrowser); Font font = fSymbolicFontName == null ? JFaceResources.getDialogFont() : JFaceResources.getFont(fSymbolicFontName); gc.setFont(font);//from w w w . j ava2s . c o m int width = gc.getFontMetrics().getAverageCharWidth(); int height = gc.getFontMetrics().getHeight(); gc.dispose(); return new Point(widthInChars * width, heightInChars * height); }
From source file:com.salesforce.ide.ui.editors.apex.preferences.ApexTemplatePreferencePage.java
License:Open Source License
@Override protected SourceViewer createViewer(Composite parent) { final SourceViewer viewer = super.createViewer(parent); new ApexDocumentSetupParticipant().setup(viewer.getDocument()); final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null);/*from ww w . j a v a2 s . c om*/ configuration.init(null); viewer.unconfigure(); viewer.configure(configuration); viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); viewer.setEditable(false); return viewer; }
From source file:com.salesforce.ide.ui.wizards.components.apex.ApexCodeTemplateSelectionPage.java
License:Open Source License
/** * Creates, configures and returns a source viewer to present the template * pattern on the preference page. Clients may override to provide a * custom source viewer featuring e.g. syntax coloring. * // w w w . jav a 2 s.c om * @param parent * the parent control * @return a configured source viewer */ @Override protected final SourceViewer createViewer(Composite parent) { final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null); configuration.init(this.componentModel.getProject()); final IDocument document = new Document(); new ApexDocumentSetupParticipant().setup(document); SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer.configure(configuration); viewer.setDocument(document); viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); viewer.setEditable(false); return viewer; }
From source file:com.salesforce.ide.ui.wizards.components.apex.VisualforceTemplateSelectionPage.java
License:Open Source License
/** * Creates, configures and returns a source viewer to present the template * pattern on the preference page. Clients may override to provide a * custom source viewer featuring e.g. syntax coloring. * //w w w . j a v a2s . c om * @param parent * the parent control * @return a configured source viewer */ @Override protected final SourceViewer createViewer(Composite parent) { SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML(); @Override public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return baseConfiguration.getConfiguredContentTypes(sourceViewer); } @Override public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); } }; SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager() .createUnManagedStructuredModelFor(ContentTypeIdForHTML.ContentTypeID_HTML); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(sourceViewerConfiguration); viewer.setDocument(document); return viewer; }
From source file:com.sap.dirigible.ide.terminal.ui.TerminalView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { GridLayout layout = new GridLayout(1, false); parent.setLayout(layout);//from w w w . ja v a2s. c om parent.setBackground(new Color(null, 0, 0, 0)); parent.setForeground(new Color(null, 0, 255, 0)); Font terminalFont = JFaceResources.getFont(JFaceResources.TEXT_FONT); commandHistory = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); commandHistory.setLayoutData(new GridData(GridData.FILL_BOTH)); commandHistory.setBackground(new Color(null, 0, 0, 0)); commandHistory.setForeground(new Color(null, 0, 255, 0)); commandHistory.setFont(terminalFont); commandLine = new Text(parent, SWT.BORDER); commandLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); commandLine.setBackground(new Color(null, 0, 0, 0)); commandLine.setForeground(new Color(null, 0, 255, 0)); commandLine.setFont(terminalFont); commandLine.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { // } @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR) { //MessageDialog.openInformation(null, "Info", commandLine.getText()); try { String result = executeCommand(ProcessUtils.translateCommandline(commandLine.getText())); commandHistory.setText(result); } catch (IOException ex) { commandHistory.setText(ex.getMessage()); } } } }); }
From source file:com.siteview.mde.internal.ui.compare.ManifestContentMergeViewer.java
License:Open Source License
protected void configureTextViewer(TextViewer textViewer) { if (textViewer instanceof SourceViewer) { if (fColorManager == null) fColorManager = ColorManager.getDefault(); ((SourceViewer) textViewer)//from w w w .ja v a 2s . c o m .configure(new ManifestConfiguration(fColorManager, null, getDocumentPartitioning())); Font font = JFaceResources.getFont(ManifestContentMergeViewer.class.getName()); if (font != null) ((SourceViewer) textViewer).getTextWidget().setFont(font); } }
From source file:com.siteview.mde.internal.ui.compare.MonitorContentMergeViewer.java
License:Open Source License
protected void configureTextViewer(final TextViewer textViewer) { if (textViewer instanceof SourceViewer) { if (fColorManager == null) fColorManager = ColorManager.getDefault(); final XMLConfiguration configuration = new XMLConfiguration(fColorManager); textViewer.getControl().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { configuration.dispose(); }/*from w w w .j a v a 2 s.com*/ }); IPropertyChangeListener propertyChangedListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { // the configuration will test if the properties affect the presentation also, // but checking it here allows us to prevent the viewer from being invalidated // and saves some unnecessary work if (configuration.affectsColorPresentation(event) || configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); textViewer.invalidateTextPresentation(); } } }; MDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangedListener); if (fPropertyChangedListeners == null) fPropertyChangedListeners = new ArrayList(3); fPropertyChangedListeners.add(propertyChangedListener); ((SourceViewer) textViewer).configure(configuration); Font font = JFaceResources.getFont(MonitorContentMergeViewer.class.getName()); if (font != null) ((SourceViewer) textViewer).getTextWidget().setFont(font); } }