From: <tea...@us...> - 2008-02-12 17:51:24
|
Revision: 623 http://cishell.svn.sourceforge.net/cishell/?rev=623&view=rev Author: teakettle22 Date: 2008-02-12 09:51:18 -0800 (Tue, 12 Feb 2008) Log Message: ----------- Incomplete - # 197: Using Options in MetaData.XML generates NullPointerException https://cns-trac.slis.indiana.edu/trac/nwb/ticket/197 Fixed, coding by Micah, error found by Tim Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2008-02-08 21:12:55 UTC (rev 622) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2008-02-12 17:51:18 UTC (rev 623) @@ -88,6 +88,7 @@ String[] defaults = attr.getDefaultValue(); if (defaults != null && defaults.length > 0) { + Object value = StringConverter.getInstance().stringToObject(attr, defaults[0]); setValue(value); } Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2008-02-08 21:12:55 UTC (rev 622) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2008-02-12 17:51:18 UTC (rev 623) @@ -13,6 +13,8 @@ * ***************************************************************************/ package org.cishell.reference.gui.guibuilder.swt.builder.components; +import java.util.Arrays; + import org.cishell.reference.gui.guibuilder.swt.builder.AbstractComponent; import org.cishell.reference.gui.guibuilder.swt.builder.StringConverter; import org.eclipse.swt.SWT; @@ -24,7 +26,6 @@ import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Text; /** @@ -98,7 +99,11 @@ } private String getListValue() { - return optionValues[combo.getSelectionIndex()]; + if (optionValues != null) { + return optionValues[combo.getSelectionIndex()]; + } else { + return "You are not specifying option values, fool!"; + } } public String validate() { @@ -113,6 +118,23 @@ } public void setValue(Object value) { + if (text != null) { text.setText(value == null ? "" : value.toString()); + } else if (combo != null) { + + int setComboToIndex = -1; + for (int i = 0; i < optionValues.length; i++) { + if (value.equals(optionValues[i])) { + setComboToIndex = i; + } + } + + if (setComboToIndex != -1) { + combo.select(setComboToIndex); + } else { + System.err.println("Attempted to set combo box to a value " + + "that didn't exist inside the combo box."); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |