List of usage examples for org.eclipse.jface.preference JFacePreferences HYPERLINK_COLOR
String HYPERLINK_COLOR
To view the source code for org.eclipse.jface.preference JFacePreferences HYPERLINK_COLOR.
Click Source Link
From source file:com.aptana.theme.internal.InvasiveThemeHijacker.java
License:Open Source License
protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults) { if (prefs == null || theme == null) { return;// www . ja va 2 s. c o m } if (revertToDefaults) { // Console preferences prefs.remove(JFacePreferences.HYPERLINK_COLOR); prefs.remove(JFacePreferences.ACTIVE_HYPERLINK_COLOR); // Editor preferences prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT); prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR); } else { TextAttribute editorHyperlink = theme.getTextAttribute("hyperlink"); //$NON-NLS-1$ prefs.put(JFacePreferences.HYPERLINK_COLOR, StringConverter.asString(editorHyperlink.getForeground().getRGB())); JFaceResources.getColorRegistry().put(JFacePreferences.HYPERLINK_COLOR, editorHyperlink.getForeground().getRGB()); prefs.put(JFacePreferences.ACTIVE_HYPERLINK_COLOR, StringConverter.asString(editorHyperlink.getForeground().getRGB())); JFaceResources.getColorRegistry().put(JFacePreferences.ACTIVE_HYPERLINK_COLOR, editorHyperlink.getForeground().getRGB()); prefs.putBoolean(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT, false); prefs.put(DefaultHyperlinkPresenter.HYPERLINK_COLOR, StringConverter.asString(editorHyperlink.getForeground().getRGB())); } }
From source file:de.walware.statet.r.internal.ui.rhelp.RHelpUIServlet.java
License:Open Source License
private static void appendELinkColors(final StringBuilder sb, final RGB foregroundColor) { final RGB hyperlinkColor = JFaceResources.getColorRegistry().getRGB(JFacePreferences.HYPERLINK_COLOR); sb.append("a { color: "); //$NON-NLS-1$ appendCssColor(sb, hyperlinkColor);/*from w w w. java2 s.c o m*/ sb.append("; }\n");//$NON-NLS-1$ sb.append("a:hover, a:active, a:focus { color: "); //$NON-NLS-1$ appendCssColor(sb, JFaceResources.getColorRegistry().getRGB(JFacePreferences.ACTIVE_HYPERLINK_COLOR)); sb.append("; }\n"); //$NON-NLS-1$ sb.append("a:visited { color: "); //$NON-NLS-1$ appendCssColor(sb, new RGB((hyperlinkColor.red + ((hyperlinkColor.red <= 127) ? +64 : -64)), (hyperlinkColor.green + foregroundColor.green) / 2, (hyperlinkColor.blue + ((hyperlinkColor.blue > 32) ? -32 : +32) + foregroundColor.blue) / 2)); sb.append("; }\n"); //$NON-NLS-1$ }
From source file:de.walware.statet.r.internal.ui.rhelp.RHelpUIServlet.java
License:Open Source License
@Override public void propertyChange(final PropertyChangeEvent event) { if (event.getProperty().equals("de.walware.workbench.themes.DocViewFont") //$NON-NLS-1$ || event.getProperty().equals("de.walware.workbench.themes.DocViewBackgroundColor") //$NON-NLS-1$ || event.getProperty().equals("de.walware.workbench.themes.DocViewColor") //$NON-NLS-1$ || event.getProperty().equals(JFaceResources.DIALOG_FONT) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals("searchResultIndicationColor")) { //$NON-NLS-1$ updateStyles();//from w w w.j av a2 s . c o m } }
From source file:mesfavoris.internal.views.comment.SpellcheckableMessageArea.java
License:Open Source License
/** * @param parent/*from ww w. java 2 s. c o m*/ * @param initialText * @param readOnly * @param styles */ public SpellcheckableMessageArea(Composite parent, String initialText, boolean readOnly, int styles) { super(parent, styles); setLayout(new FillLayout()); AnnotationModel annotationModel = new AnnotationModel(); sourceViewer = new HyperlinkSourceViewer(this, null, null, true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); getTextWidget().setAlwaysShowScrollBars(false); // getTextWidget().setFont(UIUtils // .getFont(UIPreferences.THEME_CommitMessageEditorFont)); int endSpacing = 2; int textWidth = getCharWidth() * MAX_LINE_WIDTH + endSpacing; int textHeight = getLineHeight() * 7; Point size = getTextWidget().computeSize(textWidth, textHeight); getTextWidget().setSize(size); computeBrokenBidiPlatformTextWidth(size.x); getTextWidget().setEditable(!readOnly); createMarginPainter(); final IPropertyChangeListener syntaxColoringChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (JFacePreferences.HYPERLINK_COLOR.equals(event.getProperty())) { getDisplay().asyncExec(new Runnable() { @Override public void run() { if (!isDisposed()) { sourceViewer.refresh(); } } }); } } }; JFacePreferences.getPreferenceStore().addPropertyChangeListener(syntaxColoringChangeListener); final SourceViewerDecorationSupport support = configureAnnotationPreferences(); if (isEditable(sourceViewer)) { quickFixActionHandler = createQuickFixActionHandler(sourceViewer); } Document document = new Document(initialText); configuration = new HyperlinkSourceViewer.Configuration(EditorsUI.getPreferenceStore()) { @Override public int getHyperlinkStateMask(ISourceViewer targetViewer) { if (!targetViewer.isEditable()) { return SWT.NONE; } return super.getHyperlinkStateMask(targetViewer); } @Override protected Map getHyperlinkDetectorTargets(ISourceViewer targetViewer) { return getHyperlinkTargets(); } @Override public IReconciler getReconciler(ISourceViewer viewer) { if (!isEditable(viewer)) return null; return super.getReconciler(sourceViewer); } @Override public IContentAssistant getContentAssistant(ISourceViewer viewer) { if (!viewer.isEditable()) return null; IContentAssistant assistant = createContentAssistant(viewer); // Add content assist proposal handler if assistant exists if (assistant != null) contentAssistActionHandler = createContentAssistActionHandler(sourceViewer); return assistant; } @Override public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) { PresentationReconciler reconciler = new PresentationReconciler(); reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(viewer)); DefaultDamagerRepairer hyperlinkDamagerRepairer = new DefaultDamagerRepairer( new HyperlinkTokenScanner(this, viewer)); reconciler.setDamager(hyperlinkDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(hyperlinkDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE); return reconciler; } }; sourceViewer.configure(configuration); sourceViewer.setDocument(document, annotationModel); configureContextMenu(); getTextWidget().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent disposeEvent) { support.uninstall(); JFacePreferences.getPreferenceStore().removePropertyChangeListener(syntaxColoringChangeListener); } }); }
From source file:net.bpelunit.toolsupport.editors.formwidgets.HyperlinkField.java
License:Open Source License
private static Color getHyperlinkText(Display display) { return JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); }
From source file:net.sf.eclipsensis.console.NSISConsoleViewer.java
License:Open Source License
@Override public void lineGetStyle(LineStyleEvent event) { IDocument document = getDocument();//from w w w . ja v a 2 s. c o m if (document != null && document.getLength() > 0) { List<StyleRange> ranges = new ArrayList<StyleRange>(); int offset = event.lineOffset; int length = event.lineText.length(); StyleRange[] partitionerStyles = ((IConsoleDocumentPartitioner) document.getDocumentPartitioner()) .getStyleRanges(event.lineOffset, event.lineText.length()); if (partitionerStyles != null) { for (int i = 0; i < partitionerStyles.length; i++) { ranges.add(partitionerStyles[i]); } } try { Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); Position[] overlap = findPosition(offset, length, positions); if (overlap != null) { Color color = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); for (int i = 0; i < overlap.length; i++) { Position position = overlap[i]; StyleRange linkRange = new StyleRange(position.offset, position.length, color, null); linkRange.underline = true; override(ranges, linkRange); } } } catch (BadPositionCategoryException e) { } if (ranges.size() > 0) { event.styles = ranges.toArray(new StyleRange[ranges.size()]); } } }
From source file:org.eclipse.epp.internal.logging.aeri.ui.notifications.NotificationPopup.java
License:Open Source License
@Override protected void createContentArea(Composite parent) { Composite contentComposite = new Composite(parent, SWT.NO_FOCUS); GridLayout gridLayout = new GridLayout(2, false); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(contentComposite); contentComposite.setLayout(gridLayout); // icon label: new Label(contentComposite, SWT.NO_FOCUS); final Label labelText = new Label(contentComposite, SWT.WRAP | SWT.NO_FOCUS); labelText.setForeground(CommonColors.TEXT_QUOTED); labelText.setText(abbreviate(notification.getLabel(), MAX_LABEL_CHAR_LENGTH)); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(labelText); String description = notification.getDescription(); if (isNotBlank(description)) { Label descriptionText = new Label(contentComposite, SWT.WRAP); descriptionText.setText(abbreviate(description, MAX_DESCRIPTION_CHAR_LENGTH)); GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).grab(true, false).align(SWT.FILL, SWT.TOP) .applyTo(descriptionText); }//from w w w .j a va 2 s .co m if (notification instanceof Notification) { Notification executableNotification = notification; Composite linksComposite = new Composite(contentComposite, SWT.NO_FOCUS | SWT.RIGHT); GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).grab(true, false).align(SWT.END, SWT.TOP) .applyTo(linksComposite); GridLayoutFactory.fillDefaults().numColumns(executableNotification.getActions().size()) .applyTo(linksComposite); for (final NotificationAction action : executableNotification.getActions()) { final ScalingHyperlink actionLink = new ScalingHyperlink(linksComposite, SWT.RIGHT | SWT.NO_FOCUS); GridDataFactory.fillDefaults().grab(true, false).applyTo(actionLink); Color linkColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); actionLink.setForeground(linkColor); actionLink.registerMouseTrackListener(); actionLink.setText(action.getName()); actionLink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { Shell windowShell = window.getShell(); if (windowShell != null) { if (windowShell.getMinimized()) { windowShell.setMinimized(false); } windowShell.open(); windowShell.forceActive(); } } action.execute(); } }); links.add(actionLink); } } }
From source file:org.eclipse.mat.ui.internal.views.NotesView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); // No need for a dispose listener - the SaveablePart will save it textViewer = new TextViewer(parent, SWT.MULTI | SWT.V_SCROLL | SWT.LEFT | SWT.H_SCROLL); textViewer.setDocument(new Document()); textViewer.getControl().setEnabled(false); textViewer.getTextWidget().setWordWrap(false); font = JFaceResources.getFont("org.eclipse.mat.ui.notesfont"); //$NON-NLS-1$ textViewer.getControl().setFont(font); hyperlinkColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); getSite().getPage().addPartListener(this); undoManager = new TextViewerUndoManager(UNDO_LEVEL); undoManager.connect(textViewer);/*from w w w .j av a 2 s . c o m*/ textViewer.setUndoManager(undoManager); textViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateActions(); } }); textViewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { modified = true; searchForHyperlinks(textViewer.getDocument().get(), 0); firePropertyChange(PROP_DIRTY); } }); textViewer.setHyperlinkPresenter(new DefaultHyperlinkPresenter(hyperlinkColor)); textViewer.setHyperlinkDetectors(new IHyperlinkDetector[] { new ObjectAddressHyperlinkDetector() }, SWT.MOD1); makeActions(); hookContextMenu(); showBootstrapPart(); updateActions(); }
From source file:org.eclipse.ui.internal.ide.dialogs.WelcomeEditor.java
License:Open Source License
/** * Creates the SWT controls for this workbench part. * <p>//from w w w. jav a2 s . c om * Clients should not call this method (the workbench calls this method at * appropriate times). * </p> * <p> * For implementors this is a multi-step process: * <ol> * <li>Create one or more controls within the parent.</li> * <li>Set the parent layout as needed.</li> * <li>Register any global actions with the <code>IActionService</code>.</li> * <li>Register any popup menus with the <code>IActionService</code>.</li> * <li>Register a selection provider with the <code>ISelectionService</code> * (optional). </li> * </ol> * </p> * * @param parent the parent control */ public void createPartControl(Composite parent) { // read our contents readFile(); if (parser == null) { return; } handCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); busyCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT); editorComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; editorComposite.setLayout(layout); createTitleArea(editorComposite); Label titleBarSeparator = new Label(editorComposite, SWT.HORIZONTAL | SWT.SEPARATOR); GridData gd = new GridData(GridData.FILL_HORIZONTAL); titleBarSeparator.setLayoutData(gd); createInfoArea(editorComposite); getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(editorComposite, IIDEHelpContextIds.WELCOME_EDITOR); this.colorListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR)) { Color fg = JFaceColors.getHyperlinkText(editorComposite.getDisplay()); Iterator links = hyperlinkRanges.iterator(); while (links.hasNext()) { StyleRange range = (StyleRange) links.next(); range.foreground = fg; } } } }; JFacePreferences.getPreferenceStore().addPropertyChangeListener(this.colorListener); }