List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.eclipse.oomph.setup.ui.wizards.ProgressPage.java
License:Open Source License
@Override protected Control createUI(final Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(UIUtil.createGridLayout(1)); SashForm sashForm = new SashForm(mainComposite, SWT.SMOOTH | SWT.VERTICAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); AccessUtil.setKey(sashForm, "sash"); treeViewer = new TreeViewer(sashForm, SWT.BORDER); Tree tree = treeViewer.getTree();/*w w w. j a v a 2s. c om*/ addHelpCallout(tree, 1); ILabelProvider labelProvider = createLabelProvider(); treeViewer.setLabelProvider(labelProvider); final AdapterFactoryContentProvider contentProvider = new OomphAdapterFactoryContentProvider( getAdapterFactory()); treeViewer.setContentProvider(contentProvider); treeViewer.addSelectionChangedListener(treeViewerSelectionChangedListener); new ColumnViewerInformationControlToolTipSupport(treeViewer, new LocationListener() { public void changing(LocationEvent event) { } public void changed(LocationEvent event) { } }); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); tree.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); TextViewer logTextViewer = new TextViewer(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); logTextViewer.setDocument(logDocument); logText = logTextViewer.getTextWidget(); logText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); logText.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); logText.setEditable(false); logText.setLayoutData(new GridData(GridData.FILL_BOTH)); logText.getVerticalBar().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (event.detail == SWT.DRAG && !scrollLock) { scrollLockButton.setSelection(true); scrollLock = true; } } }); addHelpCallout(logText, 2); AccessUtil.setKey(logText, "log"); return mainComposite; }
From source file:org.eclipse.pde.ds.ui.internal.editor.SourcePage.java
License:Open Source License
public void createContents(Composite parent) { int VERTICAL_RULER_WIDTH = 12; GridLayout gl = new GridLayout(getNumColumns(), true); gl.verticalSpacing = 0;/*w w w . j ava2 s . co m*/ parent.setLayout(gl); ISharedTextColors sharedColors = EditorsPlugin.getDefault().getSharedTextColors(); IOverviewRuler overviewRuler = new OverviewRuler(null, VERTICAL_RULER_WIDTH, sharedColors); String contentTypeID = "org.eclipse.pde.ds.content-type"; //$NON-NLS-1$ _sourceStructuredTextViewer = new StructuredTextViewer(parent, new VerticalRuler(VERTICAL_RULER_WIDTH), null, false, SWT.V_SCROLL | SWT.WRAP); ((StructuredTextViewer) _sourceStructuredTextViewer).getTextWidget() .setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager() .createUnManagedStructuredModelFor(contentTypeID); IDocument document = scratchModel.getStructuredDocument(); SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfigurationXML() { @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { return super.getContentAssistant(sourceViewer); } }; _sourceStructuredTextViewer.configure(sourceViewerConfiguration); _sourceStructuredTextViewer.setDocument(document); //_sourceStructuredTextViewer.setEditable(false); _sourceStructuredTextViewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { // FIXME this is ***VERY*** hackish reloadEObjectFromString(_sourceStructuredTextViewer.getDocument().get()); } }); GridDataFactory.fillDefaults().grab(true, true).applyTo(_sourceStructuredTextViewer.getControl()); }
From source file:org.eclipse.pde.emfforms.internal.editor.XmlSourcePage.java
License:Open Source License
@Override public SourceViewer createSourceViewer(Composite parent) { StructuredTextViewer sourceViewer = new org.eclipse.wst.sse.ui.internal.StructuredTextViewer(parent, new VerticalRuler(VERTICAL_RULER_WIDTH), null, false, SWT.V_SCROLL | SWT.WRAP); sourceViewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredDocument document = StructuredModelManager.getModelManager() .createStructuredDocumentFor("org.eclipse.core.runtime.xml"); //$NON-NLS-1$ SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfigurationXML() { @Override//from w w w .ja va2 s . co m public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { return super.getContentAssistant(sourceViewer); } }; // sourceViewerConfiguration.getContentFormatter(_sourceStructuredTextViewer).format(document, new Region(0, document.getLength())); sourceViewer.configure(sourceViewerConfiguration); sourceViewer.setDocument(document); sourceViewer.setEditable(false); return sourceViewer; }
From source file:org.eclipse.pde.internal.ui.compare.PluginContentMergeViewer.java
License:Open Source License
protected void configureTextViewer(final TextViewer textViewer) { if (textViewer instanceof SourceViewer) { if (fColorManager == null) fColorManager = ColorManager.getDefault(); final XMLConfiguration configuration = new XMLConfiguration(fColorManager); textViewer.getControl().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { configuration.dispose(); }/*from w ww. j a va 2 s.c om*/ }); IPropertyChangeListener propertyChangedListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { // the configuration will test if the properties affect the presentation also, // but checking it here allows us to prevent the viewer from being invalidated // and saves some unnecessary work if (configuration.affectsColorPresentation(event) || configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); textViewer.invalidateTextPresentation(); } } }; PDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangedListener); if (fPropertyChangedListeners == null) fPropertyChangedListeners = new ArrayList<IPropertyChangeListener>(3); fPropertyChangedListeners.add(propertyChangedListener); ((SourceViewer) textViewer).configure(configuration); Font font = JFaceResources.getFont(PluginContentMergeViewer.class.getName()); if (font != null) ((SourceViewer) textViewer).getTextWidget().setFont(font); } }
From source file:org.eclipse.pde.internal.ui.preferences.SyntaxColorTab.java
License:Open Source License
private void createPreviewer(Composite parent) { Composite previewComp = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = layout.marginWidth = 0; previewComp.setLayout(layout);// w ww. j a va 2s . c o m previewComp.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(previewComp, SWT.NONE); label.setText(PDEUIMessages.SyntaxColorTab_preview); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fPreviewViewer = new SourceViewer(previewComp, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); fSourceViewerConfiguration = getSourceViewerConfiguration(); if (fSourceViewerConfiguration != null) fPreviewViewer.configure(fSourceViewerConfiguration); fPreviewViewer.setEditable(false); fPreviewViewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); fPreviewViewer.setDocument(getDocument()); Control control = fPreviewViewer.getControl(); control.setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.php.internal.ui.compare.TextMergeViewer.java
License:Open Source License
private void updateFont() { Font f = JFaceResources.getFont(JFaceResources.TEXT_FONT); if (f != null) { if (fAncestor != null) fAncestor.setFont(f);/*w ww .j a v a2 s .c o m*/ if (fLeft != null) fLeft.setFont(f); if (fRight != null) fRight.setFont(f); } }
From source file:org.eclipse.php.internal.ui.compare.TextMergeViewer.java
License:Open Source License
private MergeSourceViewer createPart(Composite parent) { final MergeSourceViewer part = new MergeSourceViewer(parent, getDirection(), getResourceBundle(), getCompareConfiguration().getContainer()); final StyledText te = part.getTextWidget(); if (!fConfirmSave) part.hideSaveAction();/* www .j av a 2 s. co m*/ te.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { paint(e, part); } }); te.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleSelectionChanged(part); } }); te.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { // syncViewport(part); handleSelectionChanged(part); } }); te.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent fe) { fFocusPart = part; connectGlobalActions(fFocusPart); } public void focusLost(FocusEvent fe) { connectGlobalActions(null); } }); part.addViewportListener(new IViewportListener() { public void viewportChanged(int verticalPosition) { syncViewport(part); } }); Font font = JFaceResources.getFont(fSymbolicFontName); if (font != null) te.setFont(font); if (fBackground != null) // not default te.setBackground(getColor(parent.getDisplay(), fBackground)); // Add the find action to the popup menu of the viewer contributeFindAction(part); configureTextViewer(part); return part; }
From source file:org.eclipse.php.internal.ui.preferences.PHPCodeTemplateBlock.java
License:Open Source License
private SourceViewer createViewer(Composite parent, int nColumns) { Label label = new Label(parent, SWT.NONE); label.setText(PreferencesMessages.CodeTemplateBlock_preview); GridData data = new GridData(); data.horizontalSpan = nColumns;//w w w . ja v a 2 s. c o m label.setLayoutData(data); // // JobSafeStructuredDocument document= new JobSafeStructuredDocument(); // IDocumentPartitioner partitioner= new PHPStructuredTextPartitioner(); // // //document.setDocumentPartitioner("org.eclipse.wst.sse.core.default_structured_text_partitioning", // partitioner); // document.setDocumentPartitioner( partitioner); // // IPreferenceStore store= // PHPUiPlugin.getDefault().getPreferenceStore(); // PHPStructuredTextViewer viewer= new PHPStructuredTextViewer(parent, // null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); // //PHPStructuredTextViewerConfiguration configuration= new // PHPStructuredTextViewerConfiguration(PHPUiPlugin.getDefault().getColorManager(), // store, null, fTemplateProcessor); // //ScriptSourceViewerConfiguration configuration = new // PHPStructuredEditor().getSourceViwerConfiguration(); // // PHPStructuredTextViewerConfiguration configuration = new // PHPStructuredTextViewerConfiguration(); // viewer.configure(configuration); // viewer.setEditable(false); // viewer.setDocument(document); // // Font font= JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"); // viewer.getTextWidget().setFont(font); // new PHPSourcePreviewerUpdater(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); StructuredTextViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); IStructuredDocument document = StructuredModelManager.getModelManager() .createStructuredDocumentFor(ContentTypeIdForPHP.ContentTypeID_PHP); StyledText text = viewer.getTextWidget(); text.setLayoutData(data); text.setEditable(false); text.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ // PHPStructuredTextViewerConfiguration configuration = new // PHPStructuredTextViewerConfiguration(); SourceViewerConfiguration configuration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new PHPStructuredTextViewerConfiguration(); @Override public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return baseConfiguration.getConfiguredContentTypes(sourceViewer); } @Override public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); } }; viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); 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:org.eclipse.php.internal.ui.preferences.PHPSourcePreviewerUpdater.java
License:Open Source License
/** * Creates a Java source preview updater for the given viewer, configuration * and preference store.//w ww. j a va 2 s . co m * * @param viewer * the viewer * @param configuration * the configuration * @param preferenceStore * the preference store */ public PHPSourcePreviewerUpdater(final SourceViewer viewer, final SourceViewerConfiguration 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("org.eclipse.wst.sse.ui.textfont")) { //$NON-NLS-1$ Font font = JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"); //$NON-NLS-1$ 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:org.eclipse.php.internal.ui.preferences.PHPSyntaxColoringPage.java
License:Open Source License
@Override protected Control createContents(final Composite parent) { initializeDialogUnits(parent);//from ww w . j a va 2 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(getControl(), IPHPHelpContextIds.SYNTAX_COLORING_PREFERENCES); Link link = new Link(pageComponent, SWT.WRAP); link.setText(SSEUIMessages.SyntaxColoring_Link); link.addSelectionListener(new SelectionAdapter() { @Override 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, XMLUIMessages.SyntaxColoringPage_0); fStylesViewer = createStylesViewer(styleEditor); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.horizontalIndent = 0; Iterator<String> 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$ fEnabler = createCheckbox(editingComposite, XMLUIMessages.SyntaxColoringPage_2); fEnabler.setEnabled(false); 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); 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); fBold = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_3); fBold.setEnabled(false); ((GridData) fBold.getLayoutData()).horizontalSpan = 2; fItalic = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_4); fItalic.setEnabled(false); ((GridData) fItalic.getLayoutData()).horizontalSpan = 2; fStrike = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_5); fStrike.setEnabled(false); ((GridData) fStrike.getLayoutData()).horizontalSpan = 2; fUnderline = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_6); fUnderline.setEnabled(false); ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2; fClearStyle = new Button(editingComposite, SWT.PUSH); fClearStyle.setText(SSEUIMessages.Restore_Default_UI_); // = // "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_); // = // "&Sample text:" SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); fText = viewer.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()); final IPreferenceStore editorStore = EditorsPlugin.getDefault().getPreferenceStore(); fText.setBackground(editorStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null : new Color(fText.getDisplay(), PreferenceConverter.getColor(editorStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND))); setAccessible(fText, SSEUIMessages.Sample_text__UI_); fDocument = StructuredModelManager.getModelManager() .createStructuredDocumentFor(ContentTypeIdForPHP.ContentTypeID_PHP); fDocument.set(getExampleText()); viewer.setDocument(fDocument); top.setWeights(new int[] { 2, 1 }); editor.setWeights(new int[] { 1, 1 }); PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IPHPHelpContextIds.SYNTAX_COLORING_PREFERENCES); fStylesViewer.setInput(getStylePreferenceKeys()); fOverlayStore.addPropertyChangeListener(fHighlightingChangeListener); initHighlightingPositions(); initHighlightingStyles(); 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(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings() .containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager .getInstance().getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore().getString(semanticHighlighting.getColorPreferenceKey()); String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlighting.getColorPreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings() .containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager .getInstance().getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore() .getString(semanticHighlighting.getBackgroundColorPreferenceKey()); String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlighting.getBackgroundColorPreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings().containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager.getInstance() .getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore().getString(semanticHighlighting.getBoldPreferenceKey()); String newValue = String.valueOf(fBold.getSelection()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlighting.getBoldPreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings().containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlightingType = SemanticHighlightingManager .getInstance().getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore() .getString(semanticHighlightingType.getItalicPreferenceKey()); String newValue = String.valueOf(fItalic.getSelection()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlightingType.getItalicPreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings().containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager.getInstance() .getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore() .getString(semanticHighlighting.getStrikethroughPreferenceKey()); String newValue = String.valueOf(fStrike.getSelection()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlighting.getStrikethroughPreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings().containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager.getInstance() .getSemanticHighlightings().get(namedStyle); String oldValue = getOverlayStore().getString(semanticHighlighting.getUnderlinePreferenceKey()); String newValue = String.valueOf(fUnderline.getSelection()); if (!newValue.equals(oldValue)) { getOverlayStore().setValue(semanticHighlighting.getUnderlinePreferenceKey(), newValue); applyStyles(); fText.redraw(); } return; } 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() { @Override public void widgetSelected(SelectionEvent e) { if (fStylesViewer.getSelection().isEmpty()) return; String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement() .toString(); if (SemanticHighlightingManager.getInstance().getSemanticHighlightings().containsKey(namedStyle)) { AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager.getInstance() .getSemanticHighlightings().get(namedStyle); getOverlayStore().setToDefault(semanticHighlighting.getBoldPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getColorPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getBackgroundColorPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getEnabledPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getItalicPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getStrikethroughPreferenceKey()); getOverlayStore().setToDefault(semanticHighlighting.getUnderlinePreferenceKey()); boolean enablement = getOverlayStore() .getDefaultBoolean(semanticHighlighting.getEnabledPreferenceKey()); switchEnablement(enablement); } else { getOverlayStore().setToDefault(namedStyle); } applyStyles(); fText.redraw(); activate(namedStyle); } }); fEnabler.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // get current (newly old) style Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); String namedStyle = o.toString(); Map<String, AbstractSemanticHighlighting> highlightingMap = SemanticHighlightingManager .getInstance().getSemanticHighlightings(); if (highlightingMap.containsKey(namedStyle)) { AbstractSemanticHighlighting semantic = highlightingMap.get(namedStyle); boolean enablement = fEnabler.getSelection(); semantic.getStyle().setEnabledByDefault(enablement); switchEnablement(enablement); getOverlayStore().setValue(semantic.getEnabledPreferenceKey(), enablement); applyStyles(); fText.redraw(); } else if (getStylePreferenceKeys().contains(namedStyle)) { boolean enablement = fEnabler.getSelection(); switchEnablement(enablement); getOverlayStore().setValue(PreferenceConstants.getEnabledPreferenceKey(namedStyle), enablement); applyStyles(); fText.redraw(); } } }); switchEnablement(false); return pageComponent; }