-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.chart.property;\r
-\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.NameLabelUtil;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.swt.widgets.Button;\r
-import org.simantics.browsing.ui.swt.widgets.Combo;\r
-import org.simantics.browsing.ui.swt.widgets.Label;\r
-import org.simantics.browsing.ui.swt.widgets.Scale;\r
-import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
-import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
-import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.charts.ontology.ChartResource;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.modeling.ui.Activator;\r
-import org.simantics.selectionview.ConfigurationComposite;\r
-import org.simantics.ui.utils.ResourceAdaptionUtils;\r
-import org.simantics.utils.ui.ISelectionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ChartComposite extends ConfigurationComposite {\r
-\r
- public static final TimeInputValidator LENGTH_VALIDATOR = new TimeInputValidator(1.0);\r
- public static final TimeInputValidator START_VALIDATOR = new TimeInputValidator(-Double.MAX_VALUE); \r
-\r
- public static Read<String> getPartTitleRequest(final ISelection selection) {\r
- return new Read<String>() {\r
- @Override\r
- public String perform(ReadGraph graph) throws DatabaseException {\r
- Resource r = ResourceAdaptionUtils.toSingleResource(selection);\r
- if (r == null)\r
- return "Selection";\r
- return NameLabelUtil.modalName(graph, r);\r
- }\r
- };\r
- }\r
-\r
- @Override\r
- public Read<String> getPartNameReadRequest(ISelection forSelection) {\r
- return getPartTitleRequest(forSelection);\r
- }\r
-\r
- public void create(final Composite body, IWorkbenchSite site, final ISessionContext context, final WidgetSupport support) {\r
- final Display display = body.getDisplay();\r
-\r
- body.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
-\r
-/* Composite buttonComposite = new Composite(body, SWT.NONE);\r
- buttonComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(buttonComposite);\r
- GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(4).extendedMargins(5,5,5,5).applyTo(buttonComposite);\r
- \r
- Label nameHeader = new Label(buttonComposite, support, 0);\r
- nameHeader.setText("Name");\r
- //nameHeader.setFont(smallFont);\r
- nameHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(nameHeader.getWidget());\r
-\r
- TrackedText nameText = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);\r
- nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName, ""));\r
- nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
- GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(nameText.getWidget());\r
-*/\r
- Label autoscrollLabel = new Label(body, support, 0);\r
- autoscrollLabel.setText("Auto-scroll settings:");\r
- autoscrollLabel.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(autoscrollLabel.getControl());\r
- \r
- Composite templateComposite = new Composite(body, SWT.NONE);\r
- templateComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(templateComposite);\r
- GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(3).extendedMargins(5,5,5,5).applyTo(templateComposite);\r
-\r
- Label templateHeader = new Label(templateComposite, support, 0);\r
- templateHeader.setText("Template");\r
- //templateHeader.setFont(smallFont);\r
- templateHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(templateHeader.getWidget());\r
-\r
- Combo templateCombo = new Combo(templateComposite, support, SWT.NONE | SWT.READ_ONLY);\r
- templateCombo.setItemFactory(new AvailableTemplateFactory());\r
- templateCombo.setSelectionFactory(new CurrentTemplateFactory());\r
- templateCombo.addModifyListener(new TemplateModifier());\r
- GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(templateCombo.getWidget());\r
-\r
- Button resetButton = new Button(templateComposite, support, SWT.NONE | SWT.READ_ONLY);\r
- resetButton.setText("Apply");\r
- resetButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
- @Override\r
- public void apply(WriteGraph graph, Resource monitor) throws DatabaseException {\r
- graph.markUndoPoint();\r
- ChartResource CHART = ChartResource.getInstance(graph);\r
- if (graph.hasStatement(monitor, CHART.Chart_TimeWindowStart))\r
- graph.deny(monitor, CHART.Chart_TimeWindowStart);\r
- if (graph.hasStatement(monitor, CHART.Chart_TimeWindowLength))\r
- graph.deny(monitor, CHART.Chart_TimeWindowLength);\r
- if (graph.hasStatement(monitor, CHART.Chart_TimeWindowIncrement))\r
- graph.deny(monitor, CHART.Chart_TimeWindowIncrement);\r
- }\r
- });\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(resetButton.getWidget());\r
-\r
- Composite buttonComposite = new Composite(body, SWT.NONE);\r
- buttonComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(buttonComposite);\r
- GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(4).extendedMargins(5,5,5,5).applyTo(buttonComposite);\r
-\r
- Label startHeader = new Label(buttonComposite, support, 0);\r
- startHeader.setText("Start time");\r
- //startHeader.setFont(smallFont);\r
- startHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(startHeader.getWidget());\r
-\r
- TrackedText timeWindowStart = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);\r
- timeWindowStart.getWidget().setToolTipText("Chart Window Fixed Start Time in Seconds or Yy Dd HH:mm:ss.ddd");\r
- timeWindowStart.setTextFactory(new TimePropertyFactory(ChartResource.URIs.Chart_TimeWindowStart));\r
- timeWindowStart.addModifyListener(new TimePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowStart, START_VALIDATOR));\r
- timeWindowStart.setInputValidator( START_VALIDATOR );\r
- GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(timeWindowStart.getWidget());\r
-\r
-// Label l1 = new Label(buttonComposite, support, 0);\r
-// l1.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
-// l1.setText("seconds");\r
-\r
- Label sizeHeader = new Label(buttonComposite, support, 0);\r
- sizeHeader.setText("Length");\r
- //sizeHeader.setFont(smallFont);\r
- sizeHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(sizeHeader.getWidget());\r
-\r
- TrackedText timeWindowLength = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);\r
- timeWindowLength.getWidget().setToolTipText("Chart Window Fixed Time Axis Length in Seconds or Yy Dd HH:mm:ss.ddd");\r
- timeWindowLength.setTextFactory(new TimePropertyFactory(ChartResource.URIs.Chart_TimeWindowLength));\r
- timeWindowLength.addModifyListener(new TimePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowLength, LENGTH_VALIDATOR));\r
- timeWindowLength.setInputValidator( LENGTH_VALIDATOR );\r
- GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(timeWindowLength.getWidget());\r
-\r
-// Label l2 = new Label(buttonComposite, support, 0);\r
-// l2.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
-// l2.setText("seconds");\r
-\r
- Label incrementHeader = new Label(buttonComposite, support, 0);\r
- incrementHeader.setText("Scroll increment");\r
- //incrementHeader.setFont(smallFont);\r
- incrementHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(incrementHeader.getWidget());\r
-\r
- Scale timeWindowIncrement = new Scale(buttonComposite, support, SWT.READ_ONLY);\r
- timeWindowIncrement.getWidget().setMinimum(1);\r
- timeWindowIncrement.getWidget().setMaximum(100);\r
- timeWindowIncrement.getWidget().setIncrement(10);\r
- timeWindowIncrement.getWidget().setPageIncrement(10);\r
- timeWindowIncrement.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- timeWindowIncrement.setSelectionFactory(new DoubleToIntegerPropertyFactory(ChartResource.URIs.Chart_TimeWindowIncrement));\r
- timeWindowIncrement.addSelectionListener(new DelayedIntegerToDoublePropertyModifier(timeWindowIncrement, context, ChartResource.URIs.Chart_TimeWindowIncrement));\r
- GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(timeWindowIncrement.getWidget());\r
-\r
- TrackedText timeWindowIncrementText = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);\r
- timeWindowIncrementText.setTextFactory(new DoublePropertyFactory(ChartResource.URIs.Chart_TimeWindowIncrement));\r
- timeWindowIncrementText.addModifyListener(new DoublePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowIncrement));\r
- timeWindowIncrementText.setInputValidator(new IInputValidator() {\r
- @Override\r
- public String isValid(String newText) {\r
- if (newText.trim().isEmpty())\r
- return null;\r
- try {\r
- Double d = Double.parseDouble(newText);\r
- if (d < 1 || d > 100)\r
- return "Increment must be between 1..100";\r
- return null;\r
- } catch (NumberFormatException e) {\r
- return e.getMessage();\r
- }\r
- }\r
- });\r
- GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEAD, SWT.CENTER).span(1, 1).applyTo(timeWindowIncrementText.getWidget());\r
-\r
- Label l3 = new Label(buttonComposite, support, 0);\r
- l3.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- l3.setText("%");\r
-\r
- Composite checkboxComposite = new Composite(buttonComposite, SWT.NONE);\r
- checkboxComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(checkboxComposite);\r
- GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(2).applyTo(checkboxComposite);\r
-\r
- final Button showMilestones = new Button(checkboxComposite, support, SWT.CHECK);\r
- showMilestones.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- showMilestones.setText("Show &Milestones");\r
- GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(showMilestones.getWidget());\r
- showMilestones.setSelectionFactory(new BooleanPropertyFactory(ChartResource.URIs.Chart_ShowMilestones));\r
- showMilestones.addSelectionListener(new SelectionAdapter() {\r
- @Override\r
- public void widgetSelected(SelectionEvent e) {\r
- try {\r
- final Resource r = ISelectionUtils.filterSingleSelection(support.getInput(), Resource.class);\r
- if (r == null)\r
- return;\r
- final Boolean show = showMilestones.getWidget().getSelection();\r
- Simantics.getSession().syncRequest(new WriteRequest() {\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- graph.markUndoPoint();\r
- graph.claimLiteral(r, ChartResource.getInstance(graph).Chart_ShowMilestones, show, Bindings.BOOLEAN);\r
- }\r
- });\r
- } catch (DatabaseException e1) {\r
- Activator.getDefault().getLog().log(\r
- new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
- "Failed to set Show Milestones", e1));\r
- }\r
- }\r
- });\r
-\r
- final Button trackExperimentTime = new Button(checkboxComposite, support, SWT.CHECK);\r
- trackExperimentTime.setBackground(display.getSystemColor(SWT.COLOR_WHITE));\r
- trackExperimentTime.setText("Hairline &Tracks Experiment Time");\r
- trackExperimentTime.setTooltipText("Value Tip Hairline Tracks Experiment Time During Simulation");\r
- GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(trackExperimentTime.getWidget());\r
- trackExperimentTime.setSelectionFactory(new BooleanPropertyFactory(ChartResource.URIs.Chart_trackExperimentTime));\r
- trackExperimentTime.addSelectionListener(new SelectionAdapter() {\r
- @Override\r
- public void widgetSelected(SelectionEvent e) {\r
- try {\r
- final Resource r = ISelectionUtils.filterSingleSelection(support.getInput(), Resource.class);\r
- if (r == null)\r
- return;\r
- final Boolean track = trackExperimentTime.getWidget().getSelection();\r
- Simantics.getSession().syncRequest(new WriteRequest() {\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- graph.markUndoPoint();\r
- graph.claimLiteral(r, ChartResource.getInstance(graph).Chart_trackExperimentTime, track, Bindings.BOOLEAN);\r
- }\r
- });\r
- } catch (DatabaseException e1) {\r
- Activator.getDefault().getLog().log(\r
- new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
- "Failed to set Track Experiment Time", e1));\r
- }\r
- }\r
- });\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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.modeling.ui.chart.property;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.NameLabelUtil;
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.swt.widgets.Button;
+import org.simantics.browsing.ui.swt.widgets.Combo;
+import org.simantics.browsing.ui.swt.widgets.Label;
+import org.simantics.browsing.ui.swt.widgets.Scale;
+import org.simantics.browsing.ui.swt.widgets.TrackedText;
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
+import org.simantics.charts.ontology.ChartResource;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.db.request.Read;
+import org.simantics.modeling.ui.Activator;
+import org.simantics.selectionview.ConfigurationComposite;
+import org.simantics.ui.utils.ResourceAdaptionUtils;
+import org.simantics.utils.ui.ISelectionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ChartComposite extends ConfigurationComposite {
+
+ public static final TimeInputValidator LENGTH_VALIDATOR = new TimeInputValidator(1.0);
+ public static final TimeInputValidator START_VALIDATOR = new TimeInputValidator(-Double.MAX_VALUE);
+
+ public static Read<String> getPartTitleRequest(final ISelection selection) {
+ return new Read<String>() {
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ Resource r = ResourceAdaptionUtils.toSingleResource(selection);
+ if (r == null)
+ return "Selection";
+ return NameLabelUtil.modalName(graph, r);
+ }
+ };
+ }
+
+ @Override
+ public Read<String> getPartNameReadRequest(ISelection forSelection) {
+ return getPartTitleRequest(forSelection);
+ }
+
+ public void create(final Composite body, IWorkbenchSite site, final ISessionContext context, final WidgetSupport support) {
+ final Display display = body.getDisplay();
+
+ body.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+
+/* Composite buttonComposite = new Composite(body, SWT.NONE);
+ buttonComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(buttonComposite);
+ GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(4).extendedMargins(5,5,5,5).applyTo(buttonComposite);
+
+ Label nameHeader = new Label(buttonComposite, support, 0);
+ nameHeader.setText("Name");
+ //nameHeader.setFont(smallFont);
+ nameHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(nameHeader.getWidget());
+
+ TrackedText nameText = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName, ""));
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(nameText.getWidget());
+*/
+ Label autoscrollLabel = new Label(body, support, 0);
+ autoscrollLabel.setText("Auto-scroll settings:");
+ autoscrollLabel.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(autoscrollLabel.getControl());
+
+ Composite templateComposite = new Composite(body, SWT.NONE);
+ templateComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(templateComposite);
+ GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(3).extendedMargins(5,5,5,5).applyTo(templateComposite);
+
+ Label templateHeader = new Label(templateComposite, support, 0);
+ templateHeader.setText("Template");
+ //templateHeader.setFont(smallFont);
+ templateHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(templateHeader.getWidget());
+
+ Combo templateCombo = new Combo(templateComposite, support, SWT.NONE | SWT.READ_ONLY);
+ templateCombo.setItemFactory(new AvailableTemplateFactory());
+ templateCombo.setSelectionFactory(new CurrentTemplateFactory());
+ templateCombo.addModifyListener(new TemplateModifier());
+ GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(templateCombo.getWidget());
+
+ Button resetButton = new Button(templateComposite, support, SWT.NONE | SWT.READ_ONLY);
+ resetButton.setText("Apply");
+ resetButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {
+ @Override
+ public void apply(WriteGraph graph, Resource monitor) throws DatabaseException {
+ graph.markUndoPoint();
+ ChartResource CHART = ChartResource.getInstance(graph);
+ if (graph.hasStatement(monitor, CHART.Chart_TimeWindowStart))
+ graph.deny(monitor, CHART.Chart_TimeWindowStart);
+ if (graph.hasStatement(monitor, CHART.Chart_TimeWindowLength))
+ graph.deny(monitor, CHART.Chart_TimeWindowLength);
+ if (graph.hasStatement(monitor, CHART.Chart_TimeWindowIncrement))
+ graph.deny(monitor, CHART.Chart_TimeWindowIncrement);
+ }
+ });
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(resetButton.getWidget());
+
+ Composite buttonComposite = new Composite(body, SWT.NONE);
+ buttonComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(buttonComposite);
+ GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(4).extendedMargins(5,5,5,5).applyTo(buttonComposite);
+
+ Label startHeader = new Label(buttonComposite, support, 0);
+ startHeader.setText("Start time");
+ //startHeader.setFont(smallFont);
+ startHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(startHeader.getWidget());
+
+ TrackedText timeWindowStart = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);
+ timeWindowStart.getWidget().setToolTipText("Chart Window Fixed Start Time in Seconds or Yy Dd HH:mm:ss.ddd");
+ timeWindowStart.setTextFactory(new TimePropertyFactory(ChartResource.URIs.Chart_TimeWindowStart));
+ timeWindowStart.addModifyListener(new TimePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowStart, START_VALIDATOR));
+ timeWindowStart.setInputValidator( START_VALIDATOR );
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(timeWindowStart.getWidget());
+
+// Label l1 = new Label(buttonComposite, support, 0);
+// l1.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+// l1.setText("seconds");
+
+ Label sizeHeader = new Label(buttonComposite, support, 0);
+ sizeHeader.setText("Length");
+ //sizeHeader.setFont(smallFont);
+ sizeHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(sizeHeader.getWidget());
+
+ TrackedText timeWindowLength = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);
+ timeWindowLength.getWidget().setToolTipText("Chart Window Fixed Time Axis Length in Seconds or Yy Dd HH:mm:ss.ddd");
+ timeWindowLength.setTextFactory(new TimePropertyFactory(ChartResource.URIs.Chart_TimeWindowLength));
+ timeWindowLength.addModifyListener(new TimePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowLength, LENGTH_VALIDATOR));
+ timeWindowLength.setInputValidator( LENGTH_VALIDATOR );
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(timeWindowLength.getWidget());
+
+// Label l2 = new Label(buttonComposite, support, 0);
+// l2.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+// l2.setText("seconds");
+
+ Label incrementHeader = new Label(buttonComposite, support, 0);
+ incrementHeader.setText("Scroll increment");
+ //incrementHeader.setFont(smallFont);
+ incrementHeader.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(false, false).span(1, 1).align(SWT.LEFT, SWT.CENTER).applyTo(incrementHeader.getWidget());
+
+ Scale timeWindowIncrement = new Scale(buttonComposite, support, SWT.READ_ONLY);
+ timeWindowIncrement.getWidget().setMinimum(1);
+ timeWindowIncrement.getWidget().setMaximum(100);
+ timeWindowIncrement.getWidget().setIncrement(10);
+ timeWindowIncrement.getWidget().setPageIncrement(10);
+ timeWindowIncrement.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ timeWindowIncrement.setSelectionFactory(new DoubleToIntegerPropertyFactory(ChartResource.URIs.Chart_TimeWindowIncrement));
+ timeWindowIncrement.addSelectionListener(new DelayedIntegerToDoublePropertyModifier(timeWindowIncrement, context, ChartResource.URIs.Chart_TimeWindowIncrement));
+ GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(timeWindowIncrement.getWidget());
+
+ TrackedText timeWindowIncrementText = new TrackedText(buttonComposite, support, SWT.BORDER | SWT.FLAT);
+ timeWindowIncrementText.setTextFactory(new DoublePropertyFactory(ChartResource.URIs.Chart_TimeWindowIncrement));
+ timeWindowIncrementText.addModifyListener(new DoublePropertyModifier(context, ChartResource.URIs.Chart_TimeWindowIncrement));
+ timeWindowIncrementText.setInputValidator(new IInputValidator() {
+ @Override
+ public String isValid(String newText) {
+ if (newText.trim().isEmpty())
+ return null;
+ try {
+ Double d = Double.parseDouble(newText);
+ if (d < 1 || d > 100)
+ return "Increment must be between 1..100";
+ return null;
+ } catch (NumberFormatException e) {
+ return e.getMessage();
+ }
+ }
+ });
+ GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEAD, SWT.CENTER).span(1, 1).applyTo(timeWindowIncrementText.getWidget());
+
+ Label l3 = new Label(buttonComposite, support, 0);
+ l3.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ l3.setText("%");
+
+ Composite checkboxComposite = new Composite(buttonComposite, SWT.NONE);
+ checkboxComposite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(checkboxComposite);
+ GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(2).applyTo(checkboxComposite);
+
+ final Button showMilestones = new Button(checkboxComposite, support, SWT.CHECK);
+ showMilestones.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ showMilestones.setText("Show &Milestones");
+ GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(showMilestones.getWidget());
+ showMilestones.setSelectionFactory(new BooleanPropertyFactory(ChartResource.URIs.Chart_ShowMilestones));
+ showMilestones.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ final Resource r = ISelectionUtils.filterSingleSelection(support.getInput(), Resource.class);
+ if (r == null)
+ return;
+ final Boolean show = showMilestones.getWidget().getSelection();
+ Simantics.getSession().syncRequest(new WriteRequest() {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ graph.markUndoPoint();
+ graph.claimLiteral(r, ChartResource.getInstance(graph).Chart_ShowMilestones, show, Bindings.BOOLEAN);
+ }
+ });
+ } catch (DatabaseException e1) {
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Failed to set Show Milestones", e1));
+ }
+ }
+ });
+
+ final Button trackExperimentTime = new Button(checkboxComposite, support, SWT.CHECK);
+ trackExperimentTime.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ trackExperimentTime.setText("Hairline &Tracks Experiment Time");
+ trackExperimentTime.setTooltipText("Value Tip Hairline Tracks Experiment Time During Simulation");
+ GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(trackExperimentTime.getWidget());
+ trackExperimentTime.setSelectionFactory(new BooleanPropertyFactory(ChartResource.URIs.Chart_trackExperimentTime));
+ trackExperimentTime.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ final Resource r = ISelectionUtils.filterSingleSelection(support.getInput(), Resource.class);
+ if (r == null)
+ return;
+ final Boolean track = trackExperimentTime.getWidget().getSelection();
+ Simantics.getSession().syncRequest(new WriteRequest() {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ graph.markUndoPoint();
+ graph.claimLiteral(r, ChartResource.getInstance(graph).Chart_trackExperimentTime, track, Bindings.BOOLEAN);
+ }
+ });
+ } catch (DatabaseException e1) {
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Failed to set Track Experiment Time", e1));
+ }
+ }
+ });
+ }
+
+}