org.eclipse.jface.preference.JFacePreferences Java Examples

The following examples show how to use org.eclipse.jface.preference.JFacePreferences. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HierarchyLabelProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes")
        DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        Object data = treeNode.data;
        if (data instanceof HierarchyNodeModel) {
            HierarchyNodeModel model = (HierarchyNodeModel) data;
            String spaces = "     ";
            StyledString styledString = new StyledString(model.name + spaces);
            if (model.moduleName != null && model.moduleName.trim().length() > 0) {
                Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, null);
                styledString.append("(" + model.moduleName + ")", styler);
            }
            return styledString;
        }
        return new StyledString(data.toString());
    }
    return new StyledString(element == null ? "" : element.toString());
}
 
Example #2
Source File: ColoredViewersManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	String property= event.getProperty();
	if (property.equals(JFacePreferences.QUALIFIER_COLOR)
			|| property.equals(JFacePreferences.COUNTER_COLOR)
			|| property.equals(JFacePreferences.DECORATIONS_COLOR)
			|| property.equals(HIGHLIGHT_BG_COLOR_NAME)
			|| property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)
			|| property.equals(INHERITED_COLOR_NAME)
			|| property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)
	) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				updateAllViewers();
			}
		});
	}
}
 
Example #3
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	if (prefs == null || theme == null)
	{
		return;
	}
	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()));

	}

}
 
Example #4
Source File: DataStyledTreeLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void initStyle() {
	imageProvider = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)) ;
	italicGrey = new StyledString.Styler() {
		@Override
		public void applyStyles(TextStyle textStyle) {
			textStyle.font = BonitaStudioFontRegistry.getTransientDataFont();
			textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
		}
	};
}
 
Example #5
Source File: DecoratingFileSearchLabelProvider.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                refresh();
            }
        });
    }
}
 
Example #6
Source File: HierarchyLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Color getForeground(Object element) {
	if (element instanceof IMethod) {
		if (fSpecialColor == null) {
			fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
		}
		return fSpecialColor;
	} else if (element instanceof IType && isInDifferentHierarchyScope((IType) element)) {
		return JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
	}
	return null;
}
 
Example #7
Source File: PreviewLabelProvider.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Color getForeground( Object element ) {
  IProject project = ( IProject )element;
  Color result = null;
  if( !projectPatternMatcher.matches( project ) ) {
    result = JFaceResources.getColorRegistry().get( JFacePreferences.QUALIFIER_COLOR );
  }
  return result;
}
 
Example #8
Source File: DecoratingTypeScriptSearchLabelProvider.java    From typescript.java with MIT License 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	String property= event.getProperty();
	if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
			|| property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				refresh();
			}
		});
	}
}
 
Example #9
Source File: ModulaSearchLabelProvider.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public M2LabelProvider(ModulaSearchResultPage resultPage, ResourceRegistry resourceRegistry) {
    this.resultPage = resultPage;
    this.resourceRegistry = resourceRegistry;
    this.dlgFont = resultPage.getControl().getFont();
    fLabelProvider= new WorkbenchLabelProvider();
    positionStyler = new Styler() {
        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
            textStyle.font= getItalicFont(dlgFont);
        }
    };
}
 
Example #10
Source File: ModulaSearchLabelProvider.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
    String property= event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS) || property.equals(M2LabelProvider.EDITOR_SEARCH_RESULT_INDICATION_COLOR)) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                refresh();
            }
        });
    }
}
 
Example #11
Source File: ModulaEditorTextHover.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public ModulaEditorTextHover(ITextEditor editor, ITextHover defaultHover, ResourceRegistry resourceRegistry) {
      this.editor = editor;
      if (editor != null) {
      	this.project = CoreEditorUtils.getIProjectFrom(editor.getEditorInput());
      }
      else{
      	this.project = null;
      }
      this.defaultHover = defaultHover;
      this.fDecorationColor = JFaceResources.getColorRegistry().get(JFacePreferences.DECORATIONS_COLOR);
      this.resourceRegistry = resourceRegistry;
      
ModulaEditorHoverRegistry.get().contributions().stream()
		.forEach(ModulaEditorTextHover::addContributer);
  }
 
Example #12
Source File: XtextLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
StyledString text(EnumLiteralDeclaration object) {
	String literalName = getLiteralName(object);
	Keyword kw = object.getLiteral();
	String kwValue = kw == null ? "" : " = '" + kw.getValue() + "'";
	return new StyledString(literalName + kwValue, UNKNOWN.equalsIgnoreCase(literalName) ? stylerFactory.createStyler(
			JFacePreferences.ERROR_COLOR, null) : null);
}
 
Example #13
Source File: TemplatesHighlightingConfiguration.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public TextStyle counterStyle() {
	TextStyle textStyle = new TextStyle();
	RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.COUNTER_COLOR);
	textStyle.setColor(color);
	return textStyle;
}
 
Example #14
Source File: SARLUIStrings.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle) {
	textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
}
 
Example #15
Source File: ParameterContextInformation.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean updatePresentation(ITextViewer viewer, int position, TextPresentation presentation) {
	int currentParameter= -1;

	try {
		currentParameter= getCharCount(viewer.getDocument(), this.parameterListOffset, position, ",", "", true);  //$NON-NLS-1$//$NON-NLS-2$
	} catch (BadLocationException x) {
		return false;
	}

	if (currentParameter != -1) {
		if (currentParameter == this.currentParameter)
			return false;
	}

	presentation.clear();
	this.currentParameter= currentParameter;

	List<String> rawStrings = internalGetInformationDisplayString();
	List<int[]> commaArrays = Lists.newArrayList();
	for(String s: rawStrings) {
		commaArrays.add(computeCommaPositions(s));
	}

	int offset = 0;
	for(int i = 0; i < rawStrings.size(); i++) {
		String raw = rawStrings.get(i);
		int[] commas = commaArrays.get(i);
		if (commas.length - 2 < this.currentParameter && !data.isVarArgs(i)) {
			presentation.addStyleRange(new StyleRange(offset, raw.length(), JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR), null, SWT.NORMAL));
		} else {
			int actualParameter = this.currentParameter;
			if (actualParameter + 1 >= commas.length)
				actualParameter = commas.length - 2;
			int start= commas[actualParameter] + 1;
			int end= commas[actualParameter + 1];
			if (start > 0)
				presentation.addStyleRange(new StyleRange(offset, start, null, null, SWT.NORMAL));
			
			if (end > start)
				presentation.addStyleRange(new StyleRange(offset + start, end - start, null, null, SWT.BOLD));
			
			if (end < raw.length())
				presentation.addStyleRange(new StyleRange(offset + end, raw.length() - end, null, null, SWT.NORMAL));
		}
		offset += raw.length() + 1;
	}

	return true;
}
 
Example #16
Source File: BonitaContentProposalAdapter.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Color getForeground() {
    return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
}
 
Example #17
Source File: BonitaContentProposalAdapter.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Color getBackground() {
    return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
}
 
Example #18
Source File: TemplatesHighlightingConfiguration.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public TextStyle decorationsStyle() {
	TextStyle textStyle = new TextStyle();
	RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.DECORATIONS_COLOR);
	textStyle.setColor(color);
	return textStyle;
}