List of usage examples for org.eclipse.jface.viewers StyledString createColorRegistryStyler
public static Styler createColorRegistryStyler(String foregroundColorName, String backgroundColorName)
From source file:com.boothen.jsonedit.outline.node.JsonTreeNode.java
License:Open Source License
public StyledString getStyledString() { StyledString styledString = new StyledString(); if (jsonNode.getKey() != null) { StyledString.Styler style1 = StyledString.createColorRegistryStyler("BLACK", "WHITE"); styledString.append(jsonNode.getKey(), style1); StyledString.Styler style2 = StyledString.createColorRegistryStyler("BLACK", "WHITE"); styledString.append(" : ", style2); }//from w w w . j a v a 2 s . c om if (jsonNode.getValue() != null && (!jsonNode.getJsonType().equals(JsonDocumentType.JSON_ARRAY_OPEN) && !jsonNode.getJsonType().equals(JsonDocumentType.JSON_OBJECT_OPEN))) { StyledString.Styler style3 = styleMap.get(jsonNode.getJsonType()); styledString.append(jsonNode.getValue(), style3); } return styledString; }
From source file:com.netxforge.netxstudio.screens.f3.support.NetworkTreeLabelProvider.java
License:Open Source License
private void updateColumn0(ViewerCell cell, Object element) { if (element instanceof Operator) { Operator operator = (Operator) element; StyledString styledString = new StyledString(operator.getName() != null ? operator.getName() : "?", null);/* www . j av a 2 s .co m*/ cell.setText(styledString.getString()); Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/Company_H.png"); cell.setImage(img); cell.setStyleRanges(styledString.getStyleRanges()); } if (element instanceof Network) { Network network = (Network) element; StyledString styledString = new StyledString(network.getName() != null ? network.getName() : "?", null); // String decoration = " (" + network.getFunctions().size() + // " Functions)" // + " (" + network.getFunctions().size() + " Equipments)"; // styledString.append(decoration, StyledString.COUNTER_STYLER); cell.setText(styledString.getString()); Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/Network_H.png"); cell.setImage(img); cell.setStyleRanges(styledString.getStyleRanges()); } if (element instanceof Node) { Node node = (Node) element; StyledString styledString = new StyledString(node.getNodeID() != null ? node.getNodeID() : "?", null); cell.setText(styledString.getString()); Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/Node_H.png"); cell.setImage(img); cell.setStyleRanges(styledString.getStyleRanges()); } if (element instanceof Component) { Component c = (Component) element; StyledString styledString = new StyledString(); Styler lifecycleColorStyler = StyledString.createColorRegistryStyler(LIFECYCLE_COLOR_STYLER, null); int lifeCycleState = StudioUtils.lifecycleState(c.getLifecycle()); styledString.append(StudioUtils.componentName(c), null); if (element instanceof Function) { cell.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/Function_H.png")); } if (element instanceof Equipment) { cell.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/Equipment_H.png")); } Styler metricColorStyler = StyledString.createColorRegistryStyler(METRIC_COLOR_STYLER, null); // Add Resources info. if (!c.getResourceRefs().isEmpty()) { String decoration = " (" + c.getResourceRefs().size() + " Res.)"; styledString.append(decoration, StyledString.COUNTER_STYLER); } // Add Metrics info. if (!c.getMetricRefs().isEmpty()) { String decoration = " (" + c.getMetricRefs().size() + " Metrics)"; styledString.append(decoration, metricColorStyler); } // Add Life Cycle info. if (lifeCycleState != StudioUtils.LIFECYCLE_NOTSET) { String decoration = " (" + StudioUtils.lifecycleText(lifeCycleState) + ")"; styledString.append(decoration, lifecycleColorStyler); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); } if (element instanceof Relationship) { Styler xColorStyler = StyledString.createColorRegistryStyler(REL_NOTCONNECTED_COLOR_STYLER, null); Relationship rel = (Relationship) element; StyledString styledString = new StyledString(rel.getName() != null ? rel.getName() : "?", null); StringBuffer decoration = new StringBuffer(); decoration.append(" ("); if (rel.getNodeID1Ref() != null) { decoration.append(rel.getNodeID1Ref().getNodeID()); styledString.append(decoration.toString(), StyledString.COUNTER_STYLER); } else { styledString.append(decoration.toString(), StyledString.COUNTER_STYLER); styledString.append(" x", xColorStyler); } decoration = new StringBuffer(); decoration.append(" <--> "); if (rel.getNodeID2Ref() != null) { decoration.append(rel.getNodeID2Ref().getNodeID()); styledString.append(decoration.toString(), StyledString.COUNTER_STYLER); } else { styledString.append(decoration.toString(), StyledString.COUNTER_STYLER); styledString.append("x", xColorStyler); } decoration = new StringBuffer(); decoration.append(" )"); styledString.append(decoration.toString(), StyledString.COUNTER_STYLER); cell.setText(styledString.getString()); Image img; if (element instanceof FunctionRelationship) { img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/FunctionRelationship_H.png"); cell.setImage(img); } if (element instanceof EquipmentRelationship) { img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/obj16/EquipmentRelationship_H.png"); cell.setImage(img); } cell.setStyleRanges(styledString.getStyleRanges()); } }
From source file:com.python.pydev.ui.hierarchy.HierarchyLabelProvider.java
License:Open Source License
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);//www . j av a 2 s . co m styledString.append("(" + model.moduleName + ")", styler); } return styledString; } return new StyledString(data.toString()); } return new StyledString(element == null ? "" : element.toString()); }
From source file:com.python.pydev.ui.hierarchy.TreeNodeContentProvider.java
License:Open Source License
public StyledString getStyledText(Object element) { if (element instanceof TreeNode) { @SuppressWarnings("rawtypes") TreeNode treeNode = (TreeNode) 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);//w w w . ja v a 2s . c om styledString.append("(" + model.moduleName + ")", styler); } return styledString; } return new StyledString(data.toString()); } return new StyledString(element == null ? "" : element.toString()); }
From source file:de.ovgu.featureide.ui.editors.Completion.java
License:Open Source License
@Override public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext arg0, IProgressMonitor arg1) {// w w w . java 2s . c o m final IFile file = ((IFileEditorInput) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor().getEditorInput()).getFile(); final IFeatureProject featureProject = CorePlugin.getFeatureProject(file); final ArrayList<ICompletionProposal> list = new ArrayList<ICompletionProposal>(); if (featureProject == null) return list; String featureName = featureProject.getFeatureName(file); JavaContentAssistInvocationContext context = (JavaContentAssistInvocationContext) arg0; String prefix = new String(context.getCoreContext().getToken()); // projectStructure = MPLPlugin.getDefault().extendedModules_getStruct(featureProject, featureName); // if (projectStructure == null) { // return list; // } // List<CompletionProposal> l = MPLPlugin.getDefault().extendedModules(projectStructure); List<CompletionProposal> l = MPLPlugin.getDefault().extendedModules_getCompl(featureProject, featureName); for (CompletionProposal curProp : l) { curProp.setReplaceRange(context.getInvocationOffset() - context.getCoreContext().getToken().length, context.getInvocationOffset()); if (curProp.getKind() == CompletionProposal.TYPE_REF) { LazyJavaCompletionProposal prsss = new LazyJavaCompletionProposal(curProp, context); prsss.setStyledDisplayString(new StyledString(new String(curProp.getCompletion()))); prsss.setReplacementString(new String(curProp.getCompletion())); if (prefix.length() >= 0 && new String(curProp.getCompletion()).startsWith(prefix)) { list.add(prsss); } } else if (curProp.getKind() == CompletionProposal.METHOD_REF) { LazyJavaCompletionProposal meth = new LazyJavaCompletionProposal(curProp, context); String displayString = new String(curProp.getCompletion()); displayString = displayString.concat("("); int paramNr = Signature.getParameterCount(curProp.getSignature()); for (int i = 0; i < paramNr; i++) { displayString = displayString .concat(Signature.getParameterTypes(curProp.getSignature()) + " arg" + i); if (i + 1 < paramNr) { displayString = displayString.concat(", "); } } displayString = displayString.concat(") : "); // displayString = displayString.concat(new // String(Signature.getReturnType(curProp.getSignature()))); StyledString methString = new StyledString(displayString); Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR); // TextStyle style = new // TextStyle(JFaceResources.getDefaultFont(),JFaceResources.getResources().createColor(new // RGB(10, 10, // 10)),JFaceResources.getResources().createColor(new // RGB(0,0,0))); // styler.applyStyles(style); StyledString infoString = new StyledString( new String(" - " + new String(curProp.getName()) + " " + featureName), styler); methString.append(infoString); meth.setStyledDisplayString(methString); meth.setReplacementString(new String(curProp.getCompletion())); if (prefix.length() >= 0 && new String(curProp.getCompletion()).startsWith(prefix)) { list.add(meth); } } else if (curProp.getKind() == CompletionProposal.FIELD_REF) { LazyJavaCompletionProposal field = new LazyJavaCompletionProposal(curProp, context); StyledString fieldString = new StyledString(new String(curProp.getCompletion())); Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR); StyledString infoString = new StyledString( new String(" - " + new String(curProp.getName()) + " " + featureName), styler); fieldString.append(infoString); field.setStyledDisplayString(fieldString); field.setReplacementString(new String(curProp.getCompletion())); if (prefix.length() > 0 && new String(curProp.getCompletion()).startsWith(prefix)) { list.add(field); } } } return list; }
From source file:it.unibz.instasearch.ui.ResultLabelProvider.java
License:Open Source License
public ResultLabelProvider(ResultContentProvider contentProvider) { JFaceResources.getColorRegistry().put(HIGHLIGHT_COLOR_NAME, new RGB(206, 204, 247)); this.labelProvider = new WorkbenchLabelProvider(); this.highlightStyle = StyledString.createColorRegistryStyler(null, HIGHLIGHT_COLOR_NAME); this.contentProvider = contentProvider; this.matchImage = InstaSearchUI.getSharedImage(IMG_OBJ_TEXT_SEARCH_LINE); imageRegistry.put(DOWN_ARROW_IMG_KEY, InstaSearchPlugin.getImageDescriptor(DOWN_ARROW_IMG_KEY)); this.showMatchCount = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_SHOW_MATCH_COUNT); this.showFullPath = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_SHOW_FULL_PATH); InstaSearchPlugin.addPreferenceChangeListener(this); }
From source file:nexcore.tool.uml.ui.project.explorer.provider.UMLLabelProvider.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object) *//* w w w . j a v a 2 s. c om*/ public StyledString getStyledText(Object element) { if (element instanceof ClosedTreeNode) { return new StyledString(getText(element), StyledString.createColorRegistryStyler("QUALIFIER_COLOR", null));// gray color } else if (element instanceof ITreeNode) { EObject eobject = ((ITreeNode) element).getEObject(); if (eobject instanceof ProfileApplication) { ProfileApplication profileApplication = (ProfileApplication) eobject; Profile profile = profileApplication.getAppliedProfile(); if (profile.eIsProxy()) { String text = String.format("'%s' does not exist.", getText(element)); return new StyledString(text, StyledString.createColorRegistryStyler("ERROR_COLOR", null));// red color } } } return new StyledString(getText(element)); }
From source file:org.eclipse.emf.emfstore.client.ui.dialogs.BranchSelectionDialog.java
License:Open Source License
/** * Create contents of the dialog./*from w ww . j av a 2 s. co m*/ * * @param parent * parent component * @return a control */ @Override protected Control createDialogArea(Composite parent) { setHeaderTexts(); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); addCreationField(container); setTableViewer(new TableViewer(container, SWT.BORDER | SWT.V_SCROLL)); Table list = getTableViewer().getTable(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); getTableViewer().setContentProvider(ArrayContentProvider.getInstance()); getTableViewer().setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof BranchInfo) { BranchInfo branch = (BranchInfo) element; StyledString styledString = new StyledString("Branch: " + branch.getName() + " ", StyledString.createColorRegistryStyler("red", null)); styledString.append("[Version: " + branch.getHead().getIdentifier() + "]", StyledString.DECORATIONS_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } super.update(cell); } }); getTableViewer().setInput(getBranches()); endOfInit(); return area; }