Java Code Examples for org.eclipse.jface.resource.JFaceResources#getFont()
The following examples show how to use
org.eclipse.jface.resource.JFaceResources#getFont() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesFileEditorPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Control createPreviewer(Composite parent) { IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, JavaPlugin.getDefault().getCombinedPreferenceStore()}); fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); fColorManager= new JavaColorManager(false); PropertiesFileSourceViewerConfiguration configuration= new PropertiesFileSourceViewerConfiguration(fColorManager, store, null, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING); fPreviewViewer.configure(configuration); Font font= JFaceResources.getFont(PreferenceConstants.PROPERTIES_FILE_EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new SourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content= loadPreviewContentFromFile("PropertiesFileEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); PropertiesFileDocumentSetupParticipant.setupDocument(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
Example 2
Source File: TmxEditorImpWithNattable.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void propertyChange(PropertyChangeEvent event) { if (natTable == null || natTable.isDisposed()) { return; } String property = event.getProperty(); if ("net.heartsome.cat.te.ui.tmxeditor.font".equals(property)) { Font font = JFaceResources.getFont("net.heartsome.cat.te.ui.tmxeditor.font"); ICellPainter cellPainter = natTable.getConfigRegistry().getConfigAttribute( CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, TeNattableConstant.SOURCE_EDIT_CELL_LABEL); if (cellPainter instanceof TmxEditorTextPainter) { TmxEditorTextPainter textPainter = (TmxEditorTextPainter) cellPainter; if (textPainter.getFont() == null || !textPainter.getFont().equals(font)) { TeActiveCellEditor.commit(); textPainter.loadFont(font); refrush(); } } } }
Example 3
Source File: ThemeUIComposite.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void setFont(String fontId, FontData[] data) { String fdString = PreferenceConverter.getStoredRepresentation(data); Font existing = JFaceResources.getFont(fontId); String existingString = ""; if (!(existing.isDisposed())) { existingString = PreferenceConverter .getStoredRepresentation(existing.getFontData()); } if (existingString.equals(fdString)) { return; } JFaceResources.getFontRegistry().put(fontId, data); ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); String key = ThemeElementHelper.createPreferenceKey(currentTheme,fontId); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); store.setValue(key, fdString); }
Example 4
Source File: TextPainterWithPadding.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public TextPainterWithPadding(boolean wrapText, int topPadding, int rightPadding, int bottomPadding, int leftPadding, final XLIFFEditorImplWithNatTable editor, Font font) { Assert.isNotNull(editor.getTable(), Messages.getString("editor.TextPainterWithPadding.msg1")); this.wrapText = wrapText; this.topPadding = topPadding; this.rightPadding = rightPadding; this.bottomPadding = bottomPadding; this.leftPadding = leftPadding; this.editor = editor; if (font == null) { font = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.XLIFF_EDITOR_TEXT_FONT); } setFont(font); tagRender = new InnerTagRender(); }
Example 5
Source File: MatchViewPart.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void propertyChange(PropertyChangeEvent event) { if (gridTable == null || gridTable.isDisposed()) { return; } String property = event.getProperty(); if (net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT.equals(property)) { Font font = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT); sourceColunmCellRenderer.setFont(font); targetColumnCellRenderer.setFont(font); GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); sourceText.getTextWidget().setFont(font); int lineH = sourceText.getTextWidget().getLineHeight() * 2; sTextGd.heightHint = lineH; sTextGd.minimumHeight = lineH; sourceText.getTextWidget().setLayoutData(sTextGd); gridTable.redraw(); sourceText.getTextWidget().getParent().layout(); } }
Example 6
Source File: GUIHelper.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public static Font getFont(FontData...fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); } String key = keyBuilder.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { return JFaceResources.getFont(key); } else { JFaceResources.getFontRegistry().put(key, fontDatas); return JFaceResources.getFont(key); } }
Example 7
Source File: ResourceHelper.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static Font getFont(FontData... fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); } String key = keyBuilder.toString(); if (!JFaceResources.getFontRegistry().hasValueFor(key)) { JFaceResources.getFontRegistry().put(key, fontDatas); } return JFaceResources.getFont(key); }
Example 8
Source File: PropertiesFileViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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)); } fSourceViewer.setEditable(false); String symbolicFontName= PropertiesFileMergeViewer.class.getName(); Font font= JFaceResources.getFont(symbolicFontName); if (font != null) fSourceViewer.getTextWidget().setFont(font); }
Example 9
Source File: JavaEditorColoringConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Control createPreviewer(Composite parent) { IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore }); fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.BORDER, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaPartitions.JAVA_PARTITIONING, false); fPreviewViewer.configure(configuration); // fake 1.5 source to get 1.5 features right. configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5)); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); Cursor arrowCursor= fPreviewViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fPreviewViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fPreviewViewer.getTextWidget().setCaret(null); String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.setDocument(document); installSemanticHighlighting(); return fPreviewViewer.getControl(); }
Example 10
Source File: SnippetsCompletionProcessor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private TextFontStyler() { Font textFont = JFaceResources.getFont(JFaceResources.TEXT_FONT); FontData[] textFontData = textFont.getFontData(); // limit the height of the font if (textFontData[0].getHeight() > SnippetsContentAssistant.MAX_HEIGHT) { maxHeightTextFont = new Font(textFont.getDevice(), textFontData[0].getName(), SnippetsContentAssistant.MAX_HEIGHT, textFontData[0].getStyle()); } }
Example 11
Source File: GUIHelper.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public static Font getFont(FontData...fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); } String key = keyBuilder.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { return JFaceResources.getFont(key); } else { JFaceResources.getFontRegistry().put(key, fontDatas); return JFaceResources.getFont(key); } }
Example 12
Source File: CustomBrowserInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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); int width = gc.getFontMetrics().getAverageCharWidth(); int height = gc.getFontMetrics().getHeight(); gc.dispose(); return new Point(widthInChars * width, heightInChars * height); }
Example 13
Source File: TerminologyViewPart.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void propertyChange(PropertyChangeEvent event) { if (gridTable == null || gridTable.isDisposed()) { return; } String property = event.getProperty(); if (Constants.MATCH_VIEWER_TEXT_FONT.equals(property)) { Font font = JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT); idColumnCellRenderer.setFont(font); srcColumnCellRenderer.setFont(font); tgtColumnCellRenderer.setFont(font); propColumnCellRenderer.setFont(font); gridTable.redraw(); } }
Example 14
Source File: XLIFFEditorImplWithNatTable.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 给 NatTable 添加可编辑单元格的配置 * @return ; */ private IConfiguration editableGridConfiguration() { return new AbstractRegistryConfiguration() { public void configureRegistry(IConfigRegistry configRegistry) { TextPainterWithPadding painter = new TextPainterWithPadding(true, Constants.SEGMENT_TOP_MARGIN, Constants.SEGMENT_RIGHT_MARGIN, Constants.SEGMENT_BOTTOM_MARGIN, Constants.SEGMENT_LEFT_MARGIN, XLIFFEditorImplWithNatTable.this, JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.XLIFF_EDITOR_TEXT_FONT)); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, GridRegion.BODY); // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new StyledTextPainter( // table), DisplayMode.NORMAL, GridRegion.BODY); configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new TagDisplayConverter( XLIFFEditorImplWithNatTable.this), DisplayMode.NORMAL, SOURCE_EDIT_CELL_LABEL); configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new TagDisplayConverter( XLIFFEditorImplWithNatTable.this), DisplayMode.NORMAL, TARGET_EDIT_CELL_LABEL); configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, SOURCE_EDIT_CELL_LABEL); configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, TARGET_EDIT_CELL_LABEL); configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new StyledTextCellEditor( XLIFFEditorImplWithNatTable.this), DisplayMode.EDIT, SOURCE_EDIT_CELL_LABEL); configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new StyledTextCellEditor( XLIFFEditorImplWithNatTable.this), DisplayMode.EDIT, TARGET_EDIT_CELL_LABEL); // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new // TagDisplayConverter( // XLIFFEditorImplWithNatTable.this, innerTagUtil), DisplayMode.EDIT, EDIT_CELL_LABEL); } }; }
Example 15
Source File: N4JSStackTraceConsole.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Constructor creating the console with the console font. */ public N4JSStackTraceConsole() { super(ConsoleMessages.msgN4JSStackTraceConsole(), CONSOLE_TYPE, null, true); Font font = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT); setFont(font); partitioner.connect(getDocument()); }
Example 16
Source File: TabbedPropertyTitle.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * Constructor for TabbedPropertyTitle. * * @param parent * the parent composite. * @param factory * the widget factory for the tabbed property sheet */ public TabbedPropertyTitle(Composite parent, TabbedPropertySheetWidgetFactory factory) { super(parent, SWT.NO_FOCUS); this.factory = factory; this.addPaintListener(e -> { if (image == null && (text == null || text.equals(BLANK))) { label.setVisible(false); } else { label.setVisible(true); } drawTitleBackground(e); }); factory.getColors().initializeSectionToolBarColors(); setBackground(factory.getColors().getBackground()); setForeground(factory.getColors().getForeground()); FormLayout layout = new FormLayout(); layout.marginWidth = 1; layout.marginHeight = 2; setLayout(layout); Font font; if (! JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) { FontData[] fontData = JFaceResources.getFontRegistry().getBold( JFaceResources.DEFAULT_FONT).getFontData(); /* title font is 2pt larger than that used in the tabs. */ fontData[0].setHeight(fontData[0].getHeight() + 2); JFaceResources.getFontRegistry().put(TITLE_FONT, fontData); } font = JFaceResources.getFont(TITLE_FONT); label = factory.createCLabel(this, BLANK); label.setBackground(new Color[] { factory.getColors().getColor(IFormColors.H_GRADIENT_END), factory.getColors().getColor(IFormColors.H_GRADIENT_START) }, new int[] { 100 }, true); label.setFont(font); label.setForeground(factory.getColors().getColor(IFormColors.TITLE)); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.top = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); label.setLayoutData(data); /* * setImage(PlatformUI.getWorkbench().getSharedImages().getImage( * ISharedImages.IMG_OBJ_ELEMENT)); */ }
Example 17
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
private TextStyle createTextStyle(String foregroundKey, String backgroundKey) { Color foreground = getColor(foregroundKey); Color background = getColor(backgroundKey); return new TextStyle(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.XLIFF_EDITOR_TEXT_FONT), foreground, background); }
Example 18
Source File: GUIHelper.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public static Font getFont(String key) { return JFaceResources.getFont(key); }
Example 19
Source File: FormulaLabelProvider.java From tlaplus with MIT License | 4 votes |
@Override public Font getFont(Object element, int columnIndex) { // Regardless of the element and its position, we want to use a monospaced font. return JFaceResources.getFont(JFaceResources.TEXT_FONT); }
Example 20
Source File: ErrorTraceTreeViewer.java From tlaplus with MIT License | 4 votes |
ErrorTraceTreeViewer(final Tree parent, final ModelEditor associatedModelEditor) { treeViewer = new TreeViewer(parent); treeViewer.setUseHashlookup(true); treeViewer.setContentProvider(new StateContentProvider()); ColumnViewerToolTipSupport.enableFor(treeViewer); final TraceDisplayResizer resizer = new TraceDisplayResizer(parent); final StateLabelProvider labelProvider = new StateLabelProvider(); for (int i = 0; i < COLUMN_TEXTS.length; i++) { final TreeViewerColumn column = new TreeViewerColumn(treeViewer, i); column.getColumn().setText(COLUMN_TEXTS[i]); column.getColumn().setWidth(COLUMN_WIDTH[i]); column.setLabelProvider(labelProvider); resizer.setColumnForIndex(column, i); column.getColumn().addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { // reverse the current trace final TLCError error = (TLCError) treeViewer.getInput(); error.reverseTrace(); // Reset the viewer's selection to the empty selection. With empty // selection, the subsequent refresh call does *not* invalidate the // StateContentProvider's lazy policy. // We know that the user clicked on the tree's column header // and the real selection is of little importance. treeViewer.setSelection(new ISelection() { public boolean isEmpty() { return true; } }); treeViewer.refresh(false); // remember the order for next trace shown final IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings(); dialogSettings.put(TLCModelLaunchDataProvider.STATESORTORDER, !dialogSettings.getBoolean(TLCModelLaunchDataProvider.STATESORTORDER)); } }); } parent.addControlListener(resizer); errorTraceFontChangeListener = (event) -> { if ((event == null) || event.getProperty().equals(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT)) { final Font f = JFaceResources.getFont(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT); JFaceResources.getFontRegistry().put(TLCErrorView.JFACE_ERROR_TRACE_ID, f.getFontData()); if (treeViewer != null) { treeViewer.refresh(true); } } }; errorTraceFontChangeListener.propertyChange(null); JFaceResources.getFontRegistry().addListener(errorTraceFontChangeListener); createContextMenu(); setModelEditor(associatedModelEditor); }