< prev index next >

src/com/sun/javatest/exec/BasicCustomTestFilter.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  84  * <ul>
  85  * <li>Initial URLs
  86  * <li>Status
  87  * <li>Exclude List
  88  * <li>Keywords
  89  * </ul>
  90  *
  91  *<p>
  92  * The settings for this panel are global, so any changes made affect all
  93  * exec tool instances.
  94  */
  95 class BasicCustomTestFilter extends ConfigurableTestFilter {
  96     // UIFactory parameter assume this class stays in the exec package
  97 
  98     BasicCustomTestFilter(String name, ExecModel e, UIFactory uif) {
  99         super(name, e);
 100         this.uif = uif;
 101         init(null);
 102     }
 103 
 104     BasicCustomTestFilter(Map map, ExecModel e, UIFactory uif) {
 105         super(map, e);
 106         this.uif = uif;
 107         init(map);
 108     }
 109 
 110     BasicCustomTestFilter(ExecModel e, UIFactory uif) {
 111         super(uif.getI18NString("basicTf.namePrefix"), e);
 112         this.uif = uif;
 113 
 114         init(null);
 115     }
 116 
 117     ConfigurableTestFilter cloneInstance() {
 118         return new BasicCustomTestFilter(uif.getI18NString("basicTf.namePrefix") +
 119                 instanceCount, execModel, uif);
 120     }
 121 
 122     // override superclass methods
 123     // observers must be static data since all exec tool instances
 124     // must be notified of changes


 132         obs = DynamicArray.remove(obs, o);
 133     }
 134 
 135     @Override
 136     protected void notifyUpdated(ObservableTestFilter filter) {
 137         // obs will be null if called indirectly via load(map) from the
 138         // superclass constructor, because super(...) is defined to be
 139         // called before instance variables are initialized.
 140         // (Hence the danger of overriding methods called from a superclass
 141         // constructor.)  11/12/02
 142         if (obs == null) {
 143             return;
 144         }
 145 
 146         for (int i = 0; i < obs.length; i++) {
 147             obs[i].filterUpdated(filter);
 148         }
 149     }
 150 
 151     @Override
 152     boolean load(Map map) {
 153         boolean result = super.load(map);
 154         activeSettings = new SettingsSnapshot(map);
 155         putSettings(activeSettings);
 156         activateSettings(activeSettings);
 157 
 158         notifyUpdated(this);
 159 
 160         return result;
 161     }
 162 
 163     @Override
 164     boolean save(Map<String, String> map) {
 165         boolean result = super.save(map);
 166         activeSettings.save(map);
 167 
 168         return result;
 169     }
 170 
 171     void update(InterviewParameters ip) {
 172         activateSettings(activeSettings);


 257         return true;
 258     }
 259 
 260     public String getBaseName() {
 261         return NAME;
 262     }
 263 
 264     public String getName() {
 265         return instanceName;
 266     }
 267 
 268     public String getReason() {
 269         return REASON;
 270     }
 271 
 272     public String getDescription() {
 273         return DESCRIPTION;
 274     }
 275 
 276     // ----- PRIVATE -----
 277     private void init(Map map) {
 278         if (NAME == null) {
 279             NAME = uif.getI18NString("basicTf.name");
 280         }
 281 
 282         if (REASON == null) {
 283             REASON = uif.getI18NString("basicTf.reason");
 284         }
 285 
 286         if (DESCRIPTION == null) {
 287             DESCRIPTION = uif.getI18NString("basicTf.description");
 288         }
 289 
 290         if (map != null) {
 291             activeSettings = new SettingsSnapshot(map);
 292         } else {
 293             activeSettings = new SettingsSnapshot();
 294         }
 295 
 296         instanceCount++;
 297 


 866     private static int JTX_FILTER = 2;
 867     private static int STATUS_FILTER = 3;
 868     private static int TSS_FILTER = 4;
 869 
 870     private SettingsSnapshot activeSettings;
 871     private TestFilter[] activeFilters;     // for convenience
 872     private KeywordsFilter keyFilter;
 873     private InitialUrlFilter urlFilter;
 874     private TestFilter jtxFilter;
 875     private StatusFilter statusFilter;
 876     private TestFilter tsfFilter;           // test suite filter
 877     private final UIFactory uif;
 878     private JTabbedPane editorPane;
 879 
 880     private boolean statusFilterNeedsUpdate;
 881 
 882     // keyword info
 883     private ButtonGroup keyBtnGrp;
 884     private JRadioButton keyAllBtn;
 885     private JRadioButton keyMatchBtn;
 886     private JComboBox keywordsChoice;
 887     private JTextField keywordsField;
 888     private static final String ALL_OF = "allOf";
 889     private static final String ANY_OF = "anyOf";
 890     private static final String EXPR = "expr";
 891 
 892     // status info
 893     private ButtonGroup statusBtnGrp;
 894     private JRadioButton statusAllBtn;
 895     private JRadioButton statusAnyOfBtn;
 896     private JCheckBox[] statusChecks = new JCheckBox[Status.NUM_STATES];
 897 
 898     // tests info
 899     private ButtonGroup testsBtnGrp;
 900     //private JRadioButton allTestsBtn;
 901     //private JRadioButton selectTestsBtn;
 902     private TestTreeSelectionPane testsField;
 903 
 904     // checkboxes to enable exclude list from interview and test suite filter
 905     private JCheckBox jtxCheckBox;
 906     private JCheckBox tsfCheckBox;
 907 
 908     // jtx info fields
 909     private JTextField jtxMode;
 910     private JList jtxFileList;
 911     private DefaultListModel<String> jtxFiles;
 912     private static String NAME,  REASON,  DESCRIPTION;
 913 
 914     /**
 915      * Necessary to track changes which occur in the active interview.
 916      */
 917     private class InterviewObserver implements Interview.Observer {
 918 
 919         InterviewObserver(InterviewParameters i) {
 920             interview = i;
 921         }
 922 
 923         InterviewParameters getInterview() {
 924             return interview;
 925         }
 926 
 927         public void currentQuestionChanged(Question q) {
 928             // ignore
 929         }
 930 


 979                 }
 980             }
 981 
 982             if (needsUpdate) {
 983                 activateSettings(activeSettings);
 984                 return;     // rest of checking no longer needed
 985             }
 986         }
 987         private InterviewParameters interview;
 988     }
 989 
 990     private class SettingsSnapshot {
 991 
 992         SettingsSnapshot() {
 993             statusFields = new boolean[Status.NUM_STATES];
 994             urlsEnabled = true;
 995             keyChoice = EXPR;
 996             keyString = "";
 997         }
 998 
 999         SettingsSnapshot(Map m) {
1000             this();
1001             load(m);
1002         }
1003 
1004         public boolean equals(Object settings) {
1005 
1006             if (settings == null) {
1007                 return false;
1008             }
1009 
1010             SettingsSnapshot incoming = (SettingsSnapshot) settings;
1011 
1012             if (!Arrays.equals(initialUrls, incoming.initialUrls)) {
1013                 return false;
1014             }
1015 
1016             if (keywordsEnabled != incoming.keywordsEnabled) {
1017                 return false;
1018             } else {
1019                 if (keyChoice != incoming.keyChoice) {


1051             return true;
1052         }   // equals()
1053 
1054         void save(Map<String, String> map) {
1055             map.put(MAP_URL_ENABLE, booleanToInt(urlsEnabled));
1056             map.put(MAP_KEY_ENABLE, booleanToInt(keywordsEnabled));
1057             map.put(MAP_STATUS_ENABLE, booleanToInt(statusEnabled));
1058             map.put(MAP_JTX_ENABLE, booleanToInt(jtxEnabled));
1059             map.put(MAP_TSF_ENABLE, booleanToInt(tsfEnabled));
1060 
1061             for (int i = 0; i < statusFields.length; i++) {
1062                 map.put(MAP_STATUS_PREFIX + i, booleanToInt(statusFields[i]));
1063             }
1064 
1065             map.put(MAP_URLS, StringArray.join(initialUrls));
1066 
1067             map.put(MAP_KEY_CHOICE, keyChoice);
1068             map.put(MAP_KEY_STRING, keyString);
1069         }
1070 
1071         void load(Map map) {
1072             urlsEnabled = intToBoolean((String) (map.get(MAP_URL_ENABLE)));
1073             keywordsEnabled = intToBoolean((String) (map.get(MAP_KEY_ENABLE)));
1074             statusEnabled = intToBoolean((String) (map.get(MAP_STATUS_ENABLE)));
1075             jtxEnabled = intToBoolean((String) (map.get(MAP_JTX_ENABLE)));
1076             tsfEnabled = intToBoolean((String) (map.get(MAP_TSF_ENABLE)));
1077 
1078             for (int i = 0; i < Status.NUM_STATES; i++) {
1079                 statusFields[i] = intToBoolean((String) (map.get(MAP_STATUS_PREFIX + i)));
1080             }   // for
1081 
1082             initialUrls = StringArray.split((String) (map.get(MAP_URLS)));
1083 
1084             keyChoice = (String) (map.get(MAP_KEY_CHOICE));
1085             keyString = (String) (map.get(MAP_KEY_STRING));
1086 
1087             validate();
1088         }
1089 
1090         private void validate() {
1091             // conserve strings, but also sync with the actual
1092             // objects in the choice list for easy use
1093             if (keyChoice.equals(ALL_OF)) {
1094                 keyChoice = ALL_OF;
1095             } else if (keyChoice.equals(ANY_OF)) {
1096                 keyChoice = ANY_OF;
1097             } else if (keyChoice.equals(EXPR)) {
1098                 keyChoice = EXPR;
1099             } else {
1100                 keyChoice = ALL_OF;     // unknown, use default
1101             }
1102         }
1103 
1104         String booleanToInt(boolean val) {
1105             if (val) {




  84  * <ul>
  85  * <li>Initial URLs
  86  * <li>Status
  87  * <li>Exclude List
  88  * <li>Keywords
  89  * </ul>
  90  *
  91  *<p>
  92  * The settings for this panel are global, so any changes made affect all
  93  * exec tool instances.
  94  */
  95 class BasicCustomTestFilter extends ConfigurableTestFilter {
  96     // UIFactory parameter assume this class stays in the exec package
  97 
  98     BasicCustomTestFilter(String name, ExecModel e, UIFactory uif) {
  99         super(name, e);
 100         this.uif = uif;
 101         init(null);
 102     }
 103 
 104     BasicCustomTestFilter(Map<String, String> map, ExecModel e, UIFactory uif) {
 105         super(map, e);
 106         this.uif = uif;
 107         init(map);
 108     }
 109 
 110     BasicCustomTestFilter(ExecModel e, UIFactory uif) {
 111         super(uif.getI18NString("basicTf.namePrefix"), e);
 112         this.uif = uif;
 113 
 114         init(null);
 115     }
 116 
 117     ConfigurableTestFilter cloneInstance() {
 118         return new BasicCustomTestFilter(uif.getI18NString("basicTf.namePrefix") +
 119                 instanceCount, execModel, uif);
 120     }
 121 
 122     // override superclass methods
 123     // observers must be static data since all exec tool instances
 124     // must be notified of changes


 132         obs = DynamicArray.remove(obs, o);
 133     }
 134 
 135     @Override
 136     protected void notifyUpdated(ObservableTestFilter filter) {
 137         // obs will be null if called indirectly via load(map) from the
 138         // superclass constructor, because super(...) is defined to be
 139         // called before instance variables are initialized.
 140         // (Hence the danger of overriding methods called from a superclass
 141         // constructor.)  11/12/02
 142         if (obs == null) {
 143             return;
 144         }
 145 
 146         for (int i = 0; i < obs.length; i++) {
 147             obs[i].filterUpdated(filter);
 148         }
 149     }
 150 
 151     @Override
 152     boolean load(Map<String, String> map) {
 153         boolean result = super.load(map);
 154         activeSettings = new SettingsSnapshot(map);
 155         putSettings(activeSettings);
 156         activateSettings(activeSettings);
 157 
 158         notifyUpdated(this);
 159 
 160         return result;
 161     }
 162 
 163     @Override
 164     boolean save(Map<String, String> map) {
 165         boolean result = super.save(map);
 166         activeSettings.save(map);
 167 
 168         return result;
 169     }
 170 
 171     void update(InterviewParameters ip) {
 172         activateSettings(activeSettings);


 257         return true;
 258     }
 259 
 260     public String getBaseName() {
 261         return NAME;
 262     }
 263 
 264     public String getName() {
 265         return instanceName;
 266     }
 267 
 268     public String getReason() {
 269         return REASON;
 270     }
 271 
 272     public String getDescription() {
 273         return DESCRIPTION;
 274     }
 275 
 276     // ----- PRIVATE -----
 277     private void init(Map<String, String> map) {
 278         if (NAME == null) {
 279             NAME = uif.getI18NString("basicTf.name");
 280         }
 281 
 282         if (REASON == null) {
 283             REASON = uif.getI18NString("basicTf.reason");
 284         }
 285 
 286         if (DESCRIPTION == null) {
 287             DESCRIPTION = uif.getI18NString("basicTf.description");
 288         }
 289 
 290         if (map != null) {
 291             activeSettings = new SettingsSnapshot(map);
 292         } else {
 293             activeSettings = new SettingsSnapshot();
 294         }
 295 
 296         instanceCount++;
 297 


 866     private static int JTX_FILTER = 2;
 867     private static int STATUS_FILTER = 3;
 868     private static int TSS_FILTER = 4;
 869 
 870     private SettingsSnapshot activeSettings;
 871     private TestFilter[] activeFilters;     // for convenience
 872     private KeywordsFilter keyFilter;
 873     private InitialUrlFilter urlFilter;
 874     private TestFilter jtxFilter;
 875     private StatusFilter statusFilter;
 876     private TestFilter tsfFilter;           // test suite filter
 877     private final UIFactory uif;
 878     private JTabbedPane editorPane;
 879 
 880     private boolean statusFilterNeedsUpdate;
 881 
 882     // keyword info
 883     private ButtonGroup keyBtnGrp;
 884     private JRadioButton keyAllBtn;
 885     private JRadioButton keyMatchBtn;
 886     private JComboBox<String> keywordsChoice;
 887     private JTextField keywordsField;
 888     private static final String ALL_OF = "allOf";
 889     private static final String ANY_OF = "anyOf";
 890     private static final String EXPR = "expr";
 891 
 892     // status info
 893     private ButtonGroup statusBtnGrp;
 894     private JRadioButton statusAllBtn;
 895     private JRadioButton statusAnyOfBtn;
 896     private JCheckBox[] statusChecks = new JCheckBox[Status.NUM_STATES];
 897 
 898     // tests info
 899     private ButtonGroup testsBtnGrp;
 900     //private JRadioButton allTestsBtn;
 901     //private JRadioButton selectTestsBtn;
 902     private TestTreeSelectionPane testsField;
 903 
 904     // checkboxes to enable exclude list from interview and test suite filter
 905     private JCheckBox jtxCheckBox;
 906     private JCheckBox tsfCheckBox;
 907 
 908     // jtx info fields
 909     private JTextField jtxMode;
 910     private JList<?> jtxFileList;
 911     private DefaultListModel<String> jtxFiles;
 912     private static String NAME,  REASON,  DESCRIPTION;
 913 
 914     /**
 915      * Necessary to track changes which occur in the active interview.
 916      */
 917     private class InterviewObserver implements Interview.Observer {
 918 
 919         InterviewObserver(InterviewParameters i) {
 920             interview = i;
 921         }
 922 
 923         InterviewParameters getInterview() {
 924             return interview;
 925         }
 926 
 927         public void currentQuestionChanged(Question q) {
 928             // ignore
 929         }
 930 


 979                 }
 980             }
 981 
 982             if (needsUpdate) {
 983                 activateSettings(activeSettings);
 984                 return;     // rest of checking no longer needed
 985             }
 986         }
 987         private InterviewParameters interview;
 988     }
 989 
 990     private class SettingsSnapshot {
 991 
 992         SettingsSnapshot() {
 993             statusFields = new boolean[Status.NUM_STATES];
 994             urlsEnabled = true;
 995             keyChoice = EXPR;
 996             keyString = "";
 997         }
 998 
 999         SettingsSnapshot(Map<String, String> m) {
1000             this();
1001             load(m);
1002         }
1003 
1004         public boolean equals(Object settings) {
1005 
1006             if (settings == null) {
1007                 return false;
1008             }
1009 
1010             SettingsSnapshot incoming = (SettingsSnapshot) settings;
1011 
1012             if (!Arrays.equals(initialUrls, incoming.initialUrls)) {
1013                 return false;
1014             }
1015 
1016             if (keywordsEnabled != incoming.keywordsEnabled) {
1017                 return false;
1018             } else {
1019                 if (keyChoice != incoming.keyChoice) {


1051             return true;
1052         }   // equals()
1053 
1054         void save(Map<String, String> map) {
1055             map.put(MAP_URL_ENABLE, booleanToInt(urlsEnabled));
1056             map.put(MAP_KEY_ENABLE, booleanToInt(keywordsEnabled));
1057             map.put(MAP_STATUS_ENABLE, booleanToInt(statusEnabled));
1058             map.put(MAP_JTX_ENABLE, booleanToInt(jtxEnabled));
1059             map.put(MAP_TSF_ENABLE, booleanToInt(tsfEnabled));
1060 
1061             for (int i = 0; i < statusFields.length; i++) {
1062                 map.put(MAP_STATUS_PREFIX + i, booleanToInt(statusFields[i]));
1063             }
1064 
1065             map.put(MAP_URLS, StringArray.join(initialUrls));
1066 
1067             map.put(MAP_KEY_CHOICE, keyChoice);
1068             map.put(MAP_KEY_STRING, keyString);
1069         }
1070 
1071         void load(Map<String, String> map) {
1072             urlsEnabled = intToBoolean((map.get(MAP_URL_ENABLE)));
1073             keywordsEnabled = intToBoolean((map.get(MAP_KEY_ENABLE)));
1074             statusEnabled = intToBoolean((map.get(MAP_STATUS_ENABLE)));
1075             jtxEnabled = intToBoolean((map.get(MAP_JTX_ENABLE)));
1076             tsfEnabled = intToBoolean((map.get(MAP_TSF_ENABLE)));
1077 
1078             for (int i = 0; i < Status.NUM_STATES; i++) {
1079                 statusFields[i] = intToBoolean((map.get(MAP_STATUS_PREFIX + i)));
1080             }   // for
1081 
1082             initialUrls = StringArray.split((map.get(MAP_URLS)));
1083 
1084             keyChoice = map.get(MAP_KEY_CHOICE);
1085             keyString = map.get(MAP_KEY_STRING);
1086 
1087             validate();
1088         }
1089 
1090         private void validate() {
1091             // conserve strings, but also sync with the actual
1092             // objects in the choice list for easy use
1093             if (keyChoice.equals(ALL_OF)) {
1094                 keyChoice = ALL_OF;
1095             } else if (keyChoice.equals(ANY_OF)) {
1096                 keyChoice = ANY_OF;
1097             } else if (keyChoice.equals(EXPR)) {
1098                 keyChoice = EXPR;
1099             } else {
1100                 keyChoice = ALL_OF;     // unknown, use default
1101             }
1102         }
1103 
1104         String booleanToInt(boolean val) {
1105             if (val) {


< prev index next >