StyledString text(ResourceExpression ele) { int resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(ele).getClassifier(); if (resourceClassifier == ClassifierAdapter.UNKNOWN) validator.checkResourceExpression(ele); resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(ele).getClassifier(); StyledString label = new StyledString(); Object name = doGetText(ele.getResourceExpr()); appendStyled(label, name); final EList<ResourceBody> bodyList = ele.getResourceData(); final int bodyListSize = bodyList.size(); if (resourceClassifier == ClassifierAdapter.RESOURCE_IS_REGULAR) { // append the first named resource body, and add , ... if more than one if (bodyList.size() >= 1) { Object bodyLabel = doGetText(bodyList.get(0).getNameExpr()); label.append(" "); appendStyled(label, bodyLabel, StyledString.QUALIFIER_STYLER); if (bodyListSize > 1) label.append(", ...", StyledString.QUALIFIER_STYLER); } } StyledString typeLabel = new StyledString(); switch (resourceClassifier) { case ClassifierAdapter.UNKNOWN: typeLabel.append(" : ", StyledString.DECORATIONS_STYLER); typeLabel.append("Unknown type of Resource expression", ERROR_STYLER); break; case ClassifierAdapter.RESOURCE_IS_BAD: typeLabel.append(" : ", StyledString.DECORATIONS_STYLER); typeLabel.append("Invalid Resource", ERROR_STYLER); break; case ClassifierAdapter.RESOURCE_IS_DEFAULT: typeLabel.append(" : Resource Defaults", StyledString.DECORATIONS_STYLER); break; case ClassifierAdapter.RESOURCE_IS_OVERRIDE: typeLabel.append(" : Resource Override", StyledString.DECORATIONS_STYLER); break; case ClassifierAdapter.RESOURCE_IS_REGULAR: typeLabel.append( " : Resource" + (bodyListSize > 1 ? "s" : ""), StyledString.DECORATIONS_STYLER); break; } label.append(typeLabel); return label; }
public Object image(ResourceExpression o) { int resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(o).getClassifier(); if (resourceClassifier == ClassifierAdapter.UNKNOWN) validator.checkResourceExpression(o); resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(o).getClassifier(); switch (resourceClassifier) { case ClassifierAdapter.UNKNOWN: return RESOURCE_UNKNOWN; case ClassifierAdapter.RESOURCE_IS_BAD: return RESOURCE_UNKNOWN; case ClassifierAdapter.RESOURCE_IS_DEFAULT: return RESOURCE_DEFAULTS; case ClassifierAdapter.RESOURCE_IS_OVERRIDE: return RESOURCE_OVERRIDE; default: return RESOURCE_REGULAR; } }