guard against missing values
diff --git a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/VariableInsertionDialog.java b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/VariableInsertionDialog.java
index 9ef3619..ddf9250 100644
--- a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/VariableInsertionDialog.java
+++ b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/VariableInsertionDialog.java
@@ -147,7 +147,11 @@
fTableViewer.getControl().setLayoutData(data);
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- fDescriptionPane.setText(fTableViewer.getSelection() != null ? getVariable(fTableViewer.getSelection()).getDescription() : ""); //$NON-NLS-1$
+ ISnippetVariable variable = null;
+ if (fTableViewer.getSelection() != null) {
+ variable = getVariable(fTableViewer.getSelection());
+ }
+ fDescriptionPane.setText(variable != null ? variable.getDescription() : ""); //$NON-NLS-1$
fDescriptionPane.setHorizontalPixel(2);
fDescriptionPane.redraw();
}
diff --git a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
index fd5053c..e0a6c19 100644
--- a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
+++ b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
@@ -143,30 +143,38 @@
}
protected void setProperty(SnippetPaletteItem item, String property, Object value) {
- if (property == null || value == null)
+ if (property == null)
return;
- else if (property.equals(SnippetsPlugin.NAMES.CATEGORY))
- item.setCategoryName(value.toString());
+ Object propertyValue = value;
+ if(propertyValue == null) {
+ propertyValue = "";
+ }
+ if (property.equals(SnippetsPlugin.NAMES.CATEGORY))
+ item.setCategoryName(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.CLASSNAME))
- item.setClassName(value.toString());
+ item.setClassName(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.CONTENT))
- item.setContentString(value.toString());
+ item.setContentString(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.EDITORCLASSNAME))
- item.setEditorClassName(value.toString());
+ item.setEditorClassName(propertyValue.toString());
else
- setEntryProperty(item, property, value);
+ setEntryProperty(item, property, propertyValue);
}
protected void setProperty(SnippetVariable variable, String property, Object value) {
- if (property == null || value == null)
+ if (property == null)
return;
- else if (property.equals(SnippetsPlugin.NAMES.DEFAULT))
- variable.setDefaultValue(value.toString());
+ Object propertyValue = value;
+ if(propertyValue == null) {
+ propertyValue = "";
+ }
+ if (property.equals(SnippetsPlugin.NAMES.DEFAULT))
+ variable.setDefaultValue(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.DESCRIPTION))
- variable.setDescription(value.toString());
+ variable.setDescription(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.NAME))
- variable.setName(value.toString());
+ variable.setName(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.ID))
- variable.setId(value.toString());
+ variable.setId(propertyValue.toString());
}
}
\ No newline at end of file