\r
if(backend.isInstanceOf(plot, jfree.XYPlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new XYLineGeneralPropertiesTab(),\r
+ new XYLineGeneralPropertiesTab(r),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new XYLineAxisAndVariablesTab(),\r
+ new XYLineAxisAndVariablesTab(r),\r
9,\r
r,\r
"Axis and Variables"));\r
} else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new BarGeneralPropertiesTab(options),\r
+ new BarGeneralPropertiesTab(r, options),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new BarSeriesTab(options),\r
+ new BarSeriesTab(r, options),\r
9,\r
r,\r
"Variables"));\r
tabs.add(new ComparableTabContributor(\r
- new BarAxisTab(),\r
+ new BarAxisTab(r),\r
8,\r
r,\r
"Axis")); \r
} else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new PieGeneralPropertiesTab(options),\r
+ new PieGeneralPropertiesTab(r, options),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new PieSeriesTab(options),\r
+ new PieSeriesTab(r, options),\r
9,\r
r,\r
"Variables"));\r
}\r
\r
tabs.add(new ComparableTabContributor(\r
- new ChartTab(),\r
+ new ChartTab(r),\r
1,\r
r,\r
"Chart"));\r
\r
if(backend.isInstanceOf(plot, jfree.XYPlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new XYLineGeneralPropertiesTab(),\r
+ new XYLineGeneralPropertiesTab(r),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new XYLineAxisAndVariablesTab(),\r
+ new XYLineAxisAndVariablesTab(r),\r
9,\r
r,\r
"Axis and Variables"));\r
} else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new BarGeneralPropertiesTab(options),\r
+ new BarGeneralPropertiesTab(r, options),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new BarSeriesTab2(options),\r
+ new BarSeriesTab2(r, options),\r
9,\r
r,\r
"Variables"));\r
tabs.add(new ComparableTabContributor(\r
- new BarAxisTab(),\r
+ new BarAxisTab(r),\r
8,\r
r,\r
"Axis")); \r
} else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
tabs.add(new ComparableTabContributor(\r
- new PieGeneralPropertiesTab(options),\r
+ new PieGeneralPropertiesTab(r, options),\r
10,\r
r,\r
"General"));\r
tabs.add(new ComparableTabContributor(\r
- new PieSeriesTab2(options),\r
+ new PieSeriesTab2(r, options),\r
9,\r
r,\r
"Variables"));\r
}\r
\r
tabs.add(new ComparableTabContributor(\r
- new ChartTab(),\r
+ new ChartTab(r),\r
1,\r
r,\r
"Chart"));\r
private static final int WIDE_SCREEN_WIDTH = 1100;\r
protected Composite composite;\r
\r
+ public AdjustableTab(Object id) {\r
+ super(id);\r
+ }\r
+ \r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport _support) {\r
// Get size of the available area.\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
\r
private void setValue(WriteGraph graph, Resource resource) throws DatabaseException {\r
Resource property = graph.getResource(propertyURI);\r
Boolean value = graph.getPossibleRelatedValue(resource, property, Bindings.BOOLEAN);\r
- if (value == null)\r
+ if (value == null) {\r
graph.claimLiteral(resource, property, !defaultValue);\r
- else\r
- graph.claimLiteral(resource, property, Boolean.FALSE.equals(value));\r
+ 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);\r
+ } else { \r
+ boolean newValue = Boolean.FALSE.equals(value);\r
+ graph.claimLiteral(resource, property, newValue);\r
+ 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);\r
+ }\r
}\r
}
\ No newline at end of file
*/\r
public class ChartTab extends LabelPropertyTabContributor implements Widget {\r
\r
+ public ChartTab(Object id) {\r
+ super(id);\r
+ }\r
+\r
private Composite parent;\r
\r
@Override\r
*******************************************************************************/\r
package org.simantics.jfreechart.chart.properties;\r
\r
+import java.util.Arrays;\r
+\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Display;\r
import org.eclipse.swt.widgets.Shell;\r
+import org.simantics.Simantics;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.db.procedure.Listener;\r
import org.simantics.db.request.Read;\r
import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.RunnableWithObject;\r
import org.simantics.utils.datastructures.Triple;\r
import org.simantics.utils.ui.AdaptionUtils;\r
this.e = e;\r
super.widgetSelected(e);\r
}\r
+ \r
+ @Override\r
+ public void beforeApply(final Resource input) {\r
+ try {\r
+ final RGB oldRGB = Simantics.getSession().syncRequest(new UniqueRead<RGB>() {\r
+\r
+ @Override\r
+ public RGB perform(ReadGraph graph) throws DatabaseException {\r
+ Resource resource = getResource(graph, input);\r
+ return getColor(graph, resource);\r
+ }\r
+ });\r
+ \r
+ final Display display = color.getWidget().getDisplay();\r
+ \r
+ // Use color dialog to select a color\r
+ Shell shell = new Shell(display);\r
+ ColorDialog cd = new ColorDialog(shell);\r
+ Point point = color.getWidget().toDisplay(e.x - 150, e.y - 150);\r
+ cd.getParent().setLocation(point.x, point.y);\r
+ cd.setText("Select color");\r
+ cd.setRGB(oldRGB);\r
+ rgb = cd.open();\r
+ if(rgb == null)\r
+ return;\r
+ \r
+ \r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
\r
@Override\r
public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
- if(color.getWidget().isDisposed())\r
- return;\r
- \r
- final Resource resource = getResource(graph, input);\r
- final Display display = color.getWidget().getDisplay();\r
- final RGB oldRGB = getColor(graph, resource);\r
\r
- display.asyncExec(new RunnableWithObject(oldRGB) {\r
- @Override\r
- public void run() {\r
- // Use color dialog to select a color\r
- Shell shell = new Shell(display);\r
- ColorDialog cd = new ColorDialog(shell);\r
- Point point = color.getWidget().toDisplay(e.x - 150, e.y - 150);\r
- cd.getParent().setLocation(point.x, point.y);\r
- cd.setText("Select color");\r
- cd.setRGB((RGB)getObject());\r
- rgb = cd.open();\r
- if(rgb == null)\r
- return;\r
- \r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
- \r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- G2DResource g2d = G2DResource.getInstance(graph);\r
- float[] components = new float[] {rgb.red / 255.0f, rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f};\r
- graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components); \r
- }\r
- });\r
- \r
- }\r
- });\r
- \r
- \r
-\r
+ G2DResource g2d = G2DResource.getInstance(graph);\r
+ float[] components = new float[] {rgb.red / 255.0f, rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f};\r
+ Resource resource = getResource(graph, input);\r
+ float[] currentComponents = graph.getPossibleRelatedValue2(resource, getColorRelation(graph));\r
+ if (currentComponents == null || !Arrays.equals(components, currentComponents)) {\r
+ graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components);\r
+ Layer0Utils.addCommentMetadata(graph, "Modified color of " + NameUtils.getSafeName(graph, resource) + " to " + Arrays.toString(components));\r
+ }\r
}\r
-\r
}\r
\r
/**\r
float[] components = java.awt.Color.BLUE.getColorComponents(new float[4]);\r
components[3] = 1.0f;\r
graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components);\r
+ Layer0Utils.addCommentMetadata(graph, "Color for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING) + " set to custom ");\r
}\r
} else {\r
// Default selected, remove color definition\r
- graph.deny(resource, getColorRelation(graph));\r
+ Object o = graph.getPossibleObject(resource, getColorRelation(graph));\r
+ if (o != null) {\r
+ graph.deny(resource, getColorRelation(graph));\r
+ Layer0Utils.addCommentMetadata(graph, "Color for " + graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING) + " set to Default");\r
+ }\r
}\r
}\r
}\r
\r
public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl {\r
\r
+ protected final Object id;\r
+ \r
+ public LabelPropertyTabContributor(Object id) {\r
+ assert (id != null);\r
+ this.id = id;\r
+ }\r
+ \r
@Override\r
public Read<String> getPartNameReadRequest(final ISelection forSelection) {\r
\r
\r
}\r
\r
+ @Override\r
+ public int hashCode() {\r
+ return id.hashCode();\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ LabelPropertyTabContributor other = (LabelPropertyTabContributor) obj;\r
+ return id.equals(other.id);\r
+ }\r
+\r
}\r
*/\r
public class BarAxisTab extends AdjustableTab implements Widget {\r
\r
+ public BarAxisTab(Object id) {\r
+ super(id);\r
+ }\r
+\r
private TrackedSpinner angle;\r
private Integer angleInt = null;\r
private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl();\r
private TrackedText fraction;\r
private Point size;\r
\r
- public BarGeneralPropertiesTab() {\r
- \r
- }\r
- \r
- public BarGeneralPropertiesTab(int options) {\r
+ public BarGeneralPropertiesTab(Object id, int options) {\r
+ super(id);\r
showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); \r
showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0);\r
}\r
private int options;\r
private Composite buttonComposite;\r
\r
- public BarSeriesTab(int options) {\r
+ public BarSeriesTab(Object id, int options) {\r
+ super(id);\r
additionalSupport = new WidgetSupportImpl();\r
this.options = options;\r
}\r
private BarSeriesPropertyComposite2 spc;\r
private int options;\r
\r
- public BarSeriesTab2(int options) {\r
+ public BarSeriesTab2(Object id, int options) {\r
+ super(id);\r
additionalSupport = new WidgetSupportImpl();\r
this.options = options;\r
}\r
private TrackedText fraction;\r
private Point size;\r
\r
- public PieGeneralPropertiesTab() {\r
- \r
- }\r
- \r
- public PieGeneralPropertiesTab(int options) {\r
+ public PieGeneralPropertiesTab(Object id, int options) {\r
+ super(id);\r
showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); \r
showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0);\r
}\r
private int options;\r
private Composite buttonComposite;\r
\r
- public PieSeriesTab(int options) {\r
+ public PieSeriesTab(Object id, int options) {\r
+ super(id);\r
additionalSupport = new WidgetSupportImpl();\r
this.options = options;\r
}\r
private Resource chartResource;\r
private int options;\r
\r
- public PieSeriesTab2(int options) {\r
+ public PieSeriesTab2(Object id, int options) {\r
+ super(id);\r
additionalSupport = new WidgetSupportImpl();\r
this.options = options;\r
}\r
private WidgetSupportImpl additionalSupport;\r
private Composite buttonComposite;\r
\r
- public XYLineAxisAndVariablesTab() {\r
+ public XYLineAxisAndVariablesTab(Object id) {\r
+ super(id);\r
additionalSupport = new WidgetSupportImpl();\r
}\r
\r
*/\r
public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget {\r
\r
+ public XYLineGeneralPropertiesTab(Object id) {\r
+ super(id);\r
+ }\r
+\r
private ScrolledComposite sc;\r
private TrackedText name, title, xlabel, xvariable, xmin, xmax;\r
private TrackedCombo type;\r