List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePage.java
License:Open Source License
@Override public void createControl(Composite parent) { fViewer = new BuildConsoleViewer(parent); MenuManager manager = new MenuManager("#MessageConsole", "#MessageConsole"); //$NON-NLS-1$ //$NON-NLS-2$ manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { @Override//from w w w. ja va 2s .com public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } }); fMenu = manager.createContextMenu(getControl()); getControl().setMenu(fMenu); IPageSite site = getSite(); site.registerContextMenu(fContextMenuId, manager, getViewer()); site.setSelectionProvider(getViewer()); createActions(); configureToolBar(site.getActionBars().getToolBarManager()); fViewer.getSelectionProvider().addSelectionChangedListener(fTextListener); JFaceResources.getFontRegistry().addListener(this); setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT)); setTabs(CUIPlugin.getDefault().getPreferenceStore() .getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH)); getConsole().addPropertyChangeListener(this); CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); fViewer.addTextListener(this); fViewer.getTextWidget().setBackground(getConsole().getBackground()); setInitialSelection(); }
From source file:org.eclipse.cdt.internal.ui.language.LanguageMappingWidget.java
License:Open Source License
public LanguageMappingWidget() { fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT); fOverriddenContentTypes = Collections.emptySet(); // keep a mapping of all registered content types and their names fContentTypeNamesToIDsMap = new HashMap<String, String>(); String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds(); IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); for (int i = 0; i < contentTypesIDs.length; i++) { String name = contentTypeManager.getContentType(contentTypesIDs[i]).getName(); // keep track of what ID this name corresponds to so that when we // setup the mapping // later based upon user selection, we'll know what ID to use fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]); }/*from www . jav a 2s. c o m*/ fAffectedContentTypes = new HashSet<IContentType>(); }
From source file:org.eclipse.cdt.internal.ui.preferences.CSourcePreviewerUpdater.java
License:Open Source License
/** * Registers a source preview updater for the given viewer, configuration and preference store. * * @param viewer the viewer/*from ww w . ja va 2s . c o m*/ * @param configuration the configuration * @param preferenceStore the preference store */ static public void registerPreviewer(final SourceViewer viewer, final CSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { Assert.isNotNull(viewer); Assert.isNotNull(configuration); Assert.isNotNull(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(PreferenceConstants.EDITOR_TEXT_FONT)) { Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_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) { if (configuration.affectsTextPresentation(event)) { configuration.handlePropertyChangeEvent(event); viewer.invalidateTextPresentation(); } } }; 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.cdt.internal.ui.preferences.CTemplatePreferencePage.java
License:Open Source License
@Override protected SourceViewer createViewer(Composite parent) { IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore(); CSourceViewer viewer = new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CTextTools tools = CUIPlugin.getDefault().getTextTools(); CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning()); IDocument document = new Document(); tools.setupCDocument(document);/*from w ww. j a va 2 s .c o m*/ viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); Control control = viewer.getControl(); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = convertHeightInCharsToPixels(5); control.setLayoutData(data); control.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview; } }); CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore()); return viewer; }
From source file:org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) { ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); excomposite.setText(label);/*from ww w. ja v a 2 s. co m*/ excomposite.setExpanded(false); excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1)); excomposite.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { expandedStateChanged((ExpandableComposite) e.getSource()); } }); fExpandedComposites.add(excomposite); makeScrollableCompositeAware(excomposite); return excomposite; }
From source file:org.eclipse.cdt.internal.ui.search.CSearchPage.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page.<br> * This method has been copied from class {@link PreferencePage} * //from w ww . j av a2 s . c o m * @param font the font to use * @param composite the parent composite * @param title the title of the note * @param message the message for the note * @return the composite for the note */ protected Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new Composite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); return messageComposite; }
From source file:org.eclipse.cdt.make.ui.dialogs.SettingsBlock.java
License:Open Source License
protected Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new Composite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2;/*from w w w . ja v a 2 s .c o m*/ messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getBannerFont()); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); return messageComposite; }
From source file:org.eclipse.cdt.utils.ui.controls.ControlFactory.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @param font the font to use/*from w ww . j a v a2s. c o m*/ * @param composite the parent composite * @param title the title of the note * @param message the message for the note * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new Composite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); return messageComposite; }
From source file:org.eclipse.compare.codereview.compareEditor.RefacTextMergeViewer.java
License:Open Source License
/** * Creates a text merge viewer under the given parent control. * * @param parent the parent control//from ww w . ja v a 2s .co m * @param style SWT style bits for top level composite of this viewer * @param configuration the configuration object */ public RefacTextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); operationHistoryListener = new IOperationHistoryListener() { public void historyNotification(OperationHistoryEvent event) { RefacTextMergeViewer.this.historyNotification(event); } }; OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(operationHistoryListener); fMerger = new DocumentMerger(new IDocumentMergerInput() { public ITokenComparator createTokenComparator(String line) { return RefacTextMergeViewer.this.createTokenComparator(line); } public CompareConfiguration getCompareConfiguration() { return RefacTextMergeViewer.this.getCompareConfiguration(); } public IDocument getDocument(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getSourceViewer().getDocument(); case RIGHT_CONTRIBUTOR: return fRight.getSourceViewer().getDocument(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getSourceViewer().getDocument(); } return null; } public int getHunkStart() { return RefacTextMergeViewer.this.getHunkStart(); } public Position getRegion(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getRegion(); case RIGHT_CONTRIBUTOR: return fRight.getRegion(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getRegion(); } return null; } public boolean isHunkOnLeft() { ITypedElement left = ((ICompareInput) getInput()).getRight(); return left != null && Utilities.getAdapter(left, IHunk.class) != null; } public boolean isIgnoreAncestor() { return RefacTextMergeViewer.this.isIgnoreAncestor(); } public boolean isPatchHunk() { return RefacTextMergeViewer.this.isPatchHunk(); } public boolean isShowPseudoConflicts() { return fShowPseudoConflicts; } public boolean isThreeWay() { return RefacTextMergeViewer.this.isThreeWay(); } public boolean isPatchHunkOk() { return RefacTextMergeViewer.this.isPatchHunkOk(); } }); int inheritedStyle = parent.getStyle(); if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0) fInheritedDirection = SWT.LEFT_TO_RIGHT; else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0) fInheritedDirection = SWT.RIGHT_TO_LEFT; else fInheritedDirection = SWT.NONE; if ((style & SWT.LEFT_TO_RIGHT) != 0) fTextDirection = SWT.LEFT_TO_RIGHT; else if ((style & SWT.RIGHT_TO_LEFT) != 0) fTextDirection = SWT.RIGHT_TO_LEFT; else fTextDirection = SWT.NONE; fSymbolicFontName = getSymbolicFontName(); fIsMotif = Util.isMotif(); fIsCarbon = Util.isCarbon(); fIsMac = Util.isMac(); if (fIsMotif) fMarginWidth = 0; fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RefacTextMergeViewer.this.handlePropertyChangeEvent(event); } }; fPreferenceStore = createChainedPreferenceStore(); if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES); //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); } buildControl(parent); setColors(); INavigatable nav = new INavigatable() { public boolean selectChange(int flag) { if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) { selectFirstDiff(flag == INavigatable.FIRST_CHANGE); return false; } return navigate(flag == INavigatable.NEXT_CHANGE, false, false); } public Object getInput() { return RefacTextMergeViewer.this.getInput(); } public boolean openSelectedChange() { return false; } public boolean hasChange(int flag) { return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null; } }; fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); updateFont(); }
From source file:org.eclipse.compare.codereview.compareEditor.RefacTextMergeViewer.java
License:Open Source License
/** * Called on the viewer disposal./*ww w.j a v a 2 s. c o m*/ * Unregisters from the compare configuration. * Clients may extend if they have to do additional cleanup. * @param event */ protected void handleDispose(DisposeEvent event) { OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(operationHistoryListener); if (fHandlerService != null) fHandlerService.dispose(); Object input = getInput(); removeFromDocumentManager(ANCESTOR_CONTRIBUTOR, input); removeFromDocumentManager(LEFT_CONTRIBUTOR, input); removeFromDocumentManager(RIGHT_CONTRIBUTOR, input); if (DEBUG) DocumentManager.dump(); if (fPreferenceChangeListener != null) { JFaceResources.getFontRegistry().removeListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().removeListener(fPreferenceChangeListener); if (fPreferenceStore != null) fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); fPreferenceChangeListener = null; } fLeftCanvas = null; fRightCanvas = null; fVScrollBar = null; fBirdsEyeCanvas = null; fSummaryHeader = null; fAncestorContributor.unsetDocument(fAncestor); fLeftContributor.unsetDocument(fLeft); fRightContributor.unsetDocument(fRight); disconnect(fLeftContributor); disconnect(fRightContributor); disconnect(fAncestorContributor); if (fBirdsEyeCursor != null) { fBirdsEyeCursor.dispose(); fBirdsEyeCursor = null; } if (showWhitespaceAction != null) showWhitespaceAction.dispose(); if (toggleLineNumbersAction != null) toggleLineNumbersAction.dispose(); if (fIgnoreWhitespace != null) fIgnoreWhitespace.dispose(); getCompareConfiguration().setProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING, Boolean.TRUE); disposeCompareFilterActions(false); if (fSourceViewerDecorationSupport != null) { for (Iterator iterator = fSourceViewerDecorationSupport.iterator(); iterator.hasNext();) { ((SourceViewerDecorationSupport) iterator.next()).dispose(); } fSourceViewerDecorationSupport = null; } if (fAncestor != null) fAncestor.dispose(); fAncestor = null; if (fLeft != null) fLeft.dispose(); fLeft = null; if (fRight != null) fRight.dispose(); fRight = null; if (fColors != null) { Iterator i = fColors.values().iterator(); while (i.hasNext()) { Color color = (Color) i.next(); if (!color.isDisposed()) color.dispose(); } fColors = null; } // don't add anything here, disposing colors should be done last super.handleDispose(event); }