List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.cfeclipse.cfml.preferences.ColorEditor.java
License:Open Source License
protected Point computeImageSize(Control window) { GC gc = new GC(window); org.eclipse.swt.graphics.Font f = JFaceResources.getFontRegistry().get("org.eclipse.jface.defaultfont"); gc.setFont(f);/*w ww . j av a2s. c o m*/ int height = gc.getFontMetrics().getHeight(); gc.dispose(); Point p = new Point(height * 3 - 6, height); return p; }
From source file:org.codehaus.groovy.eclipse.dsl.inferencing.suggestions.ui.AbstractDialogue.java
License:Apache License
protected Font getRequiredParameterFont() { return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); }
From source file:org.codehaus.groovy.eclipse.preferences.ScriptFolderSelectorPreferences.java
License:Apache License
public ListDialogField createListContents() { Label label = new Label(parent, SWT.WRAP); label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); label.setText("Groovy Script Folders:"); label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); Composite inner = new Composite(parent, SWT.BORDER); inner.setFont(parent.getFont());// w ww . jav a 2 s . co m GridLayout layout = new GridLayout(); layout.marginHeight = 3; layout.marginWidth = 3; layout.numColumns = 1; inner.setLayout(layout); inner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); disableButton = new BooleanFieldEditor(Activator.GROOVY_SCRIPT_FILTERS_ENABLED, "Enable script folder support", BooleanFieldEditor.DEFAULT, inner); disableButton.setPreferenceStore(store); disableButton.load(); // inner composite contains the dialog itself final Composite innerInner = new Composite(inner, SWT.NONE); innerInner.setFont(parent.getFont()); layout = new GridLayout(); layout.marginHeight = 3; layout.marginWidth = 3; layout.numColumns = 3; innerInner.setLayout(layout); innerInner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); innerInner.setToolTipText("CHECKED boxes are COPIED to output folder.\nUNCHECKED boxes are NOT copied."); boolean enabled = disableButton.getBooleanValue(); innerInner.setEnabled(enabled); // enable/disable pattern list based disableButton.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty() == FieldEditor.VALUE) { Object o = event.getNewValue(); if (o instanceof Boolean) { boolean enabled = ((Boolean) o); innerInner.setEnabled(enabled); for (Control c : innerInner.getChildren()) { c.setEnabled(enabled); } } } } }); ScriptPatternAdapter adapter = new ScriptPatternAdapter(); patternList = new CheckedListDialogField(adapter, buttonLabels, new ScriptLabelProvider(DESCRIPTOR)); patternList.setDialogFieldListener(adapter); patternList.setLabelText("Groovy files that match these patterns are treated as scripts. " + "They will not be compiled and will be copied as-is to the output folder.\n\n" + "CHECKED boxes will be COPIED to the output folder. UNCHECKED boxes are NOT copied to the output folder."); patternList.setRemoveButtonIndex(IDX_REMOVE); patternList.enableButton(IDX_EDIT, false); patternList.setCheckAllButtonIndex(IDX_CHECKALL); patternList.setUncheckAllButtonIndex(IDX_UNCHECKALL); patternList.doFillIntoGrid(innerInner, 3); Label l = patternList.getLabelControl(innerInner); GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.widthHint = 200; l.setLayoutData(gd); resetElements(); patternList.enableButton(IDX_ADD, true); patternList.setViewerComparator(new ViewerComparator()); // finally force greying out of tree if required innerInner.setEnabled(enabled); for (Control c : innerInner.getChildren()) { c.setEnabled(enabled); } return patternList; }
From source file:org.codehaus.groovy.eclipse.ui.console.GroovyConsole.java
License:Apache License
/** * @see org.eclipse.ui.console.AbstractConsole#init() */ @Override protected void init() { JFaceResources.getFontRegistry().addListener(propertyListener); }
From source file:org.codehaus.groovy.eclipse.ui.console.GroovyConsole.java
License:Apache License
/** * @see org.eclipse.ui.console.TextConsole#dispose() *///w w w. j ava 2 s . co m @Override protected void dispose() { JFaceResources.getFontRegistry().removeListener(propertyListener); super.dispose(); }
From source file:org.dafoe.corpuslevel.ui.views.PhraseOccurenceLabelProvider.java
License:Open Source License
@Override protected void paint(Event event, Object element) { // TODO Auto-generated method stub ISentence phrase = (ISentence) element; Display display = view.GetViewer().getControl().getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(phrase.getContent()); TextStyle plain = new TextStyle(JFaceResources.getFont(JFaceResources.DEFAULT_FONT), display.getSystemColor(SWT.COLOR_LIST_FOREGROUND), null); TextStyle italic = new TextStyle(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT), display.getSystemColor(SWT.COLOR_BLUE), null); Font newFont = new Font(display, "Arial", 9, SWT.BOLD); //$NON-NLS-1$ TextStyle font = new TextStyle(newFont, display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLUE)); List<ITermOccurrence> occurences = view.GetListOccurence(phrase); if (occurences != null) { for (int i = 0; i < occurences.size(); i++) { ITermOccurrence occ = occurences.get(i); int pos = occ.getPosition(); // int len = occ.getLength(); layout.setStyle(font, pos, pos + len - 1); }// w w w. j a v a 2s .co m } // layout.setStyle(plain, 0, 2); // layout.setStyle(italic, 3, 5); // layout.setStyle(font, 6, phrase.getText().length() - 1); layout.draw(event.gc, event.x, event.y); if (this.columv.getColumn().getWidth() < event.gc.textExtent(phrase.getContent()).x + 10) { this.columv.getColumn().setWidth(event.gc.textExtent(phrase.getContent()).x + 10); } }
From source file:org.ebayopensource.vjet.eclipse.internal.ui.text.completion.VjoProposalAditionalInfoGenerator.java
License:Open Source License
private static String getCSSStyles() { if (fgCSSStyles == null) { Bundle bundle = Platform.getBundle(VjetUIPlugin.PLUGIN_ID); URL url = bundle.getEntry("/DocumentationHoverStyleSheet.css"); //$NON-NLS-1$ if (url != null) { try { url = FileLocator.toFileURL(url); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); StringBuffer buffer = new StringBuffer(200); String line = reader.readLine(); while (line != null) { buffer.append(line); buffer.append('\n'); line = reader.readLine(); }/* ww w . j av a 2 s. co m*/ fgCSSStyles = buffer.toString(); } catch (IOException ex) { DLTKUIPlugin.log(ex); } } } String css = fgCSSStyles; if (css != null) { FontData fontData = JFaceResources.getFontRegistry() .getFontData(PreferenceConstants.APPEARANCE_DOCUMENTATION_FONT)[0]; css = HTMLPrinter.convertTopLevelFont(css, fontData); } return css; }
From source file:org.ebayopensource.vjet.eclipse.ui.VjetUIPlugin.java
License:Open Source License
/** * Because clearcase cq tool cause a wrong font loaded for * "JFaceResources.TEXT_FONT", So here if the font is not correct, reload * it.//from www. j a va2s. co m */ private void reloadFont() { FontRegistry registry = JFaceResources.getFontRegistry(); if (registry.defaultFont().equals(registry.get(JFaceResources.TEXT_FONT))) { FontData[] datas = registry.getFontData(JFaceResources.TEXT_FONT); registry.put(JFaceResources.TEXT_FONT, registry.defaultFont().getFontData()); registry.put(JFaceResources.TEXT_FONT, datas); } }
From source file:org.eclipse.ant.internal.ui.preferences.AntPreviewerUpdater.java
License:Open Source License
/** * Creates a source preview updater for the given viewer, configuration and preference store. * // w ww. j ava2s. c o m * @param viewer * the viewer * @param configuration * the configuration * @param preferenceStore * the preference store */ public AntPreviewerUpdater(final SourceViewer viewer, final AntSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { initializeViewerColors(viewer, preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT .equals(property)) { initializeViewerColors(viewer, preferenceStore); } if (configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); viewer.invalidateTextPresentation(); } if (FormattingPreferences.affectsFormatting(event)) { format(viewer, preferenceStore); } } /** * @param viewer * @param preferenceStore */ private void format(final SourceViewer sourceViewer, final IPreferenceStore store) { String contents = sourceViewer.getDocument().get(); FormattingPreferences prefs = new FormattingPreferences(); prefs.setPreferenceStore(store); contents = XmlFormatter.format(contents, prefs); viewer.getDocument().set(contents); } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { /* * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) */ @Override public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer.java
License:Open Source License
public Control createUI(Composite parent) { if (parent == null) { return null; }//from w ww. ja va 2s. c o m toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createForm(parent); form.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); form.setImage( StaticHTMLPrviewPlugin.getDefault().getImageRegistry().get(StaticHTMLPrviewPlugin.IMG_FORM_TITLE)); toolkit.decorateFormHeading(form); form.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); layout.horizontalSpacing = layout.verticalSpacing = 0; layout.marginWidth = layout.marginHeight = 0; form.getBody().setLayout(layout); // Re-run the report action reRunReportAction = new Action("Re-run the report", //$NON-NLS-1$ Action.AS_PUSH_BUTTON) { public void run() { render(); } }; reRunReportAction.setToolTipText("Re-run the report"); //$NON-NLS-1$ reRunReportAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_RE_RUN)); form.getToolBarManager().add(reRunReportAction); // paramAction paramAction = new Action("Enter parameter", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { render(); } }; paramAction.setToolTipText("Open Parameters Dialog"); //$NON-NLS-1$ paramAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_PARAMS)); form.getToolBarManager().add(paramAction); // tocAction tocAction = new Action("TOC", Action.AS_RADIO_BUTTON) { //$NON-NLS-1$ public void run() { if (sashForm.getMaximizedControl() != null) { sashForm.setMaximizedControl(null); setChecked(true); } else { sashForm.setMaximizedControl(browserContainer); setChecked(false); } } }; tocAction.setToolTipText("Show TOC"); //$NON-NLS-1$ tocAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_TOC)); tocAction.setChecked(false); form.getToolBarManager().add(tocAction); form.getToolBarManager().add(new Separator()); // navFirstAction navFirstAction = new Action("First", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { currentPageNum = 1; renderWithoutAskingForParams(); } }; navFirstAction.setToolTipText("First"); //$NON-NLS-1$ navFirstAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_FIRST)); form.getToolBarManager().add(navFirstAction); // navPreAction navPreAction = new Action("Previous", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { if (currentPageNum > 1) { currentPageNum--; renderWithoutAskingForParams(); } } }; navPreAction.setToolTipText("Previous"); //$NON-NLS-1$ navPreAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_PRE)); form.getToolBarManager().add(navPreAction); // navNextAction navNextAction = new Action("Next", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { if (currentPageNum < totalPageNum) { currentPageNum++; renderWithoutAskingForParams(); } } }; navNextAction.setToolTipText("Next"); //$NON-NLS-1$ navNextAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_NEXT)); form.getToolBarManager().add(navNextAction); // navLastAction navLastAction = new Action("Last", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { currentPageNum = totalPageNum; renderWithoutAskingForParams(); } }; navLastAction.setToolTipText("Last"); //$NON-NLS-1$ navLastAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_LAST)); form.getToolBarManager().add(navLastAction); form.getToolBarManager().add(new Separator()); ContributionItem inputText = new ContributionItem() { public void fill(ToolBar parent, int index) { ToolItem toolitem = new ToolItem(parent, SWT.SEPARATOR, index); Composite container = new Composite(parent, SWT.NULL); // container.setFont( JFaceResources.getFontRegistry( ) // .get( JFaceResources.TEXT_FONT ) ); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = layout.marginHeight = 1; container.setLayout(layout); Label label = new Label(container, SWT.NULL); label.setFont(container.getFont()); label.setText("Go to page:"); //$NON-NLS-1$ goPageInput = toolkit.createText(container, "", SWT.BORDER); //$NON-NLS-1$ goPageInput.setFont(container.getFont()); goPageInput.setLayoutData(new GridData(GridData.FILL_BOTH)); goPageInput.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.LF || e.character == SWT.CR) { if (navGoAction.isEnabled()) { currentPageNum = Long.parseLong(goPageInput.getText()); renderWithoutAskingForParams(); } } } }); goPageInput.addModifyListener(new ModifyListener() { /** * last valid status */ private boolean isValid = true; public void modifyText(ModifyEvent e) { if (!"".equals(goPageInput.getText())) //$NON-NLS-1$ { try { long page = Long.parseLong(goPageInput.getText()); if (page > 0 && page <= totalPageNum) { if (!isValid) { form.setMessage(null); isValid = true; } navGoAction.setEnabled(true); } else { form.setMessage("Page Number '" //$NON-NLS-1$ + page + "' is invalid!", //$NON-NLS-1$ IMessageProvider.ERROR); isValid = false; navGoAction.setEnabled(false); } } catch (NumberFormatException e1) { form.setMessage("Page Number '" //$NON-NLS-1$ + goPageInput.getText() + "' is invalid!", //$NON-NLS-1$ IMessageProvider.ERROR); isValid = false; navGoAction.setEnabled(false); } } else { form.setMessage(null); isValid = true; } } }); toolitem.setWidth(label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + 40); toolitem.setControl(container); } }; inputText.setVisible(true); form.getToolBarManager().add(inputText); // navSelectAction navGoAction = new Action("Go to page", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ public void run() { if (goPageInput != null && !goPageInput.isDisposed()) { currentPageNum = Long.parseLong(goPageInput.getText()); // render( ); renderWithoutAskingForParams(); } } }; navGoAction.setToolTipText("Go to page"); //$NON-NLS-1$ navGoAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry() .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_GO)); form.getToolBarManager().add(navGoAction); form.updateToolBar(); sashForm = new SashForm(form.getBody(), SWT.NULL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); sashForm.setLayout(layout); toolkit.adapt(sashForm, false, false); createTOCSection(sashForm); createBrowserSection(sashForm); sashForm.setWeights(new int[] { 2, 8 }); toolkit.paintBordersFor(form.getBody()); return this.form; }