1 /*******************************************************************************
\r
2 * Copyright (c) 2013 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.trend;
\r
14 import org.eclipse.jface.layout.GridDataFactory;
\r
15 import org.eclipse.jface.layout.GridLayoutFactory;
\r
16 import org.eclipse.swt.SWT;
\r
17 import org.eclipse.swt.widgets.Composite;
\r
18 import org.simantics.browsing.ui.swt.widgets.Button;
\r
19 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
\r
20 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;
\r
21 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
\r
22 import org.simantics.databoard.Bindings;
\r
23 import org.simantics.db.ReadGraph;
\r
24 import org.simantics.db.Resource;
\r
25 import org.simantics.db.WriteGraph;
\r
26 import org.simantics.db.exception.DatabaseException;
\r
27 import org.simantics.db.management.ISessionContext;
\r
28 import org.simantics.jfreechart.chart.properties.xyline.SeriesPropertyComposite;
\r
29 import org.simantics.layer0.Layer0;
\r
30 import org.simantics.sysdyn.SysdynResource;
\r
33 * UI for setting properties for sensitivity analysis series. Sensitivity analysis
\r
34 * charts display only one variable as a "fan" chart.
\r
35 * @author Teemu Lempinen
\r
38 public class SensitivitySeriesPropertyComposite extends SeriesPropertyComposite {
\r
40 public SensitivitySeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support,
\r
42 super(parent, context, support, style);
\r
46 protected void createContent(ISessionContext context, WidgetSupport support) {
\r
47 GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);
\r
49 // Variable for the series
\r
50 variable(this, context, support);
\r
53 range(this, context, support);
\r
55 // Label to be displayed in chart for this series
\r
56 // seriesLabel(this, context, support);
\r
58 Button validateUnits = new Button(this, support, SWT.CHECK);
\r
59 validateUnits.setText("Display median");
\r
60 GridDataFactory.fillDefaults().span(2, 1).applyTo(validateUnits.getWidget());
\r
61 validateUnits.setSelectionFactory(new ReadFactoryImpl<Resource, Boolean>() {
\r
64 public Boolean perform(ReadGraph graph, Resource series) throws DatabaseException {
\r
65 Resource dataset = graph.getPossibleObject(series, Layer0.getInstance(graph).PartOf);
\r
66 Boolean result = graph.getPossibleRelatedValue(dataset, SysdynResource.getInstance(graph).Charts_SensitivityDataset_median, Bindings.BOOLEAN);
\r
67 return Boolean.TRUE.equals(result);
\r
71 validateUnits.addSelectionListener(new SelectionListenerImpl<Resource>(context){
\r
74 public void apply(WriteGraph graph, Resource series) throws DatabaseException {
\r
75 SysdynResource SR = SysdynResource.getInstance(graph);
\r
76 Resource dataset = graph.getPossibleObject(series, Layer0.getInstance(graph).PartOf);
\r
80 Boolean result = graph.getPossibleRelatedValue(dataset, SR.Charts_SensitivityDataset_median, Bindings.BOOLEAN);
\r
83 graph.claimLiteral(dataset, SR.Charts_SensitivityDataset_median, Boolean.FALSE.equals(result));
\r
88 ConfidenceBoundWidget cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 0);
\r
89 GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget);
\r
90 cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 1);
\r
91 GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget);
\r
92 cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 2);
\r
93 GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget);
\r
94 cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 3);
\r
95 GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget);
\r
96 cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 4);
\r
97 GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget);
\r