From: jsimomaa Date: Wed, 16 Jul 2014 13:11:04 +0000 (+0000) Subject: Merged trunk @29859, 29877, 29880, 29881, 29864, 29886 X-Git-Tag: 1.8.1~7 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=20961af72b7e90028e38321c41c8fcb6ca03839d;p=simantics%2Fsysdyn.git Merged trunk @29859, 29877, 29880, 29881, 29864, 29886 refs #5090 refs #5092 refs #5099 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@29908 ac1ea38d-2e2b-0410-8846-a27921b304fc --- 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/BooleanSelectionListener.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java index 3fe269b9..ff27eb2e 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java @@ -17,6 +17,7 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.management.ISessionContext; import org.simantics.layer0.Layer0; @@ -85,9 +86,13 @@ public class BooleanSelectionListener extends SelectionListenerImpl { private void setValue(WriteGraph graph, Resource resource) throws DatabaseException { Resource property = graph.getResource(propertyURI); Boolean value = graph.getPossibleRelatedValue(resource, property, Bindings.BOOLEAN); - if (value == null) + if (value == null) { graph.claimLiteral(resource, property, !defaultValue); - else - graph.claimLiteral(resource, property, Boolean.FALSE.equals(value)); + Layer0Utils.addCommentMetadata(graph, "Modified " + graph.getPossibleRelatedValue2(property, Layer0.getInstance(graph).HasName, Bindings.STRING) + " for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasLabel, Bindings.STRING) + " to " + !defaultValue); + } else { + boolean newValue = Boolean.FALSE.equals(value); + graph.claimLiteral(resource, property, newValue); + Layer0Utils.addCommentMetadata(graph, "Modified " + graph.getPossibleRelatedValue2(property, Layer0.getInstance(graph).HasName, Bindings.STRING) + " for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasLabel, Bindings.STRING) + " to " + newValue); + } } } \ No newline at end of file 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/ColorPicker.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ColorPicker.java index e5f003f8..7a0d9ce5 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ColorPicker.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ColorPicker.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.simantics.jfreechart.chart.properties; +import java.util.Arrays; + import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.resource.ImageDescriptor; @@ -24,22 +26,26 @@ import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.simantics.Simantics; import org.simantics.browsing.ui.swt.widgets.Button; import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.management.ISessionContext; import org.simantics.db.procedure.Listener; import org.simantics.db.request.Read; import org.simantics.diagram.stubs.G2DResource; +import org.simantics.layer0.Layer0; import org.simantics.sysdyn.JFreeChartResource; -import org.simantics.ui.SimanticsUI; import org.simantics.utils.RunnableWithObject; import org.simantics.utils.datastructures.Triple; import org.simantics.utils.ui.AdaptionUtils; @@ -264,47 +270,50 @@ public class ColorPicker extends Composite implements Widget { this.e = e; super.widgetSelected(e); } + + @Override + public void beforeApply(final Resource input) { + try { + final RGB oldRGB = Simantics.getSession().syncRequest(new UniqueRead() { + + @Override + public RGB perform(ReadGraph graph) throws DatabaseException { + Resource resource = getResource(graph, input); + return getColor(graph, resource); + } + }); + + final Display display = color.getWidget().getDisplay(); + + // Use color dialog to select a color + Shell shell = new Shell(display); + ColorDialog cd = new ColorDialog(shell); + Point point = color.getWidget().toDisplay(e.x - 150, e.y - 150); + cd.getParent().setLocation(point.x, point.y); + cd.setText("Select color"); + cd.setRGB(oldRGB); + rgb = cd.open(); + if(rgb == null) + return; + + + } catch (DatabaseException e) { + e.printStackTrace(); + } + } @Override public void apply(WriteGraph graph, Resource input) throws DatabaseException { - if(color.getWidget().isDisposed()) - return; - - final Resource resource = getResource(graph, input); - final Display display = color.getWidget().getDisplay(); - final RGB oldRGB = getColor(graph, resource); - display.asyncExec(new RunnableWithObject(oldRGB) { - @Override - public void run() { - // Use color dialog to select a color - Shell shell = new Shell(display); - ColorDialog cd = new ColorDialog(shell); - Point point = color.getWidget().toDisplay(e.x - 150, e.y - 150); - cd.getParent().setLocation(point.x, point.y); - cd.setText("Select color"); - cd.setRGB((RGB)getObject()); - rgb = cd.open(); - if(rgb == null) - return; - - SimanticsUI.getSession().asyncRequest(new WriteRequest() { - - @Override - public void perform(WriteGraph graph) throws DatabaseException { - G2DResource g2d = G2DResource.getInstance(graph); - float[] components = new float[] {rgb.red / 255.0f, rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f}; - graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components); - } - }); - - } - }); - - - + G2DResource g2d = G2DResource.getInstance(graph); + float[] components = new float[] {rgb.red / 255.0f, rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f}; + Resource resource = getResource(graph, input); + float[] currentComponents = graph.getPossibleRelatedValue2(resource, getColorRelation(graph)); + if (currentComponents == null || !Arrays.equals(components, currentComponents)) { + graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components); + Layer0Utils.addCommentMetadata(graph, "Modified color of " + NameUtils.getSafeName(graph, resource) + " to " + Arrays.toString(components)); + } } - } /** @@ -376,10 +385,15 @@ public class ColorPicker extends Composite implements Widget { float[] components = java.awt.Color.BLUE.getColorComponents(new float[4]); components[3] = 1.0f; graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components); + Layer0Utils.addCommentMetadata(graph, "Color for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING) + " set to custom "); } } else { // Default selected, remove color definition - graph.deny(resource, getColorRelation(graph)); + Object o = graph.getPossibleObject(resource, getColorRelation(graph)); + if (o != null) { + graph.deny(resource, getColorRelation(graph)); + Layer0Utils.addCommentMetadata(graph, "Color for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING) + " set to Default"); + } } } } 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..b1cbbbfb 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 { + protected 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;