]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/editor/PropertiesAction.java
2ec342f369748e635ac5e83dca551f395d87ca37
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / PropertiesAction.java
1 package org.simantics.charts.editor;
2
3 import org.eclipse.jface.action.Action;
4 import org.eclipse.swt.widgets.Control;
5 import org.eclipse.swt.widgets.Shell;
6 import org.simantics.charts.ontology.ChartResource;
7 import org.simantics.charts.ui.ChartDoubleClickHandler;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.Resource;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.request.Read;
12 import org.simantics.ui.SimanticsUI;
13
14 /**
15  * @author Tuukka Lehtonen
16  */
17 public class PropertiesAction extends Action {
18
19     private Control  control;
20     private Resource component;
21
22     public PropertiesAction(String name, Control control, Resource component) {
23         super(name);
24         this.control = control;
25         this.component = component;
26     }
27
28     @Override
29     public void run() {
30         final Shell shell = control.getShell();
31         SimanticsUI.getSession().asyncRequest(new Read<Object>() {
32                         @Override
33                         public Object perform(ReadGraph graph) throws DatabaseException {
34                                 ChartResource CHART = ChartResource.getInstance(graph);
35                                 if ( graph.isInstanceOf(component, CHART.Chart_Item) ) {
36                                         ChartDoubleClickHandler.openChartItemPropertiesDialog(graph, component, shell.getDisplay());
37                                 } else
38                                 if ( graph.isInstanceOf(component, CHART.Chart) ) {
39                                         ChartDoubleClickHandler.openChartPropertiesDialog(graph, component, shell.getDisplay());
40                                 } 
41                                 return null;
42                         }});
43     }
44
45 }