From cc9ae01837bcaa3b9a9b206323c5e1a0c735591f Mon Sep 17 00:00:00 2001 From: lehtonen Date: Tue, 15 Jun 2010 20:21:26 +0000 Subject: [PATCH] Prevent NPE caused by null originalName git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16169 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/properties/widgets/NameWidget.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java index 5bd9c188..ca645a7c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java @@ -17,16 +17,16 @@ import org.simantics.db.procedure.Listener; import org.simantics.sysdyn.ui.properties.EquationTab; public class NameWidget implements Widget { - + final private org.eclipse.swt.widgets.Text nameText; - String originalName; + String originalName = ""; private ReadFactory textFactory; - + public NameWidget(Composite parent, WidgetSupport support, int style) { support.register(this); nameText = new org.eclipse.swt.widgets.Text(parent, style); nameText.setFont(EquationTab.FONT); - + GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText); nameText.addVerifyListener(new VerifyListener() { @@ -34,13 +34,13 @@ public class NameWidget implements Widget { @Override public void verifyText(VerifyEvent e) { e.doit = false; - char c = e.character; + char c = e.character; if(c != ' ') { e.doit = true; } } }); - + nameText.addModifyListener(new ModifyListener() { @Override @@ -63,14 +63,14 @@ public class NameWidget implements Widget { if(e.keyCode == SWT.ESC && originalName != null) { ((Text)e.widget).setText(originalName); ((Text)e.widget).setSelection(originalName.length()); - } + } } }); } @Override public void setInput(Object input) { - + if(textFactory != null) { textFactory.listen(input, new Listener() { @@ -83,15 +83,15 @@ public class NameWidget implements Widget { public void execute(final String text) { if(text == null) return; - + nameText.getDisplay().asyncExec(new Runnable() { @Override public void run() { - + if(isDisposed()) return; nameText.setText(text); - + } }); @@ -104,12 +104,12 @@ public class NameWidget implements Widget { }); } - + } - + public void setTextFactory(ReadFactory textFactory) { this.textFactory = textFactory; } - + } -- 2.47.1