Change the InvalidComponentPresetException so it reports all errors found in a preset...
[debian/openrocket] / core / src / net / sf / openrocket / preset / InvalidComponentPresetException.java
index 53066d13c70dd0a00ab86c6aeb273387c865aa30..c28fb09304c161d1fa16f084488897546c427802 100644 (file)
@@ -1,25 +1,56 @@
 package net.sf.openrocket.preset;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class InvalidComponentPresetException extends Exception {
 
+       private List<String> errors = new ArrayList<String>();
+       private List<TypedKey<?>> invalidParameters = new ArrayList<TypedKey<?>>();
+       
        public InvalidComponentPresetException() {
                super();
-               // TODO Auto-generated constructor stub
        }
 
        public InvalidComponentPresetException(String message, Throwable cause) {
                super(message, cause);
-               // TODO Auto-generated constructor stub
        }
 
        public InvalidComponentPresetException(String message) {
                super(message);
-               // TODO Auto-generated constructor stub
        }
 
        public InvalidComponentPresetException(Throwable cause) {
                super(cause);
-               // TODO Auto-generated constructor stub
+       }
+       
+       void addInvalidParameter(TypedKey<?> key ) {
+               invalidParameters.add(key);
+       }
+       
+       void addInvalidParameter(TypedKey<?> key, String message ) {
+               invalidParameters.add(key);
+               errors.add(message);
+       }
+       
+       void addMessage( String message ) {
+               errors.add(message);
        }
 
+       boolean hasProblems() {
+               return (invalidParameters.size() + errors.size()) > 0;
+       }
+       
+       public int problemCount() {
+               return Math.max( invalidParameters.size(), errors.size() );
+       }
+       
+       public List<String> getErrors() {
+               return errors;
+       }
+
+       public List<TypedKey<?>> getInvalidParameters() {
+               return invalidParameters;
+       }
+       
 }