Ignore:
Timestamp:
2003-12-19T14:49:04+13:00 (20 years ago)
Author:
jmt12
Message:

Changed JComboBoxes for GComboBoxes to avoid Mac graphical glitch - however now I can't seem to make them the right colour

File:
1 edited

Legend:

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

    r6087 r6321  
    6262public class OptionsPane
    6363    extends JPanel
    64     implements AppendLineOnlyFileDocumentOwner {
     64    implements AppendLineOnlyFileDocumentOwner, MouseListener {
    6565
    6666    static final public char SUCCESSFUL = 's';
     
    7272    public JTextArea log_textarea = null;
    7373
     74    private ArrayList current_controls;
     75
    7476    /** The <strong>BuildOptions</strong> data object contains all the option settings we wish to persist between Gatherer sessions (and thus is stored in <strong>Collection</strong>). */
    7577    private BuildOptions build_options = null;
    7678
    7779    private FileEntry file_entry = null;
     80
    7881    /** the log pane - we only create it once now, not each time */
    7982    private JPanel log_pane = null;
     
    9396    public OptionsPane(BuildOptions build_options) {
    9497    this.build_options = build_options;
     98    this.current_controls = new ArrayList();
    9599    this.writing_documents = new Vector();
    96100
     
    104108     */
    105109    public JPanel buildBuild() {
     110    current_controls.clear();
    106111    JPanel pane = new JPanel();
    107112    pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     
    117122        ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
    118123        pane.add(argument_control);
    119     }
     124        current_controls.add(argument_control);
     125    }
     126    pane.addMouseListener(this);
    120127    return pane;
    121128    }
     
    124131     */
    125132    public JPanel buildImport() {
     133    current_controls.clear();
    126134    JPanel pane = new JPanel();
    127135    pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     
    137145        ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
    138146        pane.add(argument_control);
    139     }
     147        current_controls.add(argument_control);
     148    }
     149    pane.addMouseListener(this);
    140150    return pane;
    141151    }
     
    153163        File children[] = log_directory.listFiles();
    154164        for(int i = 0; children != null && i < children.length; i++) {
    155         if(children[i].getName().startsWith("build_log") && children[i].getName().endsWith(".txt") ) {
    156             FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath());
    157             // We are about to insert it. But where.
    158             boolean found = false;
    159             for(int j = 0; !found && j < contents.size(); j++) {
    160             FileEntry sibling = (FileEntry) contents.getElementAt(j);
    161             int order = entry.compareTo(sibling);
    162             if(order > 0) {
    163                 contents.insertElementAt(entry, j);
    164                 found = true;
     165        String filename = children[i].getName();
     166        if(filename.startsWith("build_log.") && filename.endsWith(".txt") ) {
     167            String datestamp = filename.substring(filename.indexOf(".") + 1, filename.lastIndexOf(".")).toLowerCase();
     168            if(datestamp.indexOf("s") == -1 && datestamp.indexOf("u") == -1 && datestamp.indexOf("c") == -1 && datestamp.indexOf("x") == -1) {
     169            FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath());
     170            // We are about to insert it. But where.
     171            boolean found = false;
     172            for(int j = 0; !found && j < contents.size(); j++) {
     173                FileEntry sibling = (FileEntry) contents.getElementAt(j);
     174                int order = entry.compareTo(sibling);
     175                if(order > 0) {
     176                contents.insertElementAt(entry, j);
     177                found = true;
     178                }
    165179            }
    166             }
    167             if(!found) {
    168             contents.addElement(entry);
     180            if(!found) {
     181                contents.addElement(entry);
     182            }
    169183            }
    170184        }
     
    250264    }
    251265
     266    /** Implementation side-effect
     267     * @param e a MouseEvent
     268     */
     269    public void mouseClicked(MouseEvent e) {}
     270
     271    /** Implementation side-effect
     272     * @param e a MouseEvent
     273     */
     274    public void mouseEntered(MouseEvent e) {}
     275
     276    /** Implemented to ensure that, by the time the mouse pointer leaves the current build options screen, ang changes to the value the JSpinners have been commited
     277     * @param e a MouseEvent
     278     */
     279    public void mouseExited(MouseEvent e) {
     280    // Loop through the controls, and if the current control is a JSpinner, commit its current editing
     281    for(int i = 0; i < current_controls.size(); i++) {
     282        ArgumentControl control = (ArgumentControl) current_controls.get(i);
     283        JComponent value_control = control.getValueControl();
     284        if(value_control instanceof JSpinner) {
     285        try {
     286            ((JSpinner)value_control).commitEdit();
     287        }
     288        catch(Exception exception) {
     289            Gatherer.println("Exception in OptionsPane.mouseExited() - unexpected");
     290            Gatherer.printStackTrace(exception);
     291        }
     292        }
     293        value_control = null;
     294        control = null;
     295    }
     296    }
     297
     298    /** Implementation side-effect
     299     * @param e a MouseEvent
     300     */
     301    public void mousePressed(MouseEvent e) {}
     302
     303    /** Implementation side-effect
     304     * @param e a MouseEvent
     305     */
     306    public void mouseReleased(MouseEvent e) {}
     307
    252308    private class ArgumentControl
    253309    extends JPanel {
     
    389445        add(enabled, BorderLayout.WEST);
    390446        }
     447    }
     448
     449    /** Retrieve the control used for storing values.
     450     * @return JComponent
     451     */
     452    public JComponent getValueControl() {
     453        return value_control;
    391454    }
    392455
Note: See TracChangeset for help on using the changeset viewer.