List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:edu.rice.cs.drjava.plugins.eclipse.views.InteractionsView.java
License:BSD License
/** * Sets the font of the Interactions Pane to be the value * stored in JFace's FontRegistry under the key corresponding * to DrJava's font preference./*from w w w . j a v a2 s . c o m*/ */ public void updateFont() { Font font = JFaceResources.getFont(DrJavaConstants.FONT_MAIN); _styledText.setFont(font); }
From source file:edu.tsinghua.lumaqq.resource.Resources.java
License:Open Source License
/** * @return * ? */ public Font getDefaultFont() { return JFaceResources.getFont(LUMAQQ_DEFAULT_FONT); }
From source file:edu.tsinghua.lumaqq.widgets.rich.LineStyler.java
License:Open Source License
public Font getLineFont(int lineIndex) { LineStyle style = getLineStyle(lineIndex); String symbolic = style.getFontString(); Font f = JFaceResources.getFont(symbolic); if (f == JFaceResources.getDefaultFont()) { FontData[] fd = style.createFontData(); JFaceResources.getFontRegistry().put(symbolic, fd); }/*from www.j a v a2 s. c o m*/ return JFaceResources.getFont(symbolic); }
From source file:ext.org.eclipse.jdt.internal.ui.compare.JavaTextViewer.java
License:Open Source License
JavaTextViewer(Composite parent) { fSourceViewer = new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL); JavaTextTools tools = JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING)); }// w w w .ja v a 2 s . c o m fSourceViewer.setEditable(false); String symbolicFontName = JavaMergeViewer.class.getName(); Font font = JFaceResources.getFont(symbolicFontName); if (font != null) fSourceViewer.getTextWidget().setFont(font); }
From source file:ext.org.eclipse.jdt.internal.ui.compare.PropertiesFileViewer.java
License:Open Source License
PropertiesFileViewer(Composite parent) { fSourceViewer = new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL); JavaTextTools tools = JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer.configure(new PropertiesFileSourceViewerConfiguration(tools.getColorManager(), store, null, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING)); }//w w w .j av a 2 s. com fSourceViewer.setEditable(false); String symbolicFontName = PropertiesFileMergeViewer.class.getName(); Font font = JFaceResources.getFont(symbolicFontName); if (font != null) fSourceViewer.getTextWidget().setFont(font); }
From source file:ext.org.eclipse.jdt.internal.ui.infoviews.SourceView.java
License:Open Source License
/** * Sets the font for this viewer sustaining selection and scroll position. *//*ww w .ja v a 2s .c om*/ private void setViewerFont() { Font font = JFaceResources.getFont(SYMBOLIC_FONT_NAME); if (fViewer.getDocument() != null) { Point selection = fViewer.getSelectedRange(); int topIndex = fViewer.getTopIndex(); StyledText styledText = fViewer.getTextWidget(); Control parent = fViewer.getControl(); parent.setRedraw(false); styledText.setFont(font); fViewer.setSelectedRange(selection.x, selection.y); fViewer.setTopIndex(topIndex); if (parent instanceof Composite) { Composite composite = (Composite) parent; composite.layout(true); } parent.setRedraw(true); } else { StyledText styledText = fViewer.getTextWidget(); styledText.setFont(font); } }
From source file:ext.org.eclipse.jdt.internal.ui.javaeditor.JavaTemplatesPage.java
License:Open Source License
@Override protected SourceViewer createPatternViewer(Composite parent) { IDocument document = new Document(); JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaSourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);/*from w w w . jav a 2 s.c o m*/ SimpleJavaSourceViewerConfiguration configuration = new SimpleJavaSourceViewerConfiguration( tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); viewer.setEditable(false); return viewer; }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.CodeTemplateBlock.java
License:Open Source License
private SourceViewer createViewer(Composite parent, int nColumns) { Label label = new Label(parent, SWT.NONE); label.setText(PreferencesMessages.CodeTemplateBlock_preview); GridData data = new GridData(); data.horizontalSpan = nColumns;/* w w w . j a v a 2 s . co m*/ label.setLayoutData(data); IDocument document = new Document(); JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration( tools.getColorManager(), store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(false); Cursor arrowCursor = viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // viewer.getTextWidget().setCaret(null); viewer.setDocument(document); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); data.horizontalSpan = nColumns; data.heightHint = fPixelConverter.convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.java
License:Open Source License
private SourceViewer createEditor(Composite parent) { String prefix = getPrefix();//ww w . j ava 2 s .c o m IDocument document = new Document(prefix + fTemplate.getPattern()); JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration( tools.getColorManager(), store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(true); viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length()); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); int nLines = document.getNumberOfLines(); if (nLines < 5) { nLines = 5; } else if (nLines > 12) { nLines = 12; } Control control = viewer.getControl(); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(80); data.heightHint = convertHeightInCharsToPixels(nLines); control.setLayoutData(data); viewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { if (event.getDocumentEvent() != null) doSourceChanged(event.getDocumentEvent().getDocument()); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateSelectionDependentActions(); } }); return viewer; }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview.java
License:Open Source License
public JavaPreview(Map<String, String> workingValues, Composite parent) { JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); fPreviewDocument = new Document(); fWorkingValues = workingValues;/*from w w w. j a va 2s. co m*/ tools.setupJavaDocumentPartitioner(fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING); PreferenceStore prioritizedSettings = new PreferenceStore(); prioritizedSettings.setValue(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); prioritizedSettings.setValue(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); prioritizedSettings.setValue(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); prioritizedSettings.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); IPreferenceStore[] chain = { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() }; fPreferenceStore = new ChainedPreferenceStore(chain); fSourceViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore); fSourceViewer.setEditable(false); Cursor arrowCursor = fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fSourceViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fSourceViewer.getTextWidget().setCaret(null); fViewerConfiguration = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaPartitions.JAVA_PARTITIONING, true); fSourceViewer.configure(fViewerConfiguration); fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fMarginPainter = new MarginPainter(fSourceViewer); final RGB rgb = PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb)); fSourceViewer.addPainter(fMarginPainter); new JavaSourcePreviewerUpdater(); fSourceViewer.setDocument(fPreviewDocument); }