From 3fdffcd547209ff0b178cbbb859d030199101895 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Fri, 11 Jul 2014 10:37:04 +0000 Subject: [PATCH] refs #5090 Add Default constructor, hashCode() and equals() methods to LabelPropertyTabContributor so that ComparableTabContributor comparison works correctly git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29859 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ChartSelectionTabContributor.java | 32 +++++++++---------- .../chart/properties/AdjustableTab.java | 4 +++ .../jfreechart/chart/properties/ChartTab.java | 4 +++ .../LabelPropertyTabContributor.java | 24 ++++++++++++++ .../chart/properties/bar/BarAxisTab.java | 4 +++ .../bar/BarGeneralPropertiesTab.java | 7 ++-- .../chart/properties/bar/BarSeriesTab.java | 3 +- .../chart/properties/bar/BarSeriesTab2.java | 3 +- .../pie/PieGeneralPropertiesTab.java | 7 ++-- .../chart/properties/pie/PieSeriesTab.java | 3 +- .../chart/properties/pie/PieSeriesTab2.java | 3 +- .../xyline/XYLineAxisAndVariablesTab.java | 3 +- .../xyline/XYLineGeneralPropertiesTab.java | 4 +++ 13 files changed, 70 insertions(+), 31 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java index f8b0d764..df95e714 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java @@ -41,46 +41,46 @@ public class ChartSelectionTabContributor { if(backend.isInstanceOf(plot, jfree.XYPlot)) { tabs.add(new ComparableTabContributor( - new XYLineGeneralPropertiesTab(), + new XYLineGeneralPropertiesTab(r), 10, r, "General")); tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(), + new XYLineAxisAndVariablesTab(r), 9, r, "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( - new BarGeneralPropertiesTab(options), + new BarGeneralPropertiesTab(r, options), 10, r, "General")); tabs.add(new ComparableTabContributor( - new BarSeriesTab(options), + new BarSeriesTab(r, options), 9, r, "Variables")); tabs.add(new ComparableTabContributor( - new BarAxisTab(), + new BarAxisTab(r), 8, r, "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( - new PieGeneralPropertiesTab(options), + new PieGeneralPropertiesTab(r, options), 10, r, "General")); tabs.add(new ComparableTabContributor( - new PieSeriesTab(options), + new PieSeriesTab(r, options), 9, r, "Variables")); } tabs.add(new ComparableTabContributor( - new ChartTab(), + new ChartTab(r), 1, r, "Chart")); @@ -110,46 +110,46 @@ public class ChartSelectionTabContributor { if(backend.isInstanceOf(plot, jfree.XYPlot)) { tabs.add(new ComparableTabContributor( - new XYLineGeneralPropertiesTab(), + new XYLineGeneralPropertiesTab(r), 10, r, "General")); tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(), + new XYLineAxisAndVariablesTab(r), 9, r, "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( - new BarGeneralPropertiesTab(options), + new BarGeneralPropertiesTab(r, options), 10, r, "General")); tabs.add(new ComparableTabContributor( - new BarSeriesTab2(options), + new BarSeriesTab2(r, options), 9, r, "Variables")); tabs.add(new ComparableTabContributor( - new BarAxisTab(), + new BarAxisTab(r), 8, r, "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( - new PieGeneralPropertiesTab(options), + new PieGeneralPropertiesTab(r, options), 10, r, "General")); tabs.add(new ComparableTabContributor( - new PieSeriesTab2(options), + new PieSeriesTab2(r, options), 9, r, "Variables")); } tabs.add(new ComparableTabContributor( - new ChartTab(), + new ChartTab(r), 1, r, "Chart")); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java index 7fffd394..a0f8308d 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java @@ -32,6 +32,10 @@ public abstract class AdjustableTab extends LabelPropertyTabContributor { private static final int WIDE_SCREEN_WIDTH = 1100; protected Composite composite; + public AdjustableTab(Object id) { + super(id); + } + @Override public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport _support) { // Get size of the available area. diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ChartTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ChartTab.java index d8d20f0e..1135348d 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ChartTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ChartTab.java @@ -28,6 +28,10 @@ import org.simantics.utils.ui.AdaptionUtils; */ public class ChartTab extends LabelPropertyTabContributor implements Widget { + public ChartTab(Object id) { + super(id); + } + private Composite parent; @Override diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java index 8c0441c4..14b57a98 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java @@ -24,6 +24,13 @@ import org.simantics.utils.ui.AdaptionUtils; public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl { + private final Object id; + + public LabelPropertyTabContributor(Object id) { + assert (id != null); + this.id = id; + } + @Override public Read getPartNameReadRequest(final ISelection forSelection) { @@ -63,4 +70,21 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor } + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LabelPropertyTabContributor other = (LabelPropertyTabContributor) obj; + return id.equals(other.id); + } + } 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 38f7d21e..9bb9ade9 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 @@ -61,6 +61,10 @@ import org.simantics.utils.ui.AdaptionUtils; */ public class BarAxisTab extends AdjustableTab implements Widget { + public BarAxisTab(Object id) { + super(id); + } + private TrackedSpinner angle; private Integer angleInt = null; private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl(); 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 370d14dc..79bdf922 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 @@ -90,11 +90,8 @@ public class BarGeneralPropertiesTab extends AdjustableTab { private TrackedText fraction; private Point size; - public BarGeneralPropertiesTab() { - - } - - public BarGeneralPropertiesTab(int options) { + public BarGeneralPropertiesTab(Object id, int options) { + super(id); showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); } 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 5a9c55a2..9d9ca5c6 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 @@ -63,7 +63,8 @@ public class BarSeriesTab extends AdjustableTab implements Widget { private int options; private Composite buttonComposite; - public BarSeriesTab(int options) { + public BarSeriesTab(Object id, int options) { + super(id); additionalSupport = new WidgetSupportImpl(); this.options = options; } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java index 24076dda..cff6d719 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java @@ -66,7 +66,8 @@ public class BarSeriesTab2 extends LabelPropertyTabContributor implements Widget private BarSeriesPropertyComposite2 spc; private int options; - public BarSeriesTab2(int options) { + public BarSeriesTab2(Object id, int options) { + super(id); additionalSupport = new WidgetSupportImpl(); this.options = options; } 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 3185932a..75ee2a62 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 @@ -72,11 +72,8 @@ public class PieGeneralPropertiesTab extends AdjustableTab { private TrackedText fraction; private Point size; - public PieGeneralPropertiesTab() { - - } - - public PieGeneralPropertiesTab(int options) { + public PieGeneralPropertiesTab(Object id, int options) { + super(id); showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); } 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 d5cf346a..5fbb53c1 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 @@ -62,7 +62,8 @@ public class PieSeriesTab extends AdjustableTab implements Widget { private int options; private Composite buttonComposite; - public PieSeriesTab(int options) { + public PieSeriesTab(Object id, int options) { + super(id); additionalSupport = new WidgetSupportImpl(); this.options = options; } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java index 7103b6f8..8d54eb5c 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java @@ -65,7 +65,8 @@ public class PieSeriesTab2 extends LabelPropertyTabContributor implements Widget private Resource chartResource; private int options; - public PieSeriesTab2(int options) { + public PieSeriesTab2(Object id, int options) { + super(id); additionalSupport = new WidgetSupportImpl(); this.options = options; } 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 98d7107e..ea2714ec 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 @@ -65,7 +65,8 @@ public class XYLineAxisAndVariablesTab extends AdjustableTab { private WidgetSupportImpl additionalSupport; private Composite buttonComposite; - public XYLineAxisAndVariablesTab() { + public XYLineAxisAndVariablesTab(Object id) { + super(id); additionalSupport = new WidgetSupportImpl(); } 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 81581d14..3521025b 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 @@ -71,6 +71,10 @@ import org.simantics.utils.ui.AdaptionUtils; */ public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget { + public XYLineGeneralPropertiesTab(Object id) { + super(id); + } + private ScrolledComposite sc; private TrackedText name, title, xlabel, xvariable, xmin, xmax; private TrackedCombo type; -- 2.47.1