Kevin Archie avatar Kevin Archie committed 6818470

bug fixes for PET tracer and blood glucose measurements

Comments (0)

Files changed (5)

     <dependency>
       <groupId>dcm4che</groupId>
       <artifactId>dcm4che-core</artifactId>
-      <version>2.0.21-SNAPSHOT</version>
+      <version>[2.0.21,)</version>
     </dependency>
     <dependency>
       <groupId>dcm4che</groupId>
       <artifactId>dcm4che-net</artifactId>
-      <version>2.0.21-SNAPSHOT</version>
+      <version>[2.0.22-SNAPSHOT,)</version>
     </dependency>
     <dependency>
       <groupId>netscape</groupId>

src/main/java/org/nrg/upload/data/EnumeratedSessionVariable.java

 import javax.swing.JComboBox;
 import javax.swing.JOptionPane;
 
+import org.apache.log4j.Logger;
+
 
 /**
  * @author Kevin A. Archie <karchie@npg.wustl.edu>
 	private static final String MAKE_SELECTION = "(Select)";
 	private static final String OTHER_ITEM = "Other...";
 	private static final Collection<?> UNSELECTABLES = Arrays.asList(MAKE_SELECTION, OTHER_ITEM);
+	private final Logger logger = Logger.getLogger(EnumeratedSessionVariable.class);
 	private final JComboBox comboBox;
 	private Object lastDeselected = null;
 	
 		}
 		final Object[] startItems = new Object[size];
 		int i = 0;
-		if (allowOther) {
+		if (requireSelection) {
 			startItems[i++] = MAKE_SELECTION;
+			addValidator(new ValueValidator() {
+				public boolean isValid(final Object value) {
+					logger.trace("checking " + value + " for validity");
+					return null != value;
+				}
+				public String getMessage(final Object value) {
+					return null == value ? "Select a value for " + name : null;
+				}
+			});
 		}
 		for (final Object o : items) {
 			startItems[i++] = o;
 		}
-		startItems[i++] = OTHER_ITEM;
+		if (allowOther) {
+			startItems[i++] = OTHER_ITEM;
+		}
 		comboBox = new JComboBox(startItems);
 		comboBox.setEditable(false);
 		comboBox.addItemListener(this);
 					}
 					comboBox.setSelectedItem(val);
 				}
-			} else {
-				fireHasChanged();
 			}
 		}
+		fireHasChanged();
 	}
 	
 	/* (non-Javadoc)

src/main/java/org/nrg/upload/ui/AssignSessionVariablesPage.java

 	 * @see org.nrg.upload.data.SessionVariableConsumer#update(org.nrg.upload.data.SessionVariable, boolean)
 	 */
 	public void update(final SessionVariable v, final boolean isValidValue) {
+		logger.trace(v + " updated to " + (isValidValue ? "valid" : "invalid"));
 		if (isValidValue) {
 			invalid.remove(v);
 		} else {
 				}
 			}		
 		}
+		session.addValidator(LabelValueValidator.getInstance());
+		session.addValidator(excludeExistingSessions);
+		
 		if (null != tracer) {
 			vars.addFirst(tracer);
 		}
-		session.addValidator(LabelValueValidator.getInstance());
-		session.addValidator(excludeExistingSessions);
-		
+
 		// Session name, like project and subject, must be available in the wizard params.
 		putWizardData(session.getName(), session);
 		

src/main/java/org/nrg/upload/ui/VariableAssignmentManager.java

 
 import javax.swing.JLabel;
 
+import org.apache.log4j.Logger;
 import org.nrg.upload.data.SessionVariable;
 import org.nrg.upload.data.SessionVariableConsumer;
 import org.nrg.upload.data.ValueListener;
+import org.nrg.upload.data.SessionVariable.InvalidValueException;
 
 /**
  * @author Kevin A. Archie <karchie@npg.wustl.edu>
 	
 
 	private static final class VariableRow implements ValueListener {
+		private final Logger logger = Logger.getLogger(VariableRow.class);
 		private final List<VariableRow> rows;
 		private final SessionVariable v;
 		private final SessionVariableConsumer consumer;
 			
 			v.addListener(this);
 			v.refresh();
+			
+			try {
+				v.validate(v.getValue());
+				consumer.update(v, true);
+			} catch (InvalidValueException e) {
+				consumer.update(v, false);
+			}
 		}
 		
 		public void hasChanged(final SessionVariable v) {
+			logger.trace(v + " has changed");
 			assert this.v.getName().equals(v.getName());
 			this.message.setText(null);
 			this.message.setToolTipText(null);

src/main/java/org/nrg/xnat/XnatWrappedVariable.java

 package org.nrg.xnat;
 
 import java.awt.Component;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 import org.nrg.upload.data.SessionVariable;
 import org.nrg.upload.data.ValueListener;
  * @author Kevin A. Archie <karchie@npg.wustl.edu>
  *
  */
-public final class XnatWrappedVariable implements SessionVariable, XnatVariable {
+public final class XnatWrappedVariable implements SessionVariable,ValueListener,XnatVariable {
+	private final Set<ValueListener> listeners = new LinkedHashSet<ValueListener>();
 	private final SessionVariable v;
 	private final String fieldPath;
 	
 	public XnatWrappedVariable(final SessionVariable v, final String fieldPath) {
 		this.v = v;
 		this.fieldPath = fieldPath;
+		v.addListener(this);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.nrg.upload.data.SessionVariable#addListener(org.nrg.upload.data.ValueListener)
 	 */
-	public void addListener(ValueListener listener) { v.addListener(listener); }
+	public void addListener(ValueListener listener) { listeners.add(listener); }
 
 	/* (non-Javadoc)
 	 * @see org.nrg.upload.data.SessionVariable#addValidator(org.nrg.upload.data.ValueValidator)
 	/* (non-Javadoc)
 	 * @see org.nrg.upload.data.SessionVariable#removeListener(org.nrg.upload.data.ValueListener)
 	 */
-	public void removeListener(ValueListener listener) { v.removeListener(listener); }
+	public void removeListener(ValueListener listener) { listeners.remove(listener); }
 
 	/* (non-Javadoc)
 	 * @see org.nrg.upload.data.SessionVariable#setValue(java.lang.String)
 		return v.validate(value);
 	}
 
+	/*
+	 * (non-Javadoc)
+	 * @see org.nrg.upload.data.ValueListener#hasChanged(org.nrg.upload.data.SessionVariable)
+	 */
+	public void hasChanged(SessionVariable variable) {
+		for (final ValueListener listener : listeners) {
+			listener.hasChanged(this);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.nrg.upload.data.ValueListener#isInvalid(org.nrg.upload.data.SessionVariable, java.lang.Object, java.lang.String)
+	 */
+	public void isInvalid(SessionVariable variable, Object value, String message) {
+		for (final ValueListener listener : listeners) {
+			listener.isInvalid(this, value, message);
+		}
+	}
+
 	/* (non-Javadoc)
 	 * @see org.nrg.xnat.XnatVariable#getFieldPath()
 	 */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.