Changeset 18364

Show
Ignore:
Timestamp:
12.01.2009 11:40:15 (10 years ago)
Author:
kjdon
Message:

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318, and fixed some conflicts. I think this is the last commit following merging the files. Haven't tried to compile yet... here goes...

Location:
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui
Files:
20 modified
2 copied

Legend:

Unmodified
Added
Removed
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/AboutDialog.java

    r18297 r18364  
    3434import java.awt.event.*; 
    3535import javax.swing.*; 
     36 
     37import org.greenstone.gatherer.Configuration; 
    3638import org.greenstone.gatherer.Dictionary; 
    3739import org.greenstone.gatherer.Gatherer; 
     
    7375        upper_pane.setComponentOrientation(Dictionary.getOrientation()); 
    7476         
    75     ImageIcon icon = JarTools.getImage("gatherer_medium.gif"); 
     77    String gmedium_image = "gatherer_medium.gif"; 
     78    if (Configuration.fedora_info.isActive()) { 
     79        gmedium_image = "fli-" + gmedium_image; 
     80    } 
     81 
     82    ImageIcon icon = JarTools.getImage(gmedium_image); 
    7683    ImageIcon scaled_icon = new ImageIcon(icon.getImage().getScaledInstance(ICON_SIZE, ICON_SIZE, Image.SCALE_DEFAULT)); 
    7784    JLabel icon_label = new JLabel(scaled_icon); 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r18297 r18364  
    5353import org.greenstone.gatherer.shell.GBuildProgressMonitor; 
    5454import org.greenstone.gatherer.shell.GImportProgressMonitor; 
     55import org.greenstone.gatherer.shell.GScheduleProgressMonitor;  
    5556import org.greenstone.gatherer.shell.GShell; 
    5657import org.greenstone.gatherer.shell.GShellEvent; 
     
    6162import org.greenstone.gatherer.util.Utility; 
    6263 
     64import org.greenstone.gatherer.collection.CollectionManager; 
    6365 
    6466/** This class provides a GUI view showing some statistics on your current collection, and options for building it. As the collection is built this initial view is replaced with one showing progress bars and a message log of the creation process. This log can be later accessed via the options tree located in the center of the initial pane. This class is also responsible for creating the GShellProgressMonitors that are then attatched to external shell processes, and calling the methods in the CollectionManager for actually importing and building the collection. <br><BR> 
     
    9395    /** This monitor tracks the import processes progress. */ 
    9496    private GShellProgressMonitor import_monitor = null; 
     97    /** This monitor tracks the schedule processes progress. */  
     98    private GShellProgressMonitor schedule_monitor = null;  
    9599    /** The button for begining the building processes. */ 
    96100    private JButton build_button = null; 
    97101    /** The button for stopping the building processes. */ 
    98102    private JButton cancel_button = null; 
     103    /** The button for setting up scheduling */ 
     104    private JButton schedule_button = null;  
    99105    /** The button for viewing the collection. */ 
    100106    private JButton preview_button = null; 
     
    149155    public String homepage = null; 
    150156 
    151  
    152157    /** The constructor creates important helper classes, and initializes all the components. 
    153158     * @see org.greenstone.gatherer.collection.CollectionManager 
     
    194199    Gatherer.c_man.registerBuildMonitor(build_monitor); 
    195200 
     201    //We only need a schedule monitor for text output. No use for a progress bar! 
     202     
     203    //progress_schedule_label = new JLabel(Dictionary.get("CreatePane.Schedule_Progress"));  
     204     
     205    schedule_monitor = new GScheduleProgressMonitor();  
     206    Gatherer.c_man.registerScheduleMonitor(schedule_monitor);  
     207 
    196208    // And the simple panel 
    197209    slower_panel = new JPanel(); 
     
    238250    } 
    239251     
     252    BuildSimpleButtonListener bsbl = new BuildSimpleButtonListener();  
    240253    simple_build_button = new GLIButton(Dictionary.get("CreatePane.Build_Collection"), Dictionary.get("CreatePane.Build_Collection_Tooltip")); 
    241     simple_build_button.addActionListener(bbl); 
    242      
     254    simple_build_button.addActionListener(bsbl); 
     255 
    243256    simple_cancel_button = new GLIButton(Dictionary.get("CreatePane.Cancel_Build"), Dictionary.get("CreatePane.Cancel_Build_Tooltip")); 
    244257    simple_cancel_button.addActionListener(cbl); 
     
    255268     
    256269    bbl = null; 
     270    bsbl = null;  
    257271    cbl = null; 
    258272    //pbl = null; 
     
    375389        sargument_configuration_panel = options_pane.buildImport(null); 
    376390        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 
     391        // if(CollectionManager.canDoScheduling()) { 
     392        //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);  
     393        // } 
    377394    } 
    378395    else { 
     
    498515        sargument_configuration_panel = options_pane.buildImport(null); 
    499516        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 
     517        //  if(CollectionManager.canDoScheduling()) { 
     518        //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 
     519        //} 
    500520        } 
    501521        else { 
     
    545565    DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")..."); 
    546566    if(event.getStatus() == GShell.OK) { 
    547         if(event.getType() == GShell.BUILD) { 
     567        if(event.getType() == GShell.SCHEDULE) { 
     568         
     569        processing = false;  
     570        build_button.setEnabled(true); 
     571        cancel_button.setEnabled(false); 
     572        //preview_button.setEnabled(true); 
     573        //only enable preview if the collection has been built.  
     574        preview_button.setEnabled(Gatherer.c_man.built()); 
     575        simple_build_button.setEnabled(true); 
     576        simple_cancel_button.setEnabled(false); 
     577        simple_preview_button.setEnabled(Gatherer.c_man.built());  
     578        int status = event.getStatus(); 
     579        document.setSpecialCharacter(OptionsPane.SCHEDULED);  
     580        options_pane.resetFileEntry(); 
     581        build_monitor.reset(); 
     582        import_monitor.reset(); 
     583        if(Configuration.getMode() >= THRESHOLD) { 
     584            control_pane.add(button_pane, BorderLayout.SOUTH);  
     585            card_layout.show(main_pane, CONTROL);  
     586        } 
     587        } 
     588        else if(event.getType() == GShell.BUILD) { 
    548589        processing = false; 
    549590        build_button.setEnabled(true); 
    550591        cancel_button.setEnabled(false); 
    551         //preview_button.setEnabled(true); 
     592        preview_button.setEnabled(true); 
    552593        simple_build_button.setEnabled(true); 
    553594        simple_cancel_button.setEnabled(false); 
     
    570611        build_button.setEnabled(true); 
    571612        // The build may have failed, but a previous index may still be in place 
    572         //preview_button.setEnabled(Gatherer.c_man.built()); 
     613        preview_button.setEnabled(Gatherer.c_man.built()); 
    573614 
    574615        simple_build_button.setEnabled(true); 
    575616        simple_cancel_button.setEnabled(false); 
    576         //simple_preview_button.setEnabled(Gatherer.c_man.built()); 
     617        simple_preview_button.setEnabled(Gatherer.c_man.built()); 
    577618        if(event.getStatus() == GShell.CANCELLED) { 
    578619        document.setSpecialCharacter(OptionsPane.CANCELLED); 
     
    604645    Collection current_collection = Gatherer.c_man.getCollection(); 
    605646    if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) { 
    606         this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options); 
     647        this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options, current_collection.schedule_options); 
    607648        if (previous_collection != null) { 
    608649        // clear the log 
     
    620661        sargument_configuration_panel = options_pane.buildImport(null); 
    621662        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 
     663        //if(CollectionManager.canDoScheduling()) { 
     664        //sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);  
     665        //} 
    622666        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel); 
    623667            sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation()); 
     
    654698        Collection collection = Gatherer.c_man.getCollection(); 
    655699        String collection_name = collection.getName(); 
    656         if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 
    657         //Only design options have changes, and we want to be smart in the way we handle them. 
    658         int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 
    659         if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 
    660             // Just run the buildcol command. 
    661             DebugStream.println("Just want to run buildcol.pl"); 
    662             prepareForBuild(); 
    663             Gatherer.c_man.buildCollection(isIncremental()); 
     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            } 
    664724        } 
    665         else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 
    666             // Do both import and buildcol 
    667             DebugStream.println("Want to do a complete build"); 
     725        else { 
     726            //Do a complete build. 
    668727            prepareForBuild(); 
    669728            Gatherer.c_man.importCollection(); //This starts the building process. 
    670         } 
    671         else { 
    672             //Nothing at all needs doing. 
    673             //This is bad HCI. Maybe should disable the build button in this situation? 
    674             JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 
    675         } 
    676         } 
    677         else { 
    678         //Do a complete build. 
    679         prepareForBuild(); 
    680         Gatherer.c_man.importCollection(); //This starts the building process. 
    681         } 
     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         
    682739        //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 
    683740    } 
    684  
     741         
    685742    /** 
    686743     * This does some stuff that is needed before a collection can be built. 
     
    721778    } 
    722779     
     780    /** I hope this works. Wendy */  
     781    private class BuildSimpleButtonListener 
     782    implements ActionListener { 
     783    /** 
     784     * This method checks to see what needs to be done for a build, and starts the process off. 
     785     * A complete build proccess is started by {@link CollectionManager.importCollection()}, which then imports and builds the collection. 
     786     * However, this doesn't always happen, as sometimes an incremental build will do :-) 
     787     * @param event An <strong>ActionEvent</strong> who, thanks to the power of object oriented programming, we don't give two hoots about. 
     788     * @see org.greenstone.gatherer.Gatherer 
     789     * @see org.greenstone.gatherer.collection.CollectionManager 
     790     * @see org.greenstone.gatherer.gui.BuildOptions 
     791     * @see org.greenstone.gatherer.shell.GShellProgressMonitor 
     792     */ 
     793    public void actionPerformed(ActionEvent event) { 
     794        Collection collection = Gatherer.c_man.getCollection(); 
     795        String collection_name = collection.getName(); 
     796 
     797        //prepareForBuild();  
     798        if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 
     799            //Only design options have changes, and we want to be smart in the way we handle them. 
     800            int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 
     801            if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 
     802            // Just run the buildcol command. 
     803            DebugStream.println("Just want to run buildcol.pl"); 
     804            prepareForBuild(); 
     805            Gatherer.c_man.buildCollection(isIncremental()); 
     806            } 
     807            else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 
     808            // Do both import and buildcol 
     809            DebugStream.println("Want to do a complete build"); 
     810            prepareForBuild(); 
     811            Gatherer.c_man.importCollection(); //This starts the building process. 
     812            } 
     813            else { 
     814            //Nothing at all needs doing. 
     815            //This is bad HCI. Maybe should disable the build button in this situation? 
     816            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 
     817            } 
     818        } 
     819        else { 
     820            //Do a complete build. 
     821            prepareForBuild(); 
     822            Gatherer.c_man.importCollection(); //This starts the building process. 
     823        } 
     824         
     825        // have commented this out for now - scheduling currently not 
     826        // available except in expert mode 
     827        //only schedule in SYSTEM mode - also done in EXPERT mode, but that is handled elsewhere 
     828        /*      if(Configuration.getMode() ==  Configuration.SYSTEMS_MODE) { 
     829           if(Gatherer.c_man.getCollection().schedule_options.getValueEnabled("schedule")) { 
     830            Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"add");  
     831            Gatherer.c_man.getCollection().schedule_options.setValue("email",false, null);  
     832            Gatherer.c_man.getCollection().schedule_options.setValue("smtp",false, null); 
     833            Gatherer.c_man.getCollection().schedule_options.setValue("toaddr",false, null);   
     834            Gatherer.c_man.getCollection().schedule_options.setValue("fromaddr",false, null);    
     835            Gatherer.c_man.getCollection().schedule_options.setValue("frequency",false, null);   
     836            Gatherer.c_man.scheduleBuild(isIncremental());  
     837        } else { 
     838            //need to turn off existing scheduling 
     839            Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"delete");  
     840            Gatherer.c_man.scheduleBuild(isIncremental());  
     841             
     842        } 
     843        } 
     844        */ 
     845        //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 
     846    } 
     847 
     848    /** 
     849     * This does some stuff that is needed before a collection can be built. 
     850     * For example, buttons are enabled/disabled, and certain flags are set. 
     851     * This is called from {@link actionPerformed(ActionEvent)} 
     852     */ 
     853    private void prepareForBuild() { 
     854        // First we force the build options to be updated if we haven't already. 
     855        tree.valueChanged(null); 
     856         
     857        // Remember that for lower thresholds the above doesn't work, so try this instead 
     858        if(Configuration.getMode() < THRESHOLD) { 
     859        options_pane.update(sargument_configuration_panel); 
     860        } 
     861         
     862        // Now go about building. 
     863        build_button.setEnabled(false); 
     864        cancel_button.setEnabled(true); 
     865        preview_button.setEnabled(false); 
     866         
     867        simple_build_button.setEnabled(false); 
     868        simple_cancel_button.setEnabled(true); 
     869        simple_preview_button.setEnabled(false); 
     870         
     871        document = options_pane.createNewLogDocument(); 
     872        log_textarea.setDocument(document); 
     873        options_pane.log_textarea.setDocument(document); 
     874        // Change the view. 
     875        processing = true; 
     876        if(Configuration.getMode() >= THRESHOLD) { 
     877        progress_pane.add(button_pane, BorderLayout.SOUTH); 
     878        card_layout.show(main_pane, PROGRESS); 
     879        } 
     880        // Reset the stop flag in all the process monitors, just incase. 
     881        ((GBuildProgressMonitor)build_monitor).reset(); 
     882        import_monitor.setStop(false); 
     883    } 
     884    } 
    723885     
     886 
    724887    /** This class serves as the listener for actions on the cancel button. */ 
    725888    private class CancelButtonListener 
     
    771934    /** The node corresponding to the importing options view. */ 
    772935    private OptionTreeNode importing = null; 
     936    /** The node corresponding to the scheduling options view. */  
     937    private OptionTreeNode scheduling = null;  
    773938    /** The node corresponding to the log view. */ 
    774939    private OptionTreeNode log       = null; 
     
    793958        importing = new OptionTreeNode(Dictionary.get("CreatePane.Import")); 
    794959        importing.setToolTipText(Dictionary.get("CreatePane.Import_Tooltip")); 
     960        scheduling = new OptionTreeNode(Dictionary.get("CreatePane.Schedule")); 
     961        scheduling.setToolTipText(Dictionary.get("CreatePane.Schedule_Tooltip"));  
     962 
    795963        log = new OptionTreeNode(Dictionary.get("CreatePane.Log")); 
    796964        log.setToolTipText(Dictionary.get("CreatePane.Log_Tooltip")); 
     
    801969        model.insertNodeInto(importing, options, 0); 
    802970        model.insertNodeInto(building, options, 1); 
    803         model.insertNodeInto(log, options, 2); 
     971        model.insertNodeInto(scheduling, options, 2);  
     972        model.insertNodeInto(log, options, 3); 
    804973        // Expand the root node 
    805974        expandPath(new TreePath(options)); 
     
    8311000        scroll_pane = null; 
    8321001        } 
     1002        if(node != null && node.equals(log)) {  
     1003        build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection"));  
     1004        build_button.setText(Dictionary.get("CreatePane.Build_Collection"));     
     1005        } 
    8331006        if(node != null && node.equals(building)) { 
     1007    build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection"));        
     1008        build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 
     1009  
     1010 
    8341011        previous_pane = options_pane.buildBuild(null); 
    8351012        scroll_pane = new JScrollPane(previous_pane); 
     
    8381015        } 
    8391016        else if(node != null && node.equals(importing)) { 
     1017        build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection"));  
     1018        build_button.setText(Dictionary.get("CreatePane.Build_Collection"));  
     1019 
    8401020        previous_pane = options_pane.buildImport(null); 
    8411021        scroll_pane = new JScrollPane(previous_pane); 
    8421022        right.add(scroll_pane, BorderLayout.CENTER); 
    8431023        //target_pane.add(previous_pane, BorderLayout.CENTER); 
     1024        } 
     1025        else if(node != null && node.equals(scheduling) && CollectionManager.canDoScheduling()) {  
     1026        build_button.setActionCommand(Dictionary.get("CreatePane.Schedule_Build"));  
     1027        build_button.setText(Dictionary.get("CreatePane.Schedule_Build")); 
     1028  
     1029        previous_pane = options_pane.buildSchedule(null);  
     1030        scroll_pane = new JScrollPane(previous_pane); 
     1031        right.add(scroll_pane, BorderLayout.CENTER); 
    8441032        } 
    8451033        else { 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DeleteCollectionPrompt.java

    r18297 r18364  
    269269        confirmation.setSelected(false); 
    270270        if(!list.isSelectionEmpty()) { 
    271         confirmation.setEnabled(true); 
    272271        collection = (BasicCollectionConfiguration) list.getSelectedValue(); 
    273         args = new String[3]; 
    274         args[0] = collection.getCreator(); 
    275         args[1] = collection.getMaintainer(); 
    276         args[2] = collection.getDescription(); 
    277         details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 
    278         details.setCaretPosition(0); 
     272 
     273        String currentColName = (Gatherer.c_man.getCollection() == null) ? "" : Gatherer.c_man.getCollection().getName(); 
     274        if(!collection.getShortName().equals(currentColName)) {  
     275            // the selected collection can only be deleted if it is NOT the collection that is currently open 
     276            confirmation.setEnabled(true); 
     277            confirmation.setToolTipText(null); // no tooltip 
     278            ok_button.setToolTipText(null); 
     279 
     280            args = new String[3]; 
     281            args[0] = collection.getCreator(); 
     282            args[1] = collection.getMaintainer(); 
     283            args[2] = collection.getDescription(); 
     284            details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 
     285            details.setCaretPosition(0); 
     286        } else { // trying to delete the collection that is open at present 
     287            // add a tooltip saying to the confirmation checkbox saying that the current collection can't be deleted  
     288            String tooltip = Dictionary.get("DeleteCollectionPrompt.Cannot_Delete_Open_Collection_Tooltip",  
     289                            collection.getName()); 
     290            confirmation.setToolTipText(tooltip); 
     291            ok_button.setToolTipText(tooltip); 
     292            // delete/ok button and confirmation checkbox should be disabled 
     293            ok_button.setEnabled(false); 
     294            confirmation.setEnabled(false); 
     295            confirmation.setSelected(false); 
     296        } 
    279297        } 
    280298        else { 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DesignPane.java

    r18297 r18364  
    4040import org.greenstone.gatherer.cdm.CollectionDesignManager; 
    4141import org.greenstone.gatherer.cdm.Control; 
     42 
     43import org.greenstone.gatherer.Configuration; 
     44 
    4245public class DesignPane  
    4346    extends BaseConfigPane { 
     
    4649    public DesignPane() { 
    4750    super(); 
    48     contents = new String [] { "CDM.GUI.Plugins", "CDM.GUI.Indexes", "CDM.GUI.Subcollections",  "CDM.GUI.Classifiers" }; 
     51    if (Configuration.fedora_info.isActive()) { 
     52        contents = new String [] { "CDM.GUI.Plugins" }; 
     53    } 
     54    else { 
     55        contents = new String [] { "CDM.GUI.Plugins", "CDM.GUI.Indexes", "CDM.GUI.Subcollections",  "CDM.GUI.Classifiers" }; 
     56    } 
    4957     
    5058    } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r18297 r18364  
    185185    edit_pane.add(mode_pane,BorderLayout.CENTER); 
    186186    edit_pane.add(button_pane,BorderLayout.PAGE_END); 
    187  
     187     
    188188    // Add to "this" 
    189189    setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
     
    242242        String launch = launch_str.toString();       
    243243        System.err.println("*** launch = " + launch); 
    244          
     244 
    245245        URL launch_url = new URL(launch); 
    246246        URLConnection launch_connection = launch_url.openConnection(); 
     
    514514    implements ActionListener { 
    515515    public void actionPerformed(ActionEvent event) { 
    516          
     516 
    517517        if(checkURL(true) && checkProxy() == true) { 
    518518         
     519        // Proxy settings are now set. Check that the url is not a redirect, else get 
     520        // redirect url (we do this step in order to avoid some unintuitive behaviour from wget) 
     521        Download current_download = (Download)download_map.get(mode); 
     522        Argument arg_url = current_download.getArgument("url"); 
     523        if(arg_url != null) { // it's null for z3950 and possibly for other downloaders 
     524            String url_str = arg_url.getValue(); 
     525            String redirect_url_str = getRedirectURL(url_str); 
     526             
     527            // only update the Argument and its GUI ArgumentControl if the URL 
     528            // has in fact changed 
     529            if(!url_str.equals(redirect_url_str)) { 
     530            arg_url.setValue(redirect_url_str); 
     531            updateArgument(arg_url, redirect_url_str); 
     532            } 
     533        } 
    519534        getter.newDownloadJob((Download)download_map.get(mode) ,mode,proxy_url); 
    520535        } 
    521536    } 
    522537    } 
     538 
     539    /** 
     540     * The Java code here will retrieve the page at the given url. If the response code is  
     541     * a redirect, it will get the redirect url so that wget may be called with the proper url.  
     542     * This preprocessing of the URL is necessary because: 
     543     * Wget does not behave the way the browser does when faced with urls of the form 
     544     * http://www.englishhistory.net/tudor/citizens and if that page does not exist. 
     545     * The directory listing with a slash at the end (http://www.englishhistory.net/tudor/citizens/) 
     546     * does exist, however. In order to prevent wget from assuming that the root URL 
     547     * to traverse is http://www.englishhistory.net/tudor/ instead of the intended 
     548     * http://www.englishhistory.net/tudor/citizens/, we need give wget the redirect location 
     549     * that's returned when we initially make a request for http://www.englishhistory.net/tudor/citizens 
     550     * The proper url is sent back in the Location header, allowing us to bypass wget's  
     551     * unexpected behaviour. 
     552     * This method ensures that urls like http://www.nzdl.org/niupepa also continue to work: 
     553     * there is no http://www.nzdl.org/niupepa/ page, because this url actually redirects to an  
     554     * entirely different URL. 
     555     * @return the redirect url for the given url if any redirection is involved, or the 
     556     * url_str. 
     557     */ 
     558    private String getRedirectURL(String url_str) { 
     559    HttpURLConnection connection = null; 
     560    if(url_str.startsWith("http:")) { // only test http urls 
     561        try { 
     562        URL url = new URL(url_str);  
     563        connection = (HttpURLConnection)url.openConnection(); //new HttpURLConnection(url); 
     564        // don't let it automatically follow redirects, since we want to 
     565        // find out whether we are dealing with redirects in the first place 
     566        connection.setInstanceFollowRedirects(false); 
     567         
     568        // now check for whether we get a redirect response 
     569        // HTTP Codes 3xx are redirects, http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 
     570        int responseCode = connection.getResponseCode(); 
     571        if(responseCode >= 300 && responseCode < 400) {  
     572            String responseMsg = connection.getResponseMessage(); 
     573 
     574            // Get the Location header since this specifies the new location of the resource 
     575            String location = connection.getHeaderField("Location"); 
     576             
     577            // this becomes the url that wget should download from 
     578            url_str = location.trim(); 
     579        } 
     580         
     581        connection.disconnect(); 
     582        } catch(Exception e) { 
     583        if(connection != null) { 
     584            connection.disconnect(); 
     585        } 
     586        System.err.println("Checking redirection. Tried to connect to " 
     587                   + url_str + ",\nbut got exception: " + e); 
     588        }        
     589    }  
     590 
     591    return url_str; 
     592    } 
     593 
    523594     
     595    /** For a string-based Argument whose value has changed, this method 
     596     * updates the GUI ArgumentControl's value correspondingly. */ 
     597    private void updateArgument(Argument arg, String value) { 
     598    for(int i = 0; i < options_pane.getComponentCount(); i++) { 
     599        Component component = options_pane.getComponent(i); 
     600        if(component instanceof ArgumentControl) { 
     601        ArgumentControl control = (ArgumentControl)component; 
     602        if(control.getArgument() == arg) { 
     603            control.setValue(value); 
     604            control.repaint(); 
     605        } 
     606        } 
     607    } 
     608    } 
    524609 
    525610    private boolean checkURL(boolean checkRequired){ 
     
    568653         
    569654            int count = 0; 
     655        // Only for wget, need to avoid a second automatic authentication popup (first asks 
     656        // the proxy authentication for wget, and the second will ask the same for the realm) 
     657        // Once the authentication has been reused, it will set the GAuthenticator state back to REGULAR 
     658        GAuthenticator.setMode(GAuthenticator.DOWNLOAD); 
    570659        while(count < 3 && (user_pass = (String) GAuthenticator.authentications.get(address)) == null) { 
    571660        Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.get("WGet.Prompt"), "HTTP"); 
    572661        count++; 
    573662        } 
    574  
    575663        if(count >= 3) { 
    576664        return false; 
     
    579667        if(user_pass.indexOf("@") != -1) { 
    580668             
    581         // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the follwoing can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this 
     669        // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the following can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this 
    582670        if (Utility.isWindows()) { 
    583671              
     
    607695            
    608696           } 
    609  
     697         
    610698           return true; 
    611699        } 
     
    615703 
    616704    } 
    617  
     705     
    618706    return true; 
    619707    } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r18297 r18364  
    273273 
    274274 
    275     /** Called whenever the collection tree selection changes. This causes the metadata value table to be rebuilt. */ 
    276     public void valueChanged(TreeSelectionEvent event) 
     275  /** Allows other classes to request the enrich pane to prepare for metadata 
     276   *  saving. 
     277   *  @author John Thompson, DL Consulting Ltd 
     278   */ 
     279  public void stopEditingAndRebuild() 
     280  { 
     281    // Update the metadata value table (and consequently, the metadata value tree) 
     282    metadata_value_table_pane.stopEditingAndRebuild(file_nodes); 
     283  } 
     284  /** stopEditingAndRebuild() **/ 
     285   
     286  /** Called whenever the collection tree selection changes. This causes the metadata value table to be rebuilt. */ 
     287  public void valueChanged(TreeSelectionEvent event) 
    277288    { 
    278289    // If we haven't got focus then it must have been a selection in the Gather pane, so don't bother rebuilding 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java

    r18297 r18364  
    279279        String collection_name = CollectionManager.getLoadedCollectionName(); 
    280280        String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name); 
    281         String metadata_file_relative_path = RemoteGreenstoneServer.getPathRelativeToDirectory(metadata_file, collection_directory_path); 
     281        String metadata_file_relative_path = Gatherer.remoteGreenstoneServer.getPathRelativeToDirectory( 
     282                                                          metadata_file, collection_directory_path); 
    282283        command_parts_list.add("-file"); 
    283284        command_parts_list.add(metadata_file_relative_path); 
     
    350351        if (Gatherer.isGsdlRemote) { 
    351352            Utility.delete(metadata_file.getParentFile()); 
    352             RemoteGreenstoneServer.downloadCollectionFile(CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile()); 
     353            Gatherer.remoteGreenstoneServer.downloadCollectionFile( 
     354                             CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile()); 
    353355        } 
    354356 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/ExportAsPrompt.java

    r18297 r18364  
    8383 
    8484    private ArrayList all_collections = null; 
    85     private ArrayList selected_collections = null; 
    86     /** The list of collections to include in exported cd-rom/dvd image */ 
    87     private CheckList list = null; 
     85    private BasicCollectionConfiguration selected_collection = null; 
     86  /** The list of collections to export */ 
     87    private JList list = null; 
    8888    /** The currently selected collection for deletion. */ 
    8989    private BasicCollectionConfiguration collection = null; 
     
    159159    plugoutMap.put("DSpace","dublin-core.xml"); 
    160160        plugoutMap.put("MARCXML","doc.xml");    
    161     plugoutMap.put("METS","doctxt.xml,docmets.xml");      
    162     plugoutMap.put("GA","doc.xml"); 
    163  
     161    plugoutMap.put("GreenstoneMETS","doctxt.xml,docmets.xml");      
     162    plugoutMap.put("FedoraMETS","doctxt.xml,docmets.xml");      
     163 
     164    // this is the order we want them to appear in the list 
     165    String [] saveas_formats = {"GreenstoneMETS", "FedoraMETS", "MARCXML", "DSpace"}; 
    164166        cancel_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip")); 
    165167     
     
    179181    instructions_textarea.setComponentOrientation(Dictionary.getOrientation()); 
    180182              
    181         // Save As 
    182     ArrayList saveas_formats = new ArrayList(plugoutMap.keySet()); 
    183183        
    184184        saveas_label = new JLabel(Dictionary.get("ExportAsPrompt.SaveAs") 
     
    187187        //saveas_label.setPreferredSize(LABEL_SIZE); 
    188188         
    189         saveas_combobox = new JComboBox(saveas_formats.toArray()); 
     189    saveas_combobox = new JComboBox(saveas_formats); 
    190190    saveas_combobox.setOpaque(false); 
    191191    saveas_combobox.setToolTipText(Dictionary.get("ExportAsPrompt.SaveAs_Tooltip")); 
     
    224224        convert_xml_field1 = new JTextField(); 
    225225        convert_xml_field1.setComponentOrientation(Dictionary.getOrientation()); 
     226    convert_xml_field1.setEnabled(false); 
     227 
    226228    convert_xml_field2 = new JTextField(); 
    227229        convert_xml_field2.setComponentOrientation(Dictionary.getOrientation()); 
     230    convert_xml_field2.setEnabled(false); 
     231 
    228232    mapping_xml_field = new JTextField(); 
    229233        mapping_xml_field.setComponentOrientation(Dictionary.getOrientation()); 
     234    mapping_xml_field.setEnabled(false); 
    230235 
    231236        convert_xml_pane1 = new JPanel(new BorderLayout()); 
     
    242247         
    243248    all_collections = new ArrayList(); 
    244     list = new CheckList(true); 
     249    //list = new CheckList(true); 
     250    list = new JList(getCollectionListModel()); 
    245251    list_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_List")); 
    246252    list_label.setComponentOrientation(Dictionary.getOrientation()); 
     
    257263    folder_button.addActionListener(new FolderButtonListener()); 
    258264    
    259      
    260     scanForCollections(); 
    261     list.setListData(all_collections); 
    262  
     265        
    263266    prompt = this; 
    264267    setSize(SIZE); 
     
    299302    ok_button = null; 
    300303    prompt = null; 
    301     if (selected_collections!=null) { 
    302         selected_collections.clear(); 
    303         selected_collections = null; 
    304     } 
     304    selected_collection = null; 
    305305    title_field = null; 
    306306    title_label = null; 
     
    348348         
    349349        String saveas = (String)saveas_combobox.getSelectedItem(); 
    350     if (saveas.equals("MARCXML")){ 
    351         convert_xml_pane.add(mapping_xml_pane); 
    352             convert_xml_pane.add(output_single_checkbox);  
    353     } 
    354         else{ 
    355         if (saveas.equals("METS")){ 
    356         convert_xml_pane.add(convert_xml_pane2);  
    357         } 
    358     } 
    359     convert_xml_pane.revalidate(); 
    360     convert_xml_pane.repaint(); 
     350    // force the updating of which fields we are displaying 
     351    saveas_combobox.setSelectedIndex(0); 
    361352 
    362353        // Save as pane 
     
    441432    DebugStream.println("ExportAsPrompt.exportAsCollections()"); 
    442433 
    443     int num_collections = selected_collections.size(); 
    444     if (num_collections == 0) return; 
     434    if (selected_collection == null) return; 
     435 
    445436    cd_title = title_field.getText(); 
    446437 
     
    479470        command_parts_list.add(export_dir); 
    480471 
    481         if (!export_type.equals("METS") && xsl_file1 !=null){ 
     472        if (!export_type.endsWith("METS") && xsl_file1 !=null){ 
    482473             command_parts_list.add("-xsltfile"); 
    483474             command_parts_list.add(xsl_file1.getPath());  
     
    508499 
    509500             
    510         if (export_type.equals("METS") && xsl_file1 !=null){ 
     501        if (export_type.endsWith("METS") && xsl_file1 !=null){ 
    511502             command_parts_list.add("-xslt_txt"); 
    512503             command_parts_list.add(xsl_file1.getPath());  
    513504    } 
    514505 
    515          if (export_type.equals("METS") && xsl_file2 !=null){ 
     506         if (export_type.endsWith("METS") && xsl_file2 !=null){ 
    516507             command_parts_list.add("-xslt_mets"); 
    517508             command_parts_list.add(xsl_file2.getPath());  
    518509    } 
    519510        
    520     for (int i = 0; i < num_collections; i++) { 
    521         command_parts_list.add(((BasicCollectionConfiguration) selected_collections.get(i)).getShortName()); 
    522     } 
     511     command_parts_list.add( selected_collection.getShortName()); 
     512      
    523513 
    524514    DebugStream.print("export command = "); 
     
    553543    public void resultPrompt(boolean success, String extra) { 
    554544    args = new String[2]; 
    555     StringBuffer coll_names = new StringBuffer(); 
    556     for (int i=0; i<selected_collections.size();i++) { 
    557         if (i>0) { 
    558         coll_names.append(", "); 
    559         } 
    560         BasicCollectionConfiguration complete_collection = (BasicCollectionConfiguration)selected_collections.get(i); 
    561         coll_names.append(complete_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + complete_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER); 
    562         complete_collection = null; 
    563     } 
    564      
    565     args[0] = coll_names.toString(); 
     545     
     546    // coll name 
     547    args[0] = selected_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + selected_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER; 
    566548     
    567549    String export_type = (String) saveas_combobox.getSelectedItem();        
     
    588570 
    589571    if (success) { 
    590         String successMessage 
    591         = (selected_collections.size()==1)  
    592         ? "ExportAsPrompt.Successful_ExportOne" 
    593         : "ExportAsPrompt.Successful_ExportMany"; 
    594  
    595         title = Dictionary.get("ExportAsPrompt.Successful_Title"); 
    596         label = Dictionary.get(successMessage, args); 
    597         details = Dictionary.get("ExportAsPrompt.Successful_Details", args); 
     572      String successMessage = "ExportAsPrompt.Successful_ExportOne"; 
     573      title = Dictionary.get("ExportAsPrompt.Successful_Title"); 
     574      label = Dictionary.get(successMessage, args); 
     575      details = Dictionary.get("ExportAsPrompt.Successful_Details", args); 
    598576    } else { 
    599         String failedMessage 
    600         = (selected_collections.size()==1)  
    601         ? "ExportAsPrompt.Failed_ExportOne" 
    602         : "ExportAsPrompt.Failed_ExportMany"; 
    603  
    604         title = Dictionary.get("ExportAsPrompt.Failed_Title"); 
    605         label = Dictionary.get(failedMessage, args); 
    606         details = Dictionary.get("ExportAsPrompt.Failed_Details", args); 
    607     } 
    608     SimpleResultDialog result_dialog = new SimpleResultDialog(title, label, details); 
     577      String failedMessage = "ExportAsPrompt.Failed_ExportOne"; 
     578      title = Dictionary.get("ExportAsPrompt.Failed_Title"); 
     579      label = Dictionary.get(failedMessage, args); 
     580      details = Dictionary.get("ExportAsPrompt.Failed_Details", args); 
     581    } 
     582    SimpleResultDialog result_dialog = new SimpleResultDialog(this, title, label, details); 
    609583    result_dialog.setVisible(true); // Blocks 
    610584    result_dialog.dispose(); 
     
    618592     * @see org.greenstone.gatherer.util.Utility 
    619593     */ 
    620     private void scanForCollections() { 
     594  private ListModel getCollectionListModel() { 
     595    DefaultListModel model = new DefaultListModel(); 
    621596    // Start at the collect dir. 
    622597    File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
     
    632607            if (config_file.exists()) { 
    633608            BasicCollectionConfiguration config = new BasicCollectionConfiguration(config_file); 
    634             all_collections.add(config);                 
     609            model.addElement(config);                
    635610            config = null; 
    636611            } 
     
    638613        } 
    639614    } 
     615    return model; 
    640616    // Otherwise the collect directory doesn't actually exist, so there ain't much we can do. 
    641     } 
     617  } 
    642618 
    643619 
     
    697673    { 
    698674        // Can only export when something is ticked 
    699         ok_button.setEnabled(!list.isNothingTicked()); 
     675        //ok_button.setEnabled(!list.isNothingTicked()); 
    700676 
    701677        if (list.isSelectionEmpty()) { 
    702         // This only happens when the dialog is first entered 
    703678        details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.No_Collection")); 
    704         return; 
    705         } 
    706  
    707         collection = (BasicCollectionConfiguration) ((CheckListEntry) list.getSelectedValue()).getObject(); 
    708         args = new String[3]; 
    709         args[0] = collection.getCreator(); 
    710         args[1] = collection.getMaintainer(); 
    711         args[2] = collection.getDescription(); 
    712         details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 
    713         details_textarea.setCaretPosition(0); 
    714     } 
    715     } 
    716  
    717  
     679        ok_button.setEnabled(false); 
     680        } 
     681        else { 
     682          BasicCollectionConfiguration collection = (BasicCollectionConfiguration) list.getSelectedValue(); 
     683          args = new String[3]; 
     684          args[0] = collection.getCreator(); 
     685          args[1] = collection.getMaintainer(); 
     686          args[2] = collection.getDescription(); 
     687          details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 
     688          details_textarea.setCaretPosition(0); 
     689          ok_button.setEnabled(true); 
     690        } 
     691    } 
     692 
     693    } 
    718694    /** The OK button listener implementation. */ 
    719695    private class OKButtonListener  
     
    732708        ///ystem.err.println("OK Clicked"); 
    733709        // Make sure there are some colls specified 
    734         selected_collections = list.getTicked(); 
     710        selected_collection = (BasicCollectionConfiguration)list.getSelectedValue(); 
    735711        error_message = new StringBuffer(); 
    736712         
     
    837813       
    838814        convert_xml_button1.setEnabled(convert_xml_checkbox1.isSelected()); 
     815        convert_xml_field1.setEnabled(convert_xml_checkbox1.isSelected()); 
    839816        convert_xml_button2.setEnabled(convert_xml_checkbox2.isSelected()); 
     817        convert_xml_field2.setEnabled(convert_xml_checkbox2.isSelected()); 
    840818        convert_xml_button3.setEnabled(mapping_xml_checkbox.isSelected()); 
     819        mapping_xml_field.setEnabled(mapping_xml_checkbox.isSelected()); 
    841820             
    842821    } 
     
    871850        } 
    872851 
    873         if (!saveas.equals("METS")){ 
     852        if (!saveas.endsWith("METS")){ 
    874853     
    875854        convert_xml_checkbox1.setText(Dictionary.get("ExportAsPrompt.ApplyXSL",(String)plugoutMap.get(saveas)));     
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/Filter.java

    r18297 r18364  
    7474    static final private Dimension SIZE = new Dimension(100,30); 
    7575    /** Preprogrammed default filters. */ 
    76     static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tiff?$)"}; 
     76    static final private String DEFAULTS[]  
     77    = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$",  
     78       "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tiff?$)", 
     79       "^.*\\.pdf$",  
     80       "(^.*\\.docx?$)|(^.*\\.pptx?$)|(^.*\\.xlsx?$)|(^.*\\.od(t|s|p)$)"}; 
    7781 
    7882    /** Constructor. 
     
    241245            else if(temp_str.equals(Dictionary.get("Filter.3"))) { 
    242246            } 
     247            // PDF 
     248            else if(temp_str.equals(Dictionary.get("Filter.4"))) { 
     249            } 
     250            // Office Docs 
     251            else if(temp_str.equals(Dictionary.get("Filter.5"))) { 
     252            } 
    243253            else { 
    244254            // Make sure the filter isn't already in the list 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/FormatPane.java

    r18297 r18364  
    7070            contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation" }; 
    7171        } else { 
    72             contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros" }; 
     72            contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros", "CDM.GUI.DepositorMetadata" }; 
    7373        } 
    7474        JPanel side_panel = new JPanel (); 
     
    173173            return CollectionDesignManager.supercollection_manager.getControls (); 
    174174        } 
     175    if(type.equals ("CDM.GUI.DepositorMetadata")) { 
     176        return CollectionDesignManager.depositormetadata_manager.getControls (); 
     177    } 
    175178        return null; 
    176179    } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r18297 r18364  
    6060import org.greenstone.gatherer.gui.tree.DragTree; 
    6161import org.greenstone.gatherer.metadata.MetadataSet; 
     62import org.greenstone.gatherer.metadata.MetadataXMLFileManager; 
    6263import org.greenstone.gatherer.remote.RemoteGreenstoneServer; 
    6364import org.greenstone.gatherer.util.JarTools; 
     
    204205    } 
    205206    else if (esrc == menu_bar.file_save) { 
    206         Gatherer.c_man.saveCollection(); 
     207      // Very important: make sure metadata values are saved too 
     208      enrich_pane.stopEditingAndRebuild(); 
     209      // Make sure all the metadata has been saved to file 
     210      MetadataXMLFileManager.saveMetadataXMLFiles(); 
     211       
     212      Gatherer.c_man.saveCollection(); 
    207213    } 
    208214 
     
    346352 
    347353        // Pretty corner icon 
    348         this.setIconImage(JarTools.getImage("gatherer_small.gif").getImage()); 
     354        String gsmall_image = "gatherer_small.gif"; 
     355        if (Configuration.fedora_info.isActive()) { 
     356        gsmall_image = "fli-" + gsmall_image; 
     357        } 
     358        this.setIconImage(JarTools.getImage(gsmall_image).getImage()); 
    349359        // BorderLayout for the main screen. I'll try my best to avoid these in subcomponents as they're space greedy. 
    350360        content_pane.setLayout(new BorderLayout()); 
     
    392402        if (Configuration.get("workflow.design", true)) { 
    393403        // "GUI.Design_Tooltip" is used automatically 
    394         tab_pane.addTab(Dictionary.get("GUI.Design"), JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 
     404        if (Configuration.fedora_info.isActive()) { 
     405            tab_pane.addTab("Plugins", JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 
     406        } 
     407        else { 
     408            tab_pane.addTab(Dictionary.get("GUI.Design"), JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 
     409        } 
     410 
    395411        tab_pane.setEnabledAt(tab_pane.indexOfComponent(design_pane), false); 
    396412        } 
     
    441457        remote_greenstone_server_progress_panel.setLayout(new BorderLayout()); 
    442458        remote_greenstone_server_progress_panel.add(remote_greenstone_server_progress_label, BorderLayout.LINE_START); 
    443         remote_greenstone_server_progress_panel.add(RemoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER); 
     459        remote_greenstone_server_progress_panel.add(Gatherer.remoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER); 
    444460        content_pane.add(remote_greenstone_server_progress_panel, BorderLayout.SOUTH); 
    445461        } 
     
    467483    // If we have a collection open remember it for next time, then save it and close it 
    468484    if (Gatherer.c_man.ready()) { 
    469         Configuration.setString("general.open_collection", true, CollectionManager.getLoadedCollectionColFilePath()); 
     485        Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(),  
     486                    true, CollectionManager.getLoadedCollectionColFilePath()); 
    470487        saveThenCloseCurrentCollection(); 
    471488    } 
    472489    else { 
    473         Configuration.setString("general.open_collection", true, null); 
     490        Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, null); 
    474491    } 
    475492 
     
    650667    public void setTitle(String title, String name) { 
    651668    // Finally display the collection name in the title bar. 
    652     StringBuffer title_buffer = new StringBuffer(Gatherer.PROGRAM_NAME); 
     669    StringBuffer title_buffer = new StringBuffer(Configuration.getApplicationTitle()); 
    653670    title_buffer.append(StaticStrings.SPACE_CHARACTER); 
    654671    title_buffer.append(Gatherer.PROGRAM_VERSION); 
    655672    title_buffer.append(StaticStrings.SPACE_CHARACTER); 
    656673    title_buffer.append(StaticStrings.SPACE_CHARACTER); 
     674    // Server version information 
     675    title_buffer.append(Gatherer.getServerVersionAsString()); 
     676    title_buffer.append(StaticStrings.SPACE_CHARACTER); 
     677    title_buffer.append(StaticStrings.SPACE_CHARACTER);  
    657678    // Describe the current user mode 
    658679    title_buffer.append(StaticStrings.MODE_STR); 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/HelpFrame.java

    r18297 r18364  
    120120    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 
    121121 
     122 
    122123    // Pretty corner icon 
    123     this.setIconImage(JarTools.getImage("gatherer_small.gif").getImage()); 
     124    String gsmall_image = "gatherer_small.gif"; 
     125    if (Configuration.fedora_info.isActive()) { 
     126        gsmall_image = "fli-" + gsmall_image; 
     127    } 
     128 
     129    this.setIconImage(JarTools.getImage(gsmall_image).getImage()); 
    124130 
    125131    self = this; 
     
    238244        try { 
    239245        String help_index_file_path = getHelpFolder() + "help_index.xml"; 
    240         Document document = XMLTools.parseXMLFile(help_index_file_path, true); 
    241  
     246        Document document = null; 
     247        if (Gatherer.isApplet && JarTools.getResource(help_index_file_path) != null) { 
     248            document = XMLTools.parseXMLFile(help_index_file_path, true); 
     249        } 
     250         
     251        if (new File(help_index_file_path).exists()) { 
     252            document = XMLTools.parseXMLFile(help_index_file_path, false); 
     253        }        
     254 
     255        if (document == null) { 
     256            String errormsg = "HelpFrame.HelpContentsTreeModel constructor(): There's no help document after parsing"; 
     257            System.err.println(errormsg); 
     258            DebugStream.println(errormsg); 
     259            return; 
     260        } 
    242261        // Traverse the help hierarchy, building a tree representing its structure 
    243262        Node document_node = document.getFirstChild(); 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r18297 r18364  
    248248    content_pane.add(bottom_pane, BorderLayout.SOUTH); 
    249249    // Final dialog setup & positioning. 
     250    getRootPane().setDefaultButton(create_button); 
    250251    Dimension screen_size = Configuration.screen_size; 
    251252    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 
     
    288289    // Remote collections that aren't shared have the user's username prefixed to the collection name 
    289290    if (Gatherer.isGsdlRemote && personal_collection_button.isSelected()) { 
    290         name_buffer = new StringBuffer(RemoteGreenstoneServer.getUsername() + "-" + name_buffer.toString()); 
     291        name_buffer = new StringBuffer(Gatherer.remoteGreenstoneServer.getUsername() + "-" + name_buffer.toString()); 
    291292    } 
    292293 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java

    r18297 r18364  
    269269        return; 
    270270        } 
     271 
     272        load_collection_configs(data,collect_directory); 
     273 
     274    } 
     275 
     276 
     277    protected void load_collection_configs(TreeSet data, File collect_directory) { 
     278 
    271279        File[] collection_folders = collect_directory.listFiles(); 
     280 
    272281        for(int i = 0; i < collection_folders.length; i++) { 
    273282        File collection_folder = collection_folders[i]; 
    274283        String collection_foldername = collection_folder.getName(); 
     284 
    275285        if(collection_folder.isDirectory() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) { 
    276             // this 'file_name' has already been prefixed by 'etc' 
    277             String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 
     286            // this 'file_name' has already been prefixed by 'etc' 
     287            String file_name; 
     288            if (Gatherer.GS3){ 
     289            convertToGS3Collection(collection_folder); 
     290            file_name = Utility.CONFIG_GS3_FILE; 
     291            }else{ 
     292            file_name = Utility.CONFIG_FILE; 
     293            } 
     294             
    278295            File config_file = new File(collection_folder, file_name); 
    279296            File collection_metadata_directory = new File(collection_folder, "metadata"); 
    280297            if (collection_metadata_directory.exists() && config_file.exists()) { 
    281298            BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(config_file); 
    282             data.add(collection_configuration); 
     299 
     300            // look to see if group set? 
     301            // => if it is, don't add, but recurse to look for child collections in collect-group 
     302 
     303            if (collection_configuration.getCollectGroup().equals("true")) { 
     304                load_collection_configs(data, collection_folder); 
     305            } 
     306            else { 
     307                data.add(collection_configuration); 
     308            } 
    283309            } 
    284310            config_file = null; 
     
    290316        collect_directory = null; 
    291317    } 
     318 
     319 
    292320 
    293321    public Object getElementAt(int index) { 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r18297 r18364  
    6969    static final public char CANCELLED = 'c'; 
    7070    static final public char UNKNOWN = 'x'; 
     71    static final public char SCHEDULED = 'd';  
    7172 
    7273    static private int BUILD = 0; 
    7374    static private int IMPORT = 1; 
    74     static private int MINIMUM_ROWS = 11; 
     75    static private int SCHEDULE = 2;  
     76    static private int MINIMUM_ROWS = 15; 
    7577     
    7678    /** All process messages are written to this log text area. */ 
     
    8284    private ScriptOptions build_options = null; 
    8385    private ScriptOptions import_options = null; 
     86    private ScriptOptions schedule_options = null; 
    8487 
    8588    private FileEntry file_entry = null; 
     
    9396 
    9497    /** The default constructor creates the few session length options, but either retrieves the rest from the current collection, or creates a default set of options. */ 
    95     public OptionsPane(ScriptOptions import_options, ScriptOptions build_options) { 
     98    public OptionsPane(ScriptOptions import_options, ScriptOptions build_options, ScriptOptions schedule_options) { 
    9699    this.build_options = build_options; 
    97100    this.import_options = import_options; 
     101    this.schedule_options = schedule_options;  
    98102    this.current_controls = new ArrayList(); 
    99103    this.writing_documents = new Vector(); 
     
    175179      build_arguments = null; 
    176180      return pane; 
     181    } 
     182 
     183    /**Wendy's attempt at writing a buildSchedule Jpanel. */ 
     184    public JPanel buildSchedule(JPanel pane) { 
     185    //reset the arguments 
     186    if(pane ==  null) { 
     187        current_controls.clear();  
     188    } 
     189 
     190    ArrayList schedule_arguments = new ArrayList();  
     191    int current_mode = Configuration.getMode();  
     192 
     193    int total_schedule_argument_count = schedule_options.getArgumentCount(); 
     194       
     195      for(int i = 0; i < total_schedule_argument_count; i++) { 
     196        // Retrieve the argument so we know how to format the control. 
     197        Argument argument = schedule_options.getArgument(i); 
     198         
     199        //A hack to make the disable_OAI option visible in the GLI for Greenstone 3 
     200        if(argument.getName().equals(StaticStrings.DISABLEOAI_STR) && Gatherer.GS3) { 
     201          argument.setHiddenGLI(false); 
     202        } 
     203        if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) { 
     204          // Now attempt to retrieve any existing value for this argument. 
     205          boolean enabled = schedule_options.getValueEnabled(argument.getName()); 
     206          String value = schedule_options.getValue(argument.getName()); 
     207          MyArgumentControl argument_control = new MyArgumentControl(SCHEDULE, argument, enabled, value); 
     208          schedule_arguments.add(argument_control); 
     209        } 
     210      } 
     211      current_controls.addAll(schedule_arguments); 
     212       
     213      // 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. 
     214      if(pane == null || current_mode >= Configuration.EXPERT_MODE) { 
     215        pane = new JPanel(); 
     216        pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
     217        pane.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); 
     218        int argument_count = schedule_arguments.size(); 
     219        // If in any of the higher detail modes, and assuming we don't want super phat argument controls, we better ensure there is a minimum number of lines in the grid layout 
     220        if(current_mode >= Configuration.EXPERT_MODE) { 
     221          if(argument_count < MINIMUM_ROWS) { 
     222            argument_count = MINIMUM_ROWS; 
     223          } 
     224          pane.setLayout(new GridLayout(argument_count, 1, 5, 5)); 
     225        } 
     226        // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway 
     227        else { 
     228          // use  GridLayout with 0 rows == as many rows as needed. Unfortunately, rows will 
     229          // grow fat if space too large, but we don't know how many rows we'll need yet. 
     230          pane.setLayout(new GridLayout(0, 1, 5, 5)); 
     231        } 
     232      } 
     233       
     234      for(int j = 0; j < schedule_arguments.size(); j++) { 
     235        pane.add((JComponent)schedule_arguments.get(j)); 
     236      } 
     237      pane.addMouseListener(this); 
     238      schedule_arguments = null; 
     239      return pane; 
     240 
    177241    } 
    178242 
     
    422486            build_options.removeValue(name); 
    423487        } 
     488        else if(type == SCHEDULE) { 
     489            schedule_options.removeValue(name);  
     490        } 
    424491        else { 
    425492            import_options.removeValue(name); 
     
    430497        if(type == BUILD) { 
    431498            build_options.setValue(name, enable, value); 
     499        } 
     500        else if(type == SCHEDULE) { 
     501            schedule_options.setValue(name, enable, value);  
    432502        } 
    433503        else { 
     
    523593        case CANCELLED: 
    524594            d.append(Dictionary.get("OptionsPane.Cancelled")); 
     595            break; 
     596        case SCHEDULED: 
     597            d.append(Dictionary.get("OptionsPane.Scheduled")); 
    525598            break; 
    526599        default: 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/Preferences.java

    r18297 r18364  
    731731    public void actionPerformed(ActionEvent event) 
    732732    { 
     733        // Several options requiring restarting the GLI to apply:  
     734        // interface font, interface language, changed gliserver url or library url 
     735        boolean restart_required = false; 
     736        String restart_message = ""; 
     737 
     738         
    733739        // Connection preferences 
    734740        String program_str = program_field.getText(); 
     
    738744        Configuration.setPreviewCommand(program_str); 
    739745 
     746        String old_library_url = (Configuration.library_url == null) ? null : Configuration.library_url.toString(); 
    740747        String library_url_string = library_path_field.getText(); 
     748        if(old_library_url != null && !old_library_url.equals(library_url_string)) { 
     749 
     750        // If the server is remote and the library path's been changed, then GLI client needs restart 
     751        // If the server is local, GLI is going to work with the collection of GSDLPath anyway,  
     752        // even if the library path for previewing has changed 
     753        if (Gatherer.isGsdlRemote) { 
     754            restart_required = true; 
     755            restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required"); 
     756        } 
     757        if(Gatherer.c_man.getCollection() != null) { 
     758            // if the gliserver url has changed while a collection is open,  
     759            // close the open collection of the old library URL 
     760            Gatherer.c_man.saveCollection(); 
     761            Gatherer.c_man.closeCollection(); 
     762            Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, ""); 
     763        } 
     764        } 
    741765        if (library_url_string.equals("")) { 
    742766        Configuration.library_url = null; 
     
    750774        } 
    751775        } 
    752         Configuration.setString("general.library_url", true, library_url_string); 
     776 
     777        Configuration.setString("general.library_url"+Configuration.gliPropertyNameSuffix(),  
     778                    true, library_url_string); 
    753779 
    754780        if (Gatherer.isGsdlRemote && !Gatherer.GS3) { 
     781        String old_gliserver_url = Configuration.gliserver_url.toString();  
    755782        String gliserver_url_string = gliserver_url_field.getText(); 
     783        if(!old_gliserver_url.equals(gliserver_url_string)) { 
     784            restart_required = true; 
     785            restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required"); 
     786 
     787            if(Gatherer.c_man.getCollection() != null) { 
     788            // if the gliserver url has changed while a collection is open,  
     789            // close the open collection of the old gliserver URL 
     790            Gatherer.c_man.saveCollection(); 
     791            Gatherer.c_man.closeCollection(); 
     792            Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, ""); 
     793            } 
     794        } 
    756795        if (gliserver_url_string.equals("")) { 
    757796            Configuration.gliserver_url = null; 
     
    767806        Configuration.setString("general.gliserver_url", true, gliserver_url_string); 
    768807        } 
     808         
    769809 
    770810        boolean site_changed = false; 
     
    777817        Configuration.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem()); 
    778818        } 
    779  
     819        
    780820        Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 
    781821        Configuration.setString("general.proxy_host", true, proxy_host_field.getText()); 
     
    788828        Configuration.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected()); 
    789829 
    790         // Two options requiring restarting the GLI to apply: interface font, and interface language 
    791         boolean restart_required = false; 
    792830 
    793831        // GLI interface font 
     
    796834        Configuration.setString("general.font", true, font_field.getText()); 
    797835        restart_required = true; 
     836        restart_message = Dictionary.get("Preferences.General.Restart_Required"); 
    798837        } 
    799838 
     
    803842        Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry) language_combobox.getSelectedItem()).getLocale()); 
    804843        restart_required = true; 
     844        restart_message = Dictionary.get("Preferences.General.Restart_Required"); 
    805845        } 
    806846 
    807847        // Inform the user that a restart is required, if necessary 
    808848        if (restart_required) { 
    809         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.General.Restart_Required"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE); 
     849        JOptionPane.showMessageDialog(Gatherer.g_man, restart_message, Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE); 
    810850        } 
    811851 
     
    845885        if (Gatherer.GS3 && site_changed && Gatherer.c_man.getCollection() != null && !Gatherer.isGsdlRemote) { 
    846886        // shut down the collection 
    847         System.err.println("shutting down teh collection"); 
     887        System.err.println("shutting down the collection"); 
    848888        Gatherer.g_man.saveThenCloseCurrentCollection(); 
    849889        } 
     
    867907        Configuration.save(); 
    868908        if (Gatherer.isGsdlRemote && Gatherer.GS3 && site_changed ){ 
    869         RemoteGreenstoneServer.downloadCollectionConfigurations(); 
     909        Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations(); 
    870910        } 
    871911        // Refresh the GLI to account for the configuration changes 
     
    9971037            if (Gatherer.c_man.getCollection()!=null){ 
    9981038            File lock_file = new File(Gatherer.c_man.getLoadedCollectionDirectoryPath() + "gli.lck"); 
    999             RemoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file); 
     1039            Gatherer.remoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file); 
    10001040            Gatherer.g_man.closeCurrentCollection(); 
    10011041            } 
    10021042            Configuration.site_name=site; 
    1003             RemoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null(); 
    1004             RemoteGreenstoneServer.downloadCollectionConfigurations(); 
     1043            Gatherer.remoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null(); 
     1044            Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations(); 
    10051045        } 
    10061046        } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/PreviewButton.java

    r14046 r18364  
    7575    protected void configureHomeURL() { 
    7676    // set up the home page for the current collection 
    77     if (Gatherer.GS3) { 
     77    if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case 
    7878        // don't do anything fancy here 
    7979        preview_address = Configuration.library_url.toString() + Configuration.getServletPath() + "?a=p&sa=about&c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage(); 
    8080        return; 
    8181    } 
     82    // FLI or GLI for GS2 case (no library_url) 
    8283    preview_address = Configuration.library_url.toString() + "?c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage(); 
    8384 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/SimpleResultDialog.java

    r18297 r18364  
    4848 
    4949public class SimpleResultDialog 
    50     extends ModalDialog { 
     50  extends ModalDialog { 
    5151     
    52     private Dimension size = new Dimension(600,300); 
    53     private SimpleResultDialog self; 
     52  private Dimension size = new Dimension(600,300); 
     53  private SimpleResultDialog self; 
    5454     
    55     public SimpleResultDialog(String title, String label, String results) { 
    56     super(Gatherer.g_man, title, true); 
    57     this.self = this; 
     55  public SimpleResultDialog(String title, String label, String results) { 
     56    super(Gatherer.g_man, title, true); 
     57    this.self = this; 
    5858    this.setComponentOrientation(Dictionary.getOrientation()); 
    5959         
    60     setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 
    61     setSize(size); 
     60    setUpGUI(label, results); 
     61  } 
     62 
     63  /** If you are calling this from another dialog, and you want that dialog blocked while this is open, need to use this method, passing in the calling dialog as the parent */ 
     64  public SimpleResultDialog(Dialog parent, String title, String label, String results) { 
     65 
     66    super(parent, title, true); 
     67    this.self = this; 
     68   
     69    setUpGUI(label, results); 
     70  } 
     71 
     72  private void setUpGUI(String label, String results) { 
     73    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 
     74    setSize(size); 
    6275     
    63     JPanel content_pane = (JPanel) getContentPane(); 
    64         content_pane.setComponentOrientation(Dictionary.getOrientation()); 
    65     JLabel result_label = new JLabel(label); 
    66         result_label.setComponentOrientation(Dictionary.getOrientation()); 
     76    JPanel content_pane = (JPanel) getContentPane(); 
     77    content_pane.setComponentOrientation(Dictionary.getOrientation()); 
     78    JLabel result_label = new JLabel(label); 
     79    result_label.setComponentOrientation(Dictionary.getOrientation()); 
    6780     
    68     JPanel button_pane = new JPanel(); 
    69         button_pane.setComponentOrientation(Dictionary.getOrientation()); 
    70     JButton close_button = new GLIButton(Dictionary.get("General.Close")); 
    71     close_button.addActionListener(new CloseButtonListener()); 
     81    JPanel button_pane = new JPanel(); 
     82    button_pane.setComponentOrientation(Dictionary.getOrientation()); 
     83    JButton close_button = new GLIButton(Dictionary.get("General.Close")); 
     84    close_button.addActionListener(new CloseButtonListener()); 
    7285     
    73     JPanel output_pane = new JPanel(); 
    74         output_pane.setComponentOrientation(Dictionary.getOrientation()); 
    75     JLabel output_label = new JLabel(Dictionary.get("General.Review_Output")); 
    76     output_label.setComponentOrientation(Dictionary.getOrientation()); 
    77     JTextArea output_textarea = new JTextArea(results); 
    78         output_textarea.setComponentOrientation(Dictionary.getOrientation()); 
    79     output_textarea.setCaretPosition(0); 
    80     output_textarea.setEditable(false); 
    81     output_textarea.setLineWrap(true); 
    82     output_textarea.setWrapStyleWord(true); 
     86    JPanel output_pane = new JPanel(); 
     87    output_pane.setComponentOrientation(Dictionary.getOrientation()); 
     88    JLabel output_label = new JLabel(Dictionary.get("General.Review_Output")); 
     89    output_label.setComponentOrientation(Dictionary.getOrientation()); 
     90 
     91    JTextArea output_textarea = new JTextArea(results); 
     92    output_textarea.setComponentOrientation(Dictionary.getOrientation()); 
     93    output_textarea.setCaretPosition(0); 
     94    output_textarea.setEditable(false); 
     95    output_textarea.setLineWrap(true); 
     96    output_textarea.setWrapStyleWord(true); 
    8397     
    84     button_pane.setLayout(new BorderLayout()); 
    85     button_pane.add(close_button, BorderLayout.LINE_END); 
     98    button_pane.setLayout(new BorderLayout()); 
     99    button_pane.add(close_button, BorderLayout.LINE_END); 
    86100     
    87     output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0)); 
    88     output_pane.setLayout(new BorderLayout()); 
    89     output_pane.add(output_label, BorderLayout.NORTH); 
    90     output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER); 
     101    output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0)); 
     102    output_pane.setLayout(new BorderLayout()); 
     103    output_pane.add(output_label, BorderLayout.NORTH); 
     104    output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER); 
    91105     
    92     content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
    93     content_pane.setLayout(new BorderLayout()); 
    94     content_pane.add(result_label, BorderLayout.NORTH); 
    95     content_pane.add(output_pane, BorderLayout.CENTER); 
    96     content_pane.add(button_pane, BorderLayout.SOUTH); 
     106    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
     107    content_pane.setLayout(new BorderLayout()); 
     108    content_pane.add(result_label, BorderLayout.NORTH); 
     109    content_pane.add(output_pane, BorderLayout.CENTER); 
     110    content_pane.add(button_pane, BorderLayout.SOUTH); 
    97111     
    98     // Position 
    99     Rectangle frame_bounds = Gatherer.g_man.getBounds(); 
    100     setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 
     112    // Position 
     113    Rectangle frame_bounds = Gatherer.g_man.getBounds(); 
     114    setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 
     115    //new SimpleResultDialog(Gatherer.g_man, title, label, results); 
     116  } 
     117   
     118   
     119  private class CloseButtonListener 
     120    implements ActionListener { 
     121    public void actionPerformed(ActionEvent event) { 
     122      self.setVisible(false); 
    101123    } 
    102      
    103     private class CloseButtonListener 
    104     implements ActionListener { 
    105     public void actionPerformed(ActionEvent event) { 
    106         self.setVisible(false); 
    107     } 
    108     } 
     124  } 
    109125} 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/URLField.java

    r18297 r18364  
    44import java.net.*; 
    55import javax.swing.*; 
    6 import org.greenstone.gatherer.Dictionary; 
    7  
    8  
     6import java.util.*; 
     7import java.io.*; 
     8import org.greenstone.gatherer.Gatherer; 
     9import org.greenstone.gatherer.Configuration; 
     10 
     11/** Modified.  
     12 * Class used by WarningDialog and Gatherer which represents a textual input control  
     13 * (TextField or Combobox) into which a URL can be entered. Provides some static methods 
     14 * shared by these controls and by a general JTextField control which can all be used  
     15 * in a WarningDialog. Class URLField also contains an inner Interface class and two  
     16 * static inner classes that implement this interface: Text and DropDown.  
     17 * Finally, another static inner class URLCollectionPair associates each Gliserver URL 
     18 * (or Library URL) that can be displayed in the DropDown with the last opened collection 
     19 * file for the Greenstone server at that URL.  
     20*/ 
    921public class URLField 
    10     extends JTextField 
    1122{ 
    12     public URLField(Color foreground, Color background) 
    13     { 
    14     super(); 
    15         this.setComponentOrientation(Dictionary.getOrientation()); 
    16     setBackground(background); 
    17     setForeground(foreground); 
    18     } 
    19  
    20  
    21     public boolean validateURL() 
    22     { 
    23     String url_string = getText(); 
     23    static public String getText(JComponent control) 
     24    { 
     25    if(control instanceof JTextField) { // not specifically a URL Field, therefore, we're not meant to do checking 
     26        return ((JTextField)control).getText(); 
     27    }  
     28    else if(control instanceof URLField.DropDown) { 
     29        return (String)((JComboBox)control).getSelectedItem(); 
     30    } 
     31 
     32    // unknown control, shouldn't happen 
     33    return ""; 
     34    } 
     35 
     36    static public String setText(JComponent control, String text) 
     37    { 
     38    if(control instanceof JTextField) { // not specifically a URL Field, therefore, we're not meant to do checking 
     39        ((JTextField)control).setText(text); 
     40    }  
     41    else if(control instanceof URLField.DropDown) { 
     42        ((JComboBox)control).setSelectedItem(text);      
     43    } 
     44 
     45    // unknown control, shouldn't happen 
     46    return ""; 
     47    } 
     48 
     49    static public boolean validateURL(JComponent control) 
     50    { 
     51    if(control instanceof URLField.Text) { 
     52        return ((URLField.Text)control).validateURL(); 
     53    }  
     54    else if (control instanceof JTextField) { 
     55        return true; // not specifically a URL Field, therefore, we're not meant to do checking 
     56    } 
     57    else { // control is a DropDown 
     58        return ((URLField.DropDown)control).validateURL(); 
     59    } 
     60    } 
     61 
     62    static public boolean validateURL(String url_string) 
     63    { 
    2464    if (!url_string.equals("")) { 
    2565        // Check the URL string is valid by trying to create a URL object from it 
     
    3676    return true; 
    3777    } 
     78 
     79    static public void store(JComponent control, String affected_property) { 
     80    if(control instanceof JTextField) {  
     81        String value = ((JTextField)control).getText(); 
     82        Configuration.setString(affected_property, true, value); 
     83        Configuration.save(); // save it in case of a crash 
     84    }  
     85    else { // DropDown 
     86        ((DropDown)control).saveProperties(); // saves it already 
     87    } 
     88    } 
     89 
     90     
     91    /** INTERFACE CLASS IMPLEMENTED BY Static inner classes Text and DropDown */ 
     92    public static interface URLFieldControl { 
     93    public boolean validateURL(); 
     94    } 
     95 
     96 
     97    /** STATIC INNER CLASS URLTextField */ 
     98    public static class Text  
     99    extends JTextField implements URLFieldControl  
     100    { 
     101    public Text(Color foreground, Color background) 
     102    { 
     103        super(); 
     104         this.setComponentOrientation(Dictionary.getOrientation()); 
     105        setBackground(background); 
     106        setForeground(foreground); 
     107    } 
     108 
     109    public boolean validateURL() { 
     110        String url_string = getText(); 
     111        return URLField.validateURL(url_string); 
     112    } 
     113    } 
     114 
     115    
     116    /** STATIC INNER CLASS DropDown, an editable URLComboBox */ 
     117    public static class DropDown  
     118    extends JComboBox implements URLFieldControl 
     119    { 
     120    private String checkString = null; // optional string to check the URLs items against to see whether the URLs contain this 
     121    private String affectedProperty = null; // the Configuration property associated with this DropDown 
     122    private String coaffectedProperty = null; // the Configuration property whose suffix should change along with the affectedProperty 
     123     
     124    private static final int MAX_URLS = 5; 
     125 
     126    public DropDown(Color foreground, Color background, String[] defaultURLs,  
     127            String affectedProperty, String coaffectedProperty) 
     128    { 
     129        super(URLCollectionPair.createDefaultsArray(defaultURLs)); 
     130        this.setEditable(true); 
     131        this.getEditor().selectAll(); 
     132        this.setComponentOrientation(Dictionary.getOrientation()); 
     133 
     134        setBackground(background); 
     135        setForeground(foreground); 
     136         
     137        this.affectedProperty = affectedProperty; 
     138        this.coaffectedProperty = coaffectedProperty; 
     139        // read any URLS specified in the config file 
     140        setComboBoxValues(); 
     141         
     142    } 
     143 
     144    public DropDown(Color foreground, Color background, String[] defaultURLs,  
     145            String affectedProperty, String coaffectedProperty, String checkString) 
     146    { 
     147        this(foreground, background, defaultURLs, affectedProperty, coaffectedProperty); 
     148        this.checkString = checkString; 
     149    }    
     150 
     151    public boolean validateURL() { 
     152        //String url_string = (String)this.getEditor().getItem(); 
     153        String url_string = this.getSelectedItem().toString(); // returns url of the combobox item 
     154         
     155        if(checkString != null && !url_string.endsWith(checkString)) { 
     156        return false; 
     157        } else { 
     158        return URLField.validateURL(url_string); 
     159        } 
     160    } 
     161 
     162    public void saveProperties() { 
     163        // 1. Add the first url just edited (if any)  
     164 
     165        // The user might have created a new STRING, or selected an existing URLCollectionPair 
     166        // We don't know the type! 
     167        Object o = this.getSelectedItem();  
     168        URLCollectionPair editedItem = (o instanceof URLCollectionPair)  
     169        ? (URLCollectionPair)o : new URLCollectionPair(o.toString()); 
     170                 
     171        if(editedItem != null) { 
     172        insertItemAt(editedItem, 0); 
     173        } else { 
     174        editedItem = (URLCollectionPair)getItemAt(0); // else reuse the first default: 
     175        } 
     176        Configuration.setString(affectedProperty, true, editedItem.getURL()); 
     177         
     178        // concurrently set the last opened collection for this url 
     179        String lastOpenedCollection = editedItem.getCollection(); 
     180        if(lastOpenedCollection.equals("")) { 
     181        Configuration.setString(coaffectedProperty, true, null); 
     182        } else { 
     183        Configuration.setString(coaffectedProperty, true, lastOpenedCollection); 
     184        } 
     185 
     186 
     187        // 2. Add the remaining urls into the combobox 
     188        int url_count = 1; // remain under MAX_URLS AND under the number of actual URLs in the dropdown 
     189        for(int i = 0; url_count < MAX_URLS && i < getItemCount(); i++, url_count++) { 
     190         
     191        URLCollectionPair item = (URLCollectionPair)getItemAt(i); 
     192        String url = item.getURL(); 
     193         
     194        if(item == null || url.equals(editedItem.getURL()) || url.equals("")) {  
     195            // skip any duplicates of the just-edited URL and skip empty URLs 
     196            url_count--; 
     197        }  
     198        else {  
     199            Configuration.setString(affectedProperty+url_count, true, url); 
     200             
     201            // concurrently save the name of the corresponding open collection 
     202            if(item.getCollection().equals("")) { 
     203            Configuration.setString(coaffectedProperty+url_count, true, null); 
     204            } else { 
     205            Configuration.setString(coaffectedProperty+url_count, true, item.getCollection()); 
     206            } 
     207 
     208        } // else retain old value for this affectedProperty (general.gliserver_url) 
     209        } 
     210        Configuration.save(); 
     211    } 
     212 
     213     
     214    // Get values from Configuration file, or (if none) use defaultURLs. 
     215    // Put them into the combobox 
     216    private void setComboBoxValues() { 
     217 
     218        String url = Configuration.getString(affectedProperty, true); 
     219        String collection = Configuration.getString(coaffectedProperty, true); 
     220        boolean finished = url.equals(""); 
     221        if(!finished) { 
     222        this.removeAllItems(); // remove defaults, since config file now contains init values 
     223        this.addItem(new URLCollectionPair(url, collection)); 
     224        } // else urls and combobox already contains the defaults 
     225             
     226 
     227        for(int i = 1; !finished; i++) { 
     228        url = Configuration.getString(affectedProperty+i, true); 
     229        collection = Configuration.getString(coaffectedProperty+i, true); 
     230        if(url.equals("")) { 
     231            finished = true; 
     232        } 
     233        else { // url is not empty 
     234            this.addItem(new URLCollectionPair(url, collection)); 
     235        } 
     236        } 
     237         
     238        // setting the size of the dropdown control 
     239        Dimension newSize=new Dimension(getPreferredSize().width+20, getPreferredSize().height); 
     240        setPreferredSize(newSize); 
     241    } 
     242    } 
     243 
     244 
     245    /** STATIC INNER CLASS URLCollectionPair.  
     246     * Since the configuration for a (remote) Greenstone2 and Greenstone3 is now 
     247     * stored in a single file for both, we can have GLI connecting to different servers  
     248     * while for each server, a different collection may have been left open last time. 
     249     * This class URLCollectionPair will associate a GLIServer_URL or Library_URL with 
     250     * the last opened collection file for it. It is used by URLField.DropDown combobox. */ 
     251    public static class URLCollectionPair { 
     252    String url;        // gliserverURL  
     253    String collection; // last opened collection for the corresponding gliserver 
     254 
     255     
     256    public static URLCollectionPair[] createDefaultsArray(String[] defaultURLs) { 
     257        URLCollectionPair[] pairs = new URLCollectionPair[defaultURLs.length]; 
     258        for(int i = 0; i < pairs.length; i++) { 
     259        pairs[i] = new URLCollectionPair(defaultURLs[i]); // no associated open collection 
     260        } 
     261        return pairs; 
     262    } 
     263 
     264    public URLCollectionPair(String url) { 
     265        this.set(url, ""); 
     266    } 
     267 
     268    public URLCollectionPair(String url, String collection) { 
     269        this.set(url, collection); 
     270    } 
     271 
     272    public void set(String url, String collection) { 
     273        this.url = url; 
     274        this.collection = collection; 
     275    } 
     276 
     277    public void setURL(String url) { 
     278        this.url = url; 
     279    } 
     280 
     281    public void setCollection(String collection) { 
     282        this.collection = collection; 
     283    } 
     284 
     285    public String getCollection() { 
     286        return collection; 
     287    } 
     288 
     289    public String getURL() { 
     290        return url; 
     291    } 
     292 
     293    /** For display in comboboxes */ 
     294    public String toString() { 
     295        return url; 
     296    } 
     297 
     298    /** @returns the number that is suffixed to the gliserver_url */ 
     299    public String getSuffixNumber() { 
     300        String numericSuffix = ""; 
     301        boolean stop = false; 
     302        for(int index = url.length()-1; index >= 0 && !stop; index--) { // work from the end 
     303        char character = url.charAt(index); 
     304        if(Character.isDigit(character)) { 
     305            numericSuffix = Character.toString(character) + numericSuffix; 
     306        } else { 
     307            stop = true; 
     308        } 
     309        } 
     310 
     311        return numericSuffix; 
     312    } 
     313    } 
     314 
    38315} 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/WarningDialog.java

    r18297 r18364  
    4848    private JButton ok_button; 
    4949    private JCheckBox show_check; 
    50     private JTextField value_field; 
     50    private JComponent value_field; 
    5151    private JPanel value_panel; 
    5252    private String affected_property; 
    5353    private String full_property; 
    54  
    55  
    56     public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel) 
     54    /** Whether or not to display the checkbox that will turn off this dialog in future */ 
     55    private final boolean showcheckbox; 
     56 
     57 
     58    public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel)  
     59    { 
     60    this(warning_name, warning_title, warning_message, affected_property, can_cancel, true); // true for show checkbox 
     61    } 
     62 
     63 
     64    public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel, 
     65             boolean showcheckbox) 
    5766    { 
    5867    super(Gatherer.g_man, "Warning", true); 
    5968        this.setComponentOrientation(Dictionary.getOrientation()); 
     69    this.showcheckbox = showcheckbox;  
     70 
    6071    // Determine the name of this prompt. 
    6172    this.affected_property = affected_property; 
     
    7687    JPanel text_pane = new JPanel(); 
    7788        text_pane.setComponentOrientation(Dictionary.getOrientation()); 
    78     JLabel icon_label = new JLabel(JarTools.getImage("gatherer_medium.gif")); 
     89         
     90    String gmedium_image = "gatherer_medium.gif"; 
     91    if (Configuration.fedora_info.isActive()) { 
     92        gmedium_image = "fli-" + gmedium_image; 
     93    } 
     94 
     95    JLabel icon_label = new JLabel(JarTools.getImage(gmedium_image)); 
    7996        icon_label.setComponentOrientation(Dictionary.getOrientation()); 
    80          
     97 
    8198    JTextArea text_area = new JTextArea(); 
    8299        text_area.setComponentOrientation(Dictionary.getOrientation()); 
     
    96113    JPanel bottom_pane = new JPanel(); 
    97114        bottom_pane.setComponentOrientation(Dictionary.getOrientation()); 
    98     show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 
    99         show_check.setComponentOrientation(Dictionary.getOrientation()); 
     115         
    100116    JPanel control_pane = new JPanel(); 
    101117        control_pane.setComponentOrientation(Dictionary.getOrientation()); 
     
    139155    bottom_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 
    140156    bottom_pane.setLayout(new BorderLayout()); 
    141     bottom_pane.add(show_check, BorderLayout.CENTER); 
    142157    bottom_pane.add(control_pane, BorderLayout.LINE_END); 
     158    if(showcheckbox) { 
     159        show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 
     160        show_check.setComponentOrientation(Dictionary.getOrientation()); 
     161        bottom_pane.add(show_check, BorderLayout.CENTER); 
     162    } 
    143163 
    144164    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
     
    160180 
    161181    public void actionPerformed(ActionEvent event) { 
    162     boolean bad_value = false; 
     182    boolean valid_value = true; 
    163183    if(event.getSource() == ok_button) { 
    164184        if(affected_property != null && Configuration.self != null) { 
    165         String value = value_field.getText(); 
    166         if(value.length() > 0) { 
    167            if(value_field instanceof URLField) { 
    168               bad_value = !((URLField)value_field).validateURL(); 
    169            } 
    170            if(!bad_value) { 
    171               // Store the value of the property 
    172               Configuration.setString(affected_property, true, value_field.getText()); 
    173            } 
     185        valid_value = URLField.validateURL(value_field); 
     186        if(valid_value) { 
     187            // Store the value of the property 
     188            URLField.store(value_field, affected_property); //Configuration.setString(affected_property, true, value); 
    174189        } 
    175190        } 
    176         if(!bad_value) { 
     191        if(valid_value) { 
    177192        result = JOptionPane.OK_OPTION; 
    178193        } 
    179     } 
    180     if(!bad_value) { 
    181         if (Configuration.self != null) { 
     194    }  
     195 
     196    if(valid_value) { 
     197        if (Configuration.self != null && showcheckbox) { 
    182198        // Store the state of the show message checkbox. 
    183199        Configuration.set(full_property, true, !show_check.isSelected()); 
     
    202218    } 
    203219 
    204     public void keyReleased(KeyEvent e) { } 
    205  
    206     public void keyTyped(KeyEvent e) { } 
     220    public void keyReleased(KeyEvent e) {} 
     221 
     222    public void keyTyped(KeyEvent e) {} 
    207223 
    208224 
     
    226242     */ 
    227243    public void setMessageOnly(boolean message_only) { 
     244    if(!showcheckbox) { 
     245        return; 
     246    } 
     247 
    228248    // If this is a message then change the checkbox 
    229249    if(message_only) { 
     
    239259     * @param  control the JTextField subclass you want to use for the control 
    240260     */ 
    241     public void setValueField(JTextField control) { 
     261    public void setValueField(JComponent control) { 
    242262    // Remove the current control 
    243263    value_panel.remove(value_field); 
     
    263283 
    264284    public void setValueField(String field_value){ 
    265     this.value_field.setText(field_value); 
     285    URLField.setText(this.value_field, field_value); 
    266286    } 
    267287