handle uninitialized prefs more gracefully - default to prompt vs runtime exception


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@967019 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java
index 570b195..82a94cb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java
@@ -34,7 +34,7 @@
     {
         boolean result = false;
 
-        PromptablePreference value = PromptablePreference.valueOf( prefStore.getString( prefName ) );
+        PromptablePreference value = preference(prefStore, prefName);
         switch ( value )
         {
             case Always:
@@ -64,7 +64,7 @@
     {
         int result = IDialogConstants.NO_ID;
 
-        PromptablePreference value = PromptablePreference.valueOf( prefStore.getString( prefName ) );
+        PromptablePreference value = preference(prefStore, prefName);
         switch ( value )
         {
             case Always:
@@ -91,4 +91,15 @@
 
         return result;
     }
+    
+    /**
+     * @param prefStore 
+     * @param prefName
+     * @return
+     */
+    private static PromptablePreference preference(IPreferenceStore prefStore, String prefName)
+    {
+        String val = prefStore.getString( prefName );
+        return (val == null || val.trim().length() == 0) ? PromptablePreference.Prompt : PromptablePreference.valueOf( val );
+    }    
 }