From: jkauttio Date: Tue, 11 Mar 2014 13:20:51 +0000 (+0000) Subject: Merge from trunk to branch jkauttio-dev X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=e228fc8f623ac543138dad3eae2fb75610c11109;p=simantics%2Fsysdyn.git Merge from trunk to branch jkauttio-dev refs #2924 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/dev-jkauttio@29075 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java index dd5b069a..6d571f54 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java @@ -121,6 +121,8 @@ public class ChartComposite extends Composite { JFreeChart jfreeChart = chart.getChart(); // Display the result chart + if (composite.isDisposed()) + return; composite.getDisplay().asyncExec(new RunnableWithObject(jfreeChart) { @Override diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringCategoryDataset.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringCategoryDataset.java index ec719f95..fb5ec1a7 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringCategoryDataset.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringCategoryDataset.java @@ -3,6 +3,10 @@ package org.simantics.jfreechart.chart; /** * Filters CategoryDataset by creating "Other" item for filtered data. * + * Filtering uses sum of absolute values as a comparison point and compares absolute values. + * If negative values are filtered, their absolute value is added to the others category. + * + * * @author Marko Luukkainen * */ @@ -10,7 +14,6 @@ import java.util.List; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.AbstractDataset; -import org.jfree.data.general.DatasetChangeEvent; @SuppressWarnings("rawtypes") public class FilteringCategoryDataset extends AbstractDataset implements org.jfree.data.category.CategoryDataset, FilteredDataset{ @@ -78,17 +81,18 @@ public class FilteringCategoryDataset extends AbstractDataset implements org.jfr for (Object row : original.getRowKeys()) { Number value = original.getValue((Comparable) row, (Comparable)column); if (value != null) - total+=value.doubleValue(); + total+=Math.abs(value.doubleValue()); } total *= filterFraction; for (Object row : original.getRowKeys()) { Number value = original.getValue((Comparable) row, (Comparable)column); if (value == null) continue; - if (value.doubleValue() > total) { + if (Math.abs(value.doubleValue()) > total) { filtered.addValue(value, (Comparable) row, (Comparable)column); } else { - other += value.doubleValue(); + // TODO : what is proper way to handle negative values? + other += Math.abs(value.doubleValue()); } } if (other > 0.0) { @@ -102,17 +106,18 @@ public class FilteringCategoryDataset extends AbstractDataset implements org.jfr for (Object column : original.getColumnKeys()) { Number value = original.getValue((Comparable) row, (Comparable)column); if (value != null) - total += value.doubleValue(); + total += Math.abs(value.doubleValue()); } total *= filterFraction; for (Object column : original.getColumnKeys()) { Number value = original.getValue((Comparable) row, (Comparable)column); if (value == null) continue; - if (value.doubleValue() > total) { + if (Math.abs(value.doubleValue()) > total) { filtered.addValue(value, (Comparable) row, (Comparable)column); } else { - other += value.doubleValue(); + // TODO : what is proper way to handle negative values? + other += Math.abs(value.doubleValue()); } } if (other > 0.0) { diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringPieDataset.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringPieDataset.java index 249c2aa6..dacef528 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringPieDataset.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/FilteringPieDataset.java @@ -3,7 +3,6 @@ package org.simantics.jfreechart.chart; import java.util.List; import org.jfree.data.general.AbstractDataset; -import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/NumberAxis.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/NumberAxis.java index 4f070631..a4216e10 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/NumberAxis.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/NumberAxis.java @@ -36,6 +36,7 @@ public class NumberAxis extends AbstractAxis { @Override public Axis getAxis() { axis = new ExtendedNumberAxis(); + ((org.jfree.chart.axis.NumberAxis)axis).setAutoRangeIncludesZero(false); ((ExtendedNumberAxis)axis).setLower(min); ((ExtendedNumberAxis)axis).setUpper(max); return super.getAxis(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/AdjustableTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java similarity index 89% rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/AdjustableTab.java rename to org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java index b0ad402b..da4bae8c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/AdjustableTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java @@ -9,7 +9,7 @@ * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ -package org.simantics.sysdyn.ui.properties; +package org.simantics.jfreechart.chart.properties; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; @@ -78,6 +78,15 @@ public abstract class AdjustableTab extends LabelPropertyTabContributor { } } + /** + * Determine if the layout uses vertical layout + * @return true iff the layout uses vertical layout + */ + protected boolean isVertical() { + Point size = spp.getSize(); + return size.x < size.y; + } + /** * Create vertical layout for controls. */ diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java index b3d95473..2b3ce825 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java @@ -55,7 +55,7 @@ public class RangeComposite extends Composite implements Widget { public RangeComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) { super(parent, style); support.register(this); - GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 3).applyTo(this); + GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 0).applyTo(this); GridDataFactory.fillDefaults().grab(true, false).applyTo(this); composite = this; } @@ -109,8 +109,15 @@ public class RangeComposite extends Composite implements Widget { composite.layout(); - if(getObject() == null) + if(getObject() == null) { + // No range, print an em dash. + Label label = new Label(composite, SWT.NONE); + label.setText("\u2014"); + label.setEnabled(false); + GridDataFactory.fillDefaults().applyTo(label); + composite.layout(); return; + } // New widgetSupport for the combos WidgetSupportImpl support = new WidgetSupportImpl(); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java index cf11899b..d8228492 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -18,6 +18,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; @@ -40,11 +41,11 @@ import org.simantics.db.common.request.ReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.AxisHidePropertyComposite; import org.simantics.jfreechart.chart.properties.ColorPicker; import org.simantics.jfreechart.chart.properties.DoubleValidator; import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.jfreechart.chart.properties.TrackedSpinner; import org.simantics.layer0.Layer0; import org.simantics.modeling.ui.chart.property.DoublePropertyFactory; @@ -55,9 +56,10 @@ import org.simantics.utils.ui.AdaptionUtils; /** * Tab for bar chart axis properties * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class BarAxisTab extends LabelPropertyTabContributor implements Widget { +public class BarAxisTab extends AdjustableTab implements Widget { private TrackedSpinner angle; private Integer angleInt = null; @@ -66,123 +68,24 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { private TrackedText rangelabel, rangemin, rangemax; private ScrolledComposite sc; private Composite composite; - - - @Override - public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - support.register(this); - - // Scrolled composite containing all of the properties in this tab - sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); - GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(sc); - sc.setExpandHorizontal(true); - sc.setExpandVertical(true); - - composite = new Composite(sc, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // Domain Axis properties - Group domainGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(domainGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(domainGroup); - domainGroup.setText("Domain axis"); - - // Label for x-axis - Label label = new Label(domainGroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Label:"); - - rangelabel = new TrackedText(domainGroup, domainAxisSupport, SWT.BORDER); - rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); - rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); - rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget()); - - Composite axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide); - - Label angleLabel = new Label(domainGroup, SWT.NONE); - angleLabel.setText("Label angle:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(angleLabel); - - Composite angleComposite = new Composite(domainGroup, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(angleComposite); - GridLayoutFactory.fillDefaults().applyTo(angleComposite); - angle = new TrackedSpinner(angleComposite, domainAxisSupport, SWT.BORDER); - angle.setSelectionFactory(new AngleSelectionFactory()); - angle.addModifyListener(new AngleModifyListener()); - angle.setMinimum(0); - angle.setMaximum(90); - angle.getWidget().setIncrement(5); - GridDataFactory.fillDefaults().applyTo(angle.getWidget()); - - // Domain Color - label = new Label(domainGroup, SWT.NONE); - label.setText("Color:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - - Composite colorPicker = new ColorPicker(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - - domainGroup.layout(); - - // Range Axis properties - Group rangeGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(rangeGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(rangeGroup); - rangeGroup.setText("Range axis"); - - // Label for range axis - label = new Label(rangeGroup, SWT.NONE); - label.setText("Label:"); - label.setAlignment(SWT.RIGHT); - GridDataFactory.fillDefaults().hint(angleLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(label); - - rangelabel = new TrackedText(rangeGroup, rangeAxisSupport, SWT.BORDER); - rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); - rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); - rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget()); - - axisHide = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 4).applyTo(axisHide); - - // Min and max values for range axis - label = new Label(rangeGroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Min:"); - - Composite minmax = new Composite(rangeGroup, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(minmax); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); - rangemin = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER); - rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager())); - rangemin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); - rangemin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); - rangemin.setInputValidator(new DoubleValidator(true)); - - label = new Label(minmax, SWT.NONE); - label.setText("Max:"); - rangemax = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER); - rangemax.setColorProvider(new JFreeChartPropertyColorProvider(rangemax.getResourceManager())); - rangemax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); - rangemax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); - rangemax.setInputValidator(new DoubleValidator(true)); - - // Range Color - label = new Label(rangeGroup, SWT.NONE); - label.setText("Color:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - - colorPicker = new ColorPicker(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - - // Resize scrolled composite - sc.setContent(composite); - Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); - sc.setMinSize(size); - } + private Group domainGroup; + private Label labelLabel; + private AxisHidePropertyComposite axisHide; + private Label angleLabel; + private Composite angleComposite; + private Label labelColor; + private ColorPicker colorPicker; + private Group rangeGroup; + private Label labelLabel2; + private Label labelMin; + private Composite minmax; + private Label labelMax; + private Label labelColor2; + private TrackedText rangelabel2; + private AxisHidePropertyComposite axisHide2; + private ColorPicker colorPicker2; + private Composite rangeComposite; + private Composite domainComposite; /** * ModifyListener for the angle {@link TrackedSpinner} @@ -279,14 +182,250 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { JFreeChartResource jfree = JFreeChartResource.getInstance(graph); Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot)); if(plot == null) return; - Resource rangeAxis = graph.getPossibleObject(plot, jfree.Plot_rangeAxis); - if(rangeAxis == null) return; - rangeAxisSupport.fireInput(context, new StructuredSelection(rangeAxis)); - - Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis); - if(domainAxis == null) return; - domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis)); + final Resource rangeAxis = graph.getPossibleObject(plot, jfree.Plot_rangeAxis); + final Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis); + if(rangeAxis == null && domainAxis == null) return; + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (rangeAxis != null) + rangeAxisSupport.fireInput(context, new StructuredSelection(rangeAxis)); + if (domainAxis != null) + domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis)); + + } + }); } }); } + + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + support.register(this); + + // Scrolled composite containing all of the properties in this tab + sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); + sc.setExpandHorizontal(true); + sc.setExpandVertical(true); + + composite = new Composite(sc, SWT.NONE); + + // Domain Axis properties + domainGroup = new Group(composite, SWT.NONE); + domainGroup.setText("Domain axis"); + + domainComposite = new Composite(domainGroup, SWT.NONE); + + // Label for x-axis + labelLabel = new Label(domainComposite, SWT.NONE); + labelLabel.setText("Label:"); + + rangelabel = new TrackedText(domainComposite, domainAxisSupport, SWT.BORDER); + rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); + rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); + rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager())); + + angleLabel = new Label(domainComposite, SWT.NONE); + angleLabel.setText("Label angle:"); + + angleComposite = new Composite(domainComposite, SWT.NONE); + angle = new TrackedSpinner(angleComposite, domainAxisSupport, SWT.BORDER); + angle.setSelectionFactory(new AngleSelectionFactory()); + angle.addModifyListener(new AngleModifyListener()); + angle.setMinimum(0); + angle.setMaximum(90); + angle.getWidget().setIncrement(5); + + // Domain Color + labelColor = new Label(domainComposite, SWT.NONE); + labelColor.setText("Color:"); + + colorPicker = new ColorPicker(domainComposite, context, domainAxisSupport, SWT.NONE); + + axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE); + + + // Range Axis properties + rangeGroup = new Group(composite, SWT.NONE); + rangeGroup.setText("Range axis"); + + rangeComposite = new Composite(rangeGroup, SWT.NONE); + + // Label for range axis + labelLabel2 = new Label(rangeComposite, SWT.NONE); + labelLabel2.setText("Label:"); + labelLabel2.setAlignment(SWT.RIGHT); + + rangelabel2 = new TrackedText(rangeComposite, rangeAxisSupport, SWT.BORDER); + rangelabel2.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); + rangelabel2.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); + rangelabel2.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel2.getResourceManager())); + + + // Min and max values for range axis + labelMin = new Label(rangeComposite, SWT.NONE); + labelMin.setText("Min:"); + + minmax = new Composite(rangeComposite, SWT.NONE); + rangemin = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER); + rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager())); + rangemin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); + rangemin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); + rangemin.setInputValidator(new DoubleValidator(true)); + + labelMax = new Label(minmax, SWT.NONE); + labelMax.setText("Max:"); + rangemax = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER); + rangemax.setColorProvider(new JFreeChartPropertyColorProvider(rangemax.getResourceManager())); + rangemax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); + rangemax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); + rangemax.setInputValidator(new DoubleValidator(true)); + + // Range Color + labelColor2 = new Label(rangeComposite, SWT.NONE); + labelColor2.setText("Color:"); + + colorPicker2 = new ColorPicker(rangeComposite, context, rangeAxisSupport, SWT.NONE); + + axisHide2 = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE); + + // Resize scrolled composite + sc.setContent(composite); + } + + @Override + protected void createControlLayoutVertical() { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(sc); + + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + // Domain Axis properties + GridDataFactory.fillDefaults().grab(false, false).applyTo(domainGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(1).applyTo(domainGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(domainComposite); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(domainComposite); + + // Label for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel); + + GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(rangelabel.getWidget()); + + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(angleLabel); + + GridDataFactory.fillDefaults().applyTo(angleComposite); + GridLayoutFactory.fillDefaults().applyTo(angleComposite); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(angle.getWidget()); + + // Domain Color + GridDataFactory.fillDefaults().grab(false, false).align(SWT.END, SWT.CENTER).applyTo(labelColor); + + GridDataFactory.fillDefaults().grab(false, true).minSize(SWT.DEFAULT, 31).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker); + + GridDataFactory.fillDefaults().applyTo(axisHide); + + domainGroup.layout(); + + // Range Axis properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(1).applyTo(rangeGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(rangeComposite); + + // Label for range axis + GridDataFactory.fillDefaults().hint(angleLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(labelLabel2); + + GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(rangelabel2.getWidget()); + + // Min and max values for range axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin); + + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(minmax); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(rangemax.getWidget()); + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(rangemin.getWidget()); + + // Range Color + GridDataFactory.fillDefaults().grab(false, false).align(SWT.END, SWT.CENTER).applyTo(labelColor2); + + GridDataFactory.fillDefaults().grab(false, true).minSize(SWT.DEFAULT, 31).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker2); + + GridDataFactory.fillDefaults().applyTo(axisHide2); + + // Resize scrolled composite + Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(sc); + + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + // Domain Axis properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(domainGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(domainGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(domainComposite); + GridLayoutFactory.fillDefaults().numColumns(4).applyTo(domainComposite); + + // Label for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel); + + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel.getWidget()); + + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(angleLabel); + + GridDataFactory.fillDefaults().applyTo(angleComposite); + GridLayoutFactory.fillDefaults().applyTo(angleComposite); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(angle.getWidget()); + + // Domain Color + GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(labelColor); + + GridDataFactory.fillDefaults().grab(false, true).minSize(SWT.DEFAULT, SWT.DEFAULT).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker); + + GridDataFactory.fillDefaults().applyTo(axisHide); + + domainGroup.layout(); + + // Range Axis properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(rangeGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite); + GridLayoutFactory.fillDefaults().numColumns(4).applyTo(rangeComposite); + + // Label for range axis + GridDataFactory.fillDefaults().hint(angleLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(labelLabel2); + + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel2.getWidget()); + + // Min and max values for range axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin); + + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(minmax); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); + GridDataFactory.fillDefaults().hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(rangemax.getWidget()); + GridDataFactory.fillDefaults().hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(rangemin.getWidget()); + + // Range Color + GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(labelColor2); + + GridDataFactory.fillDefaults().grab(false, true).minSize(SWT.DEFAULT, SWT.DEFAULT).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker2); + + GridDataFactory.fillDefaults().applyTo(axisHide2); + + // Resize scrolled composite + Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java index c2d97014..9d669b6c 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -39,13 +39,13 @@ import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; import org.simantics.jfreechart.ChartPropertyOptions; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory; import org.simantics.jfreechart.chart.properties.BooleanSelectionListener; import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2; import org.simantics.jfreechart.chart.properties.DoublePropertyModifier2; import org.simantics.jfreechart.chart.properties.DoubleValidator; import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.jfreechart.chart.properties.TitleFactory; import org.simantics.jfreechart.chart.properties.TitleModifier; import org.simantics.layer0.Layer0; @@ -58,9 +58,10 @@ import org.simantics.sysdyn.JFreeChartResource; /** * General properties of a bar chart * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { +public class BarGeneralPropertiesTab extends AdjustableTab { private ScrolledComposite sc; private Composite composite; @@ -71,6 +72,24 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { private boolean showTime = true; private boolean showFilter = false; + private Group general; + private Composite labelColumn1; + private Composite propertyColumn1; + private Composite labelColumn2; + private Composite propertyColumn2; + private Label labelName; + private Label labelTitle; + private Label labelTime; + private Label labelType; + private Group typeGroup; + private Label labelOrientation; + private Group hideGroup; + private Label labelUse; + private Label labelPercent; + private Group filteringGroup; + private Button useFilter; + private TrackedText fraction; + private Point size; public BarGeneralPropertiesTab() { @@ -81,171 +100,6 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); } - @Override - public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - // Scrolled composite containing all of the properties in this tab - sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); - GridLayoutFactory.fillDefaults().applyTo(sc); - sc.setExpandHorizontal(true); - sc.setExpandVertical(true); - - composite = new Composite(sc, SWT.NONE); - if (showFilter) - GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite); - else - GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); - - // General properties - Group general = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(general); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general); - general.setText("General"); - - // first column: labels - Composite labelColumn1 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); - GridLayoutFactory.fillDefaults().applyTo(labelColumn1); - - // second column: name and title - Composite propertyColumn1 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); - GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); - - // third column: labels - Composite labelColumn2 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); - GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); - - // fourth column: type and time - Composite propertyColumn2 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); - GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); - - // Name - Label label = new Label(labelColumn1, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Name:"); - - name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); - name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); - name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); - name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - - // Type -// label = new Label(labelColumn2, SWT.NONE); -// GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); -// label.setText("Type:"); -// -// type = new TrackedCombo(propertyColumn2, support, SWT.BORDER | SWT.READ_ONLY); -// type.addModifyListener(new TypeModifyListener()); -// type.setItemFactory(new TypeItemFactory()); -// type.setSelectionFactory(new TypeSelectionFactory()); -// GridDataFactory.fillDefaults().applyTo(type.getWidget()); - label = new Label(labelColumn2, SWT.NONE); - label = new Label(propertyColumn2, SWT.NONE); - - // Title (Which is different than name) - label = new Label(labelColumn1, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Title:"); - - title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); - title.setTextFactory(new TitleFactory()); - title.addModifyListener(new TitleModifier()); - title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - - if (showTime) { - // Time - label = new Label(labelColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Time:"); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - } - - Group typeGroup = new Group(composite,SWT.NONE); - GridDataFactory.fillDefaults().applyTo(typeGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(typeGroup); - typeGroup.setText("Visuals"); - - label = new Label(typeGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Type:"); - - type = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY); - type.addModifyListener(new TypeModifyListener()); - type.setItemFactory(new TypeItemFactory()); - type.setSelectionFactory(new TypeSelectionFactory()); - GridDataFactory.fillDefaults().applyTo(type.getWidget()); - - label = new Label(typeGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Orientation:"); - - orientation = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY); - orientation.addModifyListener(new OrientationModifyListener()); - orientation.setItemFactory(new OrientationItemFactory()); - orientation.setSelectionFactory(new OrientationSelectionFactory()); - GridDataFactory.fillDefaults().applyTo(type.getWidget()); - - - // Group for hide options - Group hideGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(hideGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); - hideGroup.setText("Hide"); - - hgrid = new Button(hideGroup, support, SWT.CHECK); - hgrid.setText("Grid"); - hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); - hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); - htitle = new Button(hideGroup, support, SWT.CHECK); - htitle.setText("Title"); - htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); - htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); - hlegend = new Button(hideGroup, support, SWT.CHECK); - hlegend.setText("Legend"); - hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); - hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); - - if (showFilter) { - Group filteringGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(filteringGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); - filteringGroup.setText("Filter"); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Use:"); - Button useFilter = new Button(filteringGroup, support, SWT.CHECK); - useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); - useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Percent:"); - TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); - fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); - fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); - fraction.setInputValidator(new DoubleValidator(true)); - fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); - } - - // Resize scrolled composite - sc.setContent(composite); - Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); - sc.setMinSize(size); - - - } - /** * * @author Teemu Lempinen @@ -383,4 +237,270 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { } } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + // Scrolled composite containing all of the properties in this tab + sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); + sc.setExpandHorizontal(true); + sc.setExpandVertical(true); + + composite = new Composite(sc, SWT.NONE); + + // General properties + general = new Group(composite, SWT.NONE); + general.setText("General"); + + // first column: labels + labelColumn1 = new Composite(general, SWT.NONE); + + // second column: name and title + propertyColumn1 = new Composite(general, SWT.NONE); + + // third column: labels + labelColumn2 = new Composite(general, SWT.NONE); + + // fourth column: type and time + propertyColumn2 = new Composite(general, SWT.NONE); + + // Name + labelName = new Label(labelColumn1, SWT.NONE); + labelName.setText("Name:"); + + name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); + name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); + name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); + name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); + + labelTitle = new Label(labelColumn2, SWT.NONE); + labelTitle = new Label(propertyColumn2, SWT.NONE); + + // Title (Which is different than name) + labelTitle = new Label(labelColumn1, SWT.NONE); + labelTitle.setText("Title:"); + + title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); + title.setTextFactory(new TitleFactory()); + title.addModifyListener(new TitleModifier()); + title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); + + if (showTime) { + // Time + labelTime = new Label(labelColumn2, SWT.NONE); + labelTime.setText("Time:"); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + } + + typeGroup = new Group(composite,SWT.NONE); + typeGroup.setText("Visuals"); + + labelType = new Label(typeGroup, SWT.NONE); + labelType.setText("Type:"); + + type = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY); + type.addModifyListener(new TypeModifyListener()); + type.setItemFactory(new TypeItemFactory()); + type.setSelectionFactory(new TypeSelectionFactory()); + + labelOrientation = new Label(typeGroup, SWT.NONE); + labelOrientation.setText("Orientation:"); + + orientation = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY); + orientation.addModifyListener(new OrientationModifyListener()); + orientation.setItemFactory(new OrientationItemFactory()); + orientation.setSelectionFactory(new OrientationSelectionFactory()); + + + // Group for hide options + hideGroup = new Group(composite, SWT.NONE); + hideGroup.setText("Hide"); + + hgrid = new Button(hideGroup, support, SWT.CHECK); + hgrid.setText("Grid"); + hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); + hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); + htitle = new Button(hideGroup, support, SWT.CHECK); + htitle.setText("Title"); + htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); + htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); + hlegend = new Button(hideGroup, support, SWT.CHECK); + hlegend.setText("Legend"); + hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); + hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); + + if (showFilter) { + filteringGroup = new Group(composite, SWT.NONE); + filteringGroup.setText("Filter"); + labelUse = new Label(filteringGroup, SWT.NONE); + labelUse.setText("Use:"); + useFilter = new Button(filteringGroup, support, SWT.CHECK); + useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); + useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); + labelPercent = new Label(filteringGroup, SWT.NONE); + labelPercent.setText("Percent:"); + fraction = new TrackedText(filteringGroup, support, SWT.BORDER); + fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); + fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); + fraction.setInputValidator(new DoubleValidator(true)); + fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); + } + + // Resize scrolled composite + sc.setContent(composite); + + } + + @Override + protected void createControlLayoutVertical() { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); + GridLayoutFactory.fillDefaults().applyTo(labelColumn1); + + // second column: name and title + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); + + // third column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); + + // fourth column: type and time + GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); + GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); + + // Name + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); + + if (showTime) { + // Time + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime); + + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + } + + GridDataFactory.fillDefaults().applyTo(typeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(typeGroup); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelType); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelOrientation); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + if (showFilter) { + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + } + + size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); + GridLayoutFactory.fillDefaults().applyTo(labelColumn1); + + // second column: name and title + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); + + // third column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); + + // fourth column: type and time + GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); + GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); + + // Name + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); + + if (showTime) { + // Time + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime); + + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + } + + GridDataFactory.fillDefaults().applyTo(typeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(typeGroup); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelType); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelOrientation); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + if (showFilter) { + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + } + + size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } + } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java index 3dd56229..51eefa75 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -39,7 +39,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.management.ISessionContext; import org.simantics.jfreechart.chart.ChartUtils; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.xyline.AxisAndVariablesExplorerComposite; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.JFreeChartResource; @@ -49,9 +49,10 @@ import org.simantics.utils.ui.AdaptionUtils; /** * Tab containing the series of a bar chart * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class BarSeriesTab extends LabelPropertyTabContributor implements Widget { +public class BarSeriesTab extends AdjustableTab implements Widget { private GraphExplorerComposite explorer; private ScrolledComposite propertyContainer; @@ -60,56 +61,14 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget private Resource chartResource; private BarSeriesPropertyComposite spc; private int options; + private Composite composite; + private Composite buttonComposite; public BarSeriesTab(int options) { additionalSupport = new WidgetSupportImpl(); this.options = options; } - @Override - public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) { - support.register(this); - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // (Ontology-based) GraphExplorer displaying variables in a bar chart - explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( - "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); - explorer.setBrowseContexts(JFreeChartResource.URIs.BarSeriesBrowseContext); - explorer.setInputSource(new SingleSelectionInputSource( - Resource.class)); - explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning - explorer.finish(); - - ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateSelection(context); - } - }); - GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - - // Scrolled composite for displaying properties of a selection in explorer - propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); - GridLayoutFactory.fillDefaults().applyTo(propertyContainer); - propertyContainer.setExpandHorizontal(true); - propertyContainer.setExpandVertical(true); - - // Buttons for adding and removing variables from a pie plot - Composite buttonComposite = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(buttonComposite); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); - - add = new Button(buttonComposite, additionalSupport, SWT.NONE); - add.setText("Add"); - add.addSelectionListener(new NewVariableListener(context)); - - remove = new Button(buttonComposite, additionalSupport, SWT.NONE); - remove.setText("Remove"); - remove.addSelectionListener(new RemoveListener(context)); - } - /** * Updates the content of propertyContainer * @param context @@ -209,5 +168,75 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget chartResource = AdaptionUtils.adaptToSingle(input, Resource.class); } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + final ISessionContext context, WidgetSupport support) { + support.register(this); + composite = new Composite(body, SWT.NONE); + + // (Ontology-based) GraphExplorer displaying variables in a bar chart + explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( + "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); + explorer.setBrowseContexts(JFreeChartResource.URIs.BarSeriesBrowseContext); + explorer.setInputSource(new SingleSelectionInputSource( + Resource.class)); + explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning + explorer.finish(); + + ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateSelection(context); + } + }); + + // Scrolled composite for displaying properties of a selection in explorer + propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); + propertyContainer.setExpandHorizontal(true); + propertyContainer.setExpandVertical(true); + + // Buttons for adding and removing variables from a pie plot + buttonComposite = new Composite(composite, SWT.NONE); + + add = new Button(buttonComposite, additionalSupport, SWT.NONE); + add.setText("Add"); + add.addSelectionListener(new NewVariableListener(context)); + + remove = new Button(buttonComposite, additionalSupport, SWT.NONE); + remove.setText("Remove"); + remove.addSelectionListener(new RemoveListener(context)); + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(150, 200).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().hint(150, 130).span(1, 1).grab(true, false).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding and removing variables from a pie plot + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding and removing variables from a pie plot + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } + } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java index e7dfd430..e32a1c7f 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -28,13 +28,13 @@ import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; import org.simantics.jfreechart.ChartPropertyOptions; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory; import org.simantics.jfreechart.chart.properties.BooleanSelectionListener; import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2; import org.simantics.jfreechart.chart.properties.DoublePropertyModifier2; import org.simantics.jfreechart.chart.properties.DoubleValidator; import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.jfreechart.chart.properties.TitleFactory; import org.simantics.jfreechart.chart.properties.TitleModifier; import org.simantics.layer0.Layer0; @@ -45,9 +45,10 @@ import org.simantics.sysdyn.JFreeChartResource; /** * General properties of a pie chart * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { +public class PieGeneralPropertiesTab extends AdjustableTab { private ScrolledComposite sc; private Composite composite; @@ -56,6 +57,21 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { private boolean showTime = true; private boolean showFilter = false; + private Group general; + private Composite labelColumn1; + private Composite propertyColumn1; + private Composite labelColumn2; + private Composite propertyColumn2; + private Label labelName; + private Label labelTitle; + private Label labelTime; + private Group hideGroup; + private Group filteringGroup; + private Label labelUse; + private Label labelPercent; + private Button useFilter; + private TrackedText fraction; + private Point size; public PieGeneralPropertiesTab() { @@ -66,95 +82,70 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); } - @Override - public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - // Scrolled composite containing all of the properties in this tab + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + // Scrolled composite containing all of the properties in this tab sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); - GridLayoutFactory.fillDefaults().applyTo(sc); sc.setExpandHorizontal(true); sc.setExpandVertical(true); composite = new Composite(sc, SWT.NONE); - if (showFilter) - GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); - else - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); // General properties - Group general = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(general); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general); + general = new Group(composite, SWT.NONE); general.setText("General"); // first column: labels - Composite labelColumn1 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); - GridLayoutFactory.fillDefaults().applyTo(labelColumn1); + labelColumn1 = new Composite(general, SWT.NONE); // first column: name and title - Composite propertyColumn1 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); - GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); + propertyColumn1 = new Composite(general, SWT.NONE); // first column: labels - Composite labelColumn2 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); - GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); + labelColumn2 = new Composite(general, SWT.NONE); // first column: type and time - Composite propertyColumn2 = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); - GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); + propertyColumn2 = new Composite(general, SWT.NONE); // Name - Label label = new Label(labelColumn1, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Name:"); + labelName = new Label(labelColumn1, SWT.NONE); + labelName.setText("Name:"); name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); // Dummy data for now. Waiting for different pie chart types - label = new Label(labelColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(label); - label.setText(""); + labelTitle = new Label(labelColumn2, SWT.NONE); + labelTitle.setText(""); - label = new Label(propertyColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(label); - label.setText(""); + labelTitle = new Label(propertyColumn2, SWT.NONE); + labelTitle.setText(""); // Title (Which is different than name) - label = new Label(labelColumn1, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Title:"); + labelTitle = new Label(labelColumn1, SWT.NONE); + labelTitle.setText("Title:"); title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); title.setTextFactory(new TitleFactory()); title.addModifyListener(new TitleModifier()); title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); if (showTime) { // Time - label = new Label(labelColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Time:"); + labelTime = new Label(labelColumn2, SWT.NONE); + labelTime.setText("Time:"); time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); time.setInputValidator(new DoubleValidator(true)); time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); } // Group for hide options - Group hideGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(hideGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + hideGroup = new Group(composite, SWT.NONE); hideGroup.setText("Hide"); htitle = new Button(hideGroup, support, SWT.CHECK); @@ -171,21 +162,16 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels)); if (showFilter) { - Group filteringGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(filteringGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + filteringGroup = new Group(composite, SWT.NONE); filteringGroup.setText("Filter"); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Use:"); - Button useFilter = new Button(filteringGroup, support, SWT.CHECK); + labelUse = new Label(filteringGroup, SWT.NONE); + labelUse.setText("Use:"); + useFilter = new Button(filteringGroup, support, SWT.CHECK); useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Percent:"); - TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + labelPercent = new Label(filteringGroup, SWT.NONE); + labelPercent.setText("Percent:"); + fraction = new TrackedText(filteringGroup, support, SWT.BORDER); fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); fraction.setInputValidator(new DoubleValidator(true)); @@ -193,7 +179,141 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { } sc.setContent(composite); - Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + } + + @Override + protected void createControlLayoutVertical() { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); + GridLayoutFactory.fillDefaults().applyTo(labelColumn1); + + // first column: name and title + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); + + // first column: type and time + GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); + GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); + + // Name + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + // Dummy data for now. Waiting for different pie chart types + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelTitle); + + // Title (Which is different than name) + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); + + if (showTime) { + // Time + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime); + + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + } + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + if (showFilter) { + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + } + + size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); sc.setMinSize(size); - } + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); + GridLayoutFactory.fillDefaults().applyTo(labelColumn1); + + // first column: name and title + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); + + // first column: labels + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); + GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); + + // first column: type and time + GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); + GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); + + // Name + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + // Dummy data for now. Waiting for different pie chart types + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(false, true).applyTo(labelTitle); + + // Title (Which is different than name) + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); + + if (showTime) { + // Time + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime); + + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + } + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + if (showFilter) { + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + } + + size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java index 4e4b7e80..ad0ca645 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -39,7 +39,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.management.ISessionContext; import org.simantics.jfreechart.chart.ChartUtils; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.xyline.AxisAndVariablesExplorerComposite; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.JFreeChartResource; @@ -49,9 +49,10 @@ import org.simantics.utils.ui.AdaptionUtils; /** * Tab for modifying series in a pie chart configuration * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class PieSeriesTab extends LabelPropertyTabContributor implements Widget { +public class PieSeriesTab extends AdjustableTab implements Widget { private GraphExplorerComposite explorer; private ScrolledComposite propertyContainer; @@ -59,57 +60,14 @@ public class PieSeriesTab extends LabelPropertyTabContributor implements Widget private Button add, remove; private Resource chartResource; private int options; + private Composite composite; + private Composite buttonComposite; public PieSeriesTab(int options) { additionalSupport = new WidgetSupportImpl(); this.options = options; } - @Override - public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) { - support.register(this); - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // (Ontology-based) GraphExplorer displaying variables of a pie chart - explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( - "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); - explorer.setBrowseContexts(JFreeChartResource.URIs.PieSeriesBrowseContext); - explorer.setInputSource(new SingleSelectionInputSource( - Resource.class)); - explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning - explorer.finish(); - - ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateSelection(context); - } - }); - GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - - // Scrolled composite for displaying properties of a selection in explorer - propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); - GridLayoutFactory.fillDefaults().applyTo(propertyContainer); - propertyContainer.setExpandHorizontal(true); - propertyContainer.setExpandVertical(true); - - - // Buttons for adding and removing variables from a pie plot - Composite buttonComposite = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(buttonComposite); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); - - add = new Button(buttonComposite, additionalSupport, SWT.NONE); - add.setText("Add"); - add.addSelectionListener(new NewVariableListener(context)); - - remove = new Button(buttonComposite, additionalSupport, SWT.NONE); - remove.setText("Remove"); - remove.addSelectionListener(new RemoveListener(context)); - } - /** * Updates the content of propertyContainer * @param context @@ -209,4 +167,75 @@ public class PieSeriesTab extends LabelPropertyTabContributor implements Widget chartResource = AdaptionUtils.adaptToSingle(input, Resource.class); } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + final ISessionContext context, WidgetSupport support) { + support.register(this); + composite = new Composite(body, SWT.NONE); + + // (Ontology-based) GraphExplorer displaying variables of a pie chart + explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( + "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); + explorer.setBrowseContexts(JFreeChartResource.URIs.PieSeriesBrowseContext); + explorer.setInputSource(new SingleSelectionInputSource( + Resource.class)); + explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning + explorer.finish(); + + ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateSelection(context); + } + }); + + // Scrolled composite for displaying properties of a selection in explorer + propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); + propertyContainer.setExpandHorizontal(true); + propertyContainer.setExpandVertical(true); + + + // Buttons for adding and removing variables from a pie plot + buttonComposite = new Composite(composite, SWT.NONE); + + add = new Button(buttonComposite, additionalSupport, SWT.NONE); + add.setText("Add"); + add.addSelectionListener(new NewVariableListener(context)); + + remove = new Button(buttonComposite, additionalSupport, SWT.NONE); + remove.setText("Remove"); + remove.addSelectionListener(new RemoveListener(context)); + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(150, 200).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().hint(150, 190).span(1, 1).grab(true, false).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding and removing variables from a pie plot + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding and removing variables from a pie plot + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } + } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java index 14bdb4d4..366c29b0 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -35,6 +35,7 @@ import org.simantics.sysdyn.JFreeChartResource; * Composite for displaying axis properties in {@link XYLineAxisAndVariablesTab} * * @author Teemu Lempinen + * @author Tuomas Miettinen * */ public class AxisPropertyComposite extends Composite { @@ -43,9 +44,17 @@ public class AxisPropertyComposite extends Composite { Button tlabels, tmarks; public AxisPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) { + super(parent, style); + init(parent, context, support, style, false); + } + + public AxisPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style, boolean vertical) { super(parent, style); - - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); + init(parent, context, support, style, vertical); + } + + private void init(Composite parent, ISessionContext context, WidgetSupport support, int style, boolean vertical) { + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(vertical ? 2 : 3).applyTo(this); // Label (units) Label label = new Label(this, SWT.NONE); @@ -56,7 +65,7 @@ public class AxisPropertyComposite extends Composite { units.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); // FIXME: Units units.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); // FIXME: Units units.setColorProvider(new JFreeChartPropertyColorProvider(units.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(units.getWidget()); + GridDataFactory.fillDefaults().grab(true, false).span(vertical ? 1 : 2, 1).applyTo(units.getWidget()); // Minimum and maximum values @@ -71,7 +80,8 @@ public class AxisPropertyComposite extends Composite { min.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); min.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); min.setInputValidator(new DoubleValidator(true)); - + GridDataFactory.fillDefaults().hint(55, SWT.DEFAULT).applyTo(min.getWidget()); + label = new Label(minmax, SWT.NONE); label.setText("Max:"); max = new TrackedText(minmax, support, SWT.BORDER); @@ -79,8 +89,15 @@ public class AxisPropertyComposite extends Composite { max.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); max.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); max.setInputValidator(new DoubleValidator(true)); - + GridDataFactory.fillDefaults().hint(55, SWT.DEFAULT).applyTo(max.getWidget()); + Composite hideComposite = null; + if (!vertical) { + // Tick and label visibility + hideComposite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().span(1, 2).applyTo(hideComposite); + } + // Color label = new Label(this, SWT.NONE); label.setText("Color:"); @@ -89,12 +106,17 @@ public class AxisPropertyComposite extends Composite { Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - // Tick and label visibility - Composite c = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).applyTo(c); - GridLayoutFactory.fillDefaults().applyTo(c); - Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(axisHide); - } + if (vertical) { + // Tick and label visibility + hideComposite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().span(2, 1).applyTo(hideComposite); + } + + // Fill hideComposite + GridLayoutFactory.fillDefaults().applyTo(hideComposite); + Composite axisHide = new AxisHidePropertyComposite(hideComposite, context, support, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(axisHide); + + } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineAxisAndVariablesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineAxisAndVariablesTab.java index 4081ce04..92d4f9e0 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineAxisAndVariablesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineAxisAndVariablesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -43,7 +43,7 @@ import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.management.ISessionContext; import org.simantics.db.request.Read; import org.simantics.jfreechart.chart.ChartUtils; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.JFreeChartResource; import org.simantics.ui.SimanticsUI; @@ -54,66 +54,22 @@ import org.simantics.utils.ui.AdaptionUtils; * PropertyTab displaying properties of axis and variables of a chart * * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor { +public class XYLineAxisAndVariablesTab extends AdjustableTab { private GraphExplorerComposite explorer; private ScrolledComposite propertyContainer; private Button addAxis, addVariable, remove; private WidgetSupportImpl additionalSupport; + private Composite composite; + private Composite buttonComposite; public XYLineAxisAndVariablesTab() { additionalSupport = new WidgetSupportImpl(); } - @Override - public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) { - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // (Ontology-based) GraphExplorer displaying range axis and variables mapped to those axis - explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( - "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); - explorer.setBrowseContexts(JFreeChartResource.URIs.ChartAxisAndVariablesBrowseContext); - explorer.setInputSource(new SingleSelectionInputSource( - Resource.class)); - explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning - explorer.finish(); - - ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateSelection(context); - } - }); - GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - - // Scrolled composite for displaying properties of a selection in explorer - propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); - GridLayoutFactory.fillDefaults().applyTo(propertyContainer); - propertyContainer.setExpandHorizontal(true); - propertyContainer.setExpandVertical(true); - - // Buttons for adding axis and variables and removing selected items from explorer - Composite buttonComposite = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(buttonComposite); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); - - addAxis = new Button(buttonComposite, support, SWT.NONE); - addAxis.setText("Add axis"); - addAxis.addSelectionListener(new NewAxisListener(context)); - - addVariable = new Button(buttonComposite, additionalSupport, SWT.NONE); - addVariable.setText("Add variable"); - addVariable.addSelectionListener(new NewVariableListener(context)); - - remove = new Button(buttonComposite, additionalSupport, SWT.NONE); - remove.setText("Remove"); - remove.addSelectionListener(new RemoveListener(context)); - } - /** * Updates the content of propertyContainer * @param context @@ -153,7 +109,7 @@ public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor { } if(typeUri.equals(JFreeChartResource.URIs.Axis)) { - AxisPropertyComposite apc = new AxisPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE); + AxisPropertyComposite apc = new AxisPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE, isVertical()); propertyContainer.setContent(apc); Point size = apc.computeSize(SWT.DEFAULT, SWT.DEFAULT); propertyContainer.setMinSize(size); @@ -297,4 +253,78 @@ public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor { RemoverUtil.remove(graph, input); } } + + + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + final ISessionContext context, WidgetSupport support) { + composite = new Composite(body, SWT.NONE); + + // (Ontology-based) GraphExplorer displaying range axis and variables mapped to those axis + explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( + "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); + explorer.setBrowseContexts(JFreeChartResource.URIs.ChartAxisAndVariablesBrowseContext); + explorer.setInputSource(new SingleSelectionInputSource( + Resource.class)); + explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning + explorer.finish(); + + ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateSelection(context); + } + }); + + // Scrolled composite for displaying properties of a selection in explorer + propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); + propertyContainer.setExpandHorizontal(true); + propertyContainer.setExpandVertical(true); + + // Buttons for adding axis and variables and removing selected items from explorer + buttonComposite = new Composite(composite, SWT.NONE); + + addAxis = new Button(buttonComposite, support, SWT.NONE); + addAxis.setText("Add axis"); + addAxis.addSelectionListener(new NewAxisListener(context)); + + addVariable = new Button(buttonComposite, additionalSupport, SWT.NONE); + addVariable.setText("Add variable"); + addVariable.addSelectionListener(new NewVariableListener(context)); + + remove = new Button(buttonComposite, additionalSupport, SWT.NONE); + remove.setText("Remove"); + remove.addSelectionListener(new RemoveListener(context)); + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(220, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 210).span(1, 1).grab(true, false).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding axis and variables and removing selected items from explorer + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().hint(SWT.DEFAULT, SWT.DEFAULT).span(1, 2).grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + // Buttons for adding axis and variables and removing selected items from explorer + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java index 51bd7136..2ab8ae98 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -22,6 +22,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbenchSite; @@ -43,12 +44,12 @@ import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.AxisHidePropertyComposite; import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory; import org.simantics.jfreechart.chart.properties.BooleanSelectionListener; import org.simantics.jfreechart.chart.properties.DoubleValidator; import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.jfreechart.chart.properties.RVIFactory; import org.simantics.jfreechart.chart.properties.RVIModifier; import org.simantics.jfreechart.chart.properties.TitleFactory; @@ -65,9 +66,10 @@ import org.simantics.utils.ui.AdaptionUtils; * PropertyTab displaying general properties and x-axis properties of a chart * * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor implements Widget { +public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget { private ScrolledComposite sc; private Composite composite; @@ -75,147 +77,19 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl private TrackedCombo type; private Button hgrid, htitle, hlegend; private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl(); - - @Override - public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - support.register(this); - - // Scrolled composite containing all of the properties in this tab - sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); - GridLayoutFactory.fillDefaults().applyTo(sc); - sc.setExpandHorizontal(true); - sc.setExpandVertical(true); - - composite = new Composite(sc, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // General properties - Group general = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(general); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general); - general.setText("General"); - - // Name - Label nameLabel = new Label(general, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel); - nameLabel.setText("Name:"); - nameLabel.setAlignment(SWT.RIGHT); - - Composite c = new Composite(general, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(c); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(c); - - name = new org.simantics.browsing.ui.swt.widgets.TrackedText(c, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); - name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); - name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); - name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - - // Type - Label label = new Label(c, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Type:"); - - type = new TrackedCombo(c, support, SWT.BORDER | SWT.READ_ONLY); - type.addModifyListener(new TypeModifyListener()); - type.setItemFactory(new TypeItemFactory()); - type.setSelectionFactory(new TypeSelectionFactory()); - GridDataFactory.fillDefaults().applyTo(type.getWidget()); - - // Title (Which is different than name) - label = new Label(general, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Title:"); - - title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget()); - title.setTextFactory(new TitleFactory()); - title.addModifyListener(new TitleModifier()); - title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - - // Group for hide options - Group hideGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(hideGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); - hideGroup.setText("Hide"); - - hgrid = new Button(hideGroup, support, SWT.CHECK); - hgrid.setText("Grid"); - hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); - hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); - htitle = new Button(hideGroup, support, SWT.CHECK); - htitle.setText("Title"); - htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); - htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); - hlegend = new Button(hideGroup, support, SWT.CHECK); - hlegend.setText("Legend"); - hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); - hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); - - - // X-Axis properties - Group xgroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(xgroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(xgroup); - xgroup.setText("X-axis"); - - // Variable for x-axis (default: empty == time) - Label xVariableLabel = new Label(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel); - xVariableLabel.setText("Variable:"); - - xvariable = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER); - xvariable.setTextFactory(new RVIFactory()); - xvariable.addModifyListener(new RVIModifier(xvariable.getWidget(), domainAxisSupport)); - xvariable.setColorProvider(new JFreeChartPropertyColorProvider(xvariable.getResourceManager())); - xvariable.setInputValidator(new VariableExistsValidator(support, xvariable, true)); - GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget()); - - Composite axisHide = new AxisHidePropertyComposite(xgroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide); - - // Label for x-axis - label = new Label(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Label:"); - - xlabel = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER); - xlabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); - xlabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); - xlabel.setColorProvider(new JFreeChartPropertyColorProvider(xlabel.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget()); - - // Min and max values for x-axis - label = new Label(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Min:"); - - Composite minmax = new Composite(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(minmax); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); - xmin = new TrackedText(minmax, domainAxisSupport, SWT.BORDER); - xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager())); - xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); - xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); - xmin.setInputValidator(new DoubleValidator(true)); - - label = new Label(minmax, SWT.NONE); - label.setText("Max:"); - xmax = new TrackedText(minmax, domainAxisSupport, SWT.BORDER); - xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager())); - xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); - xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); - xmax.setInputValidator(new DoubleValidator(true)); - - // Set the same width to both label rows - composite.layout(); - GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel); - - sc.setContent(composite); - Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); - sc.setMinSize(size); - } + private Group general; + private Label nameLabel; + private Label labelTitle; + private Label labelType; + private Group hideGroup; + private Group xgroup; + private Label xVariableLabel; + private Label labelMin; + private AxisHidePropertyComposite axisHide; + private Label labelLabel; + private Label labelMax; + private Composite xColumn1; + private Composite xColumn2; @Override public void setInput(final ISessionContext context, Object input) { @@ -231,9 +105,15 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl JFreeChartResource jfree = JFreeChartResource.getInstance(graph); Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot)); if(plot == null) return; - Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis); + final Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis); if(domainAxis == null) return; - domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis)); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis)); + } + }); + } }); } @@ -315,4 +195,259 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl } } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + support.register(this); + + // Scrolled composite containing all of the properties in this tab + sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); + sc.setExpandHorizontal(true); + sc.setExpandVertical(true); + + composite = new Composite(sc, SWT.NONE); + + // General properties + general = new Group(composite, SWT.NONE); + general.setText("General"); + + // Name + nameLabel = new Label(general, SWT.NONE); + nameLabel.setText("Name:"); + nameLabel.setAlignment(SWT.RIGHT); + + name = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER); + name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); + name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); + name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); + + // Type + labelType = new Label(general, SWT.NONE); + labelType.setText("Type:"); + + type = new TrackedCombo(general, support, SWT.BORDER | SWT.READ_ONLY); + type.addModifyListener(new TypeModifyListener()); + type.setItemFactory(new TypeItemFactory()); + type.setSelectionFactory(new TypeSelectionFactory()); + + // Title (Which is different than name) + labelTitle = new Label(general, SWT.NONE); + labelTitle.setText("Title:"); + + title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER); + title.setTextFactory(new TitleFactory()); + title.addModifyListener(new TitleModifier()); + title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); + + // Group for hide options + hideGroup = new Group(composite, SWT.NONE); + hideGroup.setText("Hide"); + + hgrid = new Button(hideGroup, support, SWT.CHECK); + hgrid.setText("Grid"); + hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); + hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); + htitle = new Button(hideGroup, support, SWT.CHECK); + htitle.setText("Title"); + htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); + htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); + hlegend = new Button(hideGroup, support, SWT.CHECK); + hlegend.setText("Legend"); + hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); + hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); + + + // X-Axis properties + xgroup = new Group(composite, SWT.NONE); + xgroup.setText("X-axis"); + + xColumn1 = new Composite(xgroup, SWT.NONE); + + // Variable for x-axis (default: empty == time) + xVariableLabel = new Label(xColumn1, SWT.NONE); + xVariableLabel.setText("Variable:"); + + xvariable = new TrackedText(xColumn1, domainAxisSupport, SWT.BORDER); + xvariable.setTextFactory(new RVIFactory()); + xvariable.addModifyListener(new RVIModifier(xvariable.getWidget(), domainAxisSupport)); + xvariable.setColorProvider(new JFreeChartPropertyColorProvider(xvariable.getResourceManager())); + xvariable.setInputValidator(new VariableExistsValidator(support, xvariable, true)); + + // Label for x-axis + labelLabel = new Label(xColumn1, SWT.NONE); + labelLabel.setText("Label:"); + + xlabel = new TrackedText(xColumn1, domainAxisSupport, SWT.BORDER); + xlabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); + xlabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); + xlabel.setColorProvider(new JFreeChartPropertyColorProvider(xlabel.getResourceManager())); + + xColumn2 = new Composite(xgroup, SWT.NONE); + + // Min value for x-axis + labelMin = new Label(xColumn2, SWT.NONE); + labelMin.setText("Min:"); + labelMin.setAlignment(SWT.RIGHT); + + xmin = new TrackedText(xColumn2, domainAxisSupport, SWT.BORDER); + xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager())); + xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); + xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); + xmin.setInputValidator(new DoubleValidator(true)); + + // Max value for x-axis + labelMax = new Label(xColumn2, SWT.NONE); + labelMax.setText("Max:"); + + xmax = new TrackedText(xColumn2, domainAxisSupport, SWT.BORDER); + xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager())); + xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); + xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); + xmax.setInputValidator(new DoubleValidator(true)); + + // Axis hide buttons + axisHide = new AxisHidePropertyComposite(composite, context, domainAxisSupport, SWT.NONE); + + sc.setContent(composite); + } + + @Override + protected void createControlLayoutVertical() { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general); + + // Name + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + // Type + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelType); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + // Title (Which is different than name) + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(title.getWidget()); + + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + // X-Axis properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(xgroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(1).applyTo(xgroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xColumn1); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn1); + + // Variable for x-axis (default: empty == time) + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget()); + + // Label for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget()); + + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn2); + + // Min value for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin); + GridDataFactory.fillDefaults().applyTo(xmin.getWidget()); + + // Max value for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMax); + GridDataFactory.fillDefaults().applyTo(xmax.getWidget()); + + // Axis hide buttons + GridDataFactory.fillDefaults().applyTo(axisHide); + + // Set the same width to both label rows + composite.layout(); + GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel); + GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(labelMin); + + Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + // Scrolled composite containing all of the properties in this tab + GridDataFactory.fillDefaults().grab(true, true).applyTo(sc); + GridLayoutFactory.fillDefaults().applyTo(sc); + + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + // General properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(general); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general); + + // Name + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + // Type + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelType); + + GridDataFactory.fillDefaults().applyTo(type.getWidget()); + + // Title (Which is different than name) + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelTitle); + + GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(title.getWidget()); + + // Group for hide options + GridDataFactory.fillDefaults().applyTo(hideGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup); + + // X-Axis properties + GridDataFactory.fillDefaults().grab(true, false).applyTo(xgroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xgroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xColumn1); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn1); + + // Variable for x-axis (default: empty == time) + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget()); + + // Label for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget()); + + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn2); + + // Min value for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin); + GridDataFactory.fillDefaults().applyTo(xmin.getWidget()); + + // Max value for x-axis + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMax); + GridDataFactory.fillDefaults().applyTo(xmax.getWidget()); + + // Axis hide buttons + GridDataFactory.fillDefaults().applyTo(axisHide); + + // Set the same width to both label rows + composite.layout(); + GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel); + + Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.setMinSize(size); + } + } \ No newline at end of file diff --git a/org.simantics.sysdyn.feature/feature.xml b/org.simantics.sysdyn.feature/feature.xml index e9e11f98..3aac2311 100644 --- a/org.simantics.sysdyn.feature/feature.xml +++ b/org.simantics.sysdyn.feature/feature.xml @@ -13,7 +13,7 @@ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn b/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn new file mode 100644 index 00000000..cacb3605 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdynModule b/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdynModule new file mode 100644 index 00000000..31429c2c Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdynModule differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn b/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn new file mode 100644 index 00000000..334ca7e3 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdynModule b/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdynModule new file mode 100644 index 00000000..78e03cc6 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdynModule differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn b/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn new file mode 100644 index 00000000..2abde7d6 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule b/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule new file mode 100644 index 00000000..c4cfc408 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn b/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn new file mode 100644 index 00000000..caa66cee Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule b/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule new file mode 100644 index 00000000..1186b743 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn b/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn new file mode 100644 index 00000000..5a96a7e6 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/molecules/references.txt b/org.simantics.sysdyn.feature/rootfiles/molecules/references.txt new file mode 100644 index 00000000..09ad135c --- /dev/null +++ b/org.simantics.sysdyn.feature/rootfiles/molecules/references.txt @@ -0,0 +1,3 @@ +The molecules in this folder are collected from: + +Hines, Jim. 2005. Molecules of Structure - Building Blocks for System Dynamics Models. Version 2.02. Available at: http://www.systemswiki.org/images/a/a8/Molecule.pdf . diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn new file mode 100644 index 00000000..bcbd16c2 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.tg b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.tg deleted file mode 100644 index c00a8865..00000000 Binary files a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.tg and /dev/null differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn new file mode 100644 index 00000000..60edfdfa Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.tg b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.tg deleted file mode 100644 index cedf440a..00000000 Binary files a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.tg and /dev/null differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn new file mode 100644 index 00000000..2a8f549d Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.tg b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.tg deleted file mode 100644 index 3a1c507a..00000000 Binary files a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.tg and /dev/null differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn new file mode 100644 index 00000000..132c2fc7 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.tg b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.tg deleted file mode 100644 index 4c49bbb3..00000000 Binary files a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.tg and /dev/null differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn new file mode 100644 index 00000000..d82832a4 Binary files /dev/null and b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.tg b/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.tg deleted file mode 100644 index 1dc23316..00000000 Binary files a/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.tg and /dev/null differ diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/references.txt b/org.simantics.sysdyn.feature/rootfiles/sampleModels/references.txt new file mode 100644 index 00000000..77f7b301 --- /dev/null +++ b/org.simantics.sysdyn.feature/rootfiles/sampleModels/references.txt @@ -0,0 +1,12 @@ +The sample models in this folder are collected from the "System Zoo" books by Bossel: + +Hartmut Bossel. 2007. System Zoo 2 Simulation Models - Climate, Ecosystems, Resources. BoD. +* Discovery And Exploitation Of Resources +* Global Carbon Cycle +* Predator And Limited Prey +* Resource Exploitation Use Recycling +* Tourists Environments And Hotel Facilities + +Hartmut Bossel. 2007. System Zoo 3 Simulation Models - Economy, Society, Development. BoD. + + diff --git a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF index 119c139f..25abc27c 100644 --- a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF +++ b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Simantics System Dynamics UI Bundle-SymbolicName: org.simantics.sysdyn.ui;singleton:=true -Bundle-Version: 1.7.0.qualifier +Bundle-Version: 1.8.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2", org.simantics.scenegraph;bundle-version="0.9.0", diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 4d0dfc24..c688debd 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -1859,7 +1859,6 @@ - implements IDoubleClickabl @Override public boolean handleDoubleClick() { - return true; + return false; } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java index bb04e70e..34f8fd71 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java @@ -67,6 +67,8 @@ public class DependencyRouter implements IRouter2 { } public static Arc2D createArc(Arc2D arc, Shape beginBounds, Shape endBounds, double angle) { + if (beginBounds == null || endBounds == null) + return new Arc2D.Double(); double x0 = beginBounds.getBounds2D().getCenterX(); double y0 = beginBounds.getBounds2D().getCenterY(); double x1 = endBounds.getBounds2D().getCenterX(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynTextElementNoBounds.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynTextElementNoBounds.java index 76defa5b..3d6eda9e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynTextElementNoBounds.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynTextElementNoBounds.java @@ -108,6 +108,8 @@ public class SysdynTextElementNoBounds extends TextElementNoBounds { @Override public void textEditingStarted() { TextNode node = (TextNode) e.getHint(SG_NODE); + if (node == null) + return; textBeforeEdit = node.getText(); if(component != null) return; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DisposeExperiment.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DisposeExperiment.java index 83ef73bb..45c3ef94 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DisposeExperiment.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DisposeExperiment.java @@ -31,7 +31,7 @@ public class DisposeExperiment extends AbstractHandler { project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); IExperiment experiment = manager.getActiveExperiment(); if (experiment != null) - experiment.shutdown(); + experiment.shutdown(null); return null; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java index f4a52dfb..7d690601 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -16,6 +16,7 @@ import java.util.concurrent.Semaphore; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; @@ -67,7 +68,11 @@ public class SysdynExperimentActivator { new Job(jobName) { @Override protected IStatus run(final IProgressMonitor monitor) { - return SysdynExperimentActivator.activate(monitor, project, experimentManager, experiment); + try { + return SysdynExperimentActivator.activate(monitor, project, experimentManager, experiment); + } finally { + monitor.done(); + } } }.schedule(); } @@ -95,58 +100,66 @@ public class SysdynExperimentActivator { } private IStatus activateExperiment(final IProgressMonitor monitor, final IProject project, final IExperimentManager manager, final Resource experimentResource) { - monitor.beginTask("Activating experiment", IProgressMonitor.UNKNOWN); - try { - SysdynExperimentManagerListener.listenManager(manager); - IExperiment[] experiments = manager.getExperiments(); - for(IExperiment e : experiments) - if(e.getState() != ExperimentState.DISPOSED) - e.shutdown(); - - final Semaphore activated = new Semaphore(0); - final DataContainer problem = new DataContainer(); - manager.startExperiment(experimentResource, new IExperimentActivationListener() { + final SubMonitor mon = SubMonitor.convert(monitor, "Activating experiment", 100000); - @Override - public void onExperimentActivated(final IExperiment experiment) { - MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null)); - activated.release(); - } - @Override - public void onFailure(Throwable e) { - problem.set(e); - activated.release(); - } - @Override - public void onMessage(IStatus message) { - MessageService.getDefault().log(message); - /*ILogger logger = MessageService.getDefault(); + SysdynExperimentManagerListener.listenManager(manager); + IExperiment[] experiments = manager.getExperiments(); + SubMonitor shutdownMon = mon.newChild(10000); + int workPerExperiment; + if (experiments.length > 0) + workPerExperiment = 10000 / experiments.length; + else + workPerExperiment = 10000; + for(IExperiment e : experiments) + if(e.getState() != ExperimentState.DISPOSED) + e.shutdown(shutdownMon.newChild(workPerExperiment)); + mon.setWorkRemaining(90000); + + final Semaphore activated = new Semaphore(0); + final DataContainer problem = new DataContainer(); + manager.startExperiment(experimentResource, new IExperimentActivationListener() { + + @Override + public void onExperimentActivated(final IExperiment experiment) { + MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null)); + activated.release(); + } + @Override + public void onFailure(Throwable e) { + problem.set(e); + activated.release(); + } + @Override + public void onMessage(IStatus message) { + MessageService.getDefault().log(message); + /*ILogger logger = MessageService.getDefault(); MultiStatus init = new MultiStatus(Activator.PLUGIN_ID, 0, "Activating experiment", null); for (String msg : messages) { init.add(new Status(IStatus.INFO, Activator.PLUGIN_ID, msg)); } logger.log(init);*/ + } + @Override + public IProgressMonitor getProgressMonitor() { + return mon; + } + }, true); + try { + activated.acquire(); + Throwable t = problem.get(); + if (t != null) { + if (t instanceof ExperimentLoadingFailed) { + ErrorLogger.defaultLogError(t); + ShowMessage.showError("Experiment Activation Failed", t.getMessage()); + } else { + ExceptionUtils.logAndShowError(t); } - }, true); - try { - activated.acquire(); - Throwable t = problem.get(); - if (t != null) { - if (t instanceof ExperimentLoadingFailed) { - ErrorLogger.defaultLogError(t); - ShowMessage.showError("Experiment Activation Failed", t.getMessage()); - } else { - ExceptionUtils.logAndShowError(t); - } - } - - return Status.OK_STATUS; - //return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Experiment activation failed, see exception for details.", problem.get()); - } catch (InterruptedException e) { - return Status.CANCEL_STATUS; } - } finally { - monitor.done(); + + return Status.OK_STATUS; + //return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Experiment activation failed, see exception for details.", problem.get()); + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java index 002abbbd..251ab7a4 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java @@ -85,7 +85,7 @@ public class ExportFunctionLibrary extends AbstractHandler { if(path.isEmpty() || !(new File(path).exists())) path = Platform.getLocation().toOSString(); fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdynFunctions"}; fd.setFilterExtensions(filterExt); fd.setOverwrite(true); final String selected = fd.open(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelAsButtonHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelAsButtonHandler.java index 57a6cb42..8e631842 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelAsButtonHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelAsButtonHandler.java @@ -13,7 +13,9 @@ package org.simantics.sysdyn.ui.handlers.exports; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.db.Resource; +import org.simantics.utils.ui.workbench.WorkbenchUtils; /** * Exports a selected model asking the location. @@ -27,15 +29,19 @@ public class ExportModelAsButtonHandler extends ExportModelButtonHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { + status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) ); + final Resource model = determineModel(event); if (model == null) return null; String selected = getAbsolutePath(model, event, true); - if (selected != null) + if (selected != null) { createFile(model, selected); - + setExportStatus(model, selected); + } + return null; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelButtonHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelButtonHandler.java index a9ee8a32..9954ae65 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelButtonHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelButtonHandler.java @@ -30,6 +30,7 @@ import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils; import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; import org.simantics.utils.ui.AdaptionUtils; +import org.simantics.utils.ui.workbench.WorkbenchUtils; /** * Exports a selected model without asking the location. @@ -43,16 +44,20 @@ public class ExportModelButtonHandler extends ExportModelHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { + status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) ); + final Resource model = determineModel(event); if (model == null) return null; String selected = getAbsolutePath(model, event, false); - if (selected != null) + if (selected != null) { createFile(model, selected); - - return null; + setExportStatus(model, selected); + } + + return null; } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java index ee0efbb9..92a5ac8e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java @@ -18,6 +18,7 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; @@ -43,6 +44,7 @@ import org.simantics.sysdyn.ui.Activator; import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI; import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; +import org.simantics.utils.ui.workbench.WorkbenchUtils; /** * Exports a selected model @@ -54,21 +56,55 @@ import org.simantics.ui.utils.ResourceAdaptionUtils; */ public class ExportModelHandler extends AbstractHandler { + protected static IStatusLineManager status; + @Override public Object execute(ExecutionEvent event) throws ExecutionException { + status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) ); + final Resource model = determineModel(event); if (model == null) return null; String selected = getAbsolutePath(model, event, true); - if (selected != null) + if (selected != null) { createFile(model, selected); + setExportStatus(model, selected); + } - return null; + return null; } - + + /** + * Create the export file. + * @param model Model which is exported. + * @param fileName Full name of the file. + */ + protected void setExportStatus(final Resource model, final String fileName) { + try { + String modelName = SimanticsUI.getSession().syncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + if (!graph.hasStatement(model, Layer0.getInstance(graph).PartOf)) + return null; + Layer0 l0 = Layer0.getInstance(graph); + return graph.syncRequest(new PossibleRelatedValue(model, l0.HasName, Bindings.STRING )); + } + + }); + + if (modelName != null) + setStatus("Saved model \"" + modelName + "\" to " + fileName); + + } catch (DatabaseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** * Create the export file. * @param model Model which is exported. @@ -199,7 +235,7 @@ public class ExportModelHandler extends AbstractHandler { fd.setFileName(name); fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdyn"}; fd.setFilterExtensions(filterExt); fd.setOverwrite(true); fullPath = fd.open(); @@ -236,4 +272,10 @@ public class ExportModelHandler extends AbstractHandler { return selected; } + + protected static void setStatus(final String message) { + if (status != null) + status.setMessage(message); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java index 7d7e7fcf..6a0cc12f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java @@ -154,7 +154,7 @@ public class ExportModuleHandler extends AbstractHandler { if(path.isEmpty() || !(new File(path).exists())) path = Platform.getLocation().toOSString(); fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdynModule"}; fd.setFilterExtensions(filterExt); fd.setOverwrite(true); final String selected = fd.open(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java index cdd40a04..4e227e73 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java @@ -65,7 +65,7 @@ public class ImportFunctionLibrary extends AbstractHandler { if(path.isEmpty() || !(new File(path).exists())) path = Platform.getLocation().toOSString(); fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdynFunctions; *.tg", "*.*"}; fd.setFilterExtensions(filterExt); final String selected = fd.open(); if(selected == null) return null; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java index daba04a4..48daeb98 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java @@ -18,7 +18,6 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; @@ -45,10 +44,14 @@ public class ImportModelHandler extends AbstractHandler { fd.setText("Import Model"); String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH); - if(path.isEmpty() || !(new File(path).exists())) - path = Platform.getLocation().toOSString(); + if(path.isEmpty() || !(new File(path).exists())){ + String execDir = System.getProperty("user.dir"); + String slash = System.getProperty("file.separator"); + path = execDir + slash + "sampleModels"; + } + fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdyn; *.tg", "*.*"}; fd.setFilterExtensions(filterExt); final String selected = fd.open(); if(selected == null) return null; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java index e4645106..19c40314 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java @@ -61,12 +61,12 @@ public class ImportModuleHandler extends AbstractHandler { if(path.isEmpty() || !(new File(path).exists())) path = Platform.getLocation().toOSString(); fd.setFilterPath(path); - String[] filterExt = {"*.tg"}; + String[] filterExt = {"*.sysdynModule; *.tg", "*.*"}; fd.setFilterExtensions(filterExt); final String selected = fd.open(); if(selected == null) return null; - Job job = new DatabaseJob("Import model") { + Job job = new DatabaseJob("Import module") { @Override protected IStatus run(IProgressMonitor monitor) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayDependencyTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayDependencyTab.java index e7991a22..a94c8a14 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayDependencyTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayDependencyTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -33,6 +33,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.elements.connections.DependencyEdgeClass; import org.simantics.sysdyn.ui.elements.connections.DependencyNode; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayFlowTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayFlowTab.java index ef0403f6..ad02e9ad 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayFlowTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayFlowTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -29,6 +29,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.elements.connections.FlowConnectionStyle; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java index 2b622ac8..e97de85e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java @@ -37,6 +37,7 @@ import org.simantics.db.common.utils.ListUtils; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java index c4bf7b12..3d7183e6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management in + * Copyright (c) 2007, 2012, 2014 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 @@ -24,6 +24,7 @@ import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.utils.datastructures.Callback; /** diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java index 1b6eed62..9250126c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java @@ -40,6 +40,7 @@ import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; import org.simantics.issues.ontology.IssueResource; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; import org.simantics.sysdyn.SysdynResource; @@ -147,9 +148,14 @@ public class ConfigurationTab extends AdjustableTab { map.put("euler", "euler"); map.put("rungekutta", "rungekutta"); map.put("dassl", "dassl"); - map.put("dassl2", "dassl2"); map.put("inline-euler", "inline-euler"); map.put("inline-rungekutta", "inline-rungekutta"); + map.put("dasslwort", "dasslwort"); + map.put("dasslSymJac", "dasslSymJac"); + map.put("dasslNumJac", "dasslNumJac"); + map.put("dasslColorSymJac", "dasslColorSymJac"); + map.put("dasslInternalNumJac", "dasslInternalNumJac"); + map.put("qss", "qss"); return map; } }); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java index b2ba5ca7..6cb813fa 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -32,6 +32,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.elements.connections.DependencyEdgeClass; import org.simantics.sysdyn.ui.elements.connections.DependencyNode; @@ -40,85 +41,25 @@ import org.simantics.sysdyn.ui.properties.widgets.DelayMarkWidget; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.datastructures.Triple; -public class DependencyTab extends LabelPropertyTabContributor { +/** + * Tab displaying dependency properties. + * + * @author Teemu Lempinen + * @author Tuomas Miettinen + * + */ +public class DependencyTab extends AdjustableTab { Button none, plus, minus, other, inside, outside; TrackedText polarityText, polarityLocationText; Scale lineThicknessScale; private DelayMarkWidget delayMark; private ArrowHeadWidget arrowhead; - - @Override - public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite); - - Group polarityGroup = new Group(composite, SWT.NONE); - polarityGroup.setText("Polarity"); - GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityGroup); - GridLayoutFactory.fillDefaults().numColumns(5).applyTo(polarityGroup); - - none = new Button(polarityGroup, support, SWT.RADIO); - none.setText("None"); - none.setSelectionFactory(new PolarityRadioSelectionFactory("")); - none.addSelectionListener(new PolaritySelectionListener(context, "")); - - plus = new Button(polarityGroup, support, SWT.RADIO); - plus.setText("+"); - plus.setSelectionFactory(new PolarityRadioSelectionFactory("+")); - plus.addSelectionListener(new PolaritySelectionListener(context, "+")); - - minus = new Button(polarityGroup, support, SWT.RADIO); - minus.setText("-"); - minus.setSelectionFactory(new PolarityRadioSelectionFactory("-")); - minus.addSelectionListener(new PolaritySelectionListener(context, "-")); - - other = new Button(polarityGroup, support, SWT.RADIO); - other.setText("other"); - other.setSelectionFactory(new OtherPolaritySelectionFactory(new String[] {null, "+", "-", ""})); - - polarityText = new TrackedText(polarityGroup, support, SWT.BORDER); - polarityText.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.DependencyConnection_polarity)); - polarityText.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.DependencyConnection_polarity)); - GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityText.getWidget()); - - Group locationGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(locationGroup); - GridLayoutFactory.fillDefaults().applyTo(locationGroup); - locationGroup.setText("Location"); - - inside = new Button(locationGroup, support, SWT.RADIO); - inside.setText("Inside"); - inside.setSelectionFactory(new PolarityLocationRadioSelectionFactory(DependencyNode.INSIDE)); - inside.addSelectionListener(new PolarityLocationSelectionListener(context, DependencyNode.INSIDE)); - - outside = new Button(locationGroup, support, SWT.RADIO); - outside.setText("Outside"); - outside.setSelectionFactory(new PolarityLocationRadioSelectionFactory(DependencyNode.OUTSIDE)); - outside.addSelectionListener(new PolarityLocationSelectionListener(context, DependencyNode.OUTSIDE)); - - Composite misc = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(misc); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(misc); - - arrowhead = new ArrowHeadWidget(misc, support, SWT.NULL); - GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(arrowhead.getWidget()); - delayMark = new DelayMarkWidget(misc, support, SWT.NULL); - GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(delayMark.getWidget()); - - Group lineThicknessGroup = new Group(misc, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(lineThicknessGroup); - GridLayoutFactory.fillDefaults().applyTo(lineThicknessGroup); - lineThicknessGroup.setText("Line thickness:"); - lineThicknessScale = new Scale(lineThicknessGroup, support, SWT.HORIZONTAL); - lineThicknessScale.getWidget().setMinimum(1); - lineThicknessScale.getWidget().setMaximum(15); - lineThicknessScale.getWidget().setPageIncrement(1); - lineThicknessScale.getWidget().setIncrement(1); - lineThicknessScale.setSelectionFactory(new LineThicknessRadioSelectionFactory()); - lineThicknessScale.addSelectionListener(new LineThicknessSelectionListener(context, lineThicknessScale)); - } + private Composite composite; + private Group polarityGroup; + private Group locationGroup; + private Composite misc; + private Group lineThicknessGroup; class LineThicknessSelectionListener extends SelectionListenerImpl { Scale scale; @@ -265,4 +206,110 @@ public class DependencyTab extends LabelPropertyTabContributor { } } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + composite = new Composite(body, SWT.NONE); + + polarityGroup = new Group(composite, SWT.NONE); + polarityGroup.setText("Polarity"); + + none = new Button(polarityGroup, support, SWT.RADIO); + none.setText("None"); + none.setSelectionFactory(new PolarityRadioSelectionFactory("")); + none.addSelectionListener(new PolaritySelectionListener(context, "")); + + plus = new Button(polarityGroup, support, SWT.RADIO); + plus.setText("+"); + plus.setSelectionFactory(new PolarityRadioSelectionFactory("+")); + plus.addSelectionListener(new PolaritySelectionListener(context, "+")); + + minus = new Button(polarityGroup, support, SWT.RADIO); + minus.setText("-"); + minus.setSelectionFactory(new PolarityRadioSelectionFactory("-")); + minus.addSelectionListener(new PolaritySelectionListener(context, "-")); + + other = new Button(polarityGroup, support, SWT.RADIO); + other.setText("other"); + other.setSelectionFactory(new OtherPolaritySelectionFactory(new String[] {null, "+", "-", ""})); + + polarityText = new TrackedText(polarityGroup, support, SWT.BORDER); + polarityText.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.DependencyConnection_polarity)); + polarityText.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.DependencyConnection_polarity)); + + locationGroup = new Group(composite, SWT.NONE); + locationGroup.setText("Location"); + + inside = new Button(locationGroup, support, SWT.RADIO); + inside.setText("Inside"); + inside.setSelectionFactory(new PolarityLocationRadioSelectionFactory(DependencyNode.INSIDE)); + inside.addSelectionListener(new PolarityLocationSelectionListener(context, DependencyNode.INSIDE)); + + outside = new Button(locationGroup, support, SWT.RADIO); + outside.setText("Outside"); + outside.setSelectionFactory(new PolarityLocationRadioSelectionFactory(DependencyNode.OUTSIDE)); + outside.addSelectionListener(new PolarityLocationSelectionListener(context, DependencyNode.OUTSIDE)); + + misc = new Composite(composite, SWT.NONE); + + arrowhead = new ArrowHeadWidget(misc, support, SWT.NULL); + delayMark = new DelayMarkWidget(misc, support, SWT.NULL); + + lineThicknessGroup = new Group(misc, SWT.NONE); + lineThicknessGroup.setText("Line thickness:"); + lineThicknessScale = new Scale(lineThicknessGroup, support, SWT.HORIZONTAL); + lineThicknessScale.getWidget().setMinimum(1); + lineThicknessScale.getWidget().setMaximum(15); + lineThicknessScale.getWidget().setPageIncrement(1); + lineThicknessScale.getWidget().setIncrement(1); + lineThicknessScale.setSelectionFactory(new LineThicknessRadioSelectionFactory()); + lineThicknessScale.addSelectionListener(new LineThicknessSelectionListener(context, lineThicknessScale)); + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(1).applyTo(composite); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityGroup); + GridLayoutFactory.fillDefaults().numColumns(5).applyTo(polarityGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityText.getWidget()); + + GridDataFactory.fillDefaults().applyTo(locationGroup); + GridLayoutFactory.fillDefaults().applyTo(locationGroup); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(misc); + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(misc); + + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(arrowhead.getWidget()); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(delayMark.getWidget()); + + GridDataFactory.fillDefaults().span(2, 1).applyTo(lineThicknessGroup); + GridLayoutFactory.fillDefaults().applyTo(lineThicknessGroup); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityGroup); + GridLayoutFactory.fillDefaults().numColumns(5).applyTo(polarityGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(polarityText.getWidget()); + + GridDataFactory.fillDefaults().applyTo(locationGroup); + GridLayoutFactory.fillDefaults().applyTo(locationGroup); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(misc); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(misc); + + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(arrowhead.getWidget()); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(delayMark.getWidget()); + + GridDataFactory.fillDefaults().span(1, 1).applyTo(lineThicknessGroup); + GridLayoutFactory.fillDefaults().applyTo(lineThicknessGroup); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java index b9f246ce..833a6261 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -51,6 +51,7 @@ import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.db.management.ISessionContext; import org.simantics.db.request.Read; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.simulation.ontology.SimulationResource; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java index 901d6ecc..c022808d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Association for Decentralized Information Management in + * Copyright (c) 2010, 2012, 2014 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 @@ -61,6 +61,7 @@ import org.simantics.db.management.ISessionContext; import org.simantics.db.procedure.AsyncListener; import org.simantics.db.request.Read; import org.simantics.db.service.VirtualGraphSupport; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.SysdynModel; @@ -112,6 +113,7 @@ public class EquationTab extends AdjustableTab implements Widget { super.createControls(body, site, context, _support); } + @Override protected void createControlLayoutHorizontal(boolean wideScreen) { GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite); @@ -136,6 +138,7 @@ public class EquationTab extends AdjustableTab implements Widget { GridDataFactory.fillDefaults().span(wideScreen ? 4 : 3, 1).grab(true, true).applyTo(expressionComposite); } + @Override protected void createControlLayoutVertical() { GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); @@ -160,6 +163,7 @@ public class EquationTab extends AdjustableTab implements Widget { GridDataFactory.fillDefaults().span(3, 1).grab(true, true).hint(SWT.DEFAULT, 300).applyTo(shortcutTabWidget.getWidget()); } + @Override protected void createAndAddControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport _support) { // Composite for the whole tab Composite composite = new Composite(body, SWT.NONE); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExperimentTab.java index 8d4aa90b..0c291db7 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExperimentTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -15,6 +15,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; public class ExperimentTab extends LabelPropertyTabContributor { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java index 47ba4e84..a4a91c9f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -38,6 +38,7 @@ 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.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.handlers.RemoveNodeHandler; import org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FlowTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FlowTab.java index fa864737..885d4ab9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FlowTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FlowTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -27,6 +27,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.elements.connections.FlowConnectionStyle; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java index 5164aa97..9704d074 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -21,6 +21,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.ui.properties.widgets.factories.FunctionLibraryNameInputValidator; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java index d7c57f34..de7994be 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -23,37 +23,39 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory; import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField; import org.simantics.sysdyn.ui.properties.widgets.factories.FunctionNameInputValidator; import org.simantics.sysdyn.ui.properties.widgets.functions.FunctionCodeWidget; -public class FunctionTab extends LabelPropertyTabContributor { +public class FunctionTab extends AdjustableTab { ExpressionField modelicaCode; + private Composite composite; + private TrackedText nameText; + private Group modelicaGroup; + private Label startLabel; + private Label endLabel; + private Group documentationGroup; + private TrackedText information; @Override - public void createControls(Composite body, IWorkbenchSite site, + protected void createAndAddControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { - - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + composite = new Composite(body, SWT.NONE); - TrackedText nameText = new TrackedText(composite, support, SWT.BORDER); + nameText = new TrackedText(composite, support, SWT.BORDER); nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName)); nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName)); nameText.setInputValidator(new FunctionNameInputValidator(support)); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText.getWidget()); - Group modelicaGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + modelicaGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); modelicaGroup.setText("Modelica code"); - GridDataFactory.fillDefaults().grab(true, true).minSize(150, 0).applyTo(modelicaGroup); - GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(modelicaGroup); - Label startLabel = new Label(modelicaGroup, support, SWT.NONE); + startLabel = new Label(modelicaGroup, support, SWT.NONE); startLabel.setTextFactory(new FunctionLabelFactory(Layer0.URIs.HasName, false)); new FunctionCodeWidget(modelicaGroup, support, SWT.BORDER); @@ -69,22 +71,57 @@ public class FunctionTab extends LabelPropertyTabContributor { Resource library = graph.getSingleObject(input, Layer0.getInstance(graph).PartOf); FunctionUtils.updateFunctionFileForLibrary(graph, library); } - }); + });*/ - GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaCode.getWidget()); - */ - Label endLabel = new Label(modelicaGroup, support, SWT.NONE); + endLabel = new Label(modelicaGroup, support, SWT.NONE); endLabel.setTextFactory(new FunctionLabelFactory(Layer0.URIs.HasName, true)); - Group documentationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + documentationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); documentationGroup.setText("Documentation"); - GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationGroup); - GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(documentationGroup); - TrackedText information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); + information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription)); information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription)); + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(nameText.getWidget()); + + GridDataFactory.fillDefaults().grab(true, true).minSize(150, 0).applyTo(modelicaGroup); + GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(modelicaGroup); + + /* + GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaCode.getWidget()); + */ + + GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationGroup); + GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(documentationGroup); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText.getWidget()); + + GridDataFactory.fillDefaults().grab(true, true).minSize(150, 0).applyTo(modelicaGroup); + GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(modelicaGroup); + + /* + GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaCode.getWidget()); + */ + + GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationGroup); + GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(documentationGroup); + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); - } + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java index e77b9f86..8e26cc3f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java @@ -14,6 +14,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory; @@ -43,28 +44,31 @@ public class GameExperimentTab extends LabelPropertyTabContributor { // Label Label label = new Label(composite, SWT.NONE); label.setText("Name"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText name = new TrackedText(composite, support, SWT.BORDER); name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName)); name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget()))); - + // Step duration (i.e. how many time units is one step in user's perspective) label = new Label(composite, SWT.NONE); label.setText("Step duration"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText stepDuration = new TrackedText(composite, support, SWT.BORDER); stepDuration.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepDuration)); stepDuration.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepDuration)); stepDuration.setInputValidator(new DoubleValidator()); stepDuration.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stepDuration.getWidget()))); - GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(name.getWidget()); + GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).grab(true, false).applyTo(name.getWidget()); // Integrator step length (i.e. how long is a integration step in the simulator. This time is stepped until stepDuration is full) label = new Label(composite, SWT.NONE); label.setText("Integrator step length"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText integratorStep = new TrackedText(composite, support, SWT.BORDER); integratorStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepLength)); integratorStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepLength)); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java index fe3694de..ceed5ad2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management in + * Copyright (c) 2007, 2012, 2014 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 @@ -48,6 +48,7 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.simulation.ontology.SimulationResource; import org.simantics.spreadsheet.resource.SpreadsheetResource; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java index 19146ffa..fd5480ee 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Association for Decentralized Information Management in + * Copyright (c) 2010, 2012, 2014 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 @@ -32,6 +32,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.SysdynModel; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java deleted file mode 100644 index d4a31f59..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 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.sysdyn.ui.properties; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchSite; -import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl; -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.management.ISessionContext; -import org.simantics.db.procedure.AsyncListener; -import org.simantics.db.request.Read; -import org.simantics.layer0.Layer0; -import org.simantics.modeling.ModelingResources; -import org.simantics.selectionview.PropertyTabContributorImpl; -import org.simantics.ui.SimanticsUI; -import org.simantics.utils.datastructures.Callback; -import org.simantics.utils.ui.AdaptionUtils; - -public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl { - - private boolean isDisposed = false; - - - public void createControl(Composite parent, final IWorkbenchSite site, final ISessionContext context, final WidgetSupportImpl support) { - super.createControl(parent, site, context, support); - - // Add dispose listener to make sure name listening receives the correct isDisposed -value - parent.addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - LabelPropertyTabContributor.this.dispose(); - } - }); - } - - @Override - public void updatePartName(ISelection forSelection, final Callback updateCallback) { - final Variable variable = AdaptionUtils.adaptToSingle(forSelection, Variable.class); - final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class); - if(resource == null && variable == null) { - updateCallback.run("Selection properties"); - return; - } - - SimanticsUI.getSession().asyncRequest(new Read() { - - @Override - public String perform(ReadGraph graph) throws DatabaseException { - Layer0 l0 = Layer0.getInstance(graph); - ModelingResources mr = ModelingResources.getInstance(graph); - - Resource r; - if(variable != null) { - r = (Resource)variable.getRepresents(graph); - } else { - r = resource; - } - - if(graph.hasStatement(r, mr.ElementToComponent)) { - r = graph.getSingleObject(r, mr.ElementToComponent); - } - String label = graph.getPossibleRelatedValue(r, l0.HasLabel); - if(label != null) - return label; - label = graph.getPossibleRelatedValue(r, l0.HasName); - if(label != null) - return label; - return "No name for selection"; - } - }, new AsyncListener() { - - @Override - public void execute(AsyncReadGraph graph, String result) { - updateCallback.run(result); - } - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - - } - - @Override - public boolean isDisposed() { - return isDisposed; - } - }); - } - - @Override - protected void dispose() { - this.isDisposed = true; - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LookupTableTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LookupTableTab.java index 16c92c38..25de7c92 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LookupTableTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LookupTableTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -20,6 +20,7 @@ import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.ChartTableWidget; import org.simantics.sysdyn.ui.properties.widgets.ChartWidget; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java index b8fb2f06..cc4bd43d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java @@ -41,6 +41,7 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.modeling.ModelingResources; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.utils.LoopUtils; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java index 0b5b3d68..320fb907 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Association for Decentralized Information Management in + * Copyright (c) 2010, 2012, 2014 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 @@ -24,6 +24,7 @@ import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.sysdyn.SysdynResource; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java index ef0e5cc4..9691f7e7 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Association for Decentralized Information Management in + * Copyright (c) 2010, 2012, 2014 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 @@ -24,6 +24,7 @@ import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.sysdyn.SysdynResource; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleParameterTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleParameterTab.java index 42220661..5e3f1246 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleParameterTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleParameterTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management in + * Copyright (c) 2007, 2012, 2014 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 @@ -23,6 +23,7 @@ import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.Resource; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys; import org.simantics.utils.datastructures.ArrayMap; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java index 030746cc..64a558bf 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -28,6 +28,7 @@ import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.Resource; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java index 79ebe9ab..918dafd2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -21,6 +21,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.ui.properties.widgets.factories.ModuleTypeNameInputValidator; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/PlaybackExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/PlaybackExperimentTab.java index 4b7eb906..a1038bc5 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/PlaybackExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/PlaybackExperimentTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -34,6 +34,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.management.ISessionContext; import org.simantics.diagram.stubs.G2DResource; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.utils.datastructures.Triple; import org.simantics.utils.ui.color.Color; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java index cc8f4384..55c4ce95 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -15,6 +15,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; public class ReferenceDependencyTab extends LabelPropertyTabContributor { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResultTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResultTab.java index 306cd840..fee1f4c9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResultTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResultTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2010, 2014 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 @@ -15,6 +15,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; public class ResultTab extends LabelPropertyTabContributor { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java index 2001b02f..409471cf 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -69,6 +69,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; import org.simantics.db.request.Read; import org.simantics.jfreechart.chart.ChartUtils; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.RangeComposite; import org.simantics.jfreechart.chart.properties.xyline.AxisAndVariablesExplorerComposite; import org.simantics.layer0.Layer0; @@ -92,7 +93,7 @@ import org.simantics.utils.ui.validators.IntegerValidator; * @author Tuomas Miettinen * */ -public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributor implements Widget { +public class SensitivityAnalysisExperimentTab extends AdjustableTab implements Widget { private GraphExplorerComposite explorer; private WidgetSupportImpl parameterSupport = new WidgetSupportImpl(); @@ -106,55 +107,133 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo private boolean dirtyMethod = false; private DisposableListener> contentListener; + private RemoveFocusBeforeExperimentComposite composite; + private Composite labelComposite; + private Label labelName; + private Label labelNumber; + private Label labelMethod; + private TrackedCombo methodSelector; + private Label labelSeed; + private TrackedText seed; + private Tree tree; + private Composite buttonComposite; + private Group parameterPropertyGroup; + private Label labelVariable; + private TrackedText variable; + private Label labelRange; + private RangeComposite rangeComposite; + private Label labelDistribution; + private TrackedCombo distributionSelector; + private DistributionPropertyWidget dpw; + private TrackedText name; + private TrackedText n; + private Button addVariable; @Override public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, final WidgetSupport support) { support.register(this); + super.createControls(body, site, context, support); + } - Composite composite = new RemoveFocusBeforeExperimentComposite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + /** + * Updates the content of propertyContainer + * @param context + */ + private void updateSelection(ISessionContext context) { + ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class); + IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection(); + parameterSupport.fireInput(context, selection); + + propertyContainer.setContent(content); + Point size = content.computeSize(SWT.DEFAULT, SWT.DEFAULT); + propertyContainer.setMinSize(size); + } + + + @Override + public void setInput(ISessionContext context, Object input) { + experiment = AdaptionUtils.adaptToSingle(input, Resource.class); + if(contentListener == null) { + contentListener = new DisposableListener>() { + + @Override + public void execute(Collection result) { + if(remove != null && !remove.getWidget().isDisposed() && result != null) { + remove.getWidget().getDisplay().asyncExec(new RunnableWithObject(result) { + @Override + public void run() { + if(!remove.getWidget().isDisposed()) { + @SuppressWarnings("unchecked") + Collection result = (Collection) getObject(); + if(result.size() > 1) + remove.getWidget().setEnabled(true); + else + remove.getWidget().setEnabled(false); + } + } + }); + + } + } + + @Override + public void exception(Throwable t) { + t.printStackTrace(); + } + }; + + SimanticsUI.getSession().asyncRequest(new Read> () { + + @SuppressWarnings("unchecked") + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return (Collection) new ParameterChildRule().getChildren(graph, experiment); + } + + }, contentListener); + } + + } + + + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + final ISessionContext context, final WidgetSupport support) { + + composite = new RemoveFocusBeforeExperimentComposite(body, SWT.NONE); // Scrolled composite for displaying properties of a selection in explorer propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyContainer); - GridLayoutFactory.fillDefaults().applyTo(propertyContainer); propertyContainer.setExpandHorizontal(true); propertyContainer.setExpandVertical(true); content = new Composite(propertyContainer, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(content); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(content); // Label - Composite labelComposite = new Composite(content, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(labelComposite); - GridLayoutFactory.fillDefaults().numColumns(8).applyTo(labelComposite); - Label label = new Label(labelComposite, SWT.NONE); - label.setText("Name"); + labelComposite = new Composite(content, SWT.NONE); + labelName = new Label(labelComposite, SWT.NONE); + labelName.setText("Name"); - TrackedText name = new TrackedText(labelComposite, support, SWT.BORDER); + name = new TrackedText(labelComposite, support, SWT.BORDER); name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName)); name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget()))); - GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); - label = new Label(labelComposite, SWT.NONE); - label.setText("Number of runs"); + labelNumber = new Label(labelComposite, SWT.NONE); + labelNumber.setText("Number of runs"); - TrackedText n = new TrackedText(labelComposite, support, SWT.BORDER); + n = new TrackedText(labelComposite, support, SWT.BORDER); n.setTextFactory(new IntegerPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_numberOfValues)); n.addModifyListener(new IntegerPropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_numberOfValues)); n.setInputValidator(new IntegerValidator()); n.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), n.getWidget()))); - GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(n.getWidget()); - label = new Label(labelComposite, SWT.NONE); - label.setText("Method"); + labelMethod = new Label(labelComposite, SWT.NONE); + labelMethod.setText("Method"); - TrackedCombo methodSelector = new TrackedCombo(labelComposite, support, SWT.DROP_DOWN); + methodSelector = new TrackedCombo(labelComposite, support, SWT.DROP_DOWN); methodSelector.setItemFactory(new ReadFactoryImpl>() { @Override @@ -224,15 +303,14 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }); - label = new Label(labelComposite, SWT.NONE); - label.setText("Seed"); + labelSeed = new Label(labelComposite, SWT.NONE); + labelSeed.setText("Seed"); - TrackedText seed = new TrackedText(labelComposite, support, SWT.BORDER); + seed = new TrackedText(labelComposite, support, SWT.BORDER); seed.setTextFactory(new IntegerPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_randomSeed)); seed.addModifyListener(new IntegerPropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_randomSeed)); seed.setInputValidator(new IntegerValidator()); seed.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), seed.getWidget()))); - GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(seed.getWidget()); // (Ontology-based) GraphExplorer displaying range axis and variables mapped to those axis explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( @@ -281,7 +359,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }; - Tree tree = explorer.getExplorerControl(); + tree = explorer.getExplorerControl(); tree.addListener(SWT.Activate, listener); tree.addListener(SWT.Show, listener); tree.addListener(SWT.Paint,listener); @@ -297,13 +375,9 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo }); - GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - - Composite buttonComposite = new Composite(explorer, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(buttonComposite); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + buttonComposite = new Composite(explorer, SWT.NONE); - Button addVariable = new Button(buttonComposite, support, SWT.NONE); + addVariable = new Button(buttonComposite, support, SWT.NONE); addVariable.setText("Add parameter"); addVariable.addSelectionListener(new SelectionListenerImpl(context) { @@ -347,43 +421,32 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }); - propertyContainer.setContent(content); - Point tsize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT); - propertyContainer.setMinSize(tsize); - Group parameterPropertyGroup = new Group(content, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterPropertyGroup); - GridLayoutFactory.fillDefaults().applyTo(parameterPropertyGroup); + parameterPropertyGroup = new Group(content, SWT.NONE); parameterProperties = new Composite(parameterPropertyGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterProperties); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parameterProperties); // Label - label = new Label(parameterProperties, SWT.NONE); - label.setText("Variable:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + labelVariable = new Label(parameterProperties, SWT.NONE); + labelVariable.setText("Variable:"); - TrackedText variable = new TrackedText(parameterProperties, parameterSupport, SWT.BORDER); + variable = new TrackedText(parameterProperties, parameterSupport, SWT.BORDER); variable.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable)); variable.addModifyListener(new VariableNameModifier(variable.getWidget(), parameterSupport, SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable, SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_indexes)); variable.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), variable.getWidget()))); variable.setInputValidator(new ParameterExistsValidator(parameterSupport, variable)); - GridDataFactory.fillDefaults().grab(true, false).applyTo(variable.getWidget()); - label = new Label(parameterProperties, SWT.NONE); - label.setText("Range:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + labelRange = new Label(parameterProperties, SWT.NONE); + labelRange.setText("Range:"); - RangeComposite rangeComposite = new RangeComposite(parameterProperties, context, parameterSupport, SWT.NONE) { + rangeComposite = new RangeComposite(parameterProperties, context, parameterSupport, SWT.NONE) { @Override protected Resource getIndexRelation(ReadGraph graph) { return SysdynResource.getInstance(graph).SensitivityAnalysisExperiment_Parameter_indexes; } }; - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite); // TrackedText variable = new TrackedText(parameterProperties, parameterSupport, SWT.BORDER); // variable.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable)); @@ -391,11 +454,10 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo // variable.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), variable.getWidget()))); // GridDataFactory.fillDefaults().grab(true, false).applyTo(variable.getWidget()); - label = new Label(parameterProperties, SWT.NONE); - label.setText("Distribution:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + labelDistribution = new Label(parameterProperties, SWT.NONE); + labelDistribution.setText("Distribution:"); - TrackedCombo distributionSelector = new TrackedCombo(parameterProperties, parameterSupport, SWT.DROP_DOWN); + distributionSelector = new TrackedCombo(parameterProperties, parameterSupport, SWT.DROP_DOWN); distributionSelector.setItemFactory(new ReadFactoryImpl>() { @Override @@ -473,73 +535,110 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }); - label = new Label(parameterProperties, SWT.NONE); - - DistributionPropertyWidget dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(dpw); - + dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE); } - /** - * Updates the content of propertyContainer - * @param context - */ - private void updateSelection(ISessionContext context) { - ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class); - IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection(); - parameterSupport.fireInput(context, selection); - - propertyContainer.setContent(content); - Point size = content.computeSize(SWT.DEFAULT, SWT.DEFAULT); - propertyContainer.setMinSize(size); - } + @Override + protected void createControlLayoutVertical() { + + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(content); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(content); + // Label + GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(labelComposite); + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(labelComposite); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(n.getWidget()); + + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(seed.getWidget()); - @Override - public void setInput(ISessionContext context, Object input) { - experiment = AdaptionUtils.adaptToSingle(input, Resource.class); - if(contentListener == null) { - contentListener = new DisposableListener>() { + GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + + Point tsize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT); + propertyContainer.setMinSize(tsize); + GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterPropertyGroup); + GridLayoutFactory.fillDefaults().applyTo(parameterPropertyGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterProperties); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parameterProperties); - @Override - public void execute(Collection result) { - if(remove != null && !remove.getWidget().isDisposed() && result != null) { - remove.getWidget().getDisplay().asyncExec(new RunnableWithObject(result) { - @Override - public void run() { - if(!remove.getWidget().isDisposed()) { - @SuppressWarnings("unchecked") - Collection result = (Collection) getObject(); - if(result.size() > 1) - remove.getWidget().setEnabled(true); - else - remove.getWidget().setEnabled(false); - } - } - }); + // Label + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelVariable); - } - } + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(variable.getWidget()); + + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelRange); + + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(rangeComposite); + + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelDistribution); + + GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(dpw); + GridLayoutFactory.fillDefaults().margins(6, 0).applyTo(dpw); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(content); + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(content); - @Override - public void exception(Throwable t) { - t.printStackTrace(); - } - }; + // Label + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(labelComposite); + GridLayoutFactory.fillDefaults().numColumns(8).applyTo(labelComposite); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget()); + + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(n.getWidget()); + + GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(seed.getWidget()); - SimanticsUI.getSession().asyncRequest(new Read> () { + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - @SuppressWarnings("unchecked") - @Override - public Collection perform(ReadGraph graph) throws DatabaseException { - return (Collection) new ParameterChildRule().getChildren(graph, experiment); - } + GridDataFactory.fillDefaults().applyTo(buttonComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + + Point tsize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT); + propertyContainer.setMinSize(tsize); + GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterPropertyGroup); + GridLayoutFactory.fillDefaults().applyTo(parameterPropertyGroup); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterProperties); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parameterProperties); - }, contentListener); - } + // Label + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelVariable); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(variable.getWidget()); - } + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelRange); + + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(rangeComposite); + + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelDistribution); + + GridDataFactory.fillDefaults().span(1, 1).grab(true, true).applyTo(dpw); + GridLayoutFactory.fillDefaults().margins(6, 0).applyTo(dpw); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SharedFunctionLibrariesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SharedFunctionLibrariesTab.java index 7b0301cb..ac3d2e74 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SharedFunctionLibrariesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SharedFunctionLibrariesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 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 @@ -38,6 +38,7 @@ 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.jfreechart.chart.properties.LabelPropertyTabContributor; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java index 53f7c9aa..c5b18516 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 Association for Decentralized Information Management in + * Copyright (c) 2010, 2011, 2014 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 @@ -45,6 +45,7 @@ import org.simantics.db.procedure.Listener; import org.simantics.db.request.Read; import org.simantics.diagram.G2DUtils; import org.simantics.diagram.stubs.G2DResource; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; import org.simantics.sysdyn.SysdynResource; @@ -63,16 +64,16 @@ import org.simantics.utils.ui.validators.DoubleValidator; /** * Information tab for additional information of variables. * @author Teemu Lempinen + * @author Tuomas Miettinen * */ -public class VariableInformationTab extends LabelPropertyTabContributor implements Widget { +public class VariableInformationTab extends AdjustableTab implements Widget { private Composite orientationComposite; private WidgetSupport support; private Resource component; private org.simantics.browsing.ui.swt.widgets.Label sample; private LocalResourceManager resourceManager; - @Override public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { this.support = support; @@ -81,69 +82,194 @@ public class VariableInformationTab extends LabelPropertyTabContributor implemen // Create a ResourceManager to dispose images when the widget is disposed. this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), body); + super.createControls(body, site, context, support); + } - final Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + private Read> fontAndColorRead; + private Composite composite; + private Group informationGroup; + private TrackedText information; + private Group rangeGroup; + private Label label; + private TrackedText rangeStart; + private TrackedText rangeEnd; + private TrackedText rangeStep; + private Composite fontComposite; + private Button b; + + @Override + public void setInput(ISessionContext context, Object input) { + component = AdaptionUtils.adaptToSingle(input, Resource.class); + // is the displayed variable a valve? + Boolean isValve = false; + try { + isValve = context.getSession().syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + return graph.isInstanceOf(component, sr.Valve); + } + + }); + } catch (DatabaseException e) { + e.printStackTrace(); + } + // if it is a valve, display the orientation information + if(isValve) { + ValveOrientationGroup vog = new ValveOrientationGroup(orientationComposite, context, support, SWT.NONE); + vog.setInput(context, input); + ValveTextLocationGroup vtlg = new ValveTextLocationGroup(orientationComposite, context, support, SWT.NONE); + vtlg.setInput(context, input); + orientationComposite.getParent().layout(); + } + + // Read font and color information for sample text + if(fontAndColorRead == null) { + fontAndColorRead = new Read>() { - Group informationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + @Override + public Pair perform(ReadGraph graph) throws DatabaseException { + Font font = null; + Color color = null; + if(component != null) { + Resource element = graph.getPossibleObject(component, ModelingResources.getInstance(graph).ComponentToElement); + if(element != null) { + G2DResource g2d = G2DResource.getInstance(graph); + Resource fontResource = graph.getPossibleObject(element, g2d.HasFont); + if(fontResource != null) + font = G2DUtils.getFont(graph, fontResource); + Resource colorResource = graph.getPossibleObject(element, g2d.HasColor); + if(colorResource != null) + color = G2DUtils.getColor(graph, colorResource); + } + } + return new Pair(font, color); + } + }; + + SimanticsUI.getSession().asyncRequest(fontAndColorRead, new Listener>() { + + @Override + public void execute(final Pair result) { + final Display device; + try { + device = sample.getWidget().getDisplay(); + } catch (SWTException e) { + // Widget is disposed, the GUI probably did'n function as fast as the user commanded. + // Thus do nothing. + return; + } + + device.asyncExec(new Runnable() { + + @Override + public void run() { + try { + if(sample.getWidget().isDisposed()) + return; + } catch (SWTException e) { + // Widget is disposed, the GUI probably did'n function as fast as the user commanded. + // Thus do nothing. + return; + } + if(result.first != null) { + FontData fd = toSwtFontData(result.first); + sample.setFont(resourceManager.createFont(FontDescriptor.createFrom(fd))); + } + if(result.second != null) { + RGB rgb = new RGB(result.second.getRed(), result.second.getGreen(), + result.second.getBlue()); + sample.setForeground(resourceManager.createColor(rgb)); + } + try { + sample.getWidget().getParent().getParent().layout(); + } catch (SWTException e) { + + } + } + }); + + } + + @Override + public void exception(Throwable t) { + t.printStackTrace(); + } + + @Override + public boolean isDisposed() { + return sample == null || sample.getWidget().isDisposed(); + } + + }); + } + } + + /** + * Create SWT FontData based on AWT Font + * @param font AWT Font + * @return SWT FontData based on AWT Font + */ + private static FontData toSwtFontData(Font font) { + FontData fontData = new FontData(); + fontData.setName(font.getFamily()); + fontData.setStyle(font.getStyle()); + fontData.setHeight(font.getSize()); + return fontData; + } + + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport _support) { + + composite = new Composite(body, SWT.NONE); + + informationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); informationGroup.setText("Information"); - GridDataFactory.fillDefaults().grab(false, true).applyTo(informationGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(informationGroup); // Textual format documentation - TrackedText information = new TrackedText(informationGroup, support, SWT.MULTI | SWT.BORDER); + information = new TrackedText(informationGroup, support, SWT.MULTI | SWT.BORDER); information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription)); information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription)); - GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); // Orientation information for valves orientationComposite = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 2).applyTo(orientationComposite); - GridLayoutFactory.fillDefaults().margins(3,3).applyTo(orientationComposite); // Range of a variable (e.g. from 0 to 10). Does not affect simulation, but the infor can be used for example in charts - Group rangeGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + rangeGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); rangeGroup.setText("Range"); - GridDataFactory.fillDefaults().applyTo(rangeGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(rangeGroup); - Label label = new Label(rangeGroup, SWT.NONE); + label = new Label(rangeGroup, SWT.NONE); label.setText("Start"); - TrackedText rangeStart = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); + rangeStart = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); rangeStart.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStart)); rangeStart.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeStart)); rangeStart.setInputValidator(new DoubleValidator()); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStart.getWidget()); - label = new Label(rangeGroup, SWT.NONE); label.setText("End"); - TrackedText rangeEnd = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); + rangeEnd = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); rangeEnd.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeEnd)); rangeEnd.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeEnd)); rangeEnd.setInputValidator(new DoubleValidator()); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeEnd.getWidget()); label = new Label(rangeGroup, SWT.NONE); label.setText("Step"); - TrackedText rangeStep = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); + rangeStep = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER); rangeStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStep)); rangeStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeStep)); rangeStep.setInputValidator(new DoubleValidator()); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget()); // Font options. FIXME: very bad appearance right now - final Composite fontComposite = new Composite(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(fontComposite); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fontComposite); - Button b = new Button(fontComposite, support, SWT.PUSH); + fontComposite = new Composite(composite, SWT.NONE); + b = new Button(fontComposite, support, SWT.PUSH); b.setText("Choose Font"); // Sample text with selected font @@ -243,133 +369,65 @@ public class VariableInformationTab extends LabelPropertyTabContributor implemen } }); + } + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + GridDataFactory.fillDefaults().grab(true, true).applyTo(informationGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(informationGroup); - } + // Textual format documentation + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); - private Read> fontAndColorRead; + // Orientation information for valves + GridDataFactory.fillDefaults().span(1, 2).applyTo(orientationComposite); + GridLayoutFactory.fillDefaults().margins(3,3).applyTo(orientationComposite); - @Override - public void setInput(ISessionContext context, Object input) { - component = AdaptionUtils.adaptToSingle(input, Resource.class); - // is the displayed variable a valve? - Boolean isValve = false; - try { - isValve = context.getSession().syncRequest(new Read() { + // Range of a variable (e.g. from 0 to 10). Does not affect simulation, but the infor can be used for example in charts + GridDataFactory.fillDefaults().applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(rangeGroup); - @Override - public Boolean perform(ReadGraph graph) throws DatabaseException { - SysdynResource sr = SysdynResource.getInstance(graph); - return graph.isInstanceOf(component, sr.Valve); - } + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStart.getWidget()); - }); - } catch (DatabaseException e) { - e.printStackTrace(); - } - // if it is a valve, display the orientation information - if(isValve) { - ValveOrientationGroup vog = new ValveOrientationGroup(orientationComposite, context, support, SWT.NONE); - vog.setInput(context, input); - ValveTextLocationGroup vtlg = new ValveTextLocationGroup(orientationComposite, context, support, SWT.NONE); - vtlg.setInput(context, input); - orientationComposite.getParent().layout(); - } + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeEnd.getWidget()); - // Read font and color information for sample text - if(fontAndColorRead == null) { - fontAndColorRead = new Read>() { + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget()); - @Override - public Pair perform(ReadGraph graph) throws DatabaseException { - Font font = null; - Color color = null; - if(component != null) { - Resource element = graph.getPossibleObject(component, ModelingResources.getInstance(graph).ComponentToElement); - if(element != null) { - G2DResource g2d = G2DResource.getInstance(graph); - Resource fontResource = graph.getPossibleObject(element, g2d.HasFont); - if(fontResource != null) - font = G2DUtils.getFont(graph, fontResource); - Resource colorResource = graph.getPossibleObject(element, g2d.HasColor); - if(colorResource != null) - color = G2DUtils.getColor(graph, colorResource); - } - } - return new Pair(font, color); - } - }; + GridDataFactory.fillDefaults().applyTo(fontComposite); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(fontComposite); + } - SimanticsUI.getSession().asyncRequest(fontAndColorRead, new Listener>() { + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { - @Override - public void execute(final Pair result) { - final Display device; - try { - device = sample.getWidget().getDisplay(); - } catch (SWTException e) { - // Widget is disposed, the GUI probably did'n function as fast as the user commanded. - // Thus do nothing. - return; - } - - device.asyncExec(new Runnable() { - - @Override - public void run() { - try { - if(sample.getWidget().isDisposed()) - return; - } catch (SWTException e) { - // Widget is disposed, the GUI probably did'n function as fast as the user commanded. - // Thus do nothing. - return; - } - if(result.first != null) { - FontData fd = toSwtFontData(result.first); - sample.setFont(resourceManager.createFont(FontDescriptor.createFrom(fd))); - } - if(result.second != null) { - RGB rgb = new RGB(result.second.getRed(), result.second.getGreen(), - result.second.getBlue()); - sample.setForeground(resourceManager.createColor(rgb)); - } - try { - sample.getWidget().getParent().getParent().layout(); - } catch (SWTException e) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - } - } - }); + GridDataFactory.fillDefaults().grab(true, true).applyTo(informationGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(informationGroup); - } + // Textual format documentation + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); - @Override - public void exception(Throwable t) { - t.printStackTrace(); - } + // Orientation information for valves + GridDataFactory.fillDefaults().span(1, 2).applyTo(orientationComposite); + GridLayoutFactory.fillDefaults().margins(3,3).applyTo(orientationComposite); - @Override - public boolean isDisposed() { - return sample == null || sample.getWidget().isDisposed(); - } + // Range of a variable (e.g. from 0 to 10). Does not affect simulation, but the infor can be used for example in charts + GridDataFactory.fillDefaults().applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(rangeGroup); - }); - } - } + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStart.getWidget()); - /** - * Create SWT FontData based on AWT Font - * @param font AWT Font - * @return SWT FontData based on AWT Font - */ - private static FontData toSwtFontData(Font font) { - FontData fontData = new FontData(); - fontData.setName(font.getFamily()); - fontData.setStyle(font.getStyle()); - fontData.setHeight(font.getSize()); - return fontData; - } + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeEnd.getWidget()); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget()); + + GridDataFactory.fillDefaults().applyTo(fontComposite); + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fontComposite); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java index 90b4319c..6807d491 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java @@ -87,7 +87,9 @@ public class NameAndArrayRangeModifyListener extends ComboModifyListenerImpl ALLOW_ALL_COMPLETIONS_LIST = new ArrayList(); + static { + ALLOW_ALL_COMPLETIONS_LIST.add(""); + } public CompletionProcessor(Table allowedVariables, boolean allowFunctions, ExpressionWidgetInput input) { this.allowedVariables = allowedVariables; @@ -121,7 +127,7 @@ public class CompletionProcessor implements IContentAssistProcessor { } /** - * Create CompletionProposals of the variables and add them to array. + * Create CompletionProposals of the variables and add them to array. Do not allow duplicates. * @param array result array of CompletionProposals * @param token current token * @param offset an offset within the document for which completions should be computed @@ -131,8 +137,9 @@ public class CompletionProcessor implements IContentAssistProcessor { Image imageVariableGray = resourceManager.createImage(ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/variableGray.png"))); for (String variable : variables) { - if (token.length() == 0 || variable.toUpperCase().startsWith(token.toUpperCase())) { - array.add(new CompletionProposal(variable, + if ((token.length() == 0 || variable.toUpperCase().startsWith(token.toUpperCase())) + && !listContainsVariable(array, variable)) { + array.add(new CompletionProposal(variable, offset - token.length(), token.length(), variable.length(), @@ -143,7 +150,8 @@ public class CompletionProcessor implements IContentAssistProcessor { } } for (String variable : timeAndSelfVariables) { - if (token.length() == 0 || variable.toUpperCase().startsWith(token.toUpperCase())) { + if ((token.length() == 0 || variable.toUpperCase().startsWith(token.toUpperCase())) + && !listContainsVariable(array, variable)) { array.add(new CompletionProposal(variable, offset - token.length(), token.length(), @@ -156,6 +164,15 @@ public class CompletionProcessor implements IContentAssistProcessor { } } + private boolean listContainsVariable(ArrayList array, + String variable) { + for (ICompletionProposal proposal : array) { + if (proposal.getDisplayString().equals(variable)) + return true; + } + return false; + } + /** * Create CompletionProposals of the functions and add them to array. * @param array result array of CompletionProposals @@ -186,20 +203,38 @@ public class CompletionProcessor implements IContentAssistProcessor { } /** - * Collect all matching proposals - * @param token current token + * Collect all matching proposals. Duplicates are removed; the one with the longest token stays. + * @param possibleLabelBeginnings sets of whitespace delimited tokens (as Strings) * @param offset an offset within the document for which completions should be computed * @return Array of matching proposals */ - private ICompletionProposal[] collectProposals(String token, int offset) { + private ICompletionProposal[] collectProposals(ArrayList possibleLabelBeginnings, int offset) { ArrayList resultArray = new ArrayList(); // Find variables and functions and create CompletionProposals out of them. findVariables(); - addVariables(resultArray, token, offset); - addFunctions(resultArray, token, offset); + + // Sort the list based on the length of the tokens (descending) to get "" to end. + Collections.sort(possibleLabelBeginnings, new Comparator(){ + @Override + public int compare(String o1, String o2) { + if (o1.length() > o2.length()) { + return -1; + } else if (o1.length() < o2.length()) { + return 1; + } + return 0; + } + }); + + for (String possibleLabelBeginning : possibleLabelBeginnings) { + addVariables(resultArray, possibleLabelBeginning, offset); + } - ICompletionProposal[] result = new ICompletionProposal[resultArray.size()]; + // No support for whitespace in function names; get shortest beginning + addFunctions(resultArray, possibleLabelBeginnings.get(possibleLabelBeginnings.size() - 1), offset); + + ICompletionProposal[] result = new ICompletionProposal[resultArray.size()]; for (int i = 0; i < result.length; ++i) { result[i] = resultArray.get(i); } @@ -213,35 +248,75 @@ public class CompletionProcessor implements IContentAssistProcessor { Control control = viewer.getTextWidget(); this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), control); - if (equation.length() == 0 - || offset == 0 - || Character.isWhitespace(equation.charAt(offset - 1))) { - return collectProposals("", offset); + if (equation.length() == 0 || offset == 0) { + return collectProposals(ALLOW_ALL_COMPLETIONS_LIST, offset); } equation = equation.substring(0, offset); - // Split into tokens on whitespace characters - String[] tokens = equation.split("[\\s]"); - if (tokens.length == 0) { - return collectProposals("", offset); + // Split the equation on '+', '-', etc. characters + String stringsBetweenConnectedCharacters[] = equation.split(ALLOWED_CONNECTED_CHARACTERS_REG_EXP); + if (stringsBetweenConnectedCharacters.length == 0) { + return collectProposals(ALLOW_ALL_COMPLETIONS_LIST, offset); } - String token = tokens[tokens.length - 1]; + String stringAfterLastConnectedCharacter = stringsBetweenConnectedCharacters[stringsBetweenConnectedCharacters.length - 1]; + String stringAfterWhitespaceAfterLastConnectedCharacter = removeLeadingWhitespace(stringAfterLastConnectedCharacter); + + // Split into tokens on whitespace characters, include also the trailing empty strings + String[] tokens = stringAfterWhitespaceAfterLastConnectedCharacter.split("[\\s]", -42); - // If a '+', '-', etc. character is in the end, return all. - if (allowedConnectedCharactersRegExp.indexOf(token.charAt(token.length() - 1)) != -1) { - return collectProposals("", offset); - } - - // Split the last token on '+', '-', etc. characters - String tokensOfLastToken[] = token.split(allowedConnectedCharactersRegExp); - if (tokensOfLastToken.length == 0) { - return collectProposals("", offset); + // Only whitespace after the last connection character + if (allTokensAreEmpty(tokens)) + return collectProposals(ALLOW_ALL_COMPLETIONS_LIST, offset); + + return collectProposals(getPossibleLabelBeginnings(tokens), offset); + } + + /** + * Collect all possible strings (with each whitespace replaced by a space character) + * which may be a beginning of a variable. + * Create the beginnings by adding whitespace between. E.g.: + * {"multi", "part", "variab"} + * -> { "multi part variab", + * "part variab", + * "variab" } + * @param tokens list of tokens + * @return all possible label beginnings + */ + private ArrayList getPossibleLabelBeginnings(String[] tokens) { + ArrayList possibleLabelBeginnings = new ArrayList(); + for (int i = 0; i < tokens.length; ++i) { + String token = new String(); + for (int j = i; j < tokens.length; ++j) { + token += " " + tokens[j]; + } + // Remove the excess space character from the beginning + token = token.substring(1); + + possibleLabelBeginnings.add(token); } - token = tokensOfLastToken[tokensOfLastToken.length - 1]; - //System.out.println(token + "\noffset = " + offset); + return possibleLabelBeginnings; + } + + /** + * Remove leading whitespace + * @param input + * @return + */ + private String removeLeadingWhitespace(String input) { + for (int i = 0; i < input.length(); ++i) { + if (!Character.isWhitespace(input.charAt(i))) { + return input.substring(i); + } + } + return ""; + } - return collectProposals(token, offset); + private boolean allTokensAreEmpty(String[] tokens) { + for (String token : tokens) + if (!token.equals("")) + return false; + return true; } @Override @@ -252,7 +327,7 @@ public class CompletionProcessor implements IContentAssistProcessor { @Override public char[] getCompletionProposalAutoActivationCharacters() { - return allowedCharacters; + return ALLOWED_CHARACTERS; } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java index 53e51b91..3aced206 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java @@ -33,9 +33,11 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Table; +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.ReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; @@ -140,7 +142,7 @@ public class StockExpression implements IExpression { } @Override - public void readData(final Resource expression, Map data) { + public void readData(final Resource expression, final Map data) { Pair equations = null; if (expression != null && data.get("initialEquation") == null) { try { @@ -184,7 +186,25 @@ public class StockExpression implements IExpression { data.put("integral", getDefaultIntegral(expression)); } else { - data.put("integral", equations.first); + try { + final String integral = equations.first; + SimanticsUI.getSession().syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + if (graph.hasStatement(input.expression, sr.StockExpression_useCustomIntegral)) { + data.put("integral", integral); + } else { + data.put("integral", getDefaultIntegral(graph, expression)); + } + } + + }); + } catch (DatabaseException e) { + data.put("integral", equations.first); + e.printStackTrace(); + } } } @@ -240,7 +260,7 @@ public class StockExpression implements IExpression { } g.claimLiteral(expression, sr.StockExpression_initialEquation, currentInitial); - if (!currentIntegral.equals(data.get("integral"))) { + if (!currentIntegral.equals(g.getPossibleRelatedValue(expression, sr.StockExpression_integralEquation, Bindings.STRING))) { // If the value is not same as default, enable the custom tag g.claim(expression, sr.StockExpression_useCustomIntegral, expression); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ConfidenceBoundWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ConfidenceBoundWidget.java index eb89e1d7..b7d009b9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ConfidenceBoundWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ConfidenceBoundWidget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Association for Decentralized Information Management in + * Copyright (c) 2013, 2014 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 @@ -41,6 +41,7 @@ import org.simantics.utils.ui.validators.DoubleValidator; /** * Widget for setting percentage and color for a confidence bound * @author Teemu Lempinen + * @author Tuomas Miettinen * */ public class ConfidenceBoundWidget extends Composite implements Widget { @@ -54,9 +55,18 @@ public class ConfidenceBoundWidget extends Composite implements Widget { support.register(this); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this); + GridLayoutFactory.fillDefaults().applyTo(this); confidenceBoundSupport = new WidgetSupportImpl(); + + ColorPicker colorPicker = new ColorPicker(this, context, confidenceBoundSupport, SWT.NONE, false) { + @Override + protected Resource getColorRelation(ReadGraph graph) throws DatabaseException { + return SysdynResource.getInstance(graph).Charts_SensitivityDataset_ConfidenceBound_color; + } + }; + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(colorPicker); + TrackedText variable = new TrackedText(this, confidenceBoundSupport, SWT.BORDER); variable.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.Charts_SensitivityDataset_ConfidenceBound_percent)); variable.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.Charts_SensitivityDataset_ConfidenceBound_percent)); @@ -70,16 +80,7 @@ public class ConfidenceBoundWidget extends Composite implements Widget { } }); - GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(variable.getWidget()); - - ColorPicker colorPicker = new ColorPicker(this, context, confidenceBoundSupport, SWT.NONE, false) { - @Override - protected Resource getColorRelation(ReadGraph graph) throws DatabaseException { - return SysdynResource.getInstance(graph).Charts_SensitivityDataset_ConfidenceBound_color; - } - }; - GridDataFactory.fillDefaults().applyTo(colorPicker); - + GridDataFactory.fillDefaults().hint(27, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variable.getWidget()); } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityChartAxisAndVariablesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityChartAxisAndVariablesTab.java index 0bfe1d65..2f957146 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityChartAxisAndVariablesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityChartAxisAndVariablesTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Association for Decentralized Information Management in + * Copyright (c) 2013, 2014 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 @@ -33,7 +33,7 @@ import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; import org.simantics.db.request.Read; -import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; +import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.jfreechart.chart.properties.xyline.AxisAndVariablesExplorerComposite; import org.simantics.jfreechart.chart.properties.xyline.AxisPropertyComposite; import org.simantics.jfreechart.chart.properties.xyline.SeriesPropertyComposite; @@ -42,47 +42,17 @@ import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.ArrayMap; import org.simantics.utils.ui.AdaptionUtils; -public class SensitivityChartAxisAndVariablesTab extends LabelPropertyTabContributor { +public class SensitivityChartAxisAndVariablesTab extends AdjustableTab { private GraphExplorerComposite explorer; private ScrolledComposite propertyContainer; private WidgetSupportImpl additionalSupport; + private Composite composite; public SensitivityChartAxisAndVariablesTab() { additionalSupport = new WidgetSupportImpl(); } - @Override - public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) { - Composite composite = new Composite(body, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); - - // (Ontology-based) GraphExplorer displaying range axis and variables mapped to those axis - explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( - "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); - explorer.setBrowseContexts(JFreeChartResource.URIs.ChartAxisAndVariablesBrowseContext); - explorer.setInputSource(new SingleSelectionInputSource( - Resource.class)); - explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning - explorer.finish(); - - ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateSelection(context); - } - }); - GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); - - // Scrolled composite for displaying properties of a selection in explorer - propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); - GridLayoutFactory.fillDefaults().applyTo(propertyContainer); - propertyContainer.setExpandHorizontal(true); - propertyContainer.setExpandVertical(true); - - } - /** * Updates the content of propertyContainer * @param context @@ -122,7 +92,7 @@ public class SensitivityChartAxisAndVariablesTab extends LabelPropertyTabContri } if(typeUri.equals(JFreeChartResource.URIs.Axis)) { - AxisPropertyComposite apc = new AxisPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE); + AxisPropertyComposite apc = new AxisPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE, isVertical()); propertyContainer.setContent(apc); Point size = apc.computeSize(SWT.DEFAULT, SWT.DEFAULT); propertyContainer.setMinSize(size); @@ -137,5 +107,61 @@ public class SensitivityChartAxisAndVariablesTab extends LabelPropertyTabContri additionalSupport.fireInput(context, selection); } + @Override + protected void createAndAddControls(Composite body, IWorkbenchSite site, + final ISessionContext context, WidgetSupport support) { + composite = new Composite(body, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + // (Ontology-based) GraphExplorer displaying range axis and variables mapped to those axis + explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys( + "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); + explorer.setBrowseContexts(JFreeChartResource.URIs.ChartAxisAndVariablesBrowseContext); + explorer.setInputSource(new SingleSelectionInputSource( + Resource.class)); + explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning + explorer.finish(); + + ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateSelection(context); + } + }); + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); + GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + propertyContainer.setExpandHorizontal(true); + propertyContainer.setExpandVertical(true); + + } + + @Override + protected void createControlLayoutVertical() { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(220, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().span(1, 1).hint(SWT.DEFAULT, 210).grab(true, false).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + } + + @Override + protected void createControlLayoutHorizontal(boolean wideScreen) { + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + + GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer); + + // Scrolled composite for displaying properties of a selection in explorer + GridDataFactory.fillDefaults().span(1, 2).hint(SWT.DEFAULT, SWT.DEFAULT).grab(true, true).applyTo(propertyContainer); + GridLayoutFactory.fillDefaults().applyTo(propertyContainer); + } + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java index c05d1ae4..4be6de7f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Association for Decentralized Information Management in + * Copyright (c) 2013, 2014 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 @@ -33,6 +33,7 @@ import org.simantics.sysdyn.SysdynResource; * UI for setting properties for sensitivity analysis series. Sensitivity analysis * charts display only one variable as a "fan" chart. * @author Teemu Lempinen + * @author Tuomas Miettinen * */ public class SensitivitySeriesPropertyComposite extends SeriesPropertyComposite { @@ -85,16 +86,19 @@ public class SensitivitySeriesPropertyComposite extends SeriesPropertyComposite }); - ConfidenceBoundWidget cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 0); - GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget); - cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 1); - GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget); - cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 2); - GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget); - cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 3); - GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget); - cbWidget = new ConfidenceBoundWidget(this, context, support, SWT.NONE, 4); - GridDataFactory.fillDefaults().span(2, 1).applyTo(cbWidget); + Composite c = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().span(2, 1).applyTo(c); + GridLayoutFactory.fillDefaults().numColumns(5).applyTo(c); + ConfidenceBoundWidget cbWidget = new ConfidenceBoundWidget(c, context, support, SWT.NONE, 0); + GridDataFactory.fillDefaults().applyTo(cbWidget); + cbWidget = new ConfidenceBoundWidget(c, context, support, SWT.NONE, 1); + GridDataFactory.fillDefaults().applyTo(cbWidget); + cbWidget = new ConfidenceBoundWidget(c, context, support, SWT.NONE, 2); + GridDataFactory.fillDefaults().applyTo(cbWidget); + cbWidget = new ConfidenceBoundWidget(c, context, support, SWT.NONE, 3); + GridDataFactory.fillDefaults().applyTo(cbWidget); + cbWidget = new ConfidenceBoundWidget(c, context, support, SWT.NONE, 4); + GridDataFactory.fillDefaults().applyTo(cbWidget); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java index d3a33699..928d8377 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java @@ -267,9 +267,11 @@ public class TrendView extends ViewPart { */ private void displayDefaultChart() { if(defaultchart == null) { + NumberAxis domainAxis = new NumberAxis("time"); + domainAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot( sysdynDatasets, - new NumberAxis("time"), + domainAxis, new NumberAxis(""), new XYLineAndShapeRenderer(true, false) ); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/UnitFunction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/UnitFunction.java index dbf2e2d0..2eeadea2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/UnitFunction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/UnitFunction.java @@ -62,7 +62,15 @@ public class UnitFunction { return Collections.emptyList(); // Make sure unit updates are listened to - String unit = graph.getPossibleRelatedValue(variable, SR.Variable_unit); + String unit = null; + if (graph.isInstanceOf(variable, SR.Shadow)) { + Resource original = graph.getPossibleObject(variable, SR.Shadow_original); + if (original == null) + return Collections.emptyList(); + unit = graph.getPossibleRelatedValue(original, SR.Variable_unit); + } else { + unit = graph.getPossibleRelatedValue(variable, SR.Variable_unit); + } if(unit == null || unit.trim().length() == 0) return Collections.singletonList(new StandardIssue(SR.Validations_UnitWarning, variable)); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsExportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsExportPage.java index 06b421f2..785df451 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsExportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsExportPage.java @@ -233,7 +233,7 @@ public class WizardFunctionsExportPage extends WizardPage { FileDialog dialog = new FileDialog(shell, SWT.SAVE); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdynFunctions"}; dialog.setFilterExtensions(ext); dialog.setText("Export Function Library"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsImportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsImportPage.java index 3e5600ae..702a96cd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsImportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsImportPage.java @@ -227,7 +227,7 @@ public class WizardFunctionsImportPage extends WizardPage{ FileDialog dialog = new FileDialog(shell, SWT.OPEN); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdynFunctions; *.tg", "*.*"}; dialog.setFilterExtensions(ext); dialog.setText("Import Function Library"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsExportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsExportPage.java index a7194de6..ae1f0e8e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsExportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsExportPage.java @@ -232,7 +232,7 @@ public class WizardModelsExportPage extends WizardPage { FileDialog dialog = new FileDialog(shell, SWT.SAVE); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdyn"}; dialog.setFilterExtensions(ext); dialog.setText("Export Model"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java index 636fd688..e91798ed 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java @@ -155,7 +155,7 @@ public class WizardModelsImportPage extends WizardPage{ FileDialog dialog = new FileDialog(shell, SWT.OPEN); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdyn; *.tg", "*.*"}; dialog.setFilterExtensions(ext); dialog.setText("Import Model"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesExportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesExportPage.java index d14135a9..3625dd9d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesExportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesExportPage.java @@ -236,7 +236,7 @@ public class WizardModulesExportPage extends WizardPage { FileDialog dialog = new FileDialog(shell, SWT.SAVE); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdynModule"}; dialog.setFilterExtensions(ext); dialog.setText("Export Module"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesImportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesImportPage.java index 65976791..415d02c3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesImportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesImportPage.java @@ -229,7 +229,7 @@ public class WizardModulesImportPage extends WizardPage{ FileDialog dialog = new FileDialog(shell, SWT.OPEN); - String[] ext = {"*.tg"}; + String[] ext = {"*.sysdynModule; *.tg", "*.*"}; dialog.setFilterExtensions(ext); dialog.setText("Import Module"); diff --git a/org.simantics.sysdyn.ui/sysdyn.product b/org.simantics.sysdyn.ui/sysdyn.product index ebda30ea..5c3c71bb 100644 --- a/org.simantics.sysdyn.ui/sysdyn.product +++ b/org.simantics.sysdyn.ui/sysdyn.product @@ -1,7 +1,7 @@ - + @@ -13,11 +13,12 @@ - -fixerrors ---launcher.XXMaxPermSize 192m + -fixerrors +--launcher.XXMaxPermSize 192m -data @noDefault -ea -Xmx768M -XX:MaxPermSize=192m -Xshare:off -Dorg.simantics.undo.enabled=false -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + -Dorg.osgi.framework.os.name=win32 @@ -31,6 +32,7 @@ + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 @@ -115,7 +117,7 @@ This Agreement is governed by the laws of the State of New York and the intellec - + diff --git a/org.simantics.sysdyn/META-INF/MANIFEST.MF b/org.simantics.sysdyn/META-INF/MANIFEST.MF index ef26f8fb..af0bfe79 100644 --- a/org.simantics.sysdyn/META-INF/MANIFEST.MF +++ b/org.simantics.sysdyn/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Simantics System Dynamics Bundle-SymbolicName: org.simantics.sysdyn;singleton:=true -Bundle-Version: 1.7.0.qualifier +Bundle-Version: 1.8.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.simantics.objmap;bundle-version="0.1.0", org.simantics.db;bundle-version="0.6.2", diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj index 5e8c3c2b..ce3b6126 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj @@ -109,9 +109,9 @@ TOKEN: { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | | "." ()? (["e","E"] )? - | "." (["e","E"] )? - | ["e","E"] + ( "." ()? (["e","E"] (["+","-"])? )? + | "." (["e","E"] (["+","-"])? )? + | ["e","E"] (["+","-"])? ) > } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParserTokenManager.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParserTokenManager.java index 011bc205..85adbb72 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParserTokenManager.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParserTokenManager.java @@ -27,7 +27,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) return 2; } if ((active1 & 0x20000L) != 0L) - return 16; + return 17; return -1; case 1: if ((active0 & 0x84020080400000L) != 0L) @@ -182,7 +182,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 66; return jjMoveStringLiteralDfa1_0(0x0L, 0x2cc000L); case 47: - return jjStartNfaWithStates_0(0, 81, 16); + return jjStartNfaWithStates_0(0, 81, 17); case 58: jjmatchedKind = 67; return jjMoveStringLiteralDfa1_0(0x0L, 0x800000L); @@ -830,7 +830,7 @@ static final long[] jjbitVec0 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 34; + jjnewStateCnt = 37; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -866,12 +866,12 @@ private int jjMoveNfa_0(int startState, int curPos) else if (curChar == 39) jjCheckNAddTwoStates(4, 5); break; - case 16: + case 17: if (curChar == 47) { if (kind > 3) kind = 3; - jjCheckNAdd(23); + jjCheckNAdd(24); } else if (curChar == 42) jjCheckNAddStates(10, 12); @@ -923,99 +923,111 @@ private int jjMoveNfa_0(int startState, int curPos) jjCheckNAddTwoStates(12, 13); break; case 14: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(15); + break; + case 15: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjstateSet[jjnewStateCnt++] = 14; + jjCheckNAdd(15); break; - case 15: + case 16: if (curChar == 47) jjAddStates(5, 6); break; - case 17: + case 18: if ((0xfffffbffffffffffL & l) != 0L) jjCheckNAddStates(10, 12); break; - case 18: + case 19: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 19; + jjstateSet[jjnewStateCnt++] = 20; break; - case 19: + case 20: if ((0xffff7fffffffffffL & l) != 0L) jjCheckNAddStates(10, 12); break; - case 20: + case 21: if (curChar == 47 && kind > 2) kind = 2; break; - case 21: + case 22: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 20; + jjstateSet[jjnewStateCnt++] = 21; break; - case 22: + case 23: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(23); + jjCheckNAdd(24); break; - case 23: + case 24: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(23); + jjCheckNAdd(24); break; - case 24: + case 25: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; jjCheckNAddStates(0, 4); break; - case 25: + case 26: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; - jjCheckNAdd(25); + jjCheckNAdd(26); break; - case 26: + case 27: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(26, 27); + jjCheckNAddTwoStates(27, 28); break; - case 27: + case 28: if (curChar != 46) break; if (kind > 92) kind = 92; - jjCheckNAddTwoStates(28, 29); + jjCheckNAddTwoStates(29, 30); break; - case 28: + case 29: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjCheckNAddTwoStates(28, 29); + jjCheckNAddTwoStates(29, 30); break; - case 30: + case 31: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(32); + break; + case 32: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjstateSet[jjnewStateCnt++] = 30; + jjCheckNAdd(32); break; - case 31: + case 33: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(31, 32); + jjCheckNAddTwoStates(33, 34); break; - case 33: + case 35: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(36); + break; + case 36: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjstateSet[jjnewStateCnt++] = 33; + jjCheckNAdd(36); break; default : break; } @@ -1053,24 +1065,24 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 13: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 14; + jjAddStates(15, 16); break; - case 17: - case 19: + case 18: + case 20: jjCheckNAddStates(10, 12); break; - case 23: + case 24: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 23; + jjstateSet[jjnewStateCnt++] = 24; break; - case 29: + case 30: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 30; + jjAddStates(17, 18); break; - case 32: + case 34: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 33; + jjAddStates(19, 20); break; default : break; } @@ -1089,17 +1101,17 @@ private int jjMoveNfa_0(int startState, int curPos) if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(7, 9); break; - case 17: - case 19: + case 18: + case 20: if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(10, 12); break; - case 23: + case 24: if ((jjbitVec0[i2] & l2) == 0L) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 23; + jjstateSet[jjnewStateCnt++] = 24; break; default : break; } @@ -1112,14 +1124,15 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 34 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 37 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { - 25, 26, 27, 31, 32, 16, 22, 7, 8, 10, 17, 18, 21, 4, 5, + 26, 27, 28, 33, 34, 17, 23, 7, 8, 10, 18, 19, 22, 4, 5, 14, + 15, 31, 32, 35, 36, }; /** Token literal values. */ @@ -1157,8 +1170,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[34]; -private final int[] jjstateSet = new int[68]; +private final int[] jjrounds = new int[37]; +private final int[] jjstateSet = new int[74]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1189,7 +1202,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 34; i-- > 0;) + for (i = 37; i-- > 0;) jjrounds[i] = 0x80000000; } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelParserTokenManager.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelParserTokenManager.java index 19264f96..ab57915f 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelParserTokenManager.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelParserTokenManager.java @@ -15,13 +15,13 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) switch (pos) { case 0: + if ((active1 & 0x80000L) != 0L) + return 14; if ((active0 & 0x3ffffffffffffff0L) != 0L || (active1 & 0xc0000000L) != 0L) { jjmatchedKind = 90; return 2; } - if ((active1 & 0x80000L) != 0L) - return 13; if ((active1 & 0xb30010L) != 0L) return 9; return -1; @@ -185,7 +185,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 68; return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L); case 47: - return jjStartNfaWithStates_0(0, 83, 13); + return jjStartNfaWithStates_0(0, 83, 14); case 58: jjmatchedKind = 69; return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L); @@ -936,7 +936,7 @@ static final long[] jjbitVec0 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 31; + jjnewStateCnt = 34; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -951,12 +951,12 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { - case 13: + case 14: if (curChar == 47) { if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); } else if (curChar == 42) jjCheckNAddStates(0, 2); @@ -1015,99 +1015,111 @@ private int jjMoveNfa_0(int startState, int curPos) jjCheckNAddTwoStates(9, 10); break; case 11: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(12); + break; + case 12: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 11; + jjCheckNAdd(12); break; - case 12: + case 13: if (curChar == 47) jjAddStates(8, 9); break; - case 14: + case 15: if ((0xfffffbffffffffffL & l) != 0L) jjCheckNAddStates(0, 2); break; - case 15: + case 16: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 16; + jjstateSet[jjnewStateCnt++] = 17; break; - case 16: + case 17: if ((0xffff7fffffffffffL & l) != 0L) jjCheckNAddStates(0, 2); break; - case 17: + case 18: if (curChar == 47 && kind > 2) kind = 2; break; - case 18: + case 19: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 17; + jjstateSet[jjnewStateCnt++] = 18; break; - case 19: + case 20: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); break; - case 20: + case 21: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); break; - case 21: + case 22: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; jjCheckNAddStates(3, 7); break; - case 22: + case 23: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjCheckNAdd(22); + jjCheckNAdd(23); break; - case 23: + case 24: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(23, 24); + jjCheckNAddTwoStates(24, 25); break; - case 24: + case 25: if (curChar != 46) break; if (kind > 93) kind = 93; - jjCheckNAddTwoStates(25, 26); + jjCheckNAddTwoStates(26, 27); break; - case 25: + case 26: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAddTwoStates(25, 26); + jjCheckNAddTwoStates(26, 27); break; - case 27: + case 28: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(29); + break; + case 29: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 27; + jjCheckNAdd(29); break; - case 28: + case 30: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(28, 29); + jjCheckNAddTwoStates(30, 31); break; - case 30: + case 32: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(33); + break; + case 33: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 30; + jjCheckNAdd(33); break; default : break; } @@ -1141,24 +1153,24 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 10: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; + jjAddStates(13, 14); break; - case 14: - case 16: + case 15: + case 17: jjCheckNAddStates(0, 2); break; - case 20: + case 21: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 20; + jjstateSet[jjnewStateCnt++] = 21; break; - case 26: + case 27: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; + jjAddStates(15, 16); break; - case 29: + case 31: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 30; + jjAddStates(17, 18); break; default : break; } @@ -1177,17 +1189,17 @@ private int jjMoveNfa_0(int startState, int curPos) if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(10, 12); break; - case 14: - case 16: + case 15: + case 17: if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(0, 2); break; - case 20: + case 21: if ((jjbitVec0[i2] & l2) == 0L) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 20; + jjstateSet[jjnewStateCnt++] = 21; break; default : break; } @@ -1200,14 +1212,15 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 34 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { - 14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 4, 5, 7, + 15, 16, 19, 23, 24, 25, 30, 31, 14, 20, 4, 5, 7, 11, 12, 28, + 29, 32, 33, }; /** Token literal values. */ @@ -1246,8 +1259,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[31]; -private final int[] jjstateSet = new int[62]; +private final int[] jjrounds = new int[34]; +private final int[] jjstateSet = new int[68]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1278,7 +1291,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 31; i-- > 0;) + for (i = 34; i-- > 0;) jjrounds[i] = 0x80000000; } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelicaParser.jj b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelicaParser.jj index 2f9f31eb..04e39995 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelicaParser.jj +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelicaParser.jj @@ -77,9 +77,9 @@ TOKEN: { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | | "." ()? (["e","E"] )? - | "." (["e","E"] )? - | ["e","E"] + ( "." ()? (["e","E"] (["+","-"])? )? + | "." (["e","E"] (["+","-"])? )? + | ["e","E"] (["+","-"])? ) > } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java index d74b5934..5b630875 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java @@ -32,6 +32,7 @@ import org.simantics.sysdyn.manager.SysdynModel; import org.simantics.sysdyn.representation.Configuration; import org.simantics.sysdyn.representation.IElement; import org.simantics.sysdyn.representation.Module; +import org.simantics.sysdyn.representation.Shadow; import org.simantics.sysdyn.representation.Variable; import org.simantics.sysdyn.unitParser.ParseException; import org.simantics.sysdyn.unitParser.UnitCheckingException; @@ -139,6 +140,8 @@ public class UnitUtils { // Support listening, if graph and mapping exists if(graph != null && model != null) { + if (var instanceof Shadow) + var = ((Shadow)var).getOriginal(); Resource varResource = model.getMapping().inverseGet(var); if(varResource != null) { try { @@ -187,8 +190,14 @@ public class UnitUtils { for(IElement e : configuration.getElements()) { if(e instanceof Variable) { Variable var = (Variable)e; - if(var.getName().equals(element)) - return var; + try { + if (element.equals(var.getName())) + return var; + } catch (NullPointerException npe) { + npe.printStackTrace(); + System.out.println("See UnitUtils"); + return null; + } } else if(e instanceof Module && elements.length > 1) { Module mod = (Module)e; if(mod.getName().equals(element)) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParser.jj b/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParser.jj index 74caa34c..c7bd0bd9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParser.jj +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParser.jj @@ -57,9 +57,9 @@ TOKEN: { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | | "." ()? (["e","E"] )? - | "." (["e","E"] )? - | ["e","E"] + ( "." ()? (["e","E"] (["+","-"])? )? + | "." (["e","E"] (["+","-"])? )? + | ["e","E"] (["+","-"])? ) > | | ))> } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParserTokenManager.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParserTokenManager.java index 3de87d4f..d8eae25d 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParserTokenManager.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/tableParser/TableParserTokenManager.java @@ -1,5 +1,6 @@ /* Generated By:JavaCC: Do not edit this line. TableParserTokenManager.java */ package org.simantics.sysdyn.tableParser; +import java.util.ArrayList; /** Token Manager. */ public class TableParserTokenManager implements TableParserConstants @@ -14,17 +15,17 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) switch (pos) { case 0: - if ((active1 & 0x80000L) != 0L) - return 24; if ((active0 & 0x3ffffffffffffff0L) != 0L) { jjmatchedKind = 90; return 2; } - if ((active1 & 0xb30010L) != 0L) - return 46; if ((active1 & 0x8000L) != 0L) return 9; + if ((active1 & 0xb30010L) != 0L) + return 52; + if ((active1 & 0x80000L) != 0L) + return 27; return -1; case 1: if ((active0 & 0x108420080400000L) != 0L) @@ -179,7 +180,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 68; return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L); case 47: - return jjStartNfaWithStates_0(0, 83, 24); + return jjStartNfaWithStates_0(0, 83, 27); case 58: jjmatchedKind = 69; return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L); @@ -831,7 +832,7 @@ static final long[] jjbitVec0 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 46; + jjnewStateCnt = 52; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -846,17 +847,7 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { - case 24: - if (curChar == 47) - { - if (kind > 3) - kind = 3; - jjCheckNAdd(31); - } - else if (curChar == 42) - jjCheckNAddStates(0, 2); - break; - case 46: + case 52: if ((0x3ff000000000000L & l) != 0L) { if (kind > 94) @@ -867,7 +858,7 @@ private int jjMoveNfa_0(int startState, int curPos) { if (kind > 93) kind = 93; - jjCheckNAddTwoStates(43, 44); + jjCheckNAddTwoStates(48, 49); } break; case 9: @@ -875,7 +866,7 @@ private int jjMoveNfa_0(int startState, int curPos) { if (kind > 94) kind = 94; - jjCheckNAddStates(3, 7); + jjCheckNAddStates(0, 4); } else if (curChar == 46) jjCheckNAdd(10); @@ -885,7 +876,7 @@ private int jjMoveNfa_0(int startState, int curPos) { if (kind > 92) kind = 92; - jjCheckNAddStates(8, 17); + jjCheckNAddStates(5, 14); } else if ((0x100002600L & l) != 0L) { @@ -893,12 +884,22 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 1; } else if (curChar == 46) - jjCheckNAddTwoStates(43, 10); + jjCheckNAddTwoStates(48, 10); else if (curChar == 47) - jjAddStates(18, 19); + jjAddStates(15, 16); else if (curChar == 45) - jjAddStates(20, 21); + jjAddStates(17, 18); else if (curChar == 34) + jjCheckNAddStates(19, 21); + break; + case 27: + if (curChar == 47) + { + if (kind > 3) + kind = 3; + jjCheckNAdd(34); + } + else if (curChar == 42) jjCheckNAddStates(22, 24); break; case 2: @@ -910,15 +911,15 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 3: if (curChar == 34) - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; case 4: if ((0xfffffffbfffffbffL & l) != 0L) - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; case 6: if ((0xfffffffffffffbffL & l) != 0L) - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; case 7: if (curChar == 34 && kind > 91) @@ -926,7 +927,7 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 8: if (curChar == 45) - jjAddStates(20, 21); + jjAddStates(17, 18); break; case 10: if ((0x3ff000000000000L & l) == 0L) @@ -936,167 +937,191 @@ private int jjMoveNfa_0(int startState, int curPos) jjCheckNAddTwoStates(10, 11); break; case 12: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(13); + break; + case 13: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjstateSet[jjnewStateCnt++] = 12; + jjCheckNAdd(13); break; - case 13: + case 14: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAddStates(3, 7); + jjCheckNAddStates(0, 4); break; - case 14: + case 15: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(14); + jjCheckNAdd(15); break; - case 15: + case 16: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(15, 16); + jjCheckNAddTwoStates(16, 17); break; - case 17: + case 18: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(19); + break; + case 19: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjstateSet[jjnewStateCnt++] = 17; + jjCheckNAdd(19); break; - case 18: + case 20: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(18, 19); + jjCheckNAddTwoStates(20, 21); break; - case 19: + case 21: if (curChar != 46) break; if (kind > 94) kind = 94; - jjCheckNAddTwoStates(20, 21); + jjCheckNAddTwoStates(22, 23); break; - case 20: + case 22: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAddTwoStates(20, 21); + jjCheckNAddTwoStates(22, 23); break; - case 22: + case 24: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(25); + break; + case 25: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjstateSet[jjnewStateCnt++] = 22; + jjCheckNAdd(25); break; - case 23: + case 26: if (curChar == 47) - jjAddStates(18, 19); + jjAddStates(15, 16); break; - case 25: + case 28: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); + jjCheckNAddStates(22, 24); break; - case 26: + case 29: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 27; + jjstateSet[jjnewStateCnt++] = 30; break; - case 27: + case 30: if ((0xffff7fffffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); + jjCheckNAddStates(22, 24); break; - case 28: + case 31: if (curChar == 47 && kind > 2) kind = 2; break; - case 29: + case 32: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 28; + jjstateSet[jjnewStateCnt++] = 31; break; - case 30: + case 33: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(31); + jjCheckNAdd(34); break; - case 31: + case 34: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(31); + jjCheckNAdd(34); break; - case 32: + case 35: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjCheckNAddStates(8, 17); + jjCheckNAddStates(5, 14); break; - case 33: + case 36: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 92) kind = 92; - jjCheckNAdd(33); + jjCheckNAdd(36); break; - case 34: + case 37: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(34, 35); + jjCheckNAddTwoStates(37, 38); break; - case 35: + case 38: if (curChar != 46) break; if (kind > 93) kind = 93; - jjCheckNAddTwoStates(36, 37); + jjCheckNAddTwoStates(39, 40); break; - case 36: + case 39: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAddTwoStates(36, 37); + jjCheckNAddTwoStates(39, 40); break; - case 38: + case 41: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(42); + break; + case 42: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 38; + jjCheckNAdd(42); break; - case 39: + case 43: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(39, 40); + jjCheckNAddTwoStates(43, 44); break; - case 41: + case 45: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(46); + break; + case 46: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 41; + jjCheckNAdd(46); break; - case 42: + case 47: if (curChar == 46) - jjCheckNAddTwoStates(43, 10); + jjCheckNAddTwoStates(48, 10); break; - case 43: + case 48: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAddTwoStates(43, 44); + jjCheckNAddTwoStates(48, 49); break; - case 45: + case 50: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(51); + break; + case 51: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjstateSet[jjnewStateCnt++] = 45; + jjCheckNAdd(51); break; default : break; } @@ -1119,47 +1144,47 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 4: if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; case 5: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 6; break; case 6: - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; case 11: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 12; + jjAddStates(25, 26); break; - case 16: + case 17: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 17; + jjAddStates(27, 28); break; - case 21: + case 23: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 22; + jjAddStates(29, 30); break; - case 25: - case 27: - jjCheckNAddStates(0, 2); + case 28: + case 30: + jjCheckNAddStates(22, 24); break; - case 31: + case 34: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 31; - break; - case 37: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 38; + jjstateSet[jjnewStateCnt++] = 34; break; case 40: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 41; + jjAddStates(31, 32); break; case 44: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 45; + jjAddStates(33, 34); + break; + case 49: + if ((0x2000000020L & l) != 0L) + jjAddStates(35, 36); break; default : break; } @@ -1176,19 +1201,19 @@ private int jjMoveNfa_0(int startState, int curPos) case 4: case 6: if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(22, 24); + jjCheckNAddStates(19, 21); break; - case 25: - case 27: + case 28: + case 30: if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(0, 2); + jjCheckNAddStates(22, 24); break; - case 31: + case 34: if ((jjbitVec0[i2] & l2) == 0L) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 31; + jjstateSet[jjnewStateCnt++] = 34; break; default : break; } @@ -1201,15 +1226,16 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 46 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 52 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { - 25, 26, 29, 14, 15, 16, 18, 19, 33, 34, 35, 39, 40, 14, 15, 16, - 18, 19, 24, 30, 9, 13, 4, 5, 7, + 15, 16, 17, 20, 21, 36, 37, 38, 43, 44, 15, 16, 17, 20, 21, 27, + 33, 9, 14, 4, 5, 7, 28, 29, 32, 12, 13, 18, 19, 24, 25, 41, + 42, 45, 46, 50, 51, }; /** Token literal values. */ @@ -1247,8 +1273,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[46]; -private final int[] jjstateSet = new int[92]; +private final int[] jjrounds = new int[52]; +private final int[] jjstateSet = new int[104]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1279,7 +1305,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 46; i-- > 0;) + for (i = 52; i-- > 0;) jjrounds[i] = 0x80000000; } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jj b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jj index 7261f8cf..35d321e2 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jj +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jj @@ -53,9 +53,9 @@ TOKEN: { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | | "." ()? (["e","E"] )? - | "." (["e","E"] )? - | ["e","E"] + ( "." ()? (["e","E"] (["+","-"])? )? + | "." (["e","E"] (["+","-"])? )? + | ["e","E"] (["+","-"])? ) > } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jjt b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jjt index 81d5fcb8..af0cd4bf 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jjt +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParser.jjt @@ -49,9 +49,9 @@ TOKEN: { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | | "." ()? (["e","E"] )? - | "." (["e","E"] )? - | ["e","E"] + ( "." ()? (["e","E"] (["+","-"])? )? + | "." (["e","E"] (["+","-"])? )? + | ["e","E"] (["+","-"])? ) > } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParserTokenManager.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParserTokenManager.java index 17e5dd5c..1758bea8 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParserTokenManager.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitParserTokenManager.java @@ -20,7 +20,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) return 2; } if ((active1 & 0x20000L) != 0L) - return 13; + return 14; if ((active1 & 0x2cc004L) != 0L) return 9; return -1; @@ -177,7 +177,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 66; return jjMoveStringLiteralDfa1_0(0x0L, 0x2cc000L); case 47: - return jjStartNfaWithStates_0(0, 81, 13); + return jjStartNfaWithStates_0(0, 81, 14); case 58: jjmatchedKind = 67; return jjMoveStringLiteralDfa1_0(0x0L, 0x800000L); @@ -837,7 +837,7 @@ static final long[] jjbitVec5 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 31; + jjnewStateCnt = 34; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -852,12 +852,12 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { - case 13: + case 14: if (curChar == 47) { if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); } else if (curChar == 42) jjCheckNAddStates(0, 2); @@ -929,99 +929,111 @@ private int jjMoveNfa_0(int startState, int curPos) jjCheckNAddTwoStates(9, 10); break; case 11: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(12); + break; + case 12: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; - jjstateSet[jjnewStateCnt++] = 11; + jjCheckNAdd(12); break; - case 12: + case 13: if (curChar == 47) jjAddStates(8, 9); break; - case 14: + case 15: if ((0xfffffbffffffffffL & l) != 0L) jjCheckNAddStates(0, 2); break; - case 15: + case 16: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 16; + jjstateSet[jjnewStateCnt++] = 17; break; - case 16: + case 17: if ((0xffff7fffffffffffL & l) != 0L) jjCheckNAddStates(0, 2); break; - case 17: + case 18: if (curChar == 47 && kind > 2) kind = 2; break; - case 18: + case 19: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 17; + jjstateSet[jjnewStateCnt++] = 18; break; - case 19: + case 20: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); break; - case 20: + case 21: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(20); + jjCheckNAdd(21); break; - case 21: + case 22: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 90) kind = 90; jjCheckNAddStates(3, 7); break; - case 22: + case 23: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 90) kind = 90; - jjCheckNAdd(22); + jjCheckNAdd(23); break; - case 23: + case 24: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(23, 24); + jjCheckNAddTwoStates(24, 25); break; - case 24: + case 25: if (curChar != 46) break; if (kind > 91) kind = 91; - jjCheckNAddTwoStates(25, 26); + jjCheckNAddTwoStates(26, 27); break; - case 25: + case 26: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; - jjCheckNAddTwoStates(25, 26); + jjCheckNAddTwoStates(26, 27); break; - case 27: + case 28: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(29); + break; + case 29: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; - jjstateSet[jjnewStateCnt++] = 27; + jjCheckNAdd(29); break; - case 28: + case 30: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(28, 29); + jjCheckNAddTwoStates(30, 31); break; - case 30: + case 32: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(33); + break; + case 33: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 91) kind = 91; - jjstateSet[jjnewStateCnt++] = 30; + jjCheckNAdd(33); break; default : break; } @@ -1055,24 +1067,24 @@ private int jjMoveNfa_0(int startState, int curPos) break; case 10: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; + jjAddStates(13, 14); break; - case 14: - case 16: + case 15: + case 17: jjCheckNAddStates(0, 2); break; - case 20: + case 21: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 20; + jjstateSet[jjnewStateCnt++] = 21; break; - case 26: + case 27: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; + jjAddStates(15, 16); break; - case 29: + case 31: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 30; + jjAddStates(17, 18); break; default : break; } @@ -1102,17 +1114,17 @@ private int jjMoveNfa_0(int startState, int curPos) if (jjCanMove_1(hiByte, i1, i2, l1, l2)) jjCheckNAddStates(10, 12); break; - case 14: - case 16: + case 15: + case 17: if (jjCanMove_2(hiByte, i1, i2, l1, l2)) jjCheckNAddStates(0, 2); break; - case 20: + case 21: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 20; + jjstateSet[jjnewStateCnt++] = 21; break; default : break; } @@ -1125,14 +1137,15 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 34 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { - 14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 4, 5, 7, + 15, 16, 19, 23, 24, 25, 30, 31, 14, 20, 4, 5, 7, 11, 12, 28, + 29, 32, 33, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { @@ -1206,8 +1219,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[31]; -private final int[] jjstateSet = new int[62]; +private final int[] jjrounds = new int[34]; +private final int[] jjstateSet = new int[68]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1238,7 +1251,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 31; i-- > 0;) + for (i = 34; i-- > 0;) jjrounds[i] = 0x80000000; }