Changeset 19401


Ignore:
Timestamp:
2009-05-12T12:25:20+12:00 (15 years ago)
Author:
oranfry
Message:

incremental import and build now works from gli, controlled by the minimal and full build buttons

Location:
gli/branches/incremental/src/org/greenstone/gatherer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gli/branches/incremental/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r16680 r19401  
    8080    /** A manager of configuring depositor metadata */
    8181    static public DepositorMetadataManager depositormetadata_manager;
     82
    8283    /** These mark what needs to happen when building a collection where ONLY design options have been changed.
    8384        The build requirements of the higher numbers must include doing everything from the lower numbers. */
     
    8687    static final public int NOTHING = 0;
    8788    static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
     89
     90    /** This indicates whether a minimal or complete build is required.
     91        Minimal means do everything with the -incremental flag. Complete means do everything with -removeold */
     92    static private boolean isCompleteBuild = false;
     93
    8894
    8995    /** Constructor. Loads a certain collection configuration file, which is parsed into a DOM. This model is then registered with the command information managers, each of whom knows how to, and provides controls to, alter certain commands.
     
    202208
    203209    public static int getRebuildTypeRequired() {
    204     return rebuildTypeRequired;
    205     }
     210        return rebuildTypeRequired;
     211    }
     212
    206213    public static void resetRebuildTypeRequired() {
    207     setRebuildTypeRequired(NOTHING);
     214        setRebuildTypeRequired(NOTHING);
    208215    }
    209216    public static void setRebuildTypeRequired(int number) {
    210     rebuildTypeRequired = number;
     217        rebuildTypeRequired = number;
     218    }
     219
     220    public static boolean isCompleteBuild() {
     221        return isCompleteBuild;
     222    }
     223    public static void setCompleteBuild(boolean icb) {
     224        isCompleteBuild = icb;
    211225    }
    212226
  • gli/branches/incremental/src/org/greenstone/gatherer/collection/CollectionManager.java

    r19242 r19401  
    5151import org.greenstone.gatherer.cdm.CollectionMetaManager;
    5252import org.greenstone.gatherer.cdm.CommandTokenizer;
     53import org.greenstone.gatherer.cdm.BuildTypeManager;
     54import org.greenstone.gatherer.cdm.CollectionConfiguration;
    5355import org.greenstone.gatherer.greenstone.Classifiers;
    5456import org.greenstone.gatherer.greenstone.LocalGreenstone;
     
    153155     * @see org.greenstone.gatherer.util.Utility
    154156     */
    155     public void buildCollection(boolean incremental_build)
    156     {
    157          
    158     DebugStream.println("In CollectionManager.buildCollection(), incremental_build: " + incremental_build);
     157    public void buildCollection()
     158    {
     159   
     160    DebugStream.println("In CollectionManager.buildCollection(), CollectionDesignManager.isCompleteBuild(): " + CollectionDesignManager.isCompleteBuild());
    159161    DebugStream.println("Is event dispatch thread: " + SwingUtilities.isEventDispatchThread());
    160162    building = true;
     
    187189    }
    188190    else {
    189         command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl");
     191        String buildType = (new CollectionMeta( CollectionDesignManager.collect_config.getBuildType() )).getValue(CollectionMeta.TEXT);
     192        if ( !CollectionDesignManager.isCompleteBuild() && buildType.equals( BuildTypeManager.BUILD_TYPE_LUCENE ) ) {
     193            command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "incremental-buildcol.pl");
     194        } else {
     195            command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "full-buildcol.pl");
     196        }
    190197    }
    191198    command_parts_list.add("-gli");
     
    194201    command_parts_list.add("-collectdir");
    195202    command_parts_list.add(getCollectDirectory());
    196 
    197     // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build
    198     if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {
    199         command_parts_list.add(incremental_build ? "-keepold" : "-removeold");
    200     }
    201203
    202204    String[] build_options = collection.build_options.getValues();
     
    217219
    218220    /*probably repeating alot of work, but I want to keep this separate... wendy*/
    219     public void scheduleBuild(boolean incremental_build)
    220     {
    221 
    222     DebugStream.println("In CollectionManager.scheduleBuild(), incremental_build: " + incremental_build);
     221    public void scheduleBuild()
     222    {
     223    DebugStream.println("In CollectionManager.scheduleBuild(), CollectionDesignManager.isCompleteBuild(): " + CollectionDesignManager.isCompleteBuild());
    223224    DebugStream.println("Is event dispatch threa: " + SwingUtilities.isEventDispatchThread());
    224225
     
    240241        import_list.add("-S");
    241242    }
    242         import_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl");
     243
     244    String cmdPrefix = CollectionDesignManager.isCompleteBuild() ? "full-" : "incremental-";
     245    import_list.add(LocalGreenstone.getBinScriptDirectoryPath() + cmdPrefix + "import.pl");
    243246    import_list.add("-language");
    244247    import_list.add(Configuration.getLanguage());
     
    273276        build_list.add("-S");
    274277    }
    275     build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl");
     278
     279    String buildType = (new CollectionMeta( CollectionDesignManager.collect_config.getBuildType() )).getValue(CollectionMeta.TEXT);
     280    if ( !CollectionDesignManager.isCompleteBuild() && buildType.equals( BuildTypeManager.BUILD_TYPE_LUCENE ) ) {
     281        build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "incremental-buildcol.pl");
     282    } else {
     283        build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "full-buildcol.pl");
     284    }
     285
    276286    build_list.add("-language");
    277287    build_list.add(Configuration.getLanguage());
    278288    build_list.add("-collectdir");
    279289    build_list.add(getCollectDirectory());
    280 
    281     // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build
    282     if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {
    283         build_list.add(incremental_build ? "-keepold" : "-removeold");
    284     }
    285290
    286291    String[] build_options = collection.build_options.getValues();
     
    345350    }
    346351
     352    /** Used to determine whether the currently active collection has been imported.
     353     * @return A boolean indicating the imported status of the collection.
     354     */
     355    public boolean imported() {
     356        if ( collection != null ) {
     357            String file_name = getLoadedCollectionDirectoryPath() + "archives";
     358            File test_file = new File(file_name);
     359            return test_file.exists();
     360        }
     361        return false;
     362    }
    347363
    348364    /** a test method to see if we can delete a directory/file - returns false is the file or any of the contents of a directory cannot be deleted */
     
    549565        collection = new Collection(new File(collection_directory_path, name + ".col"));
    550566
    551         // "-removeold" is on by default for import.pl
    552         collection.import_options.setValue("removeold", true, null);
     567        // "-removeold" is on by default for import.pl (not anymore; it would wreck incremental import)
     568        //collection.import_options.setValue("removeold", true, null);
    553569
    554570        // for remote case, scheduling causes an Exception on creating a new collection that
     
    10311047    }
    10321048    else {
    1033         command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl");
     1049        String cmdPrefix = CollectionDesignManager.isCompleteBuild() ? "full-" : "incremental-";
     1050        command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + cmdPrefix + "import.pl");
    10341051    }
    10351052
     
    10421059    String[] import_options = collection.import_options.getValues();
    10431060    for (int i = 0; i < import_options.length; i++) {
     1061        System.err.println( "Tacking on option: " + import_options[i] );
    10441062        command_parts_list.add(import_options[i]);
    10451063    }
     
    10501068    String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
    10511069    GShell shell = new GShell(command_parts, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT);
     1070    //shell.setEventProperty("is_incremental", Boolean.toString(is_incremental));
    10521071    shell.addGShellListener(Gatherer.g_man.create_pane);
    10531072        shell.addGShellListener(Gatherer.g_man.format_pane);
     
    14971516    //ystem.err.println("CollectionManager.processComplete(" + event.getType() + ")");
    14981517    Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false);
    1499     ///ystem.err.println("Recieved process complete event - " + event);
     1518    ///ystem.err.println("Received process complete event - " + event);
    15001519    // If we were running an import, now run a build.
    15011520    if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) {
     
    15041523        collection.setFilesChanged(false);
    15051524        collection.setMetadataChanged(false);
    1506         buildCollection(false);
     1525        buildCollection();
    15071526    }
    15081527    else if(event.getType() == GShell.SCHEDULE && event.getStatus() == GShell.OK ) {
     
    15171536    else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) {
    15181537           
    1519         if(installCollection()) {
    1520         // If we have a local library running then ask it to add our newly create collection
    1521         if (LocalLibraryServer.isRunning() == true) {
    1522             LocalLibraryServer.addCollection(collection.getName());
    1523         }
    1524         else if (Gatherer.GS3) {
    1525             //xiao comment out this: convertToGS3Collection();
    1526             Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + collection.getName());
    1527         } 
    1528 
    1529         // Fire a collection changed first to update the preview etc buttons
    1530         Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
    1531 
    1532         // Now display a message dialog saying its all built
    1533         WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", Dictionary.get("CollectionBuilt.Title"), Dictionary.get("CollectionBuilt.Message"), null, false);
    1534         collection_built_warning_dialog.setMessageOnly(true); // Not a warning
    1535         collection_built_warning_dialog.display();
    1536         collection_built_warning_dialog.dispose();
    1537         collection_built_warning_dialog = null;
    1538 
    1539         //Set nothing as needing rebuilding, as a build has just finished :-)
    1540         CollectionDesignManager.resetRebuildTypeRequired();
    1541         }
    1542         else {
    1543         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    1544         Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
    1545         DebugStream.println("Status is ok but !installCollection()");
    1546         }
     1538        if ( CollectionDesignManager.isCompleteBuild() ) {
     1539            if(installCollection()) {
     1540            // If we have a local library running then ask it to add our newly create collection
     1541            if (LocalLibraryServer.isRunning() == true) {
     1542                LocalLibraryServer.addCollection(collection.getName());
     1543            }
     1544            else if (Gatherer.GS3) {
     1545                //xiao comment out this: convertToGS3Collection();
     1546                Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + collection.getName());
     1547            } 
     1548
     1549            // Fire a collection changed first to update the preview etc buttons
     1550            Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
     1551
     1552            // Now display a message dialog saying its all built
     1553            WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", Dictionary.get("CollectionBuilt.Title"), Dictionary.get("CollectionBuilt.Message"), null, false);
     1554            collection_built_warning_dialog.setMessageOnly(true); // Not a warning
     1555            collection_built_warning_dialog.display();
     1556            collection_built_warning_dialog.dispose();
     1557            collection_built_warning_dialog = null;
     1558
     1559            //Set nothing as needing rebuilding, as a build has just finished :-)
     1560            CollectionDesignManager.resetRebuildTypeRequired();
     1561            }
     1562            else {
     1563            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
     1564            Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
     1565            DebugStream.println("Status is ok but !installCollection()");
     1566            }
     1567        }
    15471568    }
    15481569    else if (event.getStatus() == GShell.CANCELLED) {
  • gli/branches/incremental/src/org/greenstone/gatherer/gui/CreatePane.java

    r18589 r19401  
    206206    Gatherer.c_man.registerScheduleMonitor(schedule_monitor);
    207207
    208     // And the simple panel
    209     slower_panel = new JPanel();
    210     sbutton_panel = new JPanel();
    211     sinner_panel = new JPanel();
    212        
    213         slower_panel.setComponentOrientation(Dictionary.getOrientation());
    214         sbutton_panel.setComponentOrientation(Dictionary.getOrientation());
    215         sinner_panel.setComponentOrientation(Dictionary.getOrientation());
    216        
    217     //Radio buttons
    218     incremental_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Minimal_Build"));
    219         incremental_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
    220     incremental_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Minimal_Build_Tooltip"));
    221     full_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Full_Build"));
    222         full_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
    223     full_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Full_Build_Tooltip"));
    224     sincremental_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Minimal_Build"));
    225         sincremental_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
    226     sincremental_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Minimal_Build_Tooltip"));
    227     sfull_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Full_Build"));
    228         sfull_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
    229     sfull_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Full_Build_Tooltip"));
    230 
     208    // And the simple panel
     209    slower_panel = new JPanel();
     210    sbutton_panel = new JPanel();
     211    sinner_panel = new JPanel();
     212   
     213    slower_panel.setComponentOrientation(Dictionary.getOrientation());
     214    sbutton_panel.setComponentOrientation(Dictionary.getOrientation());
     215    sinner_panel.setComponentOrientation(Dictionary.getOrientation());
     216   
     217    //Radio buttons
     218    incremental_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Minimal_Build"));
     219    incremental_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
     220    incremental_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Minimal_Build_Tooltip"));
     221    full_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Full_Build"));
     222    full_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
     223    full_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Full_Build_Tooltip"));
     224    sincremental_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Minimal_Build"));
     225    sincremental_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
     226    sincremental_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Minimal_Build_Tooltip"));
     227    sfull_build_radio_button = new JRadioButton(Dictionary.get("CreatePane.Full_Build"));
     228    sfull_build_radio_button.setComponentOrientation(Dictionary.getOrientation());
     229    sfull_build_radio_button.setToolTipText(Dictionary.get("CreatePane.Full_Build_Tooltip"));
     230
     231    //keep them in sync
     232    full_build_radio_button.addActionListener(
     233        new ActionListener() { public void actionPerformed(ActionEvent e) {
     234            sfull_build_radio_button.setSelected( full_build_radio_button.isSelected() );
     235        }});
     236    sfull_build_radio_button.addActionListener(
     237        new ActionListener() { public void actionPerformed(ActionEvent e) {
     238            full_build_radio_button.setSelected( sfull_build_radio_button.isSelected() );
     239        }});
     240    incremental_build_radio_button.addActionListener(
     241        new ActionListener() { public void actionPerformed(ActionEvent e) {
     242            sincremental_build_radio_button.setSelected( incremental_build_radio_button.isSelected() );
     243        }});
     244    sincremental_build_radio_button.addActionListener(
     245        new ActionListener() { public void actionPerformed(ActionEvent e) {
     246            incremental_build_radio_button.setSelected( sincremental_build_radio_button.isSelected() );
     247        }});
    231248
    232249    // Buttons
     
    286303    public void display() {
    287304
    288     int current_mode = Configuration.getMode();
    289 
    290     //Complete/incremental build options panel
    291     //For some reason I need to create seperate objects for each mode. Is there a better way??
    292     ButtonGroup build_type_group = new ButtonGroup();
    293     build_type_group.add(incremental_build_radio_button);
    294     full_build_radio_button.setSelected(true);
    295     build_type_group.add(full_build_radio_button);
    296     ButtonGroup sbuild_type_group = new ButtonGroup();
    297     sbuild_type_group.add(sincremental_build_radio_button);
    298     sfull_build_radio_button.setSelected(true);
    299     sbuild_type_group.add(sfull_build_radio_button);
    300     JPanel build_type_pane = new JPanel(new GridLayout(2,1));
     305        int current_mode = Configuration.getMode();
     306
     307        //Complete/incremental build options panel
     308        ButtonGroup build_type_group = new ButtonGroup();
     309        build_type_group.add(incremental_build_radio_button);
     310        build_type_group.add(full_build_radio_button);
     311        full_build_radio_button.setSelected(true);
     312
     313        ButtonGroup sbuild_type_group = new ButtonGroup();
     314        sbuild_type_group.add(sincremental_build_radio_button);
     315        sbuild_type_group.add(sfull_build_radio_button);
     316        sfull_build_radio_button.setSelected(true);
     317
     318        JPanel build_type_pane = new JPanel(new GridLayout(2,1));
    301319        build_type_pane.setComponentOrientation(Dictionary.getOrientation());
    302     build_type_pane.add(full_build_radio_button);
    303     build_type_pane.add(incremental_build_radio_button);
    304     JPanel sbuild_type_pane = new JPanel(new GridLayout(2,1));
     320        build_type_pane.add(full_build_radio_button);
     321        build_type_pane.add(incremental_build_radio_button);
     322
     323        JPanel sbuild_type_pane = new JPanel(new GridLayout(2,1));
    305324        sbuild_type_pane.setComponentOrientation(Dictionary.getOrientation());
    306     sbuild_type_pane.add(sfull_build_radio_button);
    307     sbuild_type_pane.add(sincremental_build_radio_button);
    308    
    309    
    310 
    311     // Build control_pane
    312     JPanel left = new JPanel();
    313         left.setComponentOrientation(Dictionary.getOrientation());
    314     left.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
    315     left.setLayout(new BorderLayout());
    316     left.add(tree, BorderLayout.CENTER);
    317     left.add(build_type_pane, BorderLayout.SOUTH);
    318     //left.add(full_build_radio_button, BorderLayout.SOUTH);
    319 
    320     right = new JPanel();
    321         right.setComponentOrientation(Dictionary.getOrientation());
    322     right.setBorder(BorderFactory.createEmptyBorder(0,0,5,5));
    323     right.setLayout(new BorderLayout());
    324 
    325     JPanel options_area = new JPanel();
    326         options_area.setComponentOrientation(Dictionary.getOrientation());
    327     options_area.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5,5,5,5), BorderFactory.createTitledBorder(Dictionary.get("CreatePane.Options_Title"))));
    328     options_area.setLayout(new BorderLayout());
    329     options_area.add(left, BorderLayout.LINE_START);
    330     options_area.add(right, BorderLayout.CENTER);
    331 
    332     button_pane = new JPanel();
    333         button_pane.setComponentOrientation(Dictionary.getOrientation());
    334     button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
    335     button_pane.setLayout(new GridLayout(1,4));
    336     button_pane.add(build_button);
    337     button_pane.add(cancel_button);
    338     button_pane.add(preview_button);
    339 
    340     control_pane.setLayout(new BorderLayout());
    341     control_pane.add(options_area, BorderLayout.CENTER);
    342     control_pane.add(button_pane, BorderLayout.SOUTH);
    343 
    344     // Build progress_pane
    345     JPanel labels_pane = new JPanel();
    346         labels_pane.setComponentOrientation(Dictionary.getOrientation());
    347     labels_pane.setLayout(new GridLayout(2,1,0,5));
    348     labels_pane.add(progress_import_label);
    349     labels_pane.add(progress_build_label);
    350 
    351     JPanel monitors_pane = new JPanel();
    352         monitors_pane.setComponentOrientation(Dictionary.getOrientation());
    353     monitors_pane.setLayout(new GridLayout(2,1,0,5));
    354     monitors_pane.add(import_monitor.getProgress());
    355     monitors_pane.add(build_monitor.getProgress());
    356 
    357     bar_area.setBorder(BorderFactory.createEmptyBorder(10,10,5,10));
    358     bar_area.setLayout(new BorderLayout(5,5));
    359     bar_area.add(labels_pane, BorderLayout.LINE_START);
    360     bar_area.add(monitors_pane, BorderLayout.CENTER);
    361 
    362     progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    363     progress_pane.setLayout(new BorderLayout());
    364     progress_pane.add(bar_area, BorderLayout.NORTH);
    365     if(current_mode >= THRESHOLD) {
    366         progress_pane.add(log_scroll, BorderLayout.CENTER);
    367     }
    368 
    369     // Simple panel
    370     sbutton_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
    371     sbutton_panel.setLayout(new GridLayout(1,3));
    372     sbutton_panel.add(simple_build_button);
    373     sbutton_panel.add(simple_cancel_button);
    374     sbutton_panel.add(simple_preview_button);
    375 
    376     JPanel simple_bar_area = new JPanel(new GridLayout(2,1));
    377         simple_bar_area.setComponentOrientation(Dictionary.getOrientation());
    378     simple_bar_area.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
    379     simple_bar_area.add(import_monitor.getSharedProgress());
    380     simple_bar_area.add(sbutton_panel);
    381 
    382     sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    383     sinner_panel.setLayout(new BorderLayout());
    384     sinner_panel.add(sbuild_type_pane, BorderLayout.LINE_START);
    385     //sinner_panel.add(full_build_radio_button, BorderLayout.WEST);
    386     sinner_panel.add(simple_bar_area, BorderLayout.CENTER);
    387    
    388     if(options_pane != null) {
    389         sargument_configuration_panel = options_pane.buildImport(null);
    390         sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
    391         // if(CollectionManager.canDoScheduling()) {
    392         //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);
    393         // }
    394     }
    395     else {
    396         sargument_configuration_panel = new JPanel();
    397     }
    398         sargument_configuration_panel.setComponentOrientation(Dictionary.getOrientation());
    399     sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
    400     sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
    401         sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation());
    402        
    403     slower_panel.setLayout(new BorderLayout());
    404     slower_panel.add(sinner_panel, BorderLayout.NORTH);
    405     if(current_mode < THRESHOLD) {
    406         slower_panel.add(log_scroll, BorderLayout.CENTER);
    407     }
    408    
    409     simple_panel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sargument_configuration_scroll, slower_panel);
    410         simple_panel.setComponentOrientation(Dictionary.getOrientation());
    411     // Main pane
    412     main_pane = new JPanel(card_layout);
    413         main_pane.setComponentOrientation(Dictionary.getOrientation());
    414     if(current_mode < THRESHOLD) { // Simple mode - add first
    415         main_pane.add(simple_panel, SIMPLE);
    416     }
    417     main_pane.add(control_pane, CONTROL);
    418     main_pane.add(progress_pane, PROGRESS);
    419     if(current_mode >= THRESHOLD) { // Expert mode - add last
    420         main_pane.add(simple_panel, SIMPLE);
    421     }
    422 
    423     this.setLayout(new BorderLayout());
    424     this.add(main_pane, BorderLayout.CENTER);
     325        sbuild_type_pane.add(sfull_build_radio_button);
     326        sbuild_type_pane.add(sincremental_build_radio_button);
     327
     328
     329        // Build control_pane
     330        JPanel left = new JPanel();
     331            left.setComponentOrientation(Dictionary.getOrientation());
     332        left.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
     333        left.setLayout(new BorderLayout());
     334        left.add(tree, BorderLayout.CENTER);
     335        left.add(build_type_pane, BorderLayout.SOUTH);
     336        //left.add(full_build_radio_button, BorderLayout.SOUTH);
     337
     338        right = new JPanel();
     339            right.setComponentOrientation(Dictionary.getOrientation());
     340        right.setBorder(BorderFactory.createEmptyBorder(0,0,5,5));
     341        right.setLayout(new BorderLayout());
     342
     343        JPanel options_area = new JPanel();
     344            options_area.setComponentOrientation(Dictionary.getOrientation());
     345        options_area.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5,5,5,5), BorderFactory.createTitledBorder(Dictionary.get("CreatePane.Options_Title"))));
     346        options_area.setLayout(new BorderLayout());
     347        options_area.add(left, BorderLayout.LINE_START);
     348        options_area.add(right, BorderLayout.CENTER);
     349
     350        button_pane = new JPanel();
     351            button_pane.setComponentOrientation(Dictionary.getOrientation());
     352        button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
     353        button_pane.setLayout(new GridLayout(1,4));
     354        button_pane.add(build_button);
     355        button_pane.add(cancel_button);
     356        button_pane.add(preview_button);
     357
     358        control_pane.setLayout(new BorderLayout());
     359        control_pane.add(options_area, BorderLayout.CENTER);
     360        control_pane.add(button_pane, BorderLayout.SOUTH);
     361
     362        // Build progress_pane
     363        JPanel labels_pane = new JPanel();
     364            labels_pane.setComponentOrientation(Dictionary.getOrientation());
     365        labels_pane.setLayout(new GridLayout(2,1,0,5));
     366        labels_pane.add(progress_import_label);
     367        labels_pane.add(progress_build_label);
     368
     369        JPanel monitors_pane = new JPanel();
     370            monitors_pane.setComponentOrientation(Dictionary.getOrientation());
     371        monitors_pane.setLayout(new GridLayout(2,1,0,5));
     372        monitors_pane.add(import_monitor.getProgress());
     373        monitors_pane.add(build_monitor.getProgress());
     374
     375        bar_area.setBorder(BorderFactory.createEmptyBorder(10,10,5,10));
     376        bar_area.setLayout(new BorderLayout(5,5));
     377        bar_area.add(labels_pane, BorderLayout.LINE_START);
     378        bar_area.add(monitors_pane, BorderLayout.CENTER);
     379
     380        progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
     381        progress_pane.setLayout(new BorderLayout());
     382        progress_pane.add(bar_area, BorderLayout.NORTH);
     383        if(current_mode >= THRESHOLD) {
     384            progress_pane.add(log_scroll, BorderLayout.CENTER);
     385        }
     386
     387        // Simple panel
     388        sbutton_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
     389        sbutton_panel.setLayout(new GridLayout(1,3));
     390        sbutton_panel.add(simple_build_button);
     391        sbutton_panel.add(simple_cancel_button);
     392        sbutton_panel.add(simple_preview_button);
     393
     394        JPanel simple_bar_area = new JPanel(new GridLayout(2,1));
     395            simple_bar_area.setComponentOrientation(Dictionary.getOrientation());
     396        simple_bar_area.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
     397        simple_bar_area.add(import_monitor.getSharedProgress());
     398        simple_bar_area.add(sbutton_panel);
     399
     400        sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
     401        sinner_panel.setLayout(new BorderLayout());
     402        sinner_panel.add(sbuild_type_pane, BorderLayout.LINE_START);
     403        //sinner_panel.add(full_build_radio_button, BorderLayout.WEST);
     404        sinner_panel.add(simple_bar_area, BorderLayout.CENTER);
     405
     406        if(options_pane != null) {
     407            sargument_configuration_panel = options_pane.buildImport(null);
     408            sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     409            // if(CollectionManager.canDoScheduling()) {
     410            //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);
     411            // }
     412        }
     413        else {
     414            sargument_configuration_panel = new JPanel();
     415        }
     416            sargument_configuration_panel.setComponentOrientation(Dictionary.getOrientation());
     417        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     418        sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     419            sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation());
     420           
     421        slower_panel.setLayout(new BorderLayout());
     422        slower_panel.add(sinner_panel, BorderLayout.NORTH);
     423        if(current_mode < THRESHOLD) {
     424            slower_panel.add(log_scroll, BorderLayout.CENTER);
     425        }
     426
     427        simple_panel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sargument_configuration_scroll, slower_panel);
     428            simple_panel.setComponentOrientation(Dictionary.getOrientation());
     429        // Main pane
     430        main_pane = new JPanel(card_layout);
     431            main_pane.setComponentOrientation(Dictionary.getOrientation());
     432        if(current_mode < THRESHOLD) { // Simple mode - add first
     433            main_pane.add(simple_panel, SIMPLE);
     434        }
     435        main_pane.add(control_pane, CONTROL);
     436        main_pane.add(progress_pane, PROGRESS);
     437        if(current_mode >= THRESHOLD) { // Expert mode - add last
     438            main_pane.add(simple_panel, SIMPLE);
     439        }
     440
     441        this.setLayout(new BorderLayout());
     442        this.add(main_pane, BorderLayout.CENTER);
    425443    }
    426444
     
    449467    tree.setSelectionPath(path);
    450468
    451     //Disable the full/incremental buttons if the collection has not been built.
    452     if(Gatherer.c_man.built()) {
    453         full_build_radio_button.setEnabled(true);
    454         incremental_build_radio_button.setEnabled(true);
    455         sfull_build_radio_button.setEnabled(true);
    456         sincremental_build_radio_button.setEnabled(true);
    457     }
    458     else {
    459         full_build_radio_button.setEnabled(false);
    460         incremental_build_radio_button.setEnabled(false);
    461         sfull_build_radio_button.setEnabled(false);
    462         sincremental_build_radio_button.setEnabled(false);
    463     }
    464469    }
    465470
     
    467472    public void loseFocus() {
    468473    tree.valueChanged(null);
    469     }
    470 
    471     /**
    472      * Check to see if doing an incremental build is chosen.
    473      * If not, the full rebuild option must be chosen.
    474      * @return boolean - true if the collection should be rebuilt incrementally.
    475      */
    476     public boolean isIncremental() {
    477     boolean incremental = false;
    478 
    479     //This is horrible. What if the mode is changed, and different options are chosen on different modes??
    480     if(Gatherer.c_man.built()) {
    481         if(Configuration.getMode() >= THRESHOLD) {
    482         incremental = incremental_build_radio_button.isSelected();
    483         }
    484         else {
    485         incremental = sincremental_build_radio_button.isSelected();
    486         }
    487     }
    488     else {
    489         incremental = false; //The collection has not yet been built
    490     }
    491     return incremental;
    492474    }
    493475
     
    695677     * @see org.greenstone.gatherer.shell.GShellProgressMonitor
    696678     */
    697     public void actionPerformed(ActionEvent event) {
    698         Collection collection = Gatherer.c_man.getCollection();
    699         String collection_name = collection.getName();
    700 
    701         //if button is labelled for Building
    702         if(event.getActionCommand().equals(Dictionary.get("CreatePane.Build_Collection"))) {
    703 
    704         if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) {
    705             //Only design options have changes, and we want to be smart in the way we handle them.
    706             int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired();
    707             if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) {
    708             // Just run the buildcol command.
    709             DebugStream.println("Just want to run buildcol.pl");
    710             prepareForBuild();
    711             Gatherer.c_man.buildCollection(isIncremental());
    712             }
    713             else if (rebuildTypeRequired == CollectionDesignManager.ALL) {
    714             // Do both import and buildcol
    715             DebugStream.println("Want to do a complete build");
    716             prepareForBuild();
    717             Gatherer.c_man.importCollection(); //This starts the building process.
    718             }
    719             else {
    720             //Nothing at all needs doing.
    721             //This is bad HCI. Maybe should disable the build button in this situation?
    722             JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required"));
    723             }
    724         }
    725         else {
    726             //Do a complete build.
    727             prepareForBuild();
    728             Gatherer.c_man.importCollection(); //This starts the building process.
    729         }
    730 
    731         } else {   //button is labelled for setting up scheduling
    732 
    733         //this needs to be called to configure buttons... but no building is done
    734         prepareForBuild();
    735    
    736         Gatherer.c_man.scheduleBuild(isIncremental());
    737         }
    738        
    739         //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent)
    740     }
     679    public void actionPerformed(ActionEvent event) {
     680        Collection collection = Gatherer.c_man.getCollection();
     681        String collection_name = collection.getName();
     682
     683        //if button is labelled for Building
     684        if(event.getActionCommand().equals(Dictionary.get("CreatePane.Build_Collection"))) {
     685
     686            //set a static variable marking whether this is a "Complete" or "Minimal" build
     687            CollectionDesignManager.setCompleteBuild( full_build_radio_button.isSelected() );
     688
     689            //do the import and build, skipping import if possible
     690            if( !CollectionDesignManager.isCompleteBuild() &&
     691                !collection.getMetadataChanged() && !collection.getFilesChanged() && Gatherer.c_man.imported() &&
     692                CollectionDesignManager.getRebuildTypeRequired() <= CollectionDesignManager.BUILDCOL
     693                ) {
     694                    // Just do build (no import)
     695                    DebugStream.println("Just want to run buildcol.pl");
     696                    prepareForBuild();
     697                    Gatherer.c_man.buildCollection();
     698            }
     699            else {
     700                prepareForBuild();
     701                Gatherer.c_man.importCollection(); //This starts the building process.
     702            }
     703
     704        } else { //button is labelled for setting up scheduling
     705
     706            //this needs to be called to configure buttons... but no building is done
     707            prepareForBuild();
     708            Gatherer.c_man.scheduleBuild();
     709        }
     710        //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent)
     711    }
     712
    741713       
    742714    /**
     
    795767        String collection_name = collection.getName();
    796768
     769        //set a static variable marking whether this is a "Complete" or "Minimal" build
     770        CollectionDesignManager.setCompleteBuild( full_build_radio_button.isSelected() );
     771
    797772        //prepareForBuild();
    798         if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) {
     773        if(!collection.getMetadataChanged() && !collection.getFilesChanged()) {
    799774            //Only design options have changes, and we want to be smart in the way we handle them.
    800775            int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired();
     
    803778            DebugStream.println("Just want to run buildcol.pl");
    804779            prepareForBuild();
    805             Gatherer.c_man.buildCollection(isIncremental());
     780            Gatherer.c_man.buildCollection();
    806781            }
    807782            else if (rebuildTypeRequired == CollectionDesignManager.ALL) {
Note: See TracChangeset for help on using the changeset viewer.