]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
f0e0361cc04ecd2f28b35c2ca825d11096f338aa
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.browser.contributions;\r
2 \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
16 \r
17 public class ExperimentLabelDecorator extends LabelDecoratorContributor<ExperimentNode> {\r
18 \r
19     @Override\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
28                 @Override\r
29                 public String decorateLabel(String label, String column, int itemIndex) {\r
30                     return label + " [ACTIVE]";\r
31                 }\r
32 \r
33                 @SuppressWarnings("unchecked")\r
34                 @Override\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
37                 }\r
38             };\r
39         }\r
40         return null;\r
41     }\r
42 \r
43 }\r