Java Code Examples for org.eclipse.jface.viewers.StyledString#DECORATIONS_STYLER

The following examples show how to use org.eclipse.jface.viewers.StyledString#DECORATIONS_STYLER . 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: N4JSProjectExplorerHelper.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return a styled string for a given external project. Respects name, type, version, and information about
 *         shadowing and whether it is available in the xtext index
 */
public StyledString getStyledTextForExternalProject(final IN4JSProject project,
		N4JSProjectName overrideProjectName) {
	N4JSProjectName name = (overrideProjectName == null) ? project.getProjectName() : overrideProjectName;
	ProjectType type = project.getProjectType();
	// for better visual representation MyProject @1.2.3 -> MyProject v1.2.3
	String version = SemverSerializer.serialize(project.getVersion()).replaceFirst("@", "v");
	String typeLabel = getProjectTypeLabel(type);
	boolean inIndex = project.isExternal()
			&& indexSynchronizer.isInIndex((FileURI) project.getProjectDescriptionLocation());
	String rootLocationName = getRootLocationName(project);

	Styler stylerName = inIndex ? null : StyledString.QUALIFIER_STYLER;
	Styler stylerType = inIndex ? StyledString.DECORATIONS_STYLER : StyledString.QUALIFIER_STYLER;
	StyledString string = new StyledString(name + " " + version, stylerName);
	string.append(typeLabel, stylerType);
	if (rootLocationName != null) {
		string.append(rootLocationName, StyledString.COUNTER_STYLER);
	}
	return string;
}
 
Example 2
Source File: XViewerTestStyledStringLabelProvider.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public StyledString getStyledText(Object element, XViewerColumn xCol, int columnIndex) throws XViewerException {
   if (element instanceof String) {
      if (columnIndex == 1) {
         return new StyledString((String) element);
      } else {
         return new StyledString("");
      }
   }
   ISomeTask task = ((ISomeTask) element);
   if (task == null) {
      return new StyledString("");
   }
   if (xCol.equals(MyXViewerFactory.Run_Col)) {
      return new StyledString(String.valueOf(xViewerTest.isRun(task)), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Name_Col)) {
      return new StyledString(task.getId(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Schedule_Time)) {
      return new StyledString(task.getStartTime(), StyledString.QUALIFIER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Run_Db)) {
      return new StyledString(task.getRunDb().name(), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Task_Type)) {
      return new StyledString(task.getTaskType().name(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Description)) {
      return new StyledString(task.getDescription(), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Category)) {
      return new StyledString(task.getCategory(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Notification)) {
      return new StyledString(task.getEmailAddress(), StyledString.QUALIFIER_STYLER);
   }
   return new StyledString("unhandled column");
}
 
Example 3
Source File: MyXViewerStyledTextLabelProvider.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public StyledString getStyledText(Object element, XViewerColumn xCol, int column) throws Exception {
   if (element instanceof String) {
      if (column == 1) {
         return new StyledString((String) element);
      } else {
         return new StyledString("");
      }
   }
   ISomeTask task = ((ISomeTask) element);
   if (task == null) {
      return new StyledString("");
   }
   if (xCol.equals(MyXViewerFactory.Run_Col)) {
      return new StyledString(String.valueOf(xViewerTest.isRun(task)), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Name_Col)) {
      return new StyledString(task.getId(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Schedule_Time)) {
      return new StyledString(task.getStartTime(), StyledString.QUALIFIER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Run_Db)) {
      return new StyledString(task.getRunDb().name(), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Task_Type)) {
      return new StyledString(task.getTaskType().name(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Description)) {
      return new StyledString(task.getDescription(), StyledString.COUNTER_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Category)) {
      return new StyledString(task.getCategory(), StyledString.DECORATIONS_STYLER);
   }
   if (xCol.equals(MyXViewerFactory.Notification)) {
      return new StyledString(task.getEmailAddress(), StyledString.QUALIFIER_STYLER);
   }
   return new StyledString("unhandled column");
}
 
Example 4
Source File: StyledTemplateProposal.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public StyledString getStyledDisplayString() {
	StyledString.Styler styler = null;
	if (isGenericProposal) {
		styler = StyledString.DECORATIONS_STYLER;
	}
	return JSONProposalFactory.createStyledString(displayLabel, description, styler);
}
 
Example 5
Source File: XtextOutlineTreeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected StyledString getReturnTypeText(AbstractRule rule) {
	StringBuilder typeName = new StringBuilder(NAME_TYPE_SEPARATOR);
	if (rule.getType() != null && rule.getType().getClassifier() != null && rule.getType().getMetamodel() != null) {
		String alias = rule.getType().getMetamodel().getAlias();
		if (alias != null) {
			typeName.append(alias);
			typeName.append(ALIAS_TYPE_SEPARATOR);
		}
		typeName.append(safeName(rule.getType().getClassifier().getName()));
	} else {
		typeName.append(safeName(rule.getName()));
	}
	StyledString styledType = new StyledString(typeName.toString(), StyledString.DECORATIONS_STYLER);
	return styledType;
}
 
Example 6
Source File: XtendJvmLabelProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Object text(final JvmField element) {
  String _simpleName = element.getSimpleName();
  StyledString _styledString = new StyledString(_simpleName);
  String _simpleName_1 = element.getType().getSimpleName();
  String _plus = (" : " + _simpleName_1);
  StyledString _styledString_1 = new StyledString(_plus, StyledString.DECORATIONS_STYLER);
  return _styledString.append(_styledString_1);
}
 
Example 7
Source File: TmfNavigatorLabelProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static StyledString formatTraceRange(TmfTraceElement traceElement) {
    ITmfTimestamp start = traceElement.getStartTime();
    ITmfTimestamp end = traceElement.getEndTime();

    if (start == null) {
        boundsToUpdate.add(traceElement);
        if (updateBounds.getState() != Job.RUNNING) {
            updateBounds.schedule();
        }
        return new StyledString(" [...]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
    }

    if (start.equals(TmfTimestamp.BIG_BANG)) {
        /* Not a trace or empty */
        return new StyledString();
    }

    if (end == null || end.equals(TmfTimestamp.BIG_BANG)) {
        return new StyledString(" [" + TmfTimestampFormat.getDefaulTimeFormat().format(start.toNanos()) //$NON-NLS-1$
                + " - ...]", //$NON-NLS-1$
                StyledString.DECORATIONS_STYLER);
    }

    return new StyledString(" [" + TmfTimestampFormat.getDefaulTimeFormat().format(start.toNanos()) //$NON-NLS-1$
            + " - " + TmfTimestampFormat.getDefaulTimeFormat().format(end.toNanos()) + "]", //$NON-NLS-1$ //$NON-NLS-2$
            StyledString.DECORATIONS_STYLER);
}
 
Example 8
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the {@link org.eclipse.jface.viewers.StyledString.Styler} to be used for string decorations. By default the
 * {@link StyledString#DECORATIONS_STYLER decoration style}. Clients can override.
 * @param element
 *            the element that has been decorated
 * @return return the decoration style
 * @since 3.7
 */
protected Styler getDecorationStyle(Object element) {
	return StyledString.DECORATIONS_STYLER;
}
 
Example 9
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the {@link org.eclipse.jface.viewers.StyledString.Styler} to be used for string decorations. By default the
 * {@link StyledString#DECORATIONS_STYLER decoration style}. Clients can override.
 * @param element
 *            the element that has been decorated
 * @return return the decoration style
 * @since 3.7
 */
protected Styler getDecorationStyle(Object element) {
	return StyledString.DECORATIONS_STYLER;
}