From 3229e5707752a56fab10965209628887699ad821 Mon Sep 17 00:00:00 2001 From: miettinen Date: Tue, 18 Feb 2014 12:56:13 +0000 Subject: [PATCH] Added alternative vertical layout for all relevant Sysdyn selection tabs (incl. some JFreeChart tabs) (refs #4708). git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28886 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../chart}/properties/AdjustableTab.java | 11 +- .../chart/properties/bar/BarAxisTab.java | 371 +++++++++----- .../bar/BarGeneralPropertiesTab.java | 456 +++++++++++------- .../chart/properties/bar/BarSeriesTab.java | 123 +++-- .../pie/PieGeneralPropertiesTab.java | 244 +++++++--- .../chart/properties/pie/PieSeriesTab.java | 125 +++-- .../xyline/AxisPropertyComposite.java | 50 +- .../xyline/XYLineAxisAndVariablesTab.java | 132 +++-- .../xyline/XYLineGeneralPropertiesTab.java | 417 ++++++++++------ .../ui/properties/ArrayDependencyTab.java | 3 +- .../sysdyn/ui/properties/ArrayFlowTab.java | 3 +- .../sysdyn/ui/properties/ArrayIndexesTab.java | 1 + .../sysdyn/ui/properties/CommentTab.java | 3 +- .../ui/properties/ConfigurationTab.java | 1 + .../sysdyn/ui/properties/DependencyTab.java | 195 +++++--- .../sysdyn/ui/properties/EnumerationTab.java | 3 +- .../sysdyn/ui/properties/EquationTab.java | 6 +- .../sysdyn/ui/properties/ExperimentTab.java | 3 +- .../ui/properties/ExternalFilesTab.java | 3 +- .../sysdyn/ui/properties/FlowTab.java | 3 +- .../ui/properties/FunctionLibraryTab.java | 3 +- .../sysdyn/ui/properties/FunctionTab.java | 81 +++- .../ui/properties/GameExperimentTab.java | 1 + .../sysdyn/ui/properties/HistoryDataTab.java | 3 +- .../ui/properties/InputVariableTab.java | 3 +- .../LabelPropertyTabContributor.java | 110 ----- .../sysdyn/ui/properties/LookupTableTab.java | 3 +- .../sysdyn/ui/properties/LoopTab.java | 1 + .../sysdyn/ui/properties/ModuleInputTab.java | 3 +- .../sysdyn/ui/properties/ModuleOutputTab.java | 3 +- .../ui/properties/ModuleParameterTab.java | 3 +- .../sysdyn/ui/properties/ModuleTab.java | 3 +- .../sysdyn/ui/properties/ModuleTypeTab.java | 3 +- .../ui/properties/PlaybackExperimentTab.java | 3 +- .../ui/properties/ReferenceDependencyTab.java | 3 +- .../sysdyn/ui/properties/ResultTab.java | 3 +- .../SensitivityAnalysisExperimentTab.java | 319 +++++++----- .../SharedFunctionLibrariesTab.java | 3 +- .../ui/properties/VariableInformationTab.java | 336 +++++++------ .../ui/trend/ConfidenceBoundWidget.java | 25 +- .../SensitivityChartAxisAndVariablesTab.java | 96 ++-- .../SensitivitySeriesPropertyComposite.java | 26 +- 42 files changed, 1998 insertions(+), 1189 deletions(-) rename {org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui => org.simantics.jfreechart/src/org/simantics/jfreechart/chart}/properties/AdjustableTab.java (89%) delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java 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/bar/BarAxisTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java index 34862e36..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 @@ -41,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; @@ -56,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; @@ -67,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().margins(3, 3).applyTo(composite); - - // Domain Axis properties - Group domainGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(domainGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).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).span(3, 1).applyTo(rangelabel.getWidget()); - - Composite axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 2).applyTo(axisHide); - - Label angleLabel = new Label(domainGroup, SWT.NONE); - angleLabel.setText("Label angle:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).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().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(angle.getWidget()); - - // Domain Color - label = new Label(domainGroup, SWT.NONE); - label.setText("Color:"); - GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label); - - Composite colorPicker = new ColorPicker(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker); - - domainGroup.layout(); - - // Range Axis properties - Group rangeGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).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).span(3, 1).applyTo(rangelabel.getWidget()); - - axisHide = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 2).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().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).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().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label); - - colorPicker = new ColorPicker(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).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} @@ -297,4 +199,233 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { } }); } + + @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 2c4f9c4b..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(3).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).span(2, 1).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,14 +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()); - // Tick and label visibility - Composite c = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 2).applyTo(c); - GridLayoutFactory.fillDefaults().applyTo(c); - Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(axisHide); - + 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:"); @@ -94,7 +105,18 @@ public class AxisPropertyComposite extends Composite { Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - - } + + 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 40519fea..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 @@ -44,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; @@ -66,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; @@ -76,148 +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(5).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()); - - // Min value for x-axis - label = new Label(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Min:"); - - xmin = new TrackedText(xgroup, 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)); - - // Axis hide buttons - 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()); - - // Max value for x-axis - label = new Label(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Max:"); - xmax = new TrackedText(xgroup, 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)); - GridDataFactory.fillDefaults().applyTo(xmax.getWidget()); - - // 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) { @@ -323,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.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..1a8929a1 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; 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 0a2bf002..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; 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 3f747ef1..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(3).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).span(2, 1).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).span(2, 1).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,71 +535,110 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }); - DistributionPropertyWidget dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(dpw); - GridLayoutFactory.fillDefaults().margins(6, 0).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/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); } -- 2.47.1