List of usage examples for org.eclipse.jface.viewers ViewerCell setImage
public void setImage(Image image)
From source file:de.walware.statet.r.ui.RLabelProvider.java
License:Open Source License
public void update(final ViewerCell cell, final IElementPartition partition, final IModelElement element) { cell.setImage(WaDebugImages.getImageRegistry().get(WaDebugImages.OBJ_VARIABLE_PARTITION)); final StyledString text = new StyledString(); text.append("["); //$NON-NLS-1$ text.append(Long.toString((partition.getPartitionStart() + 1))); text.append(" ... "); //$NON-NLS-1$ text.append(Long.toString(partition.getPartitionStart() + partition.getPartitionLength())); text.append("]"); //$NON-NLS-1$ if (element instanceof RList) { final RList rList = (RList) element; String label = rList.getName(partition.getPartitionStart()); if (label != null) { text.append(" "); //$NON-NLS-1$ text.append(label, StyledString.QUALIFIER_STYLER); text.append(" ... ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ label = rList.getName(partition.getPartitionStart() + (partition.getPartitionLength() - 1)); if (label != null) { text.append(label, StyledString.QUALIFIER_STYLER); }//from w w w.j a v a 2 s. c o m } } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); }
From source file:de.walware.statet.rtm.base.ui.rexpr.RExprLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); cell.setImage(getImage(element)); cell.setText(getText(element));//w w w.j a v a 2s. c o m }
From source file:es.cv.gvcase.gvm.glossary.formseditor.providers.GlossaryLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { if (cell.getColumnIndex() == 0) { //Name cell.setText(((Term) cell.getElement()).getName()); } else { //Type String className = cell.getElement().getClass().getSimpleName(); //Remove the "Impl" part of the name className = className.substring(0, className.length() - 4); cell.setText(className);//from ww w. ja va2s. c o m if (cell.getElement() instanceof EObject) { cell.setImage(getImage((EObject) cell.getElement())); } } }
From source file:es.uah.aut.srg.micobs.util.impl.MICOBSAdapterFactoryLabelProvider.java
License:Open Source License
public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString styledString = getStyledText(element); String newText = styledString.toString(); StyleRange[] oldStyleRanges = cell.getStyleRanges(); StyleRange[] newStyleRanges = isOwnerDrawEnabled() ? styledString.getStyleRanges() : null; if (!Arrays.equals(oldStyleRanges, newStyleRanges)) { cell.setStyleRanges(newStyleRanges); if (cell.getText().equals(newText)) { // make sure there will be a refresh from a change cell.setText(""); //$NON-NLS-1$ }/*from w w w . j av a2 s . com*/ } cell.setText(newText); cell.setImage(getImage(element)); cell.setFont(getFont(element)); cell.setForeground(getForeground(element)); cell.setBackground(getBackground(element)); // no super call required. changes on item will trigger the refresh. }
From source file:eu.esdihumboldt.hale.ui.codelist.inspire.internal.CodeListLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text;//from w w w .j av a2 s. co m if (element instanceof CodeListRef) { CodeListRef cl = (CodeListRef) element; text = new StyledString(cl.getName()); String schema = cl.getSchemaName(); if (schema != null) { text.append(" (" + schema + ")", StyledString.COUNTER_STYLER); } // // String tag = cl.getTag(); // if (tag != null) { // text.append(" (" + tag + ")", StyledString.DECORATIONS_STYLER); // } } else { text = new StyledString(getText(element)); } cell.setImage(getImage(element)); cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider.java
License:Open Source License
/** * @see StyledCellLabelProvider#update(ViewerCell) */// ww w . ja v a2 s. c o m @Override public void update(ViewerCell cell) { Object element = cell.getElement(); element = extractElement(element); StyledString text = new StyledString(defaultLabels.getText(element)); cell.setImage(defaultLabels.getImage(element)); String contextText = null; String countText = null; if (element instanceof EntityDefinition) { PopulationService ps = (PopulationService) PlatformUI.getWorkbench() .getService(PopulationService.class); if (ps != null) { Population pop = ps.getPopulation((EntityDefinition) element); int count = pop.getOverallCount(); int parents = pop.getParentsCount(); switch (count) { case Population.UNKNOWN: countText = "\u00d7?"; break; case 0: break; default: countText = "\u00d7" + count; if (parents != count) { countText += " (" + parents + ")"; } } } contextText = AlignmentUtil.getContextText((EntityDefinition) element); element = ((EntityDefinition) element).getDefinition(); } // append cardinality if (!suppressCardinality && element instanceof ChildDefinition<?>) { Cardinality cardinality = null; if (((ChildDefinition<?>) element).asGroup() != null) { cardinality = ((ChildDefinition<?>) element).asGroup().getConstraint(Cardinality.class); } else if (((ChildDefinition<?>) element).asProperty() != null) { cardinality = ((ChildDefinition<?>) element).asProperty().getConstraint(Cardinality.class); } if (cardinality != null) { // only append cardinality if it isn't 1/1 if (cardinality.getMinOccurs() != 1 || cardinality.getMaxOccurs() != 1) { String card = " " + MessageFormat.format("({0}..{1})", new Object[] { Long.valueOf(cardinality.getMinOccurs()), (cardinality.getMaxOccurs() == Cardinality.UNBOUNDED) ? ("n") : (Long.valueOf(cardinality.getMaxOccurs())) }); text.append(card, StyledString.COUNTER_STYLER); } } } if (contextText != null) { contextText = " " + contextText; text.append(contextText, StyledString.DECORATIONS_STYLER); } if (countText != null) { countText = " " + countText; text.append(countText, StyledString.QUALIFIER_STYLER); } cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); Color foreground = getForeground(cell.getElement()); cell.setForeground(foreground); Color background = getBackground(cell.getElement()); cell.setBackground(background); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.HelperFunctionLabelProvider.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) */// w w w. ja v a 2s . com @Override public void update(ViewerCell cell) { Object element = cell.getElement(); String elementName = null; if (element instanceof Category) { cell.setText(((Category) element).getName()); cell.setImage( CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_DEFINITION_GROUP)); } else if (element instanceof HelperFunctionOrCategory) { HelperFunctionSpecification hfs = null; elementName = ((HelperFunctionOrCategory) element).getName(); StyledString text = new StyledString(elementName); try { HelperFunction<?> helper = ((HelperFunctionOrCategory) element).asFunction(); hfs = (HelperFunctionSpecification) helper.getSpec(elementName); text.append(PageFunctions.getStyledParameters(hfs)); } catch (Exception e) { // } cell.setText(text.getString()); cell.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_FUNCTION)); cell.setStyleRanges(text.getStyleRanges()); } super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.instancevalidation.report.InstanceValidationReportDetailsLabelProvider.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) *///from ww w .j av a2s .com @Override public void update(ViewerCell cell) { Object element = cell.getElement(); String label = getText(element); int newLine = label.indexOf('\n'); if (newLine > -1) label = label.substring(0, newLine) + " ..."; StyledString text = new StyledString(label); if (!(element instanceof InstanceValidationMessage)) { TreePath treePath = cell.getViewerRow().getTreePath(); boolean isLimited = contentProvider.isLimited(treePath); text.append(' '); if (!isLimited) text.append(MessageFormat.format("({0} warnings)", contentProvider.getMessageCount(treePath)), StyledString.COUNTER_STYLER); else text.append(MessageFormat.format("(showing {0} of {1})", InstanceValidationReportDetailsContentProvider.LIMIT, contentProvider.getMessageCount(treePath)), StyledString.COUNTER_STYLER); } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); cell.setImage(getImage(element)); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof SchemaPreset) { SchemaPreset schema = (SchemaPreset) element; text.append(schema.getName());/* ww w .ja va 2s .c om*/ } if (element instanceof SchemaCategory) { text.append(((SchemaCategory) element).getName()); } if (element instanceof SchemaPreset) { SchemaPreset preset = (SchemaPreset) element; String version = preset.getVersion(); if (version != null) { text.append(" " + version, StyledString.COUNTER_STYLER); } String tag = preset.getTag(); if (tag != null) { text.append(" (" + tag + ")", StyledString.DECORATIONS_STYLER); } } cell.setImage(getImage(element)); cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.views.data.internal.compare.DefinitionInstanceLabelProvider.java
License:Open Source License
/** * @see CellLabelProvider#update(ViewerCell) *///from w w w . j av a2 s. c om @Override public void update(ViewerCell cell) { TreePath treePath = cell.getViewerRow().getTreePath(); InstanceEntry entry = findInstanceEntry(treePath); Object value = entry.value; InstanceValidationReport report = null; // If childDef is null we are at the top element. if (entry.definition && entry.childDef == null) { report = InstanceValidator.validate(instance); } boolean hasValue = false; if (entry.definition && value instanceof Instance) { hasValue = ((Instance) value).getValue() != null; } else if (!entry.definition && treePath.getSegmentCount() == 1) { // metadata root if (instance.getMetaDataNames().isEmpty()) { hasValue = true; value = null; } } StyledString styledString; if (value == null) { styledString = new StyledString("no value", StyledString.DECORATIONS_STYLER); } else if (value instanceof Group && !hasValue) { styledString = new StyledString("+", StyledString.QUALIFIER_STYLER); } else { if (value instanceof Instance) { value = ((Instance) value).getValue(); } // TODO some kind of conversion? String stringValue = value.toString(); /* * Values that are very large, e.g. string representations of very * complex geometries lead to * StyledCellLabelProvider.updateTextLayout taking a very long time, * rendering the application unresponsive when the data views are * displayed. As such, we reduce the string to a maximum size. */ if (stringValue.length() > MAX_STRING_LENGTH) { stringValue = stringValue.substring(0, MAX_STRING_LENGTH) + "..."; } styledString = new StyledString(stringValue, null); } // mark cell if there are other values if (entry.valueCount > 1) { String decoration = " " + MessageFormat.format(MULTIPLE_VALUE_FORMAT, entry.choice + 1, entry.valueCount); styledString.append(decoration, StyledString.COUNTER_STYLER); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); if (report != null && !report.getWarnings().isEmpty()) cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); super.update(cell); }