List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.eclipse.dltk.internal.ui.editor.ScriptTemplatesPage.java
License:Open Source License
protected SourceViewer createPatternViewer(Composite parent) { IDocument document = new Document(); ScriptTextTools tools = fScriptEditor.getTextTools(); tools.setupDocumentPartitioner(document); IPreferenceStore store = uiToolkit().getCombinedPreferenceStore(); ScriptSourceViewer viewer = new ScriptSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);/*from w w w.ja v a 2 s. c o m*/ ScriptSourceViewerConfiguration configuration = uiToolkit().createSourceViewerConfiguration(); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFont(fScriptEditor.getSymbolicFontName()); viewer.getTextWidget().setFont(font); new ScriptSourcePreviewerUpdater(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:org.eclipse.dltk.internal.ui.preferences.ScriptSourcePreviewerUpdater.java
License:Open Source License
/** * Creates a script source preview updater for the given viewer, * configuration and preference store.//w w w. j ava 2 s . c o m * * @param viewer * the viewer * @param configuration * the configuration * @param preferenceStore * the preference store */ public ScriptSourcePreviewerUpdater(final SourceViewer viewer, final ScriptSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { Assert.isNotNull(viewer); Assert.isNotNull(configuration); Assert.isNotNull(preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { final String fontKey = configuration.getFontPropertyPreferenceKey(); if (fontKey.equals(event.getProperty())) { final Font font = JFaceResources.getFont(fontKey); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (configuration.affectsTextPresentation(event)) { configuration.handlePropertyChangeEvent(event); viewer.invalidateTextPresentation(); } } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.eclipse.dltk.internal.ui.text.hover.SourceViewerInformationControl.java
License:Open Source License
/** * Initialize the font to the Java editor font. * //from ww w . j a va 2s .co m * @since 3.2 */ private void initializeFont() { Font font = JFaceResources.getFont("org.eclipse.jdt.ui.editors.textfont"); //$NON-NLS-1$ StyledText styledText = getViewer().getTextWidget(); styledText.setFont(font); }
From source file:org.eclipse.dltk.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. c o m label.setLayoutData(data); IDocument document = new Document(); ScriptTextTools tools = toolkit.getTextTools(); tools.setupDocumentPartitioner(document); IPreferenceStore store = toolkit.getCombinedPreferenceStore(); SourceViewer viewer = new ScriptSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); ScriptSourceViewerConfiguration configuration = tools.createSourceViewerConfiguraton(store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(false); Cursor arrowCursor = viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); viewer.getTextWidget().setCaret(null); viewer.setDocument(document); Font font = JFaceResources.getFont(configuration.getFontPropertyPreferenceKey()); viewer.getTextWidget().setFont(font); new ScriptSourcePreviewerUpdater(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:org.eclipse.dltk.ui.preferences.EditTemplateDialog.java
License:Open Source License
private SourceViewer createEditor(Composite parent) { String prefix = getPrefix();/* ww w . j a v a 2s .c o m*/ IDocument document = new Document(prefix + fTemplate.getPattern()); final ScriptTextTools textTools = toolkit.getTextTools(); textTools.setupDocumentPartitioner(document); IPreferenceStore store = toolkit.getCombinedPreferenceStore(); SourceViewer viewer = new ScriptSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); ScriptSourceViewerConfiguration configuration = textTools.createSourceViewerConfiguraton(store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(true); viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length()); Font font = JFaceResources.getFont(configuration.getFontPropertyPreferenceKey()); viewer.getTextWidget().setFont(font); new ScriptSourcePreviewerUpdater(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:org.eclipse.editorconfig.ui.internal.preferences.SyntaxColoringPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() }); fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fColorManager = new EditorConfigColorManager(false); EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration( fColorManager, store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING); fPreviewViewer.configure(configuration); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new SourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false);/*w w w. j a v a 2 s.co m*/ String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document = new Document(content); EditorConfigDocumentSetupParticipant.setupDocument(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
From source file:org.eclipse.edt.ide.ui.internal.editor.SourceViewerInformationControl.java
License:Open Source License
private SourceViewer createViewer(Composite parent) { SourceViewer viewer = new SourceViewer(parent, null, SWT.NONE); SourceViewerConfiguration configuration = new EGLSourceViewerConfiguration(); viewer.configure(configuration);/*from w w w. j a v a 2s . com*/ viewer.setEditable(false); Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); return viewer; }
From source file:org.eclipse.edt.ide.ui.internal.formatting.ui.EGLPreview.java
License:Open Source License
public EGLPreview(Composite parent, Map preferenceSetting) { fPreferenceSetting = preferenceSetting; ftools = new TextTools(EDTUIPlugin.getDefault().getPreferenceStore()); fPreviewDocument = new Document(); ftools.setupEGLDocumentPartitioner(fPreviewDocument); IPreferenceStore[] chain = { EDTUIPlugin.getDefault().getPreferenceStore() }; fPreferenceStore = new ChainedPreferenceStore(chain); //@bd1a Start int styles = SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER; if (Locale.getDefault().toString().toLowerCase().indexOf("ar") != -1) { styles |= SWT.LEFT_TO_RIGHT;//www . j a va 2 s.c o m } //@bd1a End fSourceViewer = new EGLSourceViewer(parent, null, null, false, styles); //@bd1c fViewerConfiguration = new EGLSourceViewerConfiguration(ftools); fSourceViewer.configure(fViewerConfiguration); fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(EDTUIPreferenceConstants.EDITOR_TEXT_FONT)); fMarginPainter = new MarginPainter(fSourceViewer); final RGB rgb = PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(ftools.getEGLColorProvider().getColorForRGB(rgb)); fSourceViewer.addPainter(fMarginPainter); new EGLSourcePreviewerUpdater(); fSourceViewer.setDocument(fPreviewDocument); }
From source file:org.eclipse.edt.ide.ui.internal.handlers.wizards.NewHandlerSummaryPage.java
License:Open Source License
/** * @see IDialogPage#createControl(Composite) *//*from w w w. j a va 2s . c om*/ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); // TODO change help // PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IUIHelpConstants.EGL_NEW_HANDLER_SUMMARY_PAGE); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 1; Label label = new Label(container, SWT.HORIZONTAL); label.setText(NewHandlerWizardMessages.NewHandlerSummaryPage_previewLabel); TextTools tools = new TextTools(new PreferenceStore()); fPreviewViewer = new SourceViewer(container, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fPreviewViewer.configure(new EGLSourceViewerConfiguration(tools, null)); Font font = JFaceResources.getFont(EGLPreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); fPreviewViewer.setEditable(false); fPreviewViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); document = new Document(""); IDocumentPartitioner partitioner = ((DocumentProvider) EGLUI.getDocumentProvider()) .createDocumentPartitioner(); document.setDocumentPartitioner(partitioner); partitioner.connect(document); fPreviewViewer.setDocument(document); messageComposite = new HideableComposite(container, 0); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); warningLabel = new Label(messageComposite, SWT.HORIZONTAL); warningLabel.setText(NewHandlerWizardMessages.NewHandlerSummaryPage_warningLabel); warningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); messageList = new Table(messageComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); messageList.setLinesVisible(false); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 80; messageList.setLayoutData(data); setControl(container); setContent(content); }
From source file:org.eclipse.edt.ide.ui.internal.preferences.StylePreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { tools = new TextTools(fOverlayStore); fPreviewViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fPreviewViewer.configure(new EGLSourceViewerConfiguration(tools, null)); Font font = JFaceResources.getFont(EDTUIPreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); fPreviewViewer.setEditable(false);//w w w . j a va 2s . c om initializeViewerColors(fPreviewViewer); String content = getSampleText(); //$NON-NLS-1$ IDocument document = new Document(content); IDocumentPartitioner partitioner = ((DocumentProvider) EGLUI.getDocumentProvider()) .createDocumentPartitioner(); document.setDocumentPartitioner(partitioner); partitioner.connect(document); fPreviewViewer.setDocument(document); fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String p = event.getProperty(); if (p.equals(EDTUIPreferenceConstants.EDITOR_BACKGROUND_COLOR) || p.equals(EDTUIPreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)) { initializeViewerColors(fPreviewViewer); } fPreviewViewer.invalidateTextPresentation(); } }); return fPreviewViewer.getControl(); }