1 package org.simantics.sysdyn.ui.properties.widgets.modules;
\r
3 import org.eclipse.jface.resource.ColorDescriptor;
\r
4 import org.eclipse.swt.graphics.RGB;
\r
5 import org.simantics.browsing.ui.content.LabelDecorator;
\r
6 import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule;
\r
7 import org.simantics.db.ReadGraph;
\r
8 import org.simantics.db.exception.DatabaseException;
\r
9 import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;
\r
11 public class ParameterLabelDecorationRule implements LabelDecorationRule {
\r
14 public boolean isCompatible(Class<?> contentType) {
\r
15 return contentType.equals(Object.class);
\r
19 public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {
\r
20 if(content instanceof ParameterNode) {
\r
21 ParameterNode node = (ParameterNode) content;
\r
22 String notOverriding = ModuleParameterOverrideUtils.getParameterExpression(node.getIndependentVariable());
\r
23 String overriding = ModuleParameterOverrideUtils.getParameterExpressionOrOverride(graph, node.getParent(), node.getIndependentVariable());
\r
25 if(notOverriding == null)
\r
28 final boolean original = notOverriding.equals(overriding);
\r
30 return new LabelDecorator.Stub() {
\r
32 public String decorateLabel(String label, String column, int itemIndex) {
\r
33 if(ColumnKeys.VALUE.equals(column)) {
\r
34 return original ? label : label + " [Overridden]";
\r
40 @SuppressWarnings("unchecked")
\r
42 public <Color> Color decorateForeground(Color color, String column, int itemIndex) {
\r
43 Color result = null;
\r
44 if(ColumnKeys.VALUE.equals(column)) {
\r
46 result = (Color) ColorDescriptor.createFrom(new RGB(125,125,125));
\r
48 result = (Color) ColorDescriptor.createFrom(new RGB(0,0,0));
\r