Java Code Examples for org.eclipse.jface.preference.JFacePreferences

The following examples show how to use org.eclipse.jface.preference.JFacePreferences. These examples are extracted from open source projects. 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
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 2
Source Project: Pydev   Source File: HierarchyLabelProvider.java    License: 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 3
Source Project: xtext-eclipse   Source File: XtextLabelProvider.java    License: 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 4
Source Project: xds-ide   Source File: ModulaEditorTextHover.java    License: 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 5
Source Project: xds-ide   Source File: ModulaSearchLabelProvider.java    License: 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 6
Source Project: xds-ide   Source File: ModulaSearchLabelProvider.java    License: 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 7
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 8
@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 9
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 10
@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 11
@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 12
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 13
public TextStyle counterStyle() {
	TextStyle textStyle = new TextStyle();
	RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.COUNTER_COLOR);
	textStyle.setColor(color);
	return textStyle;
}
 
Example 14
public TextStyle decorationsStyle() {
	TextStyle textStyle = new TextStyle();
	RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.DECORATIONS_COLOR);
	textStyle.setColor(color);
	return textStyle;
}
 
Example 15
@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 Project: sarl   Source File: SARLUIStrings.java    License: 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 17
@Override
protected Color getForeground() {
    return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
}
 
Example 18
@Override
protected Color getBackground() {
    return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
}