List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.erlide.ui.views.SourceViewerInformationControl.java
License:Open Source License
/** * Creates a source viewer information control with the given shell as * parent. The given shell styles are applied to the created shell. The * given styles are applied to the created styled text widget. The text * widget will be initialized with the given font. The status field will * contain the given text or be hidden.// w w w.j a v a2 s. c om * * @param parent * the parent shell * @param shellStyle * the additional styles for the shell * @param style * the additional styles for the styled text widget * @param symbolicFontName * the symbolic font name * @param statusFieldText * the text to be used in the optional status field or * <code>null</code> if the status field should be hidden */ public SourceViewerInformationControl(final Shell parent, final int shellStyle, final int style, final String symbolicFontName, final String statusFieldText) { GridLayout layout; GridData gd; fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); final Display display = fShell.getDisplay(); fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); Composite composite = fShell; layout = new GridLayout(1, false); final int border = (shellStyle & SWT.NO_TRIM) == 0 ? 0 : BORDER; layout.marginHeight = border; layout.marginWidth = border; composite.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); composite.setLayoutData(gd); if (statusFieldText != null) { composite = new Composite(composite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } // Source viewer fViewer = new SourceViewer(composite, null, style); fViewer.configure(new ErlangSourceViewerConfiguration(ErlangEditor.getErlangEditorPreferenceStore(), new ColorManager())); fViewer.setEditable(false); fText = fViewer.getTextWidget(); gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); fText.setLayoutData(gd); fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); fText.setFont(JFaceResources.getFont(symbolicFontName)); fText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.character == 0x1B) { fShell.dispose(); } } @Override public void keyReleased(final KeyEvent e) { } }); // Status field if (statusFieldText != null) { // Horizontal separator line fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Status field label fStatusField = new Label(composite, SWT.RIGHT); fStatusField.setText(statusFieldText); final Font font = fStatusField.getFont(); final FontData[] fontDatas = font.getFontData(); for (final FontData element : fontDatas) { element.setHeight(element.getHeight() * 9 / 10); } fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas); fStatusField.setFont(fStatusTextFont); final GridData gd2 = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fStatusField.setLayoutData(gd2); fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } addDisposeListener(this); }
From source file:org.fusesource.tools.core.ui.TextViewerComponent.java
License:Open Source License
public static StructuredTextViewer createXMLViewer(Composite parent, Object data, int style) { data = getData(data);//from www .j a v a2 s.c o m SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXML(); @Override public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return baseConfiguration.getConfiguredContentTypes(sourceViewer); } @Override public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); } }; StructuredTextViewer structuredViewer = new StructuredTextViewer(parent, null, null, false, style); (structuredViewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); org.eclipse.wst.sse.core.internal.provisional.IStructuredModel scratchModel = StructuredModelManager .getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML); IDocument document = scratchModel.getStructuredDocument(); structuredViewer.configure(sourceViewerConfiguration); structuredViewer.setDocument(document); structuredViewer.getDocument().set(data.toString()); new SourceViewerContextMenuProvider(structuredViewer); return structuredViewer; }
From source file:org.ganoro.phing.ui.editors.templates.AntTemplatePreferencePage.java
License:Open Source License
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.jav a2 s .c o m*/ viewer.setDocument(document); viewer.setEditable(false); Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); return viewer; }
From source file:org.ganoro.phing.ui.internal.preferences.AntPreviewerUpdater.java
License:Open Source License
/** * Creates a source preview updater for the given viewer, configuration and preference store. * * @param viewer the viewer//ww w .j a va2 s. co m * @param configuration the configuration * @param preferenceStore the preference store */ public AntPreviewerUpdater(final SourceViewer viewer, final AntSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { initializeViewerColors(viewer, preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT .equals(property)) { initializeViewerColors(viewer, preferenceStore); } if (configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); viewer.invalidateTextPresentation(); } if (FormattingPreferences.affectsFormatting(event)) { format(viewer, preferenceStore); } } /** * @param viewer * @param preferenceStore */ private void format(final SourceViewer sourceViewer, final IPreferenceStore store) { String contents = sourceViewer.getDocument().get(); FormattingPreferences prefs = new FormattingPreferences(); prefs.setPreferenceStore(store); contents = XmlFormatter.format(contents, prefs); viewer.getDocument().set(contents); } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { /* * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) */ public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.gemoc.executionframework.ui.views.engine.EnginesStatusView.java
License:Open Source License
/** * This is a callback that will allow us * to create the viewer and initialize it. *///from w w w . j a v a 2 s . co m public void createPartControl(Composite parent) { _viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); _contentProvider = new ViewContentProvider(); _viewer.setContentProvider(_contentProvider); ColumnViewerToolTipSupport.enableFor(_viewer); _viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { fireEngineSelectionChanged(); } }); createColumns(); // _viewer.setColumnProperties( new String[] {"Status", "Identifier", "Step", "Status"} ); // _viewer.getTree().setHeaderVisible(true); Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT); _viewer.getTree().setFont(mono); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(_viewer.getControl(), "org.gemoc.executionframework.ui.views.engine.EngineStatusView"); // register for changes in the RunningEngineRegistry //org.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addObserver(this); buildMenu(); org.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry .addEngineRegistrationListener(this); }
From source file:org.glassmaker.ui.editor.wizards.NewCardTemplatesWizardPage.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. * /*from ww w .j a v a2s. c om*/ * @param parent * the parent control * @return a configured source viewer */ private SourceViewer createViewer(Composite parent) { SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML(); public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return baseConfiguration.getConfiguredContentTypes(sourceViewer); } 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("org.glassmaker.ui.editor.CardContent"); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(sourceViewerConfiguration); viewer.setDocument(document); return viewer; }
From source file:org.grails.ide.eclipse.editor.gsp.wizard.GSPTemplatePreferencePage.java
License:Open Source License
SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) { SourceViewer viewer = null;//from w ww . j a va2s. c o m // FIXADE change to GSP content type String contentTypeID = ContentTypeIdForJSP.ContentTypeID_JSP; 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(contentTypeID); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(viewerConfiguration); viewer.setDocument(document); return viewer; }
From source file:org.gw4e.eclipse.studio.javascript.ViewerHelper.java
License:Open Source License
public static SourceViewer createEditor(Composite parent) { IDocument document = new Document(); IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore(); JavaScriptTextTools tools = JavaScriptPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration = new SimpleJavaSourceViewerConfiguration( tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration);//from w ww .j a va2s. c o m viewer.setEditable(true); viewer.setDocument(document); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) { Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (configuration.affectsTextPresentation(event)) { configuration.handlePropertyChangeEvent(event); viewer.invalidateTextPresentation(); } } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { store.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); store.addPropertyChangeListener(propertyChangeListener); return viewer; }
From source file:org.hyperic.hypclipse.internal.preferences.SyntaxColorTab.java
License:Open Source License
private void createPreviewer(Composite parent) { Composite previewComp = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = layout.marginWidth = 0; previewComp.setLayout(layout);/*from ww w. j a v a2s.com*/ previewComp.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(previewComp, SWT.NONE); label.setText(HQDEMessages.SyntaxColorTab_preview); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fPreviewViewer = new SourceViewer(previewComp, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); fSourceViewerConfiguration = getSourceViewerConfiguration(); if (fSourceViewerConfiguration != null) fPreviewViewer.configure(fSourceViewerConfiguration); fPreviewViewer.setEditable(false); fPreviewViewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); fPreviewViewer.setDocument(getDocument()); Control control = fPreviewViewer.getControl(); control.setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.jboss.tools.aesh.ui.internal.util.FontManager.java
License:Open Source License
private void initializeDefault() { DEFAULT = JFaceResources.getFont(AESH_CONSOLE_FONT); }