List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:net.sf.eclipsensis.console.NSISConsole.java
License:Open Source License
@Override protected void dispose() { // Here we can't call super.dispose() because we actually want the partitioner to remain // connected, but we won't show lines until the console is added to the console manager // again.//from ww w .jav a2s. c o m // Called when console is removed from the console view synchronized (mPending) { mVisible = false; JFaceResources.getColorRegistry().removeListener(this); JFaceResources.getFontRegistry().removeListener(this); } }
From source file:net.sf.eclipsensis.console.NSISConsoleViewer.java
License:Open Source License
public NSISConsoleViewer(Composite parent, NSISConsole console) { super(parent, console); mAnnotationModel = console.getAnnotationModel(); mRuler.setModel(mAnnotationModel);/* ww w . jav a2 s. c o m*/ mAnnotationModel.connect(getDocument()); StyledText text = getTextWidget(); if (text != null) { text.setEditable(false); } JFaceResources.getColorRegistry().addListener(mPropertyChangeListener); JFaceResources.getFontRegistry().addListener(mPropertyChangeListener); }
From source file:net.sf.eclipsensis.console.NSISConsoleViewer.java
License:Open Source License
@Override protected void handleDispose() { JFaceResources.getColorRegistry().removeListener(mPropertyChangeListener); JFaceResources.getFontRegistry().removeListener(mPropertyChangeListener); if (getDocument() != null) { mAnnotationModel.disconnect(getDocument()); }/*from w w w . j a v a2 s. c om*/ mAnnotationModel = null; mRuler = null; mComposite = null; super.handleDispose(); }
From source file:net.sf.eclipsensis.dialogs.ColorEditor.java
License:Open Source License
protected Point calculateSize(Control window) { GC gc = new GC(window); Font old = gc.getFont();/*from ww w.j a va 2 s .co m*/ Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); gc.setFont(f); int height = gc.getFontMetrics().getHeight(); gc.setFont(old); gc.dispose(); Point p = new Point(height * 3 - 6, height); return p; }
From source file:net.sf.eclipsensis.editor.text.NSISTextUtility.java
License:Open Source License
public static void hookSourceViewer(final ISourceViewer viewer) { final StyledText textWidget = viewer.getTextWidget(); final FontRegistry fontRegistry = JFaceResources.getFontRegistry(); textWidget.setFont(fontRegistry.get(JFaceResources.TEXT_FONT)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { textWidget.setFont(fontRegistry.get(JFaceResources.TEXT_FONT)); }//from www. j a va 2s . c om } }; fontRegistry.addListener(fontListener); final Display display = textWidget.getDisplay(); final HashMap<String, Color> map = new HashMap<String, Color>(); final IPreferenceStore store = EditorsUI.getPreferenceStore(); textWidget.setBackground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, display)); textWidget.setForeground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, display)); final IPropertyChangeListener colorListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND) || event .getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { textWidget.setBackground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, display)); } else if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND) || event .getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)) { textWidget.setForeground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, display)); } } }; store.addPropertyChangeListener(colorListener); textWidget.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { fontRegistry.removeListener(fontListener); store.removePropertyChangeListener(colorListener); for (Iterator<Color> iter = map.values().iterator(); iter.hasNext();) { Color color = iter.next(); if (color != null && !color.isDisposed()) { color.dispose(); } } } }); }
From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java
License:Open Source License
private void showOneJARHelp() { MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help", MessageDialog.INFORMATION, new String[] { "OK" }, 0) { protected Font font; public boolean close() { boolean result; try { font.dispose();//w ww. j av a 2 s . c o m } finally { result = super.close(); } return result; } protected Control createCustomArea(Composite parent) { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 600; gd.heightHint = 300; String resource = "one-jar-help.txt"; StringBuffer help = null; try { help = readText(this.getClass().getResourceAsStream(resource)); } catch (IOException iox1) { help = new StringBuffer(); help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1); } Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); FontData fd = font.getFontData()[0]; // Reduce the font-size. TODO: Should make this configurable in // preferences. fd.setHeight(fd.getHeight() - 2); font = new Font(text.getDisplay(), fd); text.setFont(font); text.setEditable(false); text.setLayoutData(gd); text.setText(help.toString()); Hyperlink href = new Hyperlink(parent, SWT.NONE); href.setText("http://one-jar.sourceforge.net"); href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); href.setUnderlined(true); href.addHyperlinkListener(new IHyperlinkListener() { public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { try { SystemBrowserFactory factory = new SystemBrowserFactory(); factory.createBrowser().displayURL(e.getLabel()); } catch (Exception x) { MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(), "Unable to open browser: \n" + x.getStackTrace()); } } }); return text; } }; dialog.open(); }
From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java
License:Open Source License
private void showOneJARHelp() { MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help", MessageDialog.INFORMATION, new String[] { "OK" }, 0) { protected Font font; public boolean close() { boolean result; try { font.dispose();// w w w. jav a 2s .com } finally { result = super.close(); } return result; } protected Control createCustomArea(Composite parent) { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 600; gd.heightHint = 300; String resource = "one-jar-help.txt"; StringBuffer help = null; try { help = readText(this.getClass().getResourceAsStream(resource)); } catch (IOException iox1) { help = new StringBuffer(); help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1); } Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); FontData fd = font.getFontData()[0]; // Reduce the font-size. TODO: Should make this configurable in preferences. fd.setHeight(fd.getHeight() - 2); font = new Font(text.getDisplay(), fd); text.setFont(font); text.setEditable(false); text.setLayoutData(gd); text.setText(help.toString()); Hyperlink href = new Hyperlink(parent, SWT.NONE); href.setText("http://one-jar.sourceforge.net"); href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); href.setUnderlined(true); href.addHyperlinkListener(new IHyperlinkListener() { public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { try { SystemBrowserFactory factory = new SystemBrowserFactory(); factory.createBrowser().displayURL(e.getLabel()); } catch (Exception x) { MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(), "Unable to open browser: \n" + x.getStackTrace()); } } }); return text; } }; dialog.open(); }
From source file:net.sf.solareclipse.ui.ColorEditor.java
License:Open Source License
protected Point computeImageSize(Control control) { Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); GC gc = new GC(control); gc.setFont(f);// w ww .j a v a2s . c o m int height = gc.getFontMetrics().getHeight(); gc.dispose(); return new Point(height * 3 - 6, height); }
From source file:net.sf.solareclipse.xml.internal.ui.preferences.CSSSyntaxPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { cssTextTools = new CSSTextTools(overlay); preview = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); preview.configure(new CSSConfiguration(cssTextTools)); preview.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); preview.setEditable(false);/* ww w . j a v a 2 s . c o m*/ initializeViewerColors(preview); String content = loadPreviewContentFromFile("preview.css"); //$NON-NLS-1$ IDocument document = new Document(content); IDocumentPartitioner partitioner = cssTextTools.createCSSPartitioner(); partitioner.connect(document); document.setDocumentPartitioner(partitioner); preview.setDocument(document); overlay.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String p = event.getProperty(); if (p.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND) || p.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { initializeViewerColors(preview); } preview.invalidateTextPresentation(); } }); return preview.getControl(); }
From source file:net.sf.solareclipse.xml.internal.ui.preferences.XMLSyntaxPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { xmlTextTools = new XMLTextTools(overlay); // REVISIT: DTD preview = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); preview.configure(new XMLConfiguration(xmlTextTools)); preview.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); preview.setEditable(false);/*from w w w . j a v a 2 s .c o m*/ initializeViewerColors(preview); String content = loadPreviewContentFromFile("preview.xml"); //$NON-NLS-1$ IDocument document = new Document(content); IDocumentPartitioner partitioner = xmlTextTools.createXMLPartitioner(); // REVISIT: DTD partitioner.connect(document); document.setDocumentPartitioner(partitioner); preview.setDocument(document); overlay.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String p = event.getProperty(); if (p.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND) || p.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { initializeViewerColors(preview); } preview.invalidateTextPresentation(); } }); return preview.getControl(); }