]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d/src/org/simantics/g3d/property/StringPropertyManipulator.java
Double array properties
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / property / StringPropertyManipulator.java
index 415dd2d77e78bda21fbc8caaee491c90b8aeb435..775240e67837387d360a936a3d0e9331cc1e0ed0 100644 (file)
@@ -1,80 +1,81 @@
-/*******************************************************************************\r
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g3d.property;\r
-\r
-import java.lang.reflect.Method;\r
-\r
-public class StringPropertyManipulator implements PropertyManipulator {\r
-       \r
-       ValueProvider provider;\r
-       Object input;\r
-       \r
-       boolean editMode;\r
-       String editValue = null;\r
-       \r
-       public StringPropertyManipulator(ValueProvider provider, Object input) {\r
-               this.provider = provider;\r
-               this.input = input;\r
-       }\r
-       \r
-       @Override\r
-       public int getValueCount() {\r
-               return 1;\r
-       }\r
-       \r
-       @Override\r
-       public String getDescription(int i) {\r
-               if (i == 0)\r
-                       return "Value";\r
-               return null;\r
-       }\r
-       \r
-       @Override\r
-       public String getValue(int i) {\r
-               if (editMode)\r
-                       return editValue;\r
-               try {\r
-                       return provider.getValue(input).toString();\r
-               } catch (Exception e) {\r
-                       return null;\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public String setValue(String value, int i) {\r
-               try {\r
-                       editValue = value;\r
-                       provider.setValue(input, value);\r
-               } catch (Exception e) {\r
-                       return e.getMessage();\r
-               }\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public boolean getEditMode() {\r
-               return editMode;\r
-       }\r
-       \r
-       @Override\r
-       public void setEditMode(boolean b) {\r
-               editMode = b;\r
-               if (editMode) {\r
-                       try {\r
-                               editValue = provider.getValue(input).toString();\r
-                       } catch (Exception e) {\r
-                               \r
-                       }\r
-               }\r
-               \r
-       }\r
-}\r
+/*******************************************************************************
+ * 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 StringPropertyManipulator implements PropertyManipulator {
+       
+       ValueProvider provider;
+       Object input;
+       
+       boolean editMode;
+       String editValue = null;
+       
+       public StringPropertyManipulator(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 o = provider.getValue(input);
+                   if (o == null)
+                       return null;
+                       return o.toString();
+               } catch (Exception e) {
+                       return null;
+               }
+       }
+       
+       @Override
+       public String setValue(String value, int i) {
+               try {
+                       editValue = value;
+                       provider.setValue(input, 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) {
+                               
+                       }
+               }
+               
+       }
+}