Changeset 16133 for gli


Ignore:
Timestamp:
2008-06-24T18:16:15+12:00 (13 years ago)
Author:
osborn
Message:

Additions for Scheduling Component

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/OptionsPane.java

    r14240 r16133  
    6969    static final public char CANCELLED = 'c';
    7070    static final public char UNKNOWN = 'x';
     71    static final public char SCHEDULED = 'd';
    7172
    7273    static private int BUILD = 0;
    7374    static private int IMPORT = 1;
    74     static private int MINIMUM_ROWS = 11;
     75    static private int SCHEDULE = 2;
     76    static private int MINIMUM_ROWS = 15;
    7577   
    7678    /** All process messages are written to this log text area. */
     
    8284    private ScriptOptions build_options = null;
    8385    private ScriptOptions import_options = null;
     86    private ScriptOptions schedule_options = null;
    8487
    8588    private FileEntry file_entry = null;
     
    9396
    9497    /** The default constructor creates the few session length options, but either retrieves the rest from the current collection, or creates a default set of options. */
    95     public OptionsPane(ScriptOptions import_options, ScriptOptions build_options) {
     98    public OptionsPane(ScriptOptions import_options, ScriptOptions build_options, ScriptOptions schedule_options) {
    9699    this.build_options = build_options;
    97100    this.import_options = import_options;
     101    this.schedule_options = schedule_options;
    98102    this.current_controls = new ArrayList();
    99103    this.writing_documents = new Vector();
     
    172176      build_arguments = null;
    173177      return pane;
     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
    174238    }
    175239
     
    411475            build_options.removeValue(name);
    412476        }
     477        else if(type == SCHEDULE) {
     478            schedule_options.removeValue(name);
     479        }
    413480        else {
    414481            import_options.removeValue(name);
     
    419486        if(type == BUILD) {
    420487            build_options.setValue(name, enable, value);
     488        }
     489        else if(type == SCHEDULE) {
     490            schedule_options.setValue(name, enable, value);
    421491        }
    422492        else {
     
    512582        case CANCELLED:
    513583            d.append(Dictionary.get("OptionsPane.Cancelled"));
     584            break;
     585        case SCHEDULED:
     586            d.append(Dictionary.get("OptionsPane.Scheduled"));
    514587            break;
    515588        default:
Note: See TracChangeset for help on using the changeset viewer.