1 package org.simantics.sysdyn.ui.browser.contributions;
\r
3 import org.eclipse.jface.resource.FontDescriptor;
\r
4 import org.eclipse.swt.SWT;
\r
5 import org.eclipse.swt.graphics.Font;
\r
6 import org.simantics.browsing.ui.content.LabelDecorator;
\r
7 import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;
\r
8 import org.simantics.db.ReadGraph;
\r
9 import org.simantics.db.exception.DatabaseException;
\r
10 import org.simantics.simulation.experiment.IExperiment;
\r
11 import org.simantics.simulation.project.IExperimentManager;
\r
12 import org.simantics.sysdyn.manager.SysdynExperiment;
\r
13 import org.simantics.sysdyn.ui.Activator;
\r
14 import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;
\r
15 import org.simantics.ui.SimanticsUI;
\r
17 public class ExperimentLabelDecorator extends LabelDecoratorContributor<ExperimentNode> {
\r
20 public LabelDecorator getDecorator(ReadGraph graph, ExperimentNode experimentNode) throws DatabaseException {
\r
21 IExperimentManager manager =
\r
22 SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
\r
23 IExperiment exp = manager.getActiveExperiment();
\r
24 if(exp instanceof SysdynExperiment) {
\r
25 SysdynExperiment experiment = (SysdynExperiment) exp;
\r
26 if(experiment.getResource().equals(experimentNode.resource))
\r
27 return new LabelDecorator.Stub() {
\r
29 public String decorateLabel(String label, String column, int itemIndex) {
\r
30 return label + " [ACTIVE]";
\r
33 @SuppressWarnings("unchecked")
\r
35 public <F> F decorateFont(F font, String column, int itemIndex) {
\r
36 return (F) Activator.getResources().get(FontDescriptor.createFrom((Font) font).withStyle(SWT.BOLD));
\r