List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:com.aptana.rcp.IDEWorkbenchWindowAdvisor.java
License:Open Source License
/** * @see org.eclipse.ui.application.WorkbenchAdvisor#createEmptyWindowContents(org.eclipse.ui.application.IWorkbenchWindowConfigurer, * org.eclipse.swt.widgets.Composite) *///from w ww .ja va 2 s . co m public Control createEmptyWindowContents(Composite parent) { final IWorkbenchWindow window = getWindowConfigurer().getWindow(); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); Display display = composite.getDisplay(); Color bgCol = display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND); composite.setBackground(bgCol); Label label = new Label(composite, SWT.WRAP); label.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); label.setBackground(bgCol); label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); String msg = IDEWorkbenchMessages.IDEWorkbenchAdvisor_noPerspective; label.setText(msg); ToolBarManager toolBarManager = new ToolBarManager(); // TODO: should obtain the open perspective action from ActionFactory openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window); toolBarManager.add(openPerspectiveAction); ToolBar toolBar = toolBarManager.createControl(composite); toolBar.setBackground(bgCol); return composite; }
From source file:com.aptana.terminal.internal.emulator.VT100TerminalControl.java
License:Open Source License
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { super(target, wndParent, connectors); getRootControl().setBackground(ThemedTextLineRenderer.getStyleMap().getBackgroundColor()); preferenceChangeListener = new IPreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent event) { if (IThemeManager.THEME_CHANGED.equals(event.getKey())) { Control control = getRootControl(); if (!control.isDisposed()) { control.setBackground(ThemedTextLineRenderer.getStyleMap().getBackgroundColor()); getCtlText().redraw(); }//from w w w . j a v a 2s .c o m } } }; EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID) .addPreferenceChangeListener(preferenceChangeListener); propertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.TEXT_FONT.equals(event.getProperty())) { setFont(JFaceResources.getTextFont()); } } }; JFaceResources.getFontRegistry().addListener(propertyChangeListener); getCtlText().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (e.button == 2) { // paste clipboard selection String text = (String) getClipboard().getContents(TextTransfer.getInstance(), DND.SELECTION_CLIPBOARD); if (text != null && text.length() > 0) { pasteString(text); } } } }); }
From source file:com.aptana.terminal.internal.emulator.VT100TerminalControl.java
License:Open Source License
@Override public void disposeTerminal() { JFaceResources.getFontRegistry().removeListener(propertyChangeListener); EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID) .removePreferenceChangeListener(preferenceChangeListener); super.disposeTerminal(); }
From source file:com.aptana.theme.internal.InvasiveThemeHijacker.java
License:Open Source License
protected void applyThemetoJDT(Theme theme, boolean revertToDefaults) { // Now set for JDT... IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(ORG_ECLIPSE_JDT_UI); setGeneralEditorValues(theme, prefs, revertToDefaults); // Set prefs for JDT so it's various tokens get colors that match up to our theme! // prefs = EclipseUtil.instanceScope().getNode("org.eclipse.jdt.ui"); setToken(prefs, theme, "string.quoted.double.java", "java_string", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "source.java", "java_default", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "keyword", "java_keyword", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "keyword.operator", "java_operator", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "keyword.control.java", "java_keyword_return", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "comment.line.double-slash.java", "java_single_line_comment", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "comment.block", "java_multi_line_comment", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "punctuation.bracket.java", "java_bracket", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ // Javadoc// ww w. jav a 2 s. c om //String TASK_TAG= "java_comment_task_tag"; //$NON-NLS-1$ setToken(prefs, theme, "keyword.other.documentation.java", "java_doc_keyword", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "entity.name.tag.inline.any.html", "java_doc_tag", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "markup.underline.link.javadoc", "java_doc_link", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "comment.block.documentation.javadoc", "java_doc_default", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ // deprecated // setToken(prefs, theme, "entity.name.function.java", "java_method_name", revertToDefaults); setToken(prefs, theme, "entity.name.type.class.java", "java_type", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "storage.type.annotation.java", "java_annotation", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ // Semantic setSemanticToken(prefs, theme, "entity.name.type.class.java", "class", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "entity.name.type.enum.java", "enum", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "entity.name.type.interface.java", "interface", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "constant.numeric.java", "number", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "variable.parameter.java", "parameterVariable", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "constant.other.java", "staticField", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "constant.other.java", "staticFinalField", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "entity.name.function.java", "methodDeclarationName", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "invalid.deprecated.java", "deprecatedMember", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "storage.type.annotation.java", "annotation", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "constant.other.key.java", "annotationElementReference", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "localVariable", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "field", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "staticMethodInvocation", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "inheritedMethodInvocation", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "abstractMethodInvocation", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "localVariableDeclaration", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "method", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "typeParameter", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "autoboxing", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setSemanticToken(prefs, theme, "source.java", "typeArgument", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ // Java *.properties files setToken(prefs, theme, "keyword.other.java-props", "pf_coloring_key", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "comment.line.number-sign.java-props", "pf_coloring_comment", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "string.java-props", "pf_coloring_value", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ setToken(prefs, theme, "punctuation.separator.key-value.java-props", "pf_coloring_assignment", //$NON-NLS-1$//$NON-NLS-2$ revertToDefaults); setToken(prefs, theme, "string.interpolated.java-props", "pf_coloring_argument", revertToDefaults); //$NON-NLS-1$ //$NON-NLS-2$ // Override pair matching colors if (!revertToDefaults) { // FIXME Revert back to default value if revertToDefaults! prefs.put("matchingBracketsColor", StringConverter.asString(theme.getCharacterPairColor())); //$NON-NLS-1$ } try { prefs.flush(); } catch (BackingStoreException e) { IdeLog.logError(ThemePlugin.getDefault(), e); } // Override JDT editor font Font fFont = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); JFaceResources.getFontRegistry().put("org.eclipse.jdt.ui.editors.textfont", fFont.getFontData()); //$NON-NLS-1$ }
From source file:com.aptana.theme.internal.ThemeManager.java
License:Open Source License
private void forceFontsUpToDate() { final String[] fontIds = new String[] { IThemeManager.VIEW_FONT_NAME, JFaceResources.TEXT_FONT, "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" }; //$NON-NLS-1$ UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { for (String fontId : fontIds) { Font fFont = JFaceResources.getFontRegistry().get(fontId); // Only set new values if they're different from existing! Font existing = JFaceResources.getFont(fontId); String existingString = StringUtil.EMPTY; if (!existing.isDisposed()) { existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData()); }/*from w ww. j av a2s . c o m*/ String fdString = PreferenceConverter.getStoredRepresentation(fFont.getFontData()); if (!existingString.equals(fdString)) { // put in registry... JFaceResources.getFontRegistry().put(fontId, fFont.getFontData()); } } } }); }
From source file:com.aptana.theme.internal.TreeThemer.java
License:Open Source License
private void addFontListener() { if (controlIsDisposed()) { return;/*w w w . j a v a 2 s . c o m*/ } final Tree tree = getTree(); fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (!event.getProperty().equals(IThemeManager.VIEW_FONT_NAME) || !useEditorFont()) { return; } Display.getCurrent().asyncExec(new Runnable() { public void run() { Font font = getFont(); if (font != null && !tree.isDisposed()) // as it's asynchronous, make sure it wasn't disposed in // the meanhile. { tree.setFont(font); GC gc = new GC(Display.getDefault()); gc.setFont(font); FontMetrics metrics = gc.getFontMetrics(); int height = metrics.getHeight() + 2; gc.dispose(); if (isWindows) { try { Method m = Tree.class.getDeclaredMethod("setItemHeight", Integer.TYPE); //$NON-NLS-1$ if (m != null) { m.setAccessible(true); m.invoke(tree, height); } } catch (Exception e) { IdeLog.logError(ThemePlugin.getDefault(), e); } } // HACK! This is a major hack to force down the height of the row when we resize our font to // a // smaller height! else if (isMacOSX && isCocoa) { try { Field f = Control.class.getField("view"); //$NON-NLS-1$ if (f != null) { Object widget = f.get(tree); if (widget != null) { Method m = widget.getClass().getMethod("setRowHeight", Double.TYPE); //$NON-NLS-1$ if (m != null) { m.invoke(widget, height); } } } } catch (Exception e) { IdeLog.logError(ThemePlugin.getDefault(), e); } } } // OK, the app explorer font changed. We need to force a refresh of the app explorer tree if (fTreeViewer != null) { fTreeViewer.refresh(); } tree.redraw(); tree.update(); } }); } }; JFaceResources.getFontRegistry().addListener(fontListener); }
From source file:com.aptana.theme.internal.TreeThemer.java
License:Open Source License
private void removeFontListener() { if (fontListener != null) { JFaceResources.getFontRegistry().removeListener(fontListener); } fontListener = null; }
From source file:com.aptana.theme.preferences.ThemePreferencePage.java
License:Open Source License
private void createFontArea(Composite composite) { Composite themesComp = new Composite(composite, SWT.NONE); themesComp.setLayout(new GridLayout(3, false)); themesComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Label label = new Label(themesComp, SWT.NONE); label.setText(Messages.ThemePreferencePage_FontNameLabel); fFont = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); fFontText = new Text(themesComp, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); fFontText.setText(toString(fFont));//from w w w.ja v a2s . c om fFontText.setFont(fFont); fFontText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button selectFontButton = new Button(themesComp, SWT.PUSH); selectFontButton.setText(Messages.ThemePreferencePage_SelectFontButtonLabel); selectFontButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final FontDialog fontDialog = new FontDialog(getShell()); fontDialog.setFontList(fFont.getFontData()); final FontData data = fontDialog.open(); if (data != null) { setFont(new Font(fFont.getDevice(), fontDialog.getFontList())); } } }); }
From source file:com.aptana.theme.preferences.ThemePreferencePage.java
License:Open Source License
private void setFont(String fontId, FontData[] data) { String fdString = PreferenceConverter.getStoredRepresentation(data); // Only set new values if they're different from existing! Font existing = JFaceResources.getFont(fontId); String existingString = ""; //$NON-NLS-1$ if (!existing.isDisposed()) { existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData()); }/*from w ww . j ava2 s.c om*/ if (!existingString.equals(fdString)) { // put in registry... JFaceResources.getFontRegistry().put(fontId, data); // Save to prefs... ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); store.setValue(key, fdString); } }
From source file:com.aptana.ui.properties.NaturesLabelProvider.java
License:Open Source License
public Font getFont(Object element) { // make the primary nature bold return isPrimary(element.toString()) ? JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT) : null;//from ww w . j a v a 2 s. co m }