X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural.ui%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fui%2FmodelBrowser%2Fcontributions%2FRunLabelDecorationRule.java;h=8f09449fa455769c071dcdbd515652c828a540aa;hb=refs%2Fchanges%2F38%2F238%2F2;hp=a68064a95e3d8aef73787bc5e2c8e16f1349db1a;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/RunLabelDecorationRule.java b/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/RunLabelDecorationRule.java index a68064a95..8f09449fa 100644 --- a/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/RunLabelDecorationRule.java +++ b/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/RunLabelDecorationRule.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.structural.ui.modelBrowser.contributions; - -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.LabelDecorationRule; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PossibleModel; -import org.simantics.operation.Layer0X; -import org.simantics.simulation.ontology.SimulationResource; - -/** - * @author Tuukka Lehtonen - */ -public enum RunLabelDecorationRule implements LabelDecorationRule { - - INSTANCE; - - public static RunLabelDecorationRule get() { - return INSTANCE; - } - - @Override - public boolean isCompatible(Class contentType) { - return contentType.equals(Resource.class); - } - - @Override - public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { - Resource run = (Resource) content; - - Resource model = graph.syncRequest(new PossibleModel(run)); - if (model == null) - return null; - if (!graph.hasStatement(model, Layer0X.getInstance(graph).IsActivatedBy)) - return null; - if (!graph.hasStatement(run, SimulationResource.getInstance(graph).IsActive)) - return null; - - return new LabelDecorator.Stub() { - @Override - public String decorateLabel(String label, String column, int itemIndex) { - return label + " [ACTIVE]"; - } - @SuppressWarnings("unchecked") - @Override - public F decorateFont(F font, String column, int itemIndex) { - return (F) ((FontDescriptor) font).withStyle(SWT.BOLD); - } - }; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.structural.ui.modelBrowser.contributions; + +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.LabelDecorationRule; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PossibleModel; +import org.simantics.operation.Layer0X; +import org.simantics.simulation.ontology.SimulationResource; + +/** + * @author Tuukka Lehtonen + */ +public enum RunLabelDecorationRule implements LabelDecorationRule { + + INSTANCE; + + public static RunLabelDecorationRule get() { + return INSTANCE; + } + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Resource.class); + } + + @Override + public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { + Resource run = (Resource) content; + + Resource model = graph.syncRequest(new PossibleModel(run)); + if (model == null) + return null; + if (!graph.hasStatement(model, Layer0X.getInstance(graph).IsActivatedBy)) + return null; + if (!graph.hasStatement(run, SimulationResource.getInstance(graph).IsActive)) + return null; + + return new LabelDecorator.Stub() { + @Override + public String decorateLabel(String label, String column, int itemIndex) { + return label + " [ACTIVE]"; + } + @SuppressWarnings("unchecked") + @Override + public F decorateFont(F font, String column, int itemIndex) { + return (F) ((FontDescriptor) font).withStyle(SWT.BOLD); + } + }; + } + +}