| | 178 | } |
|---|
| | 179 | |
|---|
| | 180 | /**Wendy's attempt at writing a buildSchedule Jpanel. */ |
|---|
| | 181 | public JPanel buildSchedule(JPanel pane) { |
|---|
| | 182 | //reset the arguments |
|---|
| | 183 | if(pane == null) { |
|---|
| | 184 | current_controls.clear(); |
|---|
| | 185 | } |
|---|
| | 186 | |
|---|
| | 187 | ArrayList schedule_arguments = new ArrayList(); |
|---|
| | 188 | int current_mode = Configuration.getMode(); |
|---|
| | 189 | |
|---|
| | 190 | int total_schedule_argument_count = schedule_options.getArgumentCount(); |
|---|
| | 191 | |
|---|
| | 192 | for(int i = 0; i < total_schedule_argument_count; i++) { |
|---|
| | 193 | // Retrieve the argument so we know how to format the control. |
|---|
| | 194 | Argument argument = schedule_options.getArgument(i); |
|---|
| | 195 | |
|---|
| | 196 | //A hack to make the disable_OAI option visible in the GLI for Greenstone 3 |
|---|
| | 197 | if(argument.getName().equals(StaticStrings.DISABLEOAI_STR) && Gatherer.GS3) { |
|---|
| | 198 | argument.setHiddenGLI(false); |
|---|
| | 199 | } |
|---|
| | 200 | if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) { |
|---|
| | 201 | // Now attempt to retrieve any existing value for this argument. |
|---|
| | 202 | boolean enabled = schedule_options.getValueEnabled(argument.getName()); |
|---|
| | 203 | String value = schedule_options.getValue(argument.getName()); |
|---|
| | 204 | MyArgumentControl argument_control = new MyArgumentControl(SCHEDULE, argument, enabled, value); |
|---|
| | 205 | schedule_arguments.add(argument_control); |
|---|
| | 206 | } |
|---|
| | 207 | } |
|---|
| | 208 | current_controls.addAll(schedule_arguments); |
|---|
| | 209 | |
|---|
| | 210 | // Now that we know how many arguments there are we can build the pane to view them on. Modes lower than EXPERT can provide a previous pane on which to add the arguments. |
|---|
| | 211 | if(pane == null || current_mode >= Configuration.EXPERT_MODE) { |
|---|
| | 212 | pane = new JPanel(); |
|---|
| | 213 | pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); |
|---|
| | 214 | pane.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); |
|---|
| | 215 | int argument_count = schedule_arguments.size(); |
|---|
| | 216 | // If in any of the higher detail modes, and assuming we don't want super phat argument controls, we better ensure there is a minimum number of lines in the grid layout |
|---|
| | 217 | if(current_mode >= Configuration.EXPERT_MODE) { |
|---|
| | 218 | if(argument_count < MINIMUM_ROWS) { |
|---|
| | 219 | argument_count = MINIMUM_ROWS; |
|---|
| | 220 | } |
|---|
| | 221 | pane.setLayout(new GridLayout(argument_count, 1, 5, 5)); |
|---|
| | 222 | } |
|---|
| | 223 | // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway |
|---|
| | 224 | else { |
|---|
| | 225 | // use GridLayout with 0 rows == as many rows as needed. Unfortunately, rows will |
|---|
| | 226 | // grow fat if space too large, but we don't know how many rows we'll need yet. |
|---|
| | 227 | pane.setLayout(new GridLayout(0, 1, 5, 5)); |
|---|
| | 228 | } |
|---|
| | 229 | } |
|---|
| | 230 | |
|---|
| | 231 | for(int j = 0; j < schedule_arguments.size(); j++) { |
|---|
| | 232 | pane.add((JComponent)schedule_arguments.get(j)); |
|---|
| | 233 | } |
|---|
| | 234 | pane.addMouseListener(this); |
|---|
| | 235 | schedule_arguments = null; |
|---|
| | 236 | return pane; |
|---|
| | 237 | |
|---|