Ignore:
Timestamp:
2004-01-09T15:08:11+13:00 (20 years ago)
Author:
jmt12
Message:

Introduced the idea of detail modes - these have an effect on several parts of the gui, such as disabling or hiding all regular expression based controls, simplifying the output from perl scripts and (having been given yet another new last minute feature to implement) displays a completely different create pane. Mode is stored in the config.xml and is changable via the Preferences controls

Location:
trunk/gli/src/org/greenstone/gatherer/gui
Files:
8 edited

Legend:

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

    r6318 r6389  
    4444import javax.swing.text.*;
    4545import javax.swing.tree.*;
     46import org.greenstone.gatherer.Configuration;
    4647import org.greenstone.gatherer.Dictionary;
    4748import org.greenstone.gatherer.Gatherer;
     
    9192    extends JPanel
    9293    implements GShellListener {
     94
     95    static private Dimension ARGUMENT_SIZE = new Dimension(800,90);
     96    /** The size of the buttons at the bottom of the screen. */
     97    static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
     98    /** The size of the labels on the progress pane. */
     99    static private Dimension LABEL_SIZE = new Dimension(140, 25);
     100    /** The threshold for when the simple view is replaced by the complex one. */
     101    static private final int THRESHOLD = Configuration.EXPERT_MODE;
     102    /** An identifier for the control panel within the card layout. */
     103    static private String CONTROL  = "Control";
     104    /** An identifier for the progress panel within the card layout. */
     105    static private String PROGRESS = "Progress";
     106    /** An identifier for the simple panel within the card layout. */
     107    static private String SIMPLE   = "Simple";
     108
    93109    /** Determines the current view that should be shown for this pane. */
    94110    public boolean processing = false;
     
    120136    /** The label alongside the import progress bar gets some special treatment so... */
    121137    private JLabel progress_import_label = null;
     138    /** A panel containing the two progress bars. */
     139    private JPanel bar_area;
     140    /** The panel on which buttons are rendered on higher detail modes. */
     141    private JPanel button_pane;
    122142    /** The pane which contains the controls for configuration. */
    123143    private JPanel control_pane = null;
     
    126146    /** The pane which contains the progress information. */
    127147    private JPanel progress_pane = null;
    128     /** the pane on the right-hand side - shows the requested options view */
     148    /** The pane on the right-hand side - shows the requested options view */
    129149    private JPanel right = null;
     150    /** The simple panel on which all of the available arguments are rendered. */
     151    private JPanel sargument_configuration_panel;
     152    /** The panel on which buttons are rendered on lower details modes. */
     153    private JPanel sbutton_panel;
     154    /** A simplified version for lower detail modes containing both the control and progress panes smooshed together. */
     155    private JPanel simple_panel;
     156    /** The inner panel of the simple pane which is global so that the bar_area can be added and removed from it. */
     157    private JPanel sinner_panel;
     158    /** The outer panel of the simple pane which is global so that the arguments pane can be added and removed from it. */
     159    private JPanel souter_panel;
     160    /** The scrolling pane for the log. */
     161    private JScrollPane log_scroll;
     162    /** The scrolling pane the simple arguments are rendered within. */
     163    private JScrollPane sargument_configuration_scroll;
    130164    /** the scrolling pane the righthand side is inside - only used for import and build options. the log and log list are not inside a scrollpane */
    131165    private JScrollPane scroll_pane;
     
    138172    /** The homepage address of the current collection */
    139173    private String homepage = null;
    140     /** The size of the buttons at the bottom of the screen. */
    141     static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
    142     /** The size of the labels on the progress pane. */
    143     static private Dimension LABEL_SIZE = new Dimension(140, 25);
    144     /** An identifier for the control panel within the card layout. */
    145     static private String CONTROL = "Control";
    146     /** An identifier for the progress panel within the card layout. */
    147     static private String PROGRESS      = "Progress";
     174
    148175
    149176    /** The constructor creates important helper classes, and initializes all the components.
     
    162189    Collection collection = Gatherer.c_man.getCollection();
    163190    log_textarea = new JTextArea();
     191    log_scroll = new JScrollPane(log_textarea);
    164192
    165193    // Create components
     
    168196    control_pane = new JPanel();
    169197    tree = new OptionTree();
     198    button_pane = new JPanel();
    170199
    171200    // Progress Pane
    172     progress_pane = new JPanel();
     201    progress_pane = new JPanel(); // One owner of the bar component
     202    bar_area = new JPanel(); // This component will be shared about
    173203
    174204    progress_copy_label = new JLabel();
     
    202232    Dictionary.registerText(progress_build_label, "CreatePane.Build_Progress");
    203233
    204     build_monitor = new GBuildProgressMonitor((GImportProgressMonitor)import_monitor); //GBasicProgressMonitor();
     234    build_monitor = new GBuildProgressMonitor(); //GBasicProgressMonitor();
    205235    Gatherer.c_man.registerBuildMonitor(build_monitor);
     236
     237    // And the simple panel
     238    simple_panel = new JPanel();
     239    sbutton_panel = new JPanel();
     240    sinner_panel = new JPanel();
    206241
    207242    // Buttons
     
    240275    }
    241276    Collection current_collection = Gatherer.c_man.getCollection();
    242     if (current_collection != previous_collection) {
     277    if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) {
    243278        this.options_pane = new OptionsPane(current_collection.build_options);
    244279        previous_collection = current_collection;
     280    }
     281    // If we are in simple mode, we have to rebuild the simple arguments list
     282    if(Gatherer.config.getMode() < THRESHOLD) {
     283        souter_panel.remove(sargument_configuration_scroll);
     284        souter_panel.remove(sinner_panel);
     285        sargument_configuration_panel = options_pane.buildImport(null);
     286        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     287        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     288        sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     289        souter_panel.add(sargument_configuration_scroll);
     290        souter_panel.add(sinner_panel);
    245291    }
    246292    tree.valueChanged(null);
     
    253299    }
    254300    }
     301
     302    public void destroy() {
     303    if(document != null) {
     304        document.destroy();
     305    }
     306    }
    255307   
    256308    /** This method is called to actually layout the components.
     
    260312    public void display() {
    261313
     314    int current_mode = Gatherer.config.getMode();
     315
    262316    // Build control_pane
    263317    JPanel left = new JPanel();
     
    276330    options_area.add(right, BorderLayout.CENTER);
    277331
     332    button_pane = new JPanel();
     333    button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
     334    button_pane.setLayout(new GridLayout(1,2));
     335    if(current_mode >= THRESHOLD) {
     336        button_pane.add(build_button);
     337        button_pane.add(cancel_button);
     338        button_pane.add(preview_button);
     339    }
     340
    278341    control_pane.setLayout(new BorderLayout());
    279342    control_pane.add(options_area, BorderLayout.CENTER);
     343    control_pane.add(button_pane, BorderLayout.SOUTH);
    280344
    281345    // Build progress_pane
     
    295359    build_pane.add(build_monitor.getProgress(), BorderLayout.CENTER);
    296360
    297     JPanel bar_area = new JPanel();
    298361    bar_area.setBorder(BorderFactory.createEmptyBorder(10,10,5,10));
    299362
     
    304367    progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    305368    progress_pane.setLayout(new BorderLayout());
    306     progress_pane.add(bar_area, BorderLayout.NORTH);
    307     progress_pane.add(new JScrollPane(log_textarea), BorderLayout.CENTER);
     369    if(current_mode >= THRESHOLD) {
     370        progress_pane.add(bar_area, BorderLayout.NORTH);
     371        progress_pane.add(log_scroll, BorderLayout.CENTER);
     372    }
     373
     374    // Simple panel
     375    sbutton_panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
     376    sbutton_panel.setLayout(new GridLayout(3,1));
     377    if(current_mode < THRESHOLD) {
     378        sbutton_panel.add(build_button);
     379        sbutton_panel.add(cancel_button);
     380        sbutton_panel.add(preview_button);
     381    }
     382
     383    sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
     384    sinner_panel.setLayout(new BorderLayout());
     385    if(current_mode < THRESHOLD) {
     386        sinner_panel.add(bar_area, BorderLayout.CENTER);
     387    }
     388    sinner_panel.add(sbutton_panel, BorderLayout.EAST);
     389   
     390    if(options_pane != null) {
     391        sargument_configuration_panel = options_pane.buildImport(null);
     392        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     393    }
     394    else {
     395        sargument_configuration_panel = new JPanel();
     396    }
     397    sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     398    sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     399    souter_panel = new JPanel();
     400    souter_panel.setSize(new Dimension(400,800));
     401    souter_panel.setLayout(new GridLayout(2,1));
     402    souter_panel.add(sargument_configuration_scroll);
     403    souter_panel.add(sinner_panel);
     404
     405    simple_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     406    simple_panel.setLayout(new BorderLayout());
     407    simple_panel.add(souter_panel, BorderLayout.NORTH);
     408    if(current_mode < THRESHOLD) {
     409        simple_panel.add(log_scroll, BorderLayout.CENTER);
     410    }
    308411
    309412    // Main pane
    310413    main_pane = new JPanel(card_layout);
     414    if(current_mode < THRESHOLD) { // Simple mode - add first
     415        main_pane.add(simple_panel, SIMPLE);
     416    }
    311417    main_pane.add(control_pane, CONTROL);
    312418    main_pane.add(progress_pane, PROGRESS);
    313 
    314     // Buttons
    315     JPanel button_pane = new JPanel();
    316     button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
    317     button_pane.setLayout(new GridLayout(1,2));
    318     button_pane.add(build_button);
    319     button_pane.add(cancel_button);
    320     button_pane.add(preview_button);
     419    if(current_mode >= THRESHOLD) { // Expert mode - add last
     420        main_pane.add(simple_panel, SIMPLE);
     421    }
    321422
    322423    this.setLayout(new BorderLayout());
    323424    this.add(main_pane, BorderLayout.CENTER);
    324     this.add(button_pane, BorderLayout.SOUTH);
    325425    }
    326426
     
    331431     */
    332432    public void gainFocus() {
    333     if(!processing) {
     433    if(Gatherer.config.getMode() < THRESHOLD) {
     434        card_layout.show(main_pane, SIMPLE);
     435    }
     436    else if(!processing) {
    334437        card_layout.show(main_pane, CONTROL);
     438    }
     439    else {
     440        card_layout.show(main_pane, PROGRESS);
    335441    }
    336442    // Refresh the set of controls.
     
    339445    tree.setSelectionPath(path);
    340446    }
    341 
    342     /** Method to acquire the progress monitor associated with builds.
    343      * @return The build <strong>GShellProgressMonitor</strong>.
    344      */
    345     /* private GShellProgressMonitor getBuildProgress() {
    346     return build_monitor;
    347     } */
    348 
    349     /** Method to acquire the progress monitor associated with copying.
    350      * @return The copying <strong>GShellProgressMonitor</strong>.
    351      */
    352     /* private GShellProgressMonitor getCopyProgress() {
    353     return copy_monitor;
    354     } */
    355 
    356     /** Method to acquire the progress monitor associated with import.
    357      * @return The import <strong>GShellProgressMonitor</strong>.
    358      */
    359     /* private GShellProgressMonitor getImportProgress() {
    360     return import_monitor;
    361     } */
    362447
    363448    /** We are informed when this view pane loses focus so we can update build options. */
     
    376461    document.appendLine(event.getMessage());
    377462    log_textarea.setCaretPosition(document.getLengthToNearestLine());
     463    }
     464
     465    /** Called when the detail mode has changed which in turn may cause several import/build configuration arguments to be available/hidden
     466     * @param mode the new mode as an int
     467     */
     468    public void modeChanged(int mode) {
     469    // If we are below the complexity threshold ensure the simple controls are being shown
     470    if(Gatherer.config.getMode() < THRESHOLD) {
     471        // Update the arguments
     472        souter_panel.remove(sargument_configuration_scroll);
     473        souter_panel.remove(sinner_panel);
     474        if(options_pane != null) {
     475        sargument_configuration_panel = options_pane.buildImport(null);
     476        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     477        }
     478        else {
     479        sargument_configuration_panel = new JPanel();
     480        }
     481        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     482        sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     483        souter_panel.add(sargument_configuration_scroll);
     484        souter_panel.add(sinner_panel);
     485        // Remove the shared components from the expert panels
     486        button_pane.remove(build_button);
     487        button_pane.remove(cancel_button);
     488        button_pane.remove(preview_button);
     489        progress_pane.remove(bar_area);
     490        progress_pane.remove(log_scroll);
     491        // And add to simple one
     492        sbutton_panel.add(build_button);
     493        sbutton_panel.add(cancel_button);
     494        sbutton_panel.add(preview_button);
     495        sinner_panel.add(bar_area, BorderLayout.CENTER);
     496        simple_panel.add(log_scroll, BorderLayout.CENTER);
     497        // And bring the card to the front
     498        card_layout.show(main_pane, SIMPLE);
     499    }
     500    // And if we are above the threshold change to the complex controls
     501    else {
     502        // Remove the shared components from the simple panel
     503        sbutton_panel.remove(build_button);
     504        sbutton_panel.remove(cancel_button);
     505        sbutton_panel.remove(preview_button);
     506        sinner_panel.remove(bar_area);
     507        simple_panel.remove(log_scroll);
     508        // And add then to the expert ones
     509        button_pane.add(build_button);
     510        button_pane.add(cancel_button);
     511        button_pane.add(preview_button);
     512        progress_pane.add(bar_area, BorderLayout.NORTH);
     513        progress_pane.add(log_scroll, BorderLayout.CENTER);
     514        // And bring the appropriate card to the front
     515        if(!processing) {
     516        card_layout.show(main_pane, CONTROL);
     517        }
     518        else {
     519        card_layout.show(main_pane, PROGRESS);
     520        }
     521    }
     522    tree.valueChanged(null); // Ensure tree argument panels are rebuilt
    378523    }
    379524
     
    397542        document.setSpecialCharacter(OptionsPane.SUCCESSFUL);
    398543        options_pane.resetFileEntry();
    399         card_layout.show(main_pane, CONTROL);
     544        build_monitor.reset();
     545        import_monitor.reset();
     546        if(Gatherer.config.getMode() >= THRESHOLD) {
     547            card_layout.show(main_pane, CONTROL);
     548        }
    400549        }
    401550        // Otherwise its completed import but still got build to go
     
    414563        }
    415564        options_pane.resetFileEntry();
    416         card_layout.show(main_pane, CONTROL);
     565        if(Gatherer.config.getMode() >= THRESHOLD) {
     566        card_layout.show(main_pane, CONTROL);
     567        }
    417568    }
    418569    }
     
    457608        // First we force the build options to be updated if we haven't already.
    458609        tree.valueChanged(null);
     610       
     611        // Remember that for lower thresholds the above doesn't work, so try this instead
     612        if(Gatherer.config.getMode() < THRESHOLD) {
     613        options_pane.update(sargument_configuration_panel);
     614        }
     615
    459616        // Now go about building.
    460617        build_button.setEnabled(false);
    461618        cancel_button.setEnabled(true);
    462619        preview_button.setEnabled(false);
    463         // Create a new log document and assign it to the two textareas
    464620        document = options_pane.createNewLogDocument();
    465621        log_textarea.setDocument(document);
     
    467623        // Change the view.
    468624        processing = true;
    469         card_layout.show(main_pane, PROGRESS);
     625        if(Gatherer.config.getMode() >= THRESHOLD) {
     626        card_layout.show(main_pane, PROGRESS);
     627        }
    470628        // Reset the stop flag in all the process monitors, just incase.
    471629        ((GBuildProgressMonitor)build_monitor).reset();
     
    496654        processing = false;
    497655        document.setSpecialCharacter(OptionsPane.CANCELLED);
    498         card_layout.show(main_pane, CONTROL);
     656        if(Gatherer.config.getMode() >= THRESHOLD) {
     657        card_layout.show(main_pane, CONTROL);
     658        }
    499659        // Set the stop flag in all the process monitor.
    500660        build_monitor.setStop(true);
     661        build_monitor.reset();
    501662        copy_monitor.setStop(true);
    502663        import_monitor.setStop(true);
     664        import_monitor.reset();
    503665        // Set removeold automatically.
    504666        Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null);
     
    591753        }
    592754        if(node != null && node.equals(building)) {
    593         previous_pane = options_pane.buildBuild();
     755        previous_pane = options_pane.buildBuild(null);
    594756        scroll_pane = new JScrollPane(previous_pane);
    595757        right.add(scroll_pane, BorderLayout.CENTER);
     
    597759        }
    598760        else if(node != null && node.equals(importing)) {
    599         previous_pane = options_pane.buildImport();
     761        previous_pane = options_pane.buildImport(null);
    600762        scroll_pane = new JScrollPane(previous_pane);
    601763        right.add(scroll_pane, BorderLayout.CENTER);
  • trunk/gli/src/org/greenstone/gatherer/gui/Filter.java

    r6051 r6389  
    7272    private DragTree tree = null;
    7373    /** The default size for the label. */
    74     static final private Dimension SIZE = new Dimension(100,25);
     74    static final private Dimension SIZE = new Dimension(100,30);
    7575    /** Preprogrammed default filters. */
    7676    static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tif$)"};
     
    9797    this.tree = tree;
    9898    // Create components.
    99     combobox = new GComboBox();
     99    combobox = new GComboBox(true);
    100100    combobox.add(new Entry());
    101101    for(int i = 0; i < DEFAULTS.length; i++) {
     
    108108        }
    109109    }
    110     combobox.setEditable(true);
    111110    label = new JLabel();
    112111    label.setPreferredSize(SIZE);
     
    153152    combobox.setSelectedItem(selection);
    154153    ignore = false;
     154    }
     155
     156    /** Sets whether this combobox is editable or not
     157     * @param value true to make the control editable, false otherwise
     158     */
     159    public void setEditable(boolean value) {
     160    combobox.setEditable(value);       
    155161    }
    156162
  • trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java

    r6321 r6389  
    4545/**
    4646 * @author John Thompson, Greenstone Digital Library, University of Waikato
    47  * @version
     47 * @version 2.3
    4848 */
    4949public class GComboBox
     
    175175    super.setEditable(editable);
    176176    this.editable = editable;
    177     setEditor(new Editor());
    178     setRenderer(new Renderer());
     177    if(editable) {
     178        this.setBackground(editable_background);
     179        this.setForeground(editable_foreground);
     180    }
     181    else {
     182        this.setBackground(background);
     183        this.setForeground(foreground);
     184    }
     185    setEditor(new Editor());
     186    setRenderer(new Renderer());
     187    updateUI();
    179188    }
    180189
     
    201210    ComboBoxModel old_model = (ComboBoxModel) getModel();
    202211    setModel(model);
     212    setOpaque(true);
    203213    // Restore any data given into our model
    204214    for(int i = 0; i < old_model.getSize(); i++) {
     
    226236    setBorder(BorderFactory.createLoweredBevelBorder());
    227237    setEditor(new Editor());
    228     setOpaque(true);
    229238    setRenderer(new Renderer());
    230239    }
     
    234243    implements ComboBoxEditor {
    235244    public Editor() {
    236         setBackground(editable_background);
    237         setForeground(editable_foreground);
    238245        setOpaque(true);
    239246        if(editable) {
    240         setSelectionColor(selection_background);
    241         setSelectedTextColor(selection_foreground);
    242         }
     247        setBackground(editable_background);
     248        setForeground(editable_foreground);
     249        }
     250        else {
     251        setBackground(background);
     252        setForeground(foreground);
     253        }
     254        setSelectionColor(selection_background);
     255        setSelectedTextColor(selection_foreground);
    243256    }
    244257
     
    301314    public Renderer() {
    302315        super("");
    303         this.setBackground(background);
    304         this.setForeground(foreground);
    305316        this.setOpaque(true);
    306317    }
     
    312323        this.setText("");
    313324        }
    314         if(editable) {
     325        if(isSelected) {
     326        this.setBackground(selection_background);
     327        this.setForeground(selection_foreground);
     328        }
     329        else if(editable) {
    315330        this.setBackground(editable_background);
    316331        this.setForeground(editable_foreground);
  • trunk/gli/src/org/greenstone/gatherer/gui/GConfigPane.java

    r5658 r6389  
    104104      }
    105105   }
     106
     107    /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
     108     * @param mode the mode level as an int
     109     */
     110    public void modeChanged(int mode) {
     111    cdm.modeChanged(mode);
     112    }
    106113   
    107114   public Rectangle setSelectedElement(ElementWrapper element) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6220 r6389  
    7474import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    7575import org.greenstone.gatherer.help.HelpFrame;
     76import org.greenstone.gatherer.mem.MetadataEditorManager;
    7677import org.greenstone.gatherer.msm.ElementWrapper;
    7778import org.greenstone.gatherer.msm.Metadata;
     
    392393    }
    393394
     395    public void destroy() {
     396    // Destroying create pane ensures the latest log has been closed
     397    if(create_pane != null) {
     398        create_pane.destroy();
     399    }
     400    }
     401
    394402    /** Enabled events on the window to be trapped, creates all the visual components, then builds the tab and other layouts.
    395403     */
     
    511519    }
    512520    else {
    513         if(help != null) {
     521        // Deal to help
     522        if(help != null) {
    514523            help.destroy();
    515524            help = null;
    516         }
     525        }
    517526        Gatherer.self.exit();
    518527    }
     
    547556        int config_pos = tab_pane.indexOfComponent(config_pane);
    548557        tab_pane.setEnabledAt(config_pos, !lock);
     558    }
     559    }
     560
     561    public void modeChanged(int mode) {
     562    // Set the title
     563    String collection_title = null;
     564    String collection_name = null;
     565    if (Gatherer.c_man.ready()) {
     566        Collection collection = Gatherer.c_man.getCollection();
     567        collection_title = collection.getTitle();
     568        collection_name = collection.getName();
     569        collection = null;
     570    }
     571    setTitle(collection_title, collection_name);
     572    collection_title = null;
     573    collection_name = null;
     574    // Now pass on the message to anyone who cares
     575    if(collection_pane != null) {
     576        collection_pane.modeChanged(mode);
     577    }
     578    if(config_pane != null) {
     579        config_pane.modeChanged(mode);
     580    }
     581    if(create_pane != null) {
     582        create_pane.modeChanged(mode);
     583    }
     584    if(metaedit_pane != null) {
     585        metaedit_pane.modeChanged(mode);
    549586    }
    550587    }
     
    615652    // Finally display the collection name in the title bar.
    616653    StringBuffer title_buffer = new StringBuffer(Utility.PROGRAM_NAME);
    617     title_buffer.append(StaticStrings.COLON_CHARACTER);
    618654    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     655    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     656    // Describe the current user mode
     657    title_buffer.append(StaticStrings.MODE_STR);
     658    title_buffer.append(Gatherer.config.getModeAsString());
     659    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     660    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     661    // Now for the current collection
     662    title_buffer.append(StaticStrings.COLLECTION_STR);
    619663    if (title != null && name != null) {
    620664        title_buffer.append(title);
     
    635679    public void showEditMetadataBox() {
    636680    if(Gatherer.c_man.getCollection() != null) {
    637         Gatherer.c_man.getCollection().msm.editMDS();
     681        Gatherer.c_man.getCollection().msm.editMDS(null, MetadataEditorManager.NORMAL);
    638682    }
    639683    }
     
    9641008        }
    9651009        if(config_pos != -1) {
    966         tab_pane.setEnabledAt(config_pos, ready && Gatherer.config.get("workflow.design", false));
     1010        tab_pane.setEnabledAt(config_pos, ready && Gatherer.config.get("workflow.design", false) && Gatherer.config.getMode() > Configuration.ASSISTANT_MODE);
    9671011        }
    9681012        if(export_pos != -1) {
     
    9941038    }
    9951039}
     1040
     1041
  • trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java

    r6318 r6389  
    4646import javax.swing.table.*;
    4747import javax.swing.tree.*;
     48import org.greenstone.gatherer.Configuration;
    4849import org.greenstone.gatherer.Dictionary;
    4950import org.greenstone.gatherer.Gatherer;
     
    140141     * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree
    141142     * @see org.greenstone.gatherer.Configuration
    142      * @see org.greenstone.gatherer.gui.table.GTable
    143      * @see org.greenstone.gatherer.valuetree.GValueTree
     143     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    144144     */
    145145    public MetaEditPane(TreeSynchronizer tree_sync)
     
    190190     * @param event An <strong>ActionEvent</strong> containing information about the event.
    191191     * @see org.greenstone.gatherer.collection.CollectionManager
     192     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    192193     * @see org.greenstone.gatherer.gui.table.GTableModel
    193194     * @see org.greenstone.gatherer.msm.ElementWrapper
    194195     * @see org.greenstone.gatherer.msm.MetadataSetManager
    195196     * @see org.greenstone.gatherer.msm.MSMEvent
    196      * @see org.greenstone.gatherer.valuetree.GValueTree
    197197     */
    198198    public void actionPerformed(ActionEvent event) {
     
    317317     * @param ready <i>true</i> if there is a collection currently ready to be editing, <i>false</i> otherwise.
    318318     * @see org.greenstone.gatherer.collection.CollectionManager
    319      * @see org.greenstone.gatherer.collection.CollectionModel
    320      * @see org.greenstone.gatherer.tree.GTree
    321319     * @see org.greenstone.gatherer.util.TreeSynchronizer
    322320     */
     
    358356     * @see org.greenstone.gatherer.Gatherer
    359357     * @see org.greenstone.gatherer.collection.CollectionManager
    360      * @see org.greenstone.gatherer.collection.CollectionModel
    361358     * @see org.greenstone.gatherer.file.FileOpenActionListener
    362359     * @see org.greenstone.gatherer.gui.Filter
    363360     * @see org.greenstone.gatherer.gui.GComboBox
    364361     * @see org.greenstone.gatherer.gui.table.GTableModel
    365      * @see org.greenstone.gatherer.tree.GTree
    366      * @see org.greenstone.gatherer.tree.GTreeModel
    367      * @see org.greenstone.gatherer.valuetree.GValueTree
    368362     */
    369363    public void display() {
     
    403397    filter = Gatherer.g_man.getFilter(collection_tree);
    404398    filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
    405     // Change the default colours of this filters combobox.
    406     GComboBox fcb = filter.getComboBox();
    407     fcb.setBackgroundNonSelectionColor(Color.white);
    408     fcb.setTextNonSelectionColor(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
    409     fcb.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));
    410     fcb.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false));
    411     Dictionary.registerTooltip(fcb, "Collection.Filter_Tooltip");
    412     fcb = null;
     399    filter.setEditable(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE);
     400    Dictionary.registerTooltip(filter.getComboBox(), "Collection.Filter_Tooltip");
    413401
    414402    // Connection
     
    584572    /** Ensures a certain tree path is expanded, visible and selected within the collection tree.
    585573     * @param path The <strong>TreePath</strong> to make visible.
    586      * @see org.greenstone.gatherer.tree.GTree
     574     * @see org.greenstone.gatherer.gui.tree.DragTree
    587575     */
    588576    private void expandPath(TreePath path) {
     
    591579    }
    592580    /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab.
    593      * @see org.greenstone.gatherer.tree.GTree
     581     * @see org.greenstone.gatherer.gui.tree.DragTree
    594582     */
    595583    public void gainFocus() {
     
    630618     */
    631619    public void metadataChanged(MSMEvent event) {}
     620
     621    /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
     622     * @param mode the mode level as an int
     623     */
     624    public void modeChanged(int mode) {
     625    filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
     626    }
    632627
    633628    public void refreshTrees() {
     
    717712     * @param event The <strong>ListSelectionEvent</strong> which contains all the information about the event that has been fired.
    718713     * @see org.greenstone.gatherer.gui.table.GTableModel
    719      * @see org.greenstone.gatherer.valuetree.GValueTree
     714     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    720715     */
    721716    public void valueChanged(ListSelectionEvent event) {
     
    750745     * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
    751746     * @see org.greenstone.gatherer.Gatherer
    752      * @see org.greenstone.gatherer.collection.FileNode
     747     * @see org.greenstone.gatherer.file.FileNode
    753748     * @see org.greenstone.gatherer.gui.GUIManager
    754749     * @see org.greenstone.gatherer.gui.MenuBar
    755750     * @see org.greenstone.gatherer.gui.table.GTableModel
    756751     * @see org.greenstone.gatherer.msm.MetadataSetManager
    757      * @see org.greenstone.gatherer.tree.GTree
     752     * @see org.greenstone.gatherer.gui.tree.DragTree
    758753     * @see org.greenstone.gatherer.util.ArrayTools
    759754     */
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r6321 r6389  
    4444import javax.swing.event.*;
    4545import javax.swing.text.*;
     46import org.greenstone.gatherer.Configuration;
    4647import org.greenstone.gatherer.Dictionary;
    4748import org.greenstone.gatherer.Gatherer;
     
    6970    static final public char UNKNOWN = 'x';
    7071
     72    static private int BUILD = 0;
     73    static private int IMPORT = 1;
     74    static private int MINIMUM_ROWS = 11;
     75    static private Dimension LABEL_SIZE = new Dimension(180, 25);
     76    static private Dimension ROW_SIZE = new Dimension(610, 30);
     77    static private Dimension SPINNER_SIZE = new Dimension(100, 25);
     78    static private String DESCRIPTION_SEP = " + ";
     79
    7180    /** All process messages are written to this log text area. */
    7281    public JTextArea log_textarea = null;
     
    8594    private Vector writing_documents;
    8695
    87     static private int BUILD = 0;
    88     static private int IMPORT = 1;
    89     static private Dimension LABEL_SIZE = new Dimension(180, 25);
    90     static private Dimension ROW_SIZE = new Dimension(610, 25);
    91     static private Dimension SPINNER_SIZE = new Dimension(100, 25);
    92     static private String DESCRIPTION_SEP = " + ";
    93 
    9496
    9597    /** 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. */
     
    105107
    106108    /** This method creates the panel with all the build only options on it.
    107      * @return A <strong>JPanel</strong> which can be used to display all the build only options.
     109     * @param pane a JPanel which already has previous arguments available on it, to allow for lower moes to concatenate all of the arguments together
     110     * @return a JPanel which can be used to display all the build only options
     111     * @see org.greenstone.gatherer.Configuration#EXPERT_MODE
     112     * @see org.greenstone.gatherer.Configuration#getColor
     113     * @see org.greenstone.gatherer.Configuration#getMode
     114     * @see org.greenstone.gatherer.Gatherer#config
     115     * @see org.greenstone.gatherer.cdm.Argument
     116     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildArgument
     117     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildArgumentCount
     118     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValue
     119     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValueEnabled
     120     * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
    108121     */
    109     public JPanel buildBuild() {
    110     current_controls.clear();
    111     JPanel pane = new JPanel();
    112     pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    113     pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    114     int build_argument_count = build_options.getBuildArgumentCount();
    115     pane.setLayout(new GridLayout(build_argument_count, 1, 5, 5));
    116     for(int i = 0; i < build_argument_count; i++) {
     122    public JPanel buildBuild(JPanel pane) {
     123    // Reset the arguments
     124    if(pane == null) {
     125        current_controls.clear();
     126    }
     127    ArrayList build_arguments = new ArrayList();
     128    int current_mode = Gatherer.config.getMode();
     129    int total_build_argument_count = build_options.getBuildArgumentCount();       
     130    for(int i = 0; i < total_build_argument_count; i++) {
    117131        // Retrieve the argument so we know how to format the control.
    118132        Argument argument = build_options.getBuildArgument(i);
    119         // Now attempt to retrieve any existing value for this argument.
    120         boolean enabled = build_options.getBuildValueEnabled(argument.getName());
    121         String value = build_options.getBuildValue(argument.getName());
    122         ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
    123         pane.add(argument_control);
    124         current_controls.add(argument_control);
     133        if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) {
     134        // Now attempt to retrieve any existing value for this argument.
     135        boolean enabled = build_options.getBuildValueEnabled(argument.getName());
     136        String value = build_options.getBuildValue(argument.getName());
     137        ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
     138        build_arguments.add(argument_control);
     139        }
     140    }
     141    current_controls.addAll(build_arguments);
     142    // 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.
     143    if(pane == null || current_mode >= Configuration.EXPERT_MODE) {
     144        pane = new JPanel();
     145        pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     146        pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     147        int argument_count = build_arguments.size();
     148        // 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 or lines in the grid layout
     149        if(current_mode >= Configuration.EXPERT_MODE) {
     150        if(argument_count < MINIMUM_ROWS) {
     151            argument_count = MINIMUM_ROWS;
     152        }
     153        pane.setLayout(new GridLayout(argument_count, 1, 5, 5));
     154        }
     155        // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway
     156        else {
     157        pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
     158        }
     159    }
     160    for(int j = 0; j < build_arguments.size(); j++) {
     161        pane.add((JComponent)build_arguments.get(j));
    125162    }
    126163    pane.addMouseListener(this);
     164    build_arguments = null;
    127165    return pane;
    128166    }
     167
    129168    /** This method creates the panel with all the import only options on it.
    130      * @return A <strong>JPanel</strong> which can be used to display all the import only options.
     169     * @param pane a JPanel which already has previous arguments available on it, to allow for lower moes to concatenate all of the arguments together
     170     * @return a JPanel which can be used to display all the build only options
     171     * @see org.greenstone.gatherer.Configuration#EXPERT_MODE
     172     * @see org.greenstone.gatherer.Configuration#getColor
     173     * @see org.greenstone.gatherer.Configuration#getMode
     174     * @see org.greenstone.gatherer.Gatherer#config
     175     * @see org.greenstone.gatherer.cdm.Argument
     176     * @see org.greenstone.gatherer.collection.BuildOptions#getImportArgument
     177     * @see org.greenstone.gatherer.collection.BuildOptions#getImportArgumentCount
     178     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValue
     179     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValueEnabled
     180     * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
    131181     */
    132     public JPanel buildImport() {
    133     current_controls.clear();
    134     JPanel pane = new JPanel();
    135     pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    136     pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    137     int import_argument_count = build_options.getImportArgumentCount();
    138     pane.setLayout(new GridLayout(import_argument_count, 1, 5, 5));
    139     for(int i = 0; i < import_argument_count; i++) {
     182    public JPanel buildImport(JPanel pane) {
     183    // Reset the arguments
     184    if(pane == null) {
     185        current_controls.clear();
     186    }
     187    ArrayList import_arguments = new ArrayList();
     188    int current_mode = Gatherer.config.getMode();
     189    int total_import_argument_count = build_options.getImportArgumentCount();       
     190    for(int i = 0; i < total_import_argument_count; i++) {
    140191        // Retrieve the argument so we know how to format the control.
    141192        Argument argument = build_options.getImportArgument(i);
    142         // Now attempt to retrieve any existing value for this argument.
    143         boolean enabled = build_options.getImportValueEnabled(argument.getName());
    144         String value = build_options.getImportValue(argument.getName());
    145         ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
    146         pane.add(argument_control);
    147         current_controls.add(argument_control);
     193        if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) {
     194        // Now attempt to retrieve any existing value for this argument.
     195        boolean enabled = build_options.getImportValueEnabled(argument.getName());
     196        String value = build_options.getImportValue(argument.getName());
     197        ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
     198        import_arguments.add(argument_control);
     199        }
     200    }
     201    current_controls.addAll(import_arguments);
     202    // 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.
     203    if(pane == null || current_mode >= Configuration.EXPERT_MODE) {
     204        pane = new JPanel();
     205        pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     206        pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     207        int argument_count = import_arguments.size();
     208        // 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 or lines in the grid layout
     209        if(current_mode >= Configuration.EXPERT_MODE) {
     210        if(argument_count < MINIMUM_ROWS) {
     211            argument_count = MINIMUM_ROWS;
     212        }
     213        pane.setLayout(new GridLayout(argument_count, 1, 5, 5));
     214        }
     215        // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway
     216        else {
     217        pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
     218        }
     219    }
     220    for(int j = 0; j < import_arguments.size(); j++) {
     221        pane.add((JComponent)import_arguments.get(j));
    148222    }
    149223    pane.addMouseListener(this);
     224    import_arguments = null;
    150225    return pane;
    151226    }
     227
    152228    /** This method is used to build a panel based on the message log, which is nothing like any of the other panels.
    153229     * @return A <strong>JPanel</strong> containing a scrollable text area which represents the shell process message log.
     
    322398        setLayout(new BorderLayout());
    323399        setPreferredSize(ROW_SIZE);
     400        setMaximumSize(ROW_SIZE);
    324401
    325402        // Try to determine what the value_controls value should be.
     
    425502        value_control = textfield;
    426503        break;
     504        case Argument.METADATUM:
     505        GComboBox gcombobox = new GComboBox(Gatherer.c_man.getCollection().msm.getAssignedElements(), false);
     506        gcombobox.setEnabled(enable);
     507        // Now ensure we have the existing value or default value selected if either exist.
     508        if(value != null) {
     509            boolean found = selectValue(gcombobox, value);
     510            // Its possible that this is a custom value and so doesn't exist in the combobox. If so add it and then select it
     511            if(!found) {
     512            gcombobox.addItem(value);
     513            gcombobox.setSelectedItem(value);
     514            }
     515        }
     516        add(gcombobox, BorderLayout.CENTER);
     517        value_control = gcombobox;
     518        break;
    427519        }
    428520
     
    454546    }
    455547
     548    /** Method to ensure that a certain value is selected, if it exists within that combobox to begin with.
     549     * @param combobox the JComboBox whose selection we are trying to preset
     550     * @param target The desired value of the selection as a String
     551     * @return true if the item was found and selected, false otherwise
     552     */
     553    public boolean selectValue(JComboBox combobox, String target) {
     554        for(int i = 0; i < combobox.getItemCount(); i++) {
     555        if(combobox.getItemAt(i).toString().equals(target)) {
     556            combobox.setSelectedIndex(i);
     557            return true;
     558        }
     559        }
     560        return false;
     561    }
     562
    456563    /** Update the values stored in the collection so as to rememebr the current state of this argument. */
    457564    public void update() {
     
    472579        }
    473580        else if(value_control instanceof JComboBox) {
    474         value = (String) ((JComboBox)value_control).getSelectedItem();
    475         }
    476                 // If this argument was a flag, but is now disabled, remove from the build options altogether
     581        value = (((JComboBox)value_control).getSelectedItem()).toString();
     582        }
     583        // If this argument was a flag, but is now disabled, remove from the build options altogether
    477584        if(!enable && value == null) {
    478585        if(type == BUILD) {
     
    483590        }
    484591        }
    485                 // Otherwise update the argument value
     592        // Otherwise update the argument value
    486593        else {
    487594        if(type == BUILD) {
     
    638745    public void valueChanged(ListSelectionEvent e) {
    639746        if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one)
     747        ///ystem.err.println("Log change detected.");
    640748        JList source  = (JList)e.getSource();
    641749        file_entry = (FileEntry) source.getSelectedValue();
    642750        // First we determine if the old log has been completely written to file
    643751        Document document = log_textarea.getDocument();
    644         if(document instanceof AppendLineOnlyFileDocument) {
    645             AppendLineOnlyFileDocument append_line_only_file_document = (AppendLineOnlyFileDocument) document;
     752        ///ystem.err.println(" * current document: " + document);
     753        ///ystem.err.println(" * new document:     " + file_entry.getDocument());
     754        // If we are dealing with the same document don't do anything.
     755        if(document != file_entry.getDocument()) {
     756            if(document instanceof AppendLineOnlyFileDocument) {
     757            AppendLineOnlyFileDocument append_line_only_file_document = (AppendLineOnlyFileDocument) document;
    646758            if(append_line_only_file_document.isStillWriting()) {
     759                ///ystem.err.println("Current log is still active... finishing.");
    647760                writing_documents.add(append_line_only_file_document); // We have to maintain a reference until they are all done.
    648761                append_line_only_file_document.setOwner(OptionsPane.this);
    649762                append_line_only_file_document.setExit();
    650763            }
    651         }
    652         // Load the new log
    653         log_textarea.setDocument(file_entry.getDocument());
     764            else {
     765                ///ystem.err.println("Current log is complete. Nothing to do.");
     766            }
     767            }
     768            // Load the new log
     769            log_textarea.setDocument(file_entry.getDocument());
     770        }
    654771        }
    655772    }
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r6319 r6389  
    7676    private JLabel recursion_depth_label;
    7777    private JLabel title_label;
     78    private JRadioButton assistant_mode_radio_button;
     79    private JRadioButton expert_mode_radio_button;
     80    private JRadioButton librarian_mode_radio_button;
     81    private JRadioButton systems_mode_radio_button;
     82    private JSpinner proxy_port_field;
     83    private JSpinner recursion_depth_spinner;
    7884    private JTabbedPane tab_pane;
     85    private JTextArea mode_description_textarea;
    7986    private JTextField library_path_field;
    8087    private JTextField proxy_host_field;
    81     private JSpinner proxy_port_field;
    82     private JSpinner recursion_depth_spinner;
    8388    private Preferences self;
    8489
    85     static final Dimension LABEL_SIZE = new Dimension(175, 25);
     90    static final Dimension LABEL_SIZE = new Dimension(240, 25);
    8691    static final Dimension ROW_SIZE = new Dimension(640, 25);
    8792    static final Dimension SIZE = new Dimension(640, 345);
     
    101106    JPanel general_preferences = createGeneralPreferences();
    102107    tab_pane.add("Preferences.General", general_preferences);
     108    tab_pane.add("Preferences.Mode", createModePreferences());
    103109    tab_pane.add("Preferences.Workflow", createWorkflowPreferences());
    104110    tab_pane.add("Preferences.Connection", createConnectionPreferences());
     
    330336    }
    331337
     338    /** Generate the controls for altering the detail mode.
     339     * @return a JPanel of controls
     340     */
     341    private JPanel createModePreferences() {
     342    // Create Controls
     343    JPanel mode_panel = new JPanel();
     344    JPanel button_panel = new JPanel();
     345    ButtonGroup mode_button_group = new ButtonGroup();
     346    assistant_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Assistant"));
     347    assistant_mode_radio_button.setOpaque(false);
     348    mode_button_group.add(assistant_mode_radio_button);
     349    expert_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Expert"));
     350    expert_mode_radio_button.setOpaque(false);
     351    mode_button_group.add(expert_mode_radio_button);
     352    librarian_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Librarian"));
     353    librarian_mode_radio_button.setOpaque(false);
     354    mode_button_group.add(librarian_mode_radio_button);
     355    systems_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Systems"));
     356    systems_mode_radio_button.setOpaque(false);
     357    mode_button_group.add(systems_mode_radio_button);
     358    mode_description_textarea = new JTextArea();
     359    mode_description_textarea.setEditable(false);
     360    mode_description_textarea.setLineWrap(true);
     361    mode_description_textarea.setWrapStyleWord(true);
     362    // Determine which value is already selected
     363    switch(Gatherer.config.getMode()) {
     364    case Configuration.ASSISTANT_MODE:
     365        assistant_mode_radio_button.setSelected(true);
     366        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
     367        break;
     368    case Configuration.SYSTEMS_MODE:
     369        systems_mode_radio_button.setSelected(true);
     370        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Systems_Description"));
     371        break;
     372    case Configuration.EXPERT_MODE:
     373        expert_mode_radio_button.setSelected(true);
     374        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
     375        break;
     376    default:
     377        librarian_mode_radio_button.setSelected(true);
     378        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
     379    }
     380    // Connection - when a radio button is selected we have to change the description
     381    ModeRadioButtonListener listener = new ModeRadioButtonListener();
     382    assistant_mode_radio_button.addActionListener(listener);
     383    expert_mode_radio_button.addActionListener(listener);
     384    librarian_mode_radio_button.addActionListener(listener);
     385    systems_mode_radio_button.addActionListener(listener);
     386    listener = null;
     387    // Layout
     388    button_panel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     389    button_panel.setLayout(new GridLayout(4,1,2,2));
     390    button_panel.add(assistant_mode_radio_button);
     391    button_panel.add(librarian_mode_radio_button);
     392    button_panel.add(systems_mode_radio_button);
     393    button_panel.add(expert_mode_radio_button);
     394
     395    mode_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     396    mode_panel.setLayout(new BorderLayout());
     397    mode_panel.add(button_panel, BorderLayout.NORTH);
     398    mode_panel.add(new JScrollPane(mode_description_textarea), BorderLayout.CENTER);
     399
     400    return mode_panel;
     401    }
     402
    332403    /** The warning preferences are controlled through a checklist. */
    333404    private JPanel createWarningPreferences() {
     
    504575        Gatherer.config.setInt("general.max_folder_depth", Configuration.COLLECTION_SPECIFIC, ((Integer)recursion_depth_spinner.getValue()).intValue());
    505576
     577        // Mode preferences
     578        int current_mode = Gatherer.config.getMode();
     579        int new_mode;
     580        if(assistant_mode_radio_button.isSelected()) {
     581        new_mode = Configuration.ASSISTANT_MODE;
     582        }
     583        else if(systems_mode_radio_button.isSelected()) {
     584        new_mode = Configuration.SYSTEMS_MODE;
     585        }
     586        else if(expert_mode_radio_button.isSelected()) {
     587        new_mode = Configuration.EXPERT_MODE;
     588        }
     589        else  {
     590        new_mode = Configuration.LIBRARIAN_MODE;
     591        }
     592        // If there has been a change in modes, update the config, and also inform the persistant gui views that have a need to know
     593        if(new_mode != current_mode) {
     594        Gatherer.config.setMode(new_mode);
     595        Gatherer.c_man.getCollection().cdm.modeChanged(new_mode);
     596        Gatherer.g_man.modeChanged(new_mode);
     597        }
    506598        // Warning preferences
    507599        for(int i = 0; i < warning_preferences_check_list.getEntryCount(); i++) {
     
    522614        Gatherer.g_man.workflowUpdate("Gather", workflow_gather.isSelected());
    523615        Gatherer.g_man.workflowUpdate("Enrich", workflow_enrich.isSelected());
    524         Gatherer.g_man.workflowUpdate("Design", workflow_design.isSelected());
     616        Gatherer.g_man.workflowUpdate("Design", (workflow_design.isSelected() && Gatherer.config.getMode() > Configuration.ASSISTANT_MODE));
    525617        Gatherer.g_man.workflowUpdate("Export", workflow_export.isSelected());
    526618        Gatherer.g_man.workflowUpdate("Create", workflow_create.isSelected());
     
    568660        return locale.getDisplayName();
    569661        }
     662    }
     663    }
     664
     665    /** This listener updates the mode description depending on what mode is selected. */
     666    private class ModeRadioButtonListener
     667    implements ActionListener {
     668    public void actionPerformed(ActionEvent event) {
     669        Object source = event.getSource();
     670        if(source == assistant_mode_radio_button) {
     671        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
     672        }
     673        else if(source == expert_mode_radio_button) {
     674        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
     675        }
     676        else if(source == systems_mode_radio_button) {
     677        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Systems_Description"));
     678        }
     679        else {
     680        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
     681        }
     682        source = null;
    570683    }
    571684    }
Note: See TracChangeset for help on using the changeset viewer.