List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.eclipse.php.internal.ui.wizards.NewGenericFileTemplatesWizardPage.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 w w w . jav a 2s . c om * @param parent * the parent control * @return a configured source viewer */ private SourceViewer createViewer(Composite parent) { SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new PHPStructuredTextViewerConfiguration(); @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); ((StructuredTextViewer) viewer).getTextWidget() .setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager() .createUnManagedStructuredModelFor(ContentTypeIdForPHP.ContentTypeID_PHP); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(sourceViewerConfiguration); viewer.setDocument(document); return viewer; }
From source file:org.eclipse.php.refactoring.ui.wizard.PHPFileStatusContextViewer.java
License:Open Source License
public void createControl(Composite parent) { super.createControl(parent); getSourceViewer().getControl().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ }
From source file:org.eclipse.rcptt.ui.editors.ecl.EnhancedSourceViewer.java
License:Open Source License
@Override public void configure(SourceViewerConfiguration configuration) { StyledText textWidget = getTextWidget(); // reset foreground & background colors if (textWidget != null && !textWidget.isDisposed()) { Color foregroundColor = textWidget.getForeground(); if (foregroundColor != null && foregroundColor.isDisposed()) textWidget.setForeground(null); Color backgroundColor = textWidget.getBackground(); if (backgroundColor != null && backgroundColor.isDisposed()) textWidget.setBackground(null); }/*from w w w.java 2 s. c o m*/ super.configure(configuration); // set font from preferences if (configuration instanceof EnhancedSourceViewerConfiguration) { toolkit = ((EnhancedSourceViewerConfiguration) configuration).getEditorToolkit(); if (textWidget != null) { textWidget.setFont(JFaceResources.getFont(toolkit.getEditorTextFont())); } IDocument document = getDocument(); if (document != null) { IDocumentPartitioner partitioner = new FastPartitioner(toolkit.getPartitionScanner(), toolkit.getPartitions()); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } } }
From source file:org.eclipse.recommenders.internal.snipmatch.rcp.editors.SnippetSourcePage.java
License:Open Source License
@Override protected void createFormContent(IManagedForm managedForm) { FormToolkit toolkit = managedForm.getToolkit(); form = managedForm.getForm();//from w w w .j a va 2 s . co m createHeader(form); toolkit.decorateFormHeading(form.getForm()); Composite body = form.getBody(); toolkit.paintBordersFor(body); body.setLayout(new FillLayout(SWT.HORIZONTAL)); codePart = new AbstractFormPart() { @Override public void initialize(IManagedForm managedForm) { super.initialize(managedForm); textWidget = managedForm.getToolkit().createText(managedForm.getForm().getBody(), snippet.getCode(), SWT.WRAP | SWT.MULTI); textWidget.setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); } @Override public void refresh() { context.updateTargets(); super.refresh(); updateMessage(); } @Override public void commit(boolean onSave) { if (onSave) { super.commit(onSave); } } @Override public void dispose() { context.dispose(); super.dispose(); } }; managedForm.addPart(codePart); context = createDataBindingContext(); }
From source file:org.eclipse.sirius.ui.debug.AbstractDebugView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { getSite().getPage().addSelectionListener(this); GridLayout layout = new GridLayout(1, false); parent.setLayout(layout);/*from www . j av a 2s .c o m*/ info = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); info.setText("Sirius/GMF Debug View"); info.setLayoutData(new GridData(GridData.FILL_BOTH)); info.setFont(JFaceResources.getFont("org.eclipse.debug.ui.consoleFont")); buttons = new Group(parent, SWT.SHADOW_ETCHED_IN); buttons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); buttons.setLayout(new RowLayout(SWT.HORIZONTAL)); createActionButtons(); }
From source file:org.eclipse.tcf.internal.debug.ui.launch.TestErrorsDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); Label label = new Label(composite, SWT.WRAP); label.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); label.setText("Connection diagnostics ended with errors:"); text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); text.setEditable(false);//from w ww . jav a2 s .c om text.setText(createText()); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = SIZING_TEXT_WIDTH; data.heightHint = SIZING_TEXT_HEIGHT; text.setLayoutData(data); return composite; }
From source file:org.eclipse.tcf.te.ui.swt.widgets.NoteCompositeHelper.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @see PreferencePage#createNoteComposite, this is a plain copy of that! * @param font/*from w w w. j a v a 2 s . c o m*/ * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @param minCharsPerLine * the minimum number of characters per line. Defaults to '65' if less than '20'. * * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message, int minCharsPerLine) { Composite messageComposite = new NoteComposite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); if (composite.getLayout() instanceof GridLayout) { layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; } messageComposite.setLayoutData(layoutData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Note: This is actually wrong but the same as in platforms // PreferencePage if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); /** * Set the controls style to FILL_HORIZONTAL making it multi-line if * needed */ layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(messageLabel, minCharsPerLine >= 20 ? minCharsPerLine : 65); messageLabel.setLayoutData(layoutData); return messageComposite; }
From source file:org.eclipse.tm.te.ui.swt.widgets.NoteCompositeHelper.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @see PreferencePage#createNoteComposite, this is a plain copy of that! * @param font/* ww w. j a v a 2 s . com*/ * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new NoteComposite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); if (composite.getLayout() instanceof GridLayout) { layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; } messageComposite.setLayoutData(layoutData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Note: This is actually wrong but the same as in platforms // PreferencePage if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); /** * Set the controls style to FILL_HORIZONTAL making it multi-line if * needed */ layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(messageLabel, 65); messageLabel.setLayoutData(layoutData); return messageComposite; }
From source file:org.eclipse.tm.te.ui.terminals.tabs.TabPropertyChangeListener.java
License:Open Source License
/** * Called if a property change event for the terminal font * definition is received./*from w w w . jav a 2 s. co m*/ */ protected void onFontDefinitionProperyChanged() { // Get the current font from JFace Font font = JFaceResources.getFont(FONT_DEFINITION); // Get the terminal control from the tab item if (getTabItem().getData() instanceof ITerminalViewControl) { ITerminalViewControl terminal = (ITerminalViewControl) getTabItem().getData(); terminal.setFont(font); } }
From source file:org.eclipse.tm.terminal.view.ui.controls.NoteCompositeHelper.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @see PreferencePage#createNoteComposite, this is a plain copy of that! * @param font/* w w w .ja v a2 s . c om*/ * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @param minCharsPerLine * the minimum number of characters per line. Defaults to '65' if less than '20'. * * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message, int minCharsPerLine) { final GC gc = new GC(composite); gc.setFont(font); Composite messageComposite = new NoteComposite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); if (composite.getLayout() instanceof GridLayout) { layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; } messageComposite.setLayoutData(layoutData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Note: This is actually wrong but the same as in platforms // PreferencePage if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); /** * Set the controls style to FILL_HORIZONTAL making it multi-line if * needed */ layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), minCharsPerLine >= 20 ? minCharsPerLine : 65); messageLabel.setLayoutData(layoutData); gc.dispose(); return messageComposite; }