1 package org.simantics.sysdyn.ui.properties.widgets.factories;
\r
3 import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;
\r
4 import org.simantics.databoard.binding.java.DoubleBindingDefault;
\r
5 import org.simantics.db.Resource;
\r
6 import org.simantics.db.WriteGraph;
\r
7 import org.simantics.db.exception.DatabaseException;
\r
8 import org.simantics.db.management.ISessionContext;
\r
10 public class DoublePropertyModifier extends TextModifyListenerImpl<Resource> {
\r
12 final private String propertyURI;
\r
14 public DoublePropertyModifier(ISessionContext context, String propertyURI) {
\r
15 this.propertyURI = propertyURI;
\r
19 public void applyText(WriteGraph graph, Resource input, String text) throws DatabaseException {
\r
20 if (text == null || text.equals("")) {
\r
21 if(graph.hasStatement(input, graph.getResource(propertyURI)))
\r
22 graph.deny(input, graph.getResource(propertyURI));
\r
24 graph.claimLiteral(input, graph.getResource(propertyURI), Double.parseDouble(text), DoubleBindingDefault.INSTANCE);
\r