X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Fui%2FChartItemLabelDecorationRule.java;fp=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Fui%2FChartItemLabelDecorationRule.java;h=1ba036e0bb1f7b2ba3290ef480fc86b4c8cfec73;hp=b4d72392c7364992c36be45e20e22bb4b5194a56;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemLabelDecorationRule.java b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemLabelDecorationRule.java index b4d72392c..1ba036e0b 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemLabelDecorationRule.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemLabelDecorationRule.java @@ -1,54 +1,54 @@ -package org.simantics.charts.ui; - -import org.eclipse.jface.resource.FontDescriptor; -import org.eclipse.swt.SWT; -import org.simantics.browsing.ui.content.LabelDecorator; -import org.simantics.browsing.ui.model.labeldecorators.AbstractLabelDecorator; -import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule; -import org.simantics.charts.ontology.ChartResource; -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; - -/** - * Used for labeling both chart plots and subscription items. - * - * @author Tuukka Lehtonen - */ -public class ChartItemLabelDecorationRule implements LabelDecorationRule { - - public static final ChartItemLabelDecorationRule INSTANCE = new ChartItemLabelDecorationRule(); - - @Override - public boolean isCompatible(Class contentType) { - return contentType.equals(Resource.class); - } - - @Override - public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { - Resource item = (Resource) content; - ChartResource CHART = ChartResource.getInstance(graph); - - Boolean hidden = graph.getPossibleRelatedValue(item, CHART.Chart_Item_hidden, Bindings.BOOLEAN); - if (hidden == null || !hidden) - return null; - - return HIDDEN_DECORATOR; - } - - private static class HiddenLabelDecorator extends AbstractLabelDecorator { - @SuppressWarnings("unchecked") - @Override - public F decorateFont(F font, String column, int itemIndex) { - return (F) ((FontDescriptor) font).withStyle(SWT.ITALIC); - } - @Override - public String decorateLabel(String label, String column, int itemIndex) { - return label + " (hidden)"; - } - }; - - private static HiddenLabelDecorator HIDDEN_DECORATOR = new HiddenLabelDecorator(); - +package org.simantics.charts.ui; + +import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.swt.SWT; +import org.simantics.browsing.ui.content.LabelDecorator; +import org.simantics.browsing.ui.model.labeldecorators.AbstractLabelDecorator; +import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule; +import org.simantics.charts.ontology.ChartResource; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; + +/** + * Used for labeling both chart plots and subscription items. + * + * @author Tuukka Lehtonen + */ +public class ChartItemLabelDecorationRule implements LabelDecorationRule { + + public static final ChartItemLabelDecorationRule INSTANCE = new ChartItemLabelDecorationRule(); + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Resource.class); + } + + @Override + public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { + Resource item = (Resource) content; + ChartResource CHART = ChartResource.getInstance(graph); + + Boolean hidden = graph.getPossibleRelatedValue(item, CHART.Chart_Item_hidden, Bindings.BOOLEAN); + if (hidden == null || !hidden) + return null; + + return HIDDEN_DECORATOR; + } + + private static class HiddenLabelDecorator extends AbstractLabelDecorator { + @SuppressWarnings("unchecked") + @Override + public F decorateFont(F font, String column, int itemIndex) { + return (F) ((FontDescriptor) font).withStyle(SWT.ITALIC); + } + @Override + public String decorateLabel(String label, String column, int itemIndex) { + return label + " (hidden)"; + } + }; + + private static HiddenLabelDecorator HIDDEN_DECORATOR = new HiddenLabelDecorator(); + } \ No newline at end of file