List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont
public static Font getTextFont()
From source file:com.aptana.theme.internal.TextViewerThemer.java
License:Open Source License
/** * This is a TextViewer (usually editor contents), so use the text font explicitly, not the view font we set up in * parent class.//from www. j a v a2s.c om */ protected Font getFont() { return JFaceResources.getTextFont(); }
From source file:com.aptana.theme.internal.TreeThemer.java
License:Open Source License
private void addMeasureItemListener() { if (controlIsDisposed()) { return;/*from w ww . j a v a 2 s . co m*/ } final Tree tree = getTree(); // Hack to force a specific row height and width based on font measureItemListener = new Listener() { public void handleEvent(Event event) { if (!useEditorFont()) { return; } Font font = JFaceResources.getFont(IThemeManager.VIEW_FONT_NAME); if (font == null) { font = JFaceResources.getTextFont(); } if (font != null) { event.gc.setFont(font); FontMetrics metrics = event.gc.getFontMetrics(); int height = metrics.getHeight() + 2; TreeItem item = (TreeItem) event.item; int width = event.gc.stringExtent(item.getText()).x + 24; // minimum width we need for text plus eye event.height = height; if (width > event.width) { event.width = width; } } } }; tree.addListener(SWT.MeasureItem, measureItemListener); }
From source file:com.aptana.theme.ThemedDelegatingLabelProvider.java
License:Open Source License
public Font getFont(Object element) { if (disabled) { if (wrapped instanceof IFontProvider) { return ((IFontProvider) wrapped).getFont(element); }/* ww w . j av a 2 s .co m*/ return null; } if (!useEditorFont()) { return null; } Font font = JFaceResources.getFont(IThemeManager.VIEW_FONT_NAME); if (font == null) { font = JFaceResources.getTextFont(); } return font; }
From source file:com.beck.ep.team.views.TeamFileListView.java
License:BSD License
/** * This is a callback that will allow us * to create the viewer and initialize it. *//*from w w w. jav a2 s . co m*/ public void createPartControl(Composite parent) { fShell = parent.getShell(); Composite container = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, true); gl.horizontalSpacing = 0; gl.verticalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; container.setLayout(gl); fMsg = new Label(container, SWT.NONE); fMsg.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); msgColor = fMsg.getDisplay().getSystemColor(SWT.COLOR_BLACK); redColor = fMsg.getDisplay().getSystemColor(SWT.COLOR_RED); fDoc = new Document(); edFileList = new SourceViewer(container, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); edFileList.setDocument(fDoc); edFileList.configure(new SourceViewerConfiguration());//for undoManager & other... edFileList.getTextWidget().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); edFileList.getTextWidget().setFont(JFaceResources.getTextFont()); DropTarget target = new DropTarget(edFileList.getTextWidget(), DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT); target.setTransfer(new Transfer[] { ResourceTransfer.getInstance() }); target.addDropListener(new DropListender(target.getTransfer()[0])); new SourceViewerKeyHandler().install(edFileList); fAT = new IAccessText() { public void setText(String newTxt) { setTextFromBG(newTxt); } public String getText() { return _getText(); } public void showMessage(int msgType, String s) { showMessageFromBG(msgType, s); } public Shell getShell() { return _getShell(); } }; boolean newBlockSelection = true; try { edFileList.getTextWidget().getBlockSelection(); } catch (Throwable e) { newBlockSelection = false; } makeActions(newBlockSelection); IActionBars bars = getViewSite().getActionBars(); fillLocalPullDown(bars.getMenuManager()); fillLocalToolBar(bars.getToolBarManager()); }
From source file:com.blackducksoftware.integration.eclipseplugin.views.providers.DependencyNumVulnColumnLabelProvider.java
License:Apache License
@Override public void styleCell(ViewerCell cell) { if (cell.getText().equals(VALUE_UNKNOWN)) { cell.setText(""); return;//from www.j a va 2s . com } String[] vulnChunks = cell.getText().split(":"); cell.setFont(JFaceResources.getTextFont()); Display display = Display.getCurrent(); final String noVulns = " 0 "; final Color textColor = display.getSystemColor(SWT.COLOR_WHITE); final Color highColor = decodeHex(display, "#b52b24"); final Color mediumColor = decodeHex(display, "#eca4a0"); final Color lowColor = decodeHex(display, "#999999"); final Color invisible = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); final Color[] vulnColors = new Color[] { highColor, mediumColor, lowColor }; StyleRange[] styleRanges = new StyleRange[vulnChunks.length]; int lastLabelEnd = 0; cell.setText(String.format("%1$-5s %2$-5s %3$-5s", StringUtils.center(vulnChunks[0], 5), StringUtils.center(vulnChunks[1], 5), StringUtils.center(vulnChunks[2], 5))); for (int i = 0; i < vulnChunks.length; i++) { int labelStart = cell.getText().indexOf(vulnChunks[i], lastLabelEnd); int labelSize = vulnChunks[i].length(); if (vulnChunks[i].equals(noVulns)) { styleRanges[i] = new StyleRange(labelStart, labelSize, invisible, invisible); } else { styleRanges[i] = new StyleRange(labelStart, labelSize, textColor, vulnColors[i]); } lastLabelEnd = labelStart + labelSize; } cell.setStyleRanges(styleRanges); }
From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestView.java
License:Apache License
private SashForm createSashForm(Composite parent) { sashForm = new SashForm(parent, SWT.HORIZONTAL); ViewForm results = new ViewForm(sashForm, SWT.NONE); PageBook viewerBook = new PageBook(results, SWT.BORDER); treeViewer = new TreeViewer(viewerBook, SWT.V_SCROLL | SWT.SINGLE); treeViewer.setUseHashlookup(true);/*from w w w . j av a 2 s. c o m*/ treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(new AutomatedTestLabelProvider()); treeViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { actionGroup.getActionHandler().open(selectedItem); } }); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged((IStructuredSelection) event.getSelection()); } }); viewerBook.showPage(treeViewer.getTree()); results.setContent(viewerBook); ViewForm output = new ViewForm(sashForm, SWT.NONE); outputText = new Text(output, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); outputText.setFont(JFaceResources.getTextFont()); output.setContent(outputText); sashForm.setWeights(new int[] { 33, 67 }); return sashForm; }
From source file:com.drgarbage.bytecodevisualizer.editors.BytecodeEditor.java
License:Apache License
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { super.init(site, input); store = createCombinedPreferenceStore(input); setPreferenceStore(store);/* w w w . j a va2s . c o m*/ JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools(); final IColorManager colorManager = textTools.getColorManager(); final ClassFileConfiguration classFileConfiguration = new ClassFileConfiguration(colorManager, store, this, IJavaPartitions.JAVA_PARTITIONING); setSourceViewerConfiguration(classFileConfiguration); /* create preference property listener */ preferenceListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { //System.out.println("event=" + event.getProperty()); //TODO: log for debuging /* Text Editor current line selector */ if (event.getProperty() .equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)) { RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); Color c = getSharedColors().getColor(rgb); if (!canvasControlFlowGraph.getLineSelectorColor().equals(c)) { canvasControlFlowGraph.setLineSelectorColor(c); } } /* Text Editor background */ else if (event.getProperty().startsWith(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) { setControlFlowViewBackGround(); } /* figure colors */ else if (event.getProperty().startsWith(CorePreferenceConstants.GRAPH_COLOR_PREFIX)) { canvasControlFlowGraph.documentUpdated(byteCodeDocumentProvider.getClassFileDocument()); } /* text fond has been changed (size and Fonts)*/ else if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { /* * Hack: The default handler has a bug. * The JavaPlugin.getDefault().getPreferenceStore() is not updated synchronously. * This code copy the new font value to the default preference store. */ Font f = JFaceResources.getTextFont(); FontData data = f.getFontData()[0]; //System.out.println(data); //TODO: Log for debuging JavaPlugin.getDefault().getPreferenceStore().setValue(event.getProperty(), data.toString()); /* * Set new font in the text widget. The font will be overwriten later with * the same value. But we have to set font to calculate the line heght. */ getSourceViewer().getTextWidget().setFont(f); int h = getSourceViewer().getTextWidget().getLineHeight(); canvasControlFlowGraph.setLineHight(h); /* update control flow graph figure */ canvasControlFlowGraph.documentUpdated(byteCodeDocumentProvider.getClassFileDocument()); } /* Bytecode Mnemonics */ else if (event.getProperty().startsWith(bytecodeMnemonicPreferencesPrefix)) { classFileConfiguration.adaptToPreferenceChange(event); getSourceViewer().invalidateTextPresentation(); } /* Syntax and Coloring */ else if (event.getProperty().startsWith("java_")) { classFileConfiguration.adaptToPreferenceChange(event); getSourceViewer().invalidateTextPresentation(); } /* classfile attributes */ // else if(event.getProperty().startsWith(BytecodeVizualizerPreferenceConstants.classFileAttributePreferencesPrefix)){ // //Do not support. The document has to be reloaded. // } else { /* other references which are not matched befor */ //System.out.println("event=" + event.getProperty());//TODO: log } } }; /* add preference store listener */ store.addPropertyChangeListener(preferenceListener); /* add listener */ JFaceResources.getFontRegistry().addListener(preferenceListener); }
From source file:com.google.dart.tools.ui.web.yaml.PubspecYamlEditor.java
License:Open Source License
private void initializeViewerFont(ISourceViewer viewer) { Font font = null;/*from w w w .j a v a 2 s. c om*/ String symbolicFontName = PreferenceConstants.EDITOR_TEXT_FONT; font = JFaceResources.getFont(symbolicFontName); if (font == null) { font = JFaceResources.getTextFont(); } if (!font.equals(getSourceViewer().getTextWidget().getFont())) { setFont(viewer, font); } else { font.dispose(); } }
From source file:com.google.eclipse.elt.emulator.core.VT100TerminalControl.java
License:Open Source License
protected void setUpControls(Composite parent) { // The Terminal view now aims to be an ANSI-conforming terminal emulator, so it can't have a horizontal scroll bar // (but a vertical one is ok). Also, do _not_ make the TextViewer read-only, because that prevents it from seeing a // TAB character when the user presses TAB (instead, the TAB causes focus to switch to another Workbench control). // We prevent local keyboard input from modifying the text in method TerminalVerifyKeyListener.verifyKey(). rootControl = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0;// ww w .j a v a 2s . co m layout.marginHeight = 0; layout.verticalSpacing = 0; rootControl.setLayout(layout); ITerminalTextDataSnapshot snapshot = terminalModel.makeSnapshot(); // TODO how to get the initial size correctly! snapshot.updateSnapshot(false); ITextCanvasModel canvasModel = new PollingTextCanvasModel(snapshot); textControl = new TextCanvas(rootControl, canvasModel, SWT.NONE, new TextLineRenderer(textControl, canvasModel)); textControl.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { IHyperlink hyperlink = hyperlinkAt(e); if (hyperlink != null) { hyperlink.open(); } } }); textControl.addMouseMoveListener(new MouseMoveListener() { @Override public void mouseMove(MouseEvent e) { IHyperlink hyperlink = hyperlinkAt(e); int cursorId = (hyperlink == null) ? SWT.CURSOR_IBEAM : SWT.CURSOR_HAND; Cursor newCursor = textControl.getDisplay().getSystemCursor(cursorId); if (!newCursor.equals(textControl.getCursor())) { textControl.setCursor(newCursor); } } }); textControl.setLayoutData(new GridData(GridData.FILL_BOTH)); textControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); textControl.addResizeHandler(new TextCanvas.ResizeListener() { @Override public void sizeChanged(int lines, int columns) { terminalText.setDimensions(lines, columns); } }); textControl.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { // update selection used by middle mouse button paste if (e.button == 1 && getSelection().length() > 0) { copy(DND.SELECTION_CLIPBOARD); } } }); display = getTextControl().getDisplay(); clipboard = new Clipboard(display); setFont(JFaceResources.getTextFont()); }
From source file:com.google.eclipse.elt.view.preferences.ColorsAndFontsPreferencePage.java
License:Open Source License
private void updateFontDataWithTextFont() { updateFontData(JFaceResources.getTextFont().getFontData()[0]); }