]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Prevent NPE caused by null originalName
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 15 Jun 2010 20:21:26 +0000 (20:21 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 15 Jun 2010 20:21:26 +0000 (20:21 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16169 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java

index 5bd9c1889677f36ae524abee9cb66c8ccdafa24d..ca645a7cdeaf0b498ce9943fcc467cdced99d458 100644 (file)
@@ -17,16 +17,16 @@ import org.simantics.db.procedure.Listener;
 import org.simantics.sysdyn.ui.properties.EquationTab;\r
 \r
 public class NameWidget implements Widget {\r
-    \r
+\r
     final private org.eclipse.swt.widgets.Text nameText;\r
-    String originalName;\r
+    String originalName = "";\r
     private ReadFactory<?, String> textFactory;\r
-    \r
+\r
     public NameWidget(Composite parent, WidgetSupport support, int style) {\r
         support.register(this);\r
         nameText = new org.eclipse.swt.widgets.Text(parent, style);\r
         nameText.setFont(EquationTab.FONT);\r
-        \r
+\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);\r
 \r
         nameText.addVerifyListener(new VerifyListener() {\r
@@ -34,13 +34,13 @@ public class NameWidget implements Widget {
             @Override\r
             public void verifyText(VerifyEvent e) {\r
                 e.doit = false;\r
-                char c = e.character;   \r
+                char c = e.character;\r
                 if(c != ' ') {\r
                     e.doit = true;\r
                 }\r
             }\r
         });\r
-        \r
+\r
         nameText.addModifyListener(new ModifyListener() {\r
 \r
             @Override\r
@@ -63,14 +63,14 @@ public class NameWidget implements Widget {
                 if(e.keyCode == SWT.ESC && originalName != null) {\r
                     ((Text)e.widget).setText(originalName);\r
                     ((Text)e.widget).setSelection(originalName.length());\r
-                }                \r
+                }\r
             }\r
         });\r
     }\r
 \r
     @Override\r
     public void setInput(Object input) {\r
-        \r
+\r
         if(textFactory != null) {\r
             textFactory.listen(input, new Listener<String>() {\r
 \r
@@ -83,15 +83,15 @@ public class NameWidget implements Widget {
                 public void execute(final String text) {\r
 \r
                     if(text == null) return;\r
-                    \r
+\r
                     nameText.getDisplay().asyncExec(new Runnable() {\r
 \r
                         @Override\r
                         public void run() {\r
-                            \r
+\r
                             if(isDisposed()) return;\r
                             nameText.setText(text);\r
-                            \r
+\r
                         }\r
 \r
                     });\r
@@ -104,12 +104,12 @@ public class NameWidget implements Widget {
 \r
             });\r
         }\r
-        \r
+\r
     }\r
-    \r
+\r
     public void setTextFactory(ReadFactory<?, String> textFactory) {\r
         this.textFactory = textFactory;\r
     }\r
-    \r
+\r
 \r
 }\r