List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.dltk.internal.debug.ui.log.ScriptDebugLogView.java
License:Open Source License
public void createPartControl(Composite parent) { final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); viewer = new TableViewer(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); viewer.getTable().setHeaderVisible(true); viewer.getTable().setLinesVisible(true); addColumn(Messages.Column_Date, 100, true); addColumn(Messages.Column_Time, 100, true); addColumn(Messages.Column_Type, 80, true); addColumn(Messages.Column_Session, 80, true); addColumn(Messages.Column_Message, 400, false); viewer.getTable().addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { final Table table = (Table) event.widget; final int columnCount = table.getColumnCount(); int w = table.getClientArea().width; for (int i = 0; i < columnCount - 1; ++i) { w -= table.getColumn(i).getWidth(); }/*from w w w.ja v a 2s . c o m*/ if (w > 0) { table.getColumn(columnCount - 1).setWidth(w); } } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { final Object first = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (first instanceof ScriptDebugLogItem) { textDocument.set(((ScriptDebugLogItem) first).getMessage()); return; } } textDocument.set(""); //$NON-NLS-1$ } }); viewer.setContentProvider(new ScriptDebugLogContentProvider()); viewer.setLabelProvider(new ScriptDebugLogLabelProvider()); viewer.setInput(items); textDocument = new Document(); textViewer = new TextViewer(sashForm, SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP | SWT.READ_ONLY); textViewer.setDocument(textDocument); fontRegistryChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { handlePropertyChangeEvent(event); } }; JFaceResources.getFontRegistry().addListener(fontRegistryChangeListener); updateFont(); sashForm.setWeights(new int[] { 75, 25 }); createActions(); createMenu(); createToolbar(); createContextMenu(); IContextService ctxService = (IContextService) getSite().getService(IContextService.class); if (ctxService != null) { fContextActivation = ctxService.activateContext(DLTKUIPlugin.CONTEXT_VIEWS); } }
From source file:org.eclipse.dltk.internal.debug.ui.log.ScriptDebugLogView.java
License:Open Source License
public void dispose() { if (fContextActivation != null) { IContextService ctxService = (IContextService) getSite().getService(IContextService.class); if (ctxService != null) { ctxService.deactivateContext(fContextActivation); }//from ww w . j av a 2s .c om } if (fontRegistryChangeListener != null) { JFaceResources.getFontRegistry().removeListener(fontRegistryChangeListener); fontRegistryChangeListener = null; } super.dispose(); }
From source file:org.eclipse.dltk.internal.ui.preferences.ScriptSourcePreviewerUpdater.java
License:Open Source License
/** * Creates a script source preview updater for the given viewer, * configuration and preference store./* ww w. ja v a 2s .co m*/ * * @param viewer * the viewer * @param configuration * the configuration * @param preferenceStore * the preference store */ public ScriptSourcePreviewerUpdater(final SourceViewer viewer, final ScriptSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { Assert.isNotNull(viewer); Assert.isNotNull(configuration); Assert.isNotNull(preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { final String fontKey = configuration.getFontPropertyPreferenceKey(); if (fontKey.equals(event.getProperty())) { final Font font = JFaceResources.getFont(fontKey); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (configuration.affectsTextPresentation(event)) { configuration.handlePropertyChangeEvent(event); viewer.invalidateTextPresentation(); } } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.eclipse.dltk.internal.ui.text.hover.AbstractScriptEditorTextHover.java
License:Open Source License
/** * Returns the style sheet.// www. j a va2 s. c o m * * */ protected static String getStyleSheet() { if (fgCSSStyles == null) { Bundle bundle = Platform.getBundle(DLTKUIPlugin.getPluginId()); 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(); } 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.eclipse.dltk.mod.internal.debug.ui.log.ScriptDebugLogView.java
License:Open Source License
public void createPartControl(Composite parent) { final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); viewer = new TableViewer(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); viewer.getTable().setHeaderVisible(true); viewer.getTable().setLinesVisible(true); addColumn(Messages.Column_Date, 100, true); addColumn(Messages.Column_Time, 100, true); addColumn(Messages.Column_Type, 80, true); addColumn(Messages.Column_Session, 80, true); addColumn(Messages.Column_Message, 400, false); viewer.getTable().addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { final Table table = (Table) event.widget; final int columnCount = table.getColumnCount(); int w = table.getClientArea().width; for (int i = 0; i < columnCount - 1; ++i) { w -= table.getColumn(i).getWidth(); }/*w ww . j av a 2 s .co m*/ if (w > 0) { table.getColumn(columnCount - 1).setWidth(w); } } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { final Object first = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (first instanceof ScriptDebugLogItem) { textDocument.set(((ScriptDebugLogItem) first).getMessage()); return; } } textDocument.set(""); //$NON-NLS-1$ } }); viewer.setContentProvider(new ScriptDebugLogContentProvider()); viewer.setLabelProvider(new ScriptDebugLogLabelProvider()); viewer.setInput(items); textDocument = new Document(); textViewer = new TextViewer(sashForm, SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP | SWT.READ_ONLY); textViewer.setDocument(textDocument); fontRegistryChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { handlePropertyChangeEvent(event); } }; JFaceResources.getFontRegistry().addListener(fontRegistryChangeListener); updateFont(); sashForm.setWeights(new int[] { 75, 25 }); createActions(); createMenu(); createToolbar(); createContextMenu(); }
From source file:org.eclipse.dltk.mod.internal.debug.ui.log.ScriptDebugLogView.java
License:Open Source License
public void dispose() { if (fontRegistryChangeListener != null) { JFaceResources.getFontRegistry().removeListener(fontRegistryChangeListener); fontRegistryChangeListener = null; }//from ww w. j av a 2 s. com super.dispose(); }
From source file:org.eclipse.dltk.mod.ui.text.completion.AbstractScriptCompletionProposal.java
License:Open Source License
/** * Returns the style sheet URL.//from w w w .j a v a 2 s.co m * * */ protected String getCSSStyles() { if (fgCSSStyles == null) { Bundle bundle = Platform.getBundle(DLTKUIPlugin.getPluginId()); 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(); } 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.eclipse.dltk.ui.infoviews.AbstractDocumentationView.java
License:Open Source License
private static void initStyleSheet() { Bundle bundle = Platform.getBundle(DLTKUIPlugin.getPluginId()); URL styleSheetURL = bundle.getEntry("/DocumentationViewStyleSheet.css"); //$NON-NLS-1$ if (styleSheetURL == null) return;/*from w w w . ja v a 2s . co m*/ try { styleSheetURL = FileLocator.toFileURL(styleSheetURL); BufferedReader reader = new BufferedReader(new InputStreamReader(styleSheetURL.openStream())); StringBuffer buffer = new StringBuffer(200); String line = reader.readLine(); while (line != null) { buffer.append(line); buffer.append('\n'); line = reader.readLine(); } FontData fontData = JFaceResources.getFontRegistry() .getFontData(PreferenceConstants.APPEARANCE_DOCUMENTATION_FONT)[0]; fgStyleSheet = org.eclipse.dltk.ui.text.completion.HTMLPrinter.convertTopLevelFont(buffer.toString(), fontData); } catch (IOException ex) { DLTKUIPlugin.log(ex); } }
From source file:org.eclipse.e4.demo.cssbridge.ui.views.FolderPreviewView.java
License:Open Source License
private void createMessageBodyComposite(Composite parent) { messageBodyComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;// w w w.jav a 2 s . co m layout.marginWidth = 0; messageBodyComposite.setLayout(layout); // top banner Composite banner = new Composite(messageBodyComposite, SWT.NONE); banner.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); layout = new GridLayout(); layout.marginHeight = 5; layout.marginWidth = 10; layout.numColumns = 2; banner.setLayout(layout); // setup bold font Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); Label l = new Label(banner, SWT.NONE); l.setText("Subject:"); l.setFont(boldFont); l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); gridData.minimumWidth = 100; subjectLabel = new Label(banner, SWT.WRAP); subjectLabel.setLayoutData(gridData); subjectLabel.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); l = new Label(banner, SWT.NONE); l.setText("From:"); l.setFont(boldFont); l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); senderLink = new Link(banner, SWT.NONE); senderLink.addSelectionListener(senderLinkSelectionAdapter); senderLink.setLayoutData(gridData); senderLink.addPaintListener(senderLinkPaintListener); l = new Label(banner, SWT.NONE); l.setText("Date:"); l.setFont(boldFont); l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); dateLabel = new Label(banner, SWT.WRAP); dateLabel.setLayoutData(gridData); dateLabel.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); // message contents messageText = new Text(messageBodyComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP); messageText.setLayoutData(new GridData(GridData.FILL_BOTH)); messageText.setEditable(false); messageText.setBackground(messageText.getDisplay().getSystemColor(SWT.COLOR_WHITE)); messageText.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND)); messageText.setBackground(viewer.getTable().getBackground()); }
From source file:org.eclipse.e4.demo.simpleide.jdt.internal.editor.JavaEditor.java
License:Open Source License
@Inject public JavaEditor(Composite parent, IDocumentInput input, IWorkspace workspace, MPart part) { this.input = input; this.part = part; this.workspace = workspace; VerticalRuler verticalRuler = new VerticalRuler(VERTICAL_RULER_WIDTH); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; SourceViewer viewer = new SourceViewer(parent, verticalRuler, styles); Font f = null;/*from ww w . j a v a 2 s . c o m*/ if (!JFaceResources.getFontRegistry().hasValueFor("JavaEditorFont")) { if (SWT.getPlatform().equals("carbon") || SWT.getPlatform().equals("cocoa")) { JFaceResources.getFontRegistry().put("JavaEditorFont", new FontData[] { new FontData("Monaco", 11, SWT.NONE) }); } } f = JFaceResources.getFontRegistry().get("JavaEditorFont"); viewer.getTextWidget().setFont(f); viewer.configure(new JavaSourceViewerConfiguration(textTools)); IDocument document = input.getDocument(); textTools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); viewer.setDocument(document); }