X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fproperty%2FDoublePropertyManipulator.java;h=4f7c670fc71ab186e722c31ff72adc0bab35ca71;hb=faa2c9d309cd59039b49cb4a2f6b21b21546b951;hp=7f120b277b24b870786f98b5a6073ffe93c6a000;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java b/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java index 7f120b27..4f7c670f 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java @@ -1,69 +1,80 @@ -package org.simantics.g3d.property; - -import java.lang.reflect.Method; - -public class DoublePropertyManipulator implements PropertyManipulator { - - ValueProvider provider; - Object input; - - boolean editMode; - String editValue = null; - - public DoublePropertyManipulator(ValueProvider provider, Object input) { - this.provider = provider; - this.input = input; - } - - @Override - public int getValueCount() { - return 1; - } - - @Override - public String getDescription(int i) { - if (i == 0) - return "Value"; - return null; - } - - @Override - public String getValue(int i) { - if (editMode) - return editValue; - try { - return provider.getValue(input).toString(); - } catch (Exception e) { - return null; - } - } - - @Override - public String setValue(String value, int i) { - try { - editValue = value; - provider.setValue(input, Double.parseDouble(value)); - } catch (Exception e) { - return e.getMessage(); - } - return null; - } - - @Override - public boolean getEditMode() { - return editMode; - } - - @Override - public void setEditMode(boolean b) { - editMode = b; - if (editMode) { - try { - editValue = provider.getValue(input).toString(); - } catch (Exception e) { - - } - } - - } -} +/******************************************************************************* + * Copyright (c) 2012, 2013 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.g3d.property; + +public class DoublePropertyManipulator implements PropertyManipulator { + + ValueProvider provider; + Object input; + + boolean editMode; + String editValue = null; + + public DoublePropertyManipulator(ValueProvider provider, Object input) { + this.provider = provider; + this.input = input; + } + + @Override + public int getValueCount() { + return 1; + } + + @Override + public String getDescription(int i) { + if (i == 0) + return "Value"; + return null; + } + + @Override + public String getValue(int i) { + if (editMode) + return editValue; + try { + Object value = provider.getValue(input); + if (value == null) return null; + return value.toString(); + } catch (Exception e) { + return null; + } + } + + @Override + public String setValue(String value, int i) { + try { + editValue = value; + provider.setValue(input, Double.parseDouble(value)); + } catch (Exception e) { + return e.getMessage(); + } + return null; + } + + @Override + public boolean getEditMode() { + return editMode; + } + + @Override + public void setEditMode(boolean b) { + editMode = b; + if (editMode) { + try { + editValue = provider.getValue(input).toString(); + } catch (Exception e) { + + } + } + + } +}