List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.xtuml.bp.ui.text.editor.oal.preference.OALEditorSyntaxPreferencePage.java
License:Apache License
protected Control createPreviewer(Composite parent) { final SyntaxHighlightingPreferences clonedPreferences = (SyntaxHighlightingPreferences) clonedModel; final SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); OALEditorConfiguration viewerConfiguration = new OALEditorConfiguration(clonedPreferences); viewer.configure(viewerConfiguration); Font font = JFaceResources.getFont("org.eclipse.jdt.ui.editors.textfont"); viewer.getTextWidget().setFont(font); viewer.getTextWidget().setBackground(clonedPreferences.getBackgroundColor()); viewer.setTabsToSpacesConverter(new OALAutoEditStrategy()); viewer.setEditable(false);/*w w w . jav a 2 s .co m*/ String content = loadPreviewContentFromFile("OALPreviewCode.txt"); IDocument document = new Document(content); OALDocumentProvider.setDocumentPartitioner(document); viewer.setDocument(document); clonedPreferences.addModelChangeListener(new IChangeListener() { public void modelChanged(IPreferenceModel model, int changeHints) { switch (changeHints) { case SyntaxHighlightingPreferences.MODEL_BACKGROUND_CHANGED: viewer.getTextWidget().setBackground(clonedPreferences.getBackgroundColor()); break; case SyntaxHighlightingPreferences.MODEL_TOKEN_ATTRIBUTE_CHANGED: viewer.invalidateTextPresentation(); break; } } }); return viewer.getControl(); }
From source file:reprotool.ide.txtspec.editors.SourceViewerInformationControl.java
License:Open Source License
/** * Creates a source viewer information control with the given shell as parent. The given shell * styles are applied to the created shell. The given styles are applied to the created styled * text widget. The text widget will be initialized with the given font. The status field will * contain the given text or be hidden./* www . j a v a 2 s . com*/ * * @param parent the parent shell * @param isResizable <code>true</code> if resizable * @param symbolicFontName the symbolic font name * @param statusFieldText the text to be used in the optional status field or <code>null</code> * if the status field should be hidden */ public SourceViewerInformationControl(Shell parent, boolean isResizable, String symbolicFontName, String statusFieldText) { GridLayout layout; GridData gd; int shellStyle = SWT.TOOL | SWT.ON_TOP | (isResizable ? SWT.RESIZE : 0); int textStyle = isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE; fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); Display display = fShell.getDisplay(); Composite composite = fShell; layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); composite.setLayoutData(gd); if (statusFieldText != null) { composite = new Composite(composite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } // Source viewer fViewer = new SourceViewer(composite, null, textStyle); fViewer.configure(new SourceViewerConfiguration()); fViewer.setEditable(false); fText = fViewer.getTextWidget(); gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); fText.setLayoutData(gd); fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); fSymbolicFontName = symbolicFontName; fTextFont = JFaceResources.getFont(symbolicFontName); fText.setFont(fTextFont); fText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.character == 0x1B) // ESC fShell.dispose(); } public void keyReleased(KeyEvent e) { } }); // Status field if (statusFieldText != null) { // Horizontal separator line fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Status field label fStatusField = new Label(composite, SWT.RIGHT); fStatusField.setText(statusFieldText); Font font = fStatusField.getFont(); FontData[] fontDatas = font.getFontData(); for (int i = 0; i < fontDatas.length; i++) fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas); fStatusField.setFont(fStatusTextFont); GridData gd2 = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fStatusField.setLayoutData(gd2); fStatusTextForegroundColor = new Color(fStatusField.getDisplay(), blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f)); fStatusField.setForeground(fStatusTextForegroundColor); fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } addDisposeListener(this); }
From source file:ts.eclipse.ide.angular2.internal.ui.preferences.html.HTMLAngular2EditorSyntaxColoringPreferencePage.java
License:Open Source License
protected Control createContents(final Composite parent) { initializeDialogUnits(parent);// w w w. j ava2 s . c o m fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); Composite pageComponent = createComposite(parent, 2); PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); Link link = new Link(pageComponent, SWT.WRAP); link.setText(SSEUIMessages.SyntaxColoring_Link); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null); } }); GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1); linkData.widthHint = 150; // only expand further if anyone else requires // it link.setLayoutData(linkData); new Label(pageComponent, SWT.NONE).setLayoutData(new GridData()); new Label(pageComponent, SWT.NONE).setLayoutData(new GridData()); SashForm editor = new SashForm(pageComponent, SWT.VERTICAL); GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true); gridData2.horizontalSpan = 2; editor.setLayoutData(gridData2); SashForm top = new SashForm(editor, SWT.HORIZONTAL); Composite styleEditor = createComposite(top, 1); ((GridLayout) styleEditor.getLayout()).marginRight = 5; ((GridLayout) styleEditor.getLayout()).marginLeft = 0; createLabel(styleEditor, HTMLUIMessages.SyntaxColoringPage_0); fStylesViewer = createStylesViewer(styleEditor); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.horizontalIndent = 0; Iterator iterator = fStyleToDescriptionMap.values().iterator(); while (iterator.hasNext()) { gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length())); } gridData.heightHint = convertHeightInCharsToPixels(5); fStylesViewer.getControl().setLayoutData(gridData); Composite editingComposite = createComposite(top, 1); ((GridLayout) styleEditor.getLayout()).marginLeft = 5; createLabel(editingComposite, ""); //$NON-NLS-1$ Button enabler = createCheckbox(editingComposite, HTMLUIMessages.SyntaxColoringPage_2); enabler.setEnabled(false); enabler.setSelection(true); Composite editControls = createComposite(editingComposite, 2); ((GridLayout) editControls.getLayout()).marginLeft = 20; fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_); ((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER; fForegroundLabel.setEnabled(false); fForegroundColorEditor = new ColorSelector(editControls); Button fForegroundColor = fForegroundColorEditor.getButton(); GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); fForegroundColor.setLayoutData(gd); fForegroundColorEditor.setEnabled(false); fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(final AccessibleEvent e) { e.result = SSEUIMessages.Foreground_Color_Selector_Button; } }); fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_); ((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER; fBackgroundLabel.setEnabled(false); fBackgroundColorEditor = new ColorSelector(editControls); Button fBackgroundColor = fBackgroundColorEditor.getButton(); gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); fBackgroundColor.setLayoutData(gd); fBackgroundColorEditor.setEnabled(false); fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(final AccessibleEvent e) { e.result = SSEUIMessages.Background_Color_Selector_Button; } }); fBold = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_3); fBold.setEnabled(false); ((GridData) fBold.getLayoutData()).horizontalSpan = 2; fItalic = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_4); fItalic.setEnabled(false); ((GridData) fItalic.getLayoutData()).horizontalSpan = 2; fStrike = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_5); fStrike.setEnabled(false); ((GridData) fStrike.getLayoutData()).horizontalSpan = 2; fUnderline = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_6); fUnderline.setEnabled(false); ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2; fClearStyle = new Button(editingComposite, SWT.PUSH); fClearStyle.setText(SSEUIMessages.Restore_Default_UI_); // $NON-NLS-1$ = // "Restore // Default" fClearStyle.setLayoutData(new GridData(SWT.BEGINNING)); ((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20; fClearStyle.setEnabled(false); Composite sampleArea = createComposite(editor, 1); ((GridLayout) sampleArea.getLayout()).marginLeft = 5; ((GridLayout) sampleArea.getLayout()).marginTop = 5; createLabel(sampleArea, SSEUIMessages.Sample_text__UI_); // $NON-NLS-1$ // = // "&Sample // text:" fPreviewViewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); fText = fPreviewViewer.getTextWidget(); GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true); gridData3.widthHint = convertWidthInCharsToPixels(20); gridData3.heightHint = convertHeightInCharsToPixels(5); gridData3.horizontalSpan = 2; fText.setLayoutData(gridData3); fText.setEditable(false); fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ fText.addKeyListener(getTextKeyListener()); fText.addSelectionListener(getTextSelectionListener()); fText.addMouseListener(getTextMouseListener()); fText.addTraverseListener(getTraverseListener()); setAccessible(fText, SSEUIMessages.Sample_text__UI_); initializeSourcePreviewColors(fPreviewViewer); IStructuredModel model = null; try { model = getDomModel(); fPreviewViewer.setDocument(getDomModel().getStructuredDocument()); } catch (IOException e) { Trace.trace(Trace.SEVERE, "Error while loading DOM", e); } finally { if (model != null) { model.releaseFromRead(); } } top.setWeights(new int[] { 1, 1 }); editor.setWeights(new int[] { 1, 1 }); PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); fStylesViewer.setInput(getStylePreferenceKeys()); applyStyles(); fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (!event.getSelection().isEmpty()) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); String namedStyle = o.toString(); activate(namedStyle); if (namedStyle == null) return; } } }); fForegroundColorEditor.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) { Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[0]; // open color dialog to get new color String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue()); if (!newValue.equals(oldValue)) { stylePrefs[0] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); } } } } }); fBackgroundColorEditor.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) { Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[1]; // open color dialog to get new color String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue()); if (!newValue.equals(oldValue)) { stylePrefs[1] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); activate(namedStyle); } } } } }); fBold.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[2]; String newValue = String.valueOf(fBold.getSelection()); if (!newValue.equals(oldValue)) { stylePrefs[2] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); } } } }); fItalic.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[3]; String newValue = String.valueOf(fItalic.getSelection()); if (!newValue.equals(oldValue)) { stylePrefs[3] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); } } } }); fStrike.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[4]; String newValue = String.valueOf(fStrike.getSelection()); if (!newValue.equals(oldValue)) { stylePrefs[4] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); } } } }); fUnderline.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); String prefString = getOverlayStore().getString(namedStyle); String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); if (stylePrefs != null) { String oldValue = stylePrefs[5]; String newValue = String.valueOf(fUnderline.getSelection()); if (!newValue.equals(oldValue)) { stylePrefs[5] = newValue; String newPrefString = ColorHelper.packStylePreferences(stylePrefs); getOverlayStore().setValue(namedStyle, newPrefString); applyStyles(); fText.redraw(); } } } }); fClearStyle.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (fStylesViewer.getSelection().isEmpty()) return; String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement() .toString(); getOverlayStore().setToDefault(namedStyle); applyStyles(); fText.redraw(); activate(namedStyle); } }); return pageComponent; }
From source file:ts.eclipse.ide.jsdt.internal.ui.template.preferences.CodeTemplateBlock.java
License:Open Source License
private SourceViewer createViewer(Composite parent, int nColumns) { Label label = new Label(parent, SWT.NONE); label.setText(JSDTTypeScriptUIMessages.CodeTemplateBlock_preview); GridData data = new GridData(); data.horizontalSpan = nColumns;/*from ww w . ja v a 2 s .c om*/ label.setLayoutData(data); IDocument document = new Document(); JavaScriptTextTools tools = JavaScriptPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration( tools.getColorManager(), store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new TypeScriptSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); data.horizontalSpan = nColumns; data.heightHint = fPixelConverter.convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; }
From source file:ts.eclipse.ide.jsdt.internal.ui.template.preferences.EditTemplateDialog.java
License:Open Source License
private SourceViewer createEditor(Composite parent) { String prefix = getPrefix();//from w ww. j a va2 s.co m IDocument document = new Document(prefix + fTemplate.getPattern()); JavaScriptTextTools tools = JavaScriptPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration( tools.getColorManager(), store, null, fTemplateProcessor); viewer.configure(configuration); viewer.setEditable(true); viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length()); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new TypeScriptSourcePreviewerUpdater(viewer, configuration, store); int nLines = document.getNumberOfLines(); if (nLines < 5) { nLines = 5; } else if (nLines > 12) { nLines = 12; } Control control = viewer.getControl(); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(80); data.heightHint = convertHeightInCharsToPixels(nLines); control.setLayoutData(data); viewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { if (event.getDocumentEvent() != null) doSourceChanged(event.getDocumentEvent().getDocument()); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateSelectionDependentActions(); } }); viewer.prependVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent event) { handleVerifyKeyPressed(event); } }); return viewer; }
From source file:ts.eclipse.ide.jsdt.internal.ui.template.preferences.TypeScriptSourcePreviewerUpdater.java
License:Open Source License
/** * Creates a Java source preview updater for the given viewer, configuration and preference store. * * @param viewer the viewer/*from w w w . j a v a 2 s . c om*/ * @param configuration the configuration * @param preferenceStore the preference store */ TypeScriptSourcePreviewerUpdater(final SourceViewer viewer, final JavaScriptSourceViewerConfiguration 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) */ 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) */ 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) */ public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:ts.eclipse.ide.jsdt.internal.ui.template.preferences.TypeScriptTemplatePreferencePage.java
License:Open Source License
protected SourceViewer createViewer(Composite parent) { IDocument document = new Document(); JavaScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); IPreferenceStore store = JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration = new SimpleJavaSourceViewerConfiguration( tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration);/*from w w w.j a v a2s .c om*/ viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new TypeScriptSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
From source file:_org.eclipse.dltk.internal.ui.editor.ScriptSourceViewer.java
License:Open Source License
@Override public void configure(SourceViewerConfiguration configuration) { /*/* w w w. jav a 2 s. c o m*/ * Prevent access to colors disposed in unconfigure(), see: * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53641 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86177 */ StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { Color foregroundColor = textWidget.getForeground(); if (foregroundColor != null && foregroundColor.isDisposed()) textWidget.setForeground(null); Color backgroundColor = textWidget.getBackground(); if (backgroundColor != null && backgroundColor.isDisposed()) textWidget.setBackground(null); } super.configure(configuration); if (configuration instanceof ScriptSourceViewerConfiguration) { ScriptSourceViewerConfiguration dltkSVCconfiguration = (ScriptSourceViewerConfiguration) configuration; fOutlinePresenter = dltkSVCconfiguration.getOutlinePresenter(this, false); if (fOutlinePresenter != null) fOutlinePresenter.install(this); fStructurePresenter = dltkSVCconfiguration.getOutlinePresenter(this, true); if (fStructurePresenter != null) fStructurePresenter.install(this); // fHierarchyPresenter = dltkSVCconfiguration.getHierarchyPresenter( // this, true); dltkSVCconfiguration.getHierarchyPresenter(null, true); if (fHierarchyPresenter != null) fHierarchyPresenter.install(this); if (textWidget != null) { textWidget.setFont(JFaceResources.getFont(dltkSVCconfiguration.getFontPropertyPreferenceKey())); } } if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(this); initializeViewerColors(); } fIsConfigured = true; }
From source file:_org.eclipse.dltk.internal.ui.editor.ScriptTemplatesPage2.java
License:Open Source License
@Override protected SourceViewer createPatternViewer(Composite parent) { IDocument document = new Document(); ScriptTextTools tools = fScriptEditor.getTextTools(); tools.setupDocumentPartitioner(document); IPreferenceStore store = uiToolkit().getCombinedPreferenceStore(); ScriptSourceViewer viewer = new ScriptSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);//from w w w. java2 s . c o m ScriptSourceViewerConfiguration configuration = uiToolkit().createSourceViewerConfiguration(); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font = JFaceResources.getFont(fScriptEditor.getSymbolicFontName()); viewer.getTextWidget().setFont(font); new ScriptSourcePreviewerUpdater(viewer, configuration, store); Control control = viewer.getControl(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); viewer.setEditable(false); return viewer; }