X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FVariableColoringDecorationRule.java;h=940109191c6cb99e8ddee29ccc5d1a0e937d5cc9;hb=HEAD;hp=d636a7f25a32e235681fc898bec9adeb15ddf97b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariableColoringDecorationRule.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariableColoringDecorationRule.java index d636a7f25..940109191 100644 --- a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariableColoringDecorationRule.java +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariableColoringDecorationRule.java @@ -1,46 +1,46 @@ -package org.simantics.selectionview; - -import org.eclipse.jface.resource.ColorDescriptor; -import org.eclipse.swt.graphics.RGB; -import org.simantics.browsing.ui.common.ColumnKeys; -import org.simantics.browsing.ui.content.LabelDecorator; -import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; - -/** - * @author Tuukka Lehtonen - */ -public class VariableColoringDecorationRule implements LabelDecorationRule { - - private final static ColorDescriptor READONLY_GRAY = ColorDescriptor.createFrom(new RGB(240, 240, 240)); - - @Override - public boolean isCompatible(Class contentType) { - return contentType.equals(Variable.class); - } - - @Override - public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) - throws DatabaseException { - Variable variable = (Variable)content; - Object o = variable.getPossiblePropertyValue(graph, Variables.READONLY); - if (!Boolean.TRUE.equals(o)) - return null; - return ReadOnlyDecorator.INSTANCE; - } - - private static class ReadOnlyDecorator extends LabelDecorator.Stub { - public static ReadOnlyDecorator INSTANCE = new ReadOnlyDecorator(); - @SuppressWarnings("unchecked") - @Override - public C decorateBackground(C color, String column, int itemIndex) { - if (ColumnKeys.DISPLAY_VALUE.equals(column) || ColumnKeys.DISPLAY_UNIT.equals(column)) - return (C) READONLY_GRAY; - return null; - } - } - -} +package org.simantics.selectionview; + +import org.eclipse.jface.resource.ColorDescriptor; +import org.eclipse.swt.graphics.RGB; +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.content.LabelDecorator; +import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; + +/** + * @author Tuukka Lehtonen + */ +public class VariableColoringDecorationRule implements LabelDecorationRule { + + private final static ColorDescriptor READONLY_GRAY = ColorDescriptor.createFrom(new RGB(240, 240, 240)); + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Variable.class); + } + + @Override + public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) + throws DatabaseException { + Variable variable = (Variable)content; + Object o = variable.getPossiblePropertyValue(graph, Variables.READONLY); + if (!Boolean.TRUE.equals(o)) + return null; + return ReadOnlyDecorator.INSTANCE; + } + + private static class ReadOnlyDecorator extends LabelDecorator.Stub { + public static ReadOnlyDecorator INSTANCE = new ReadOnlyDecorator(); + @SuppressWarnings("unchecked") + @Override + public C decorateBackground(C color, String column, int itemIndex) { + if (ColumnKeys.DISPLAY_VALUE.equals(column) || ColumnKeys.DISPLAY_UNIT.equals(column)) + return (C) READONLY_GRAY; + return null; + } + } + +}