Changeset 6637


Ignore:
Timestamp:
2004-01-28T14:44:44+13:00 (20 years ago)
Author:
jmt12
Message:

Further tweaks, fixes and changes to the mirroring stuff, the highlight of which is the new log files. I've also removed the speech marks from around login and pass. While this means you can't have a login or pass with spaces in it, it does save me a lot of effort. Rather than tell people about the further options, they now click on a button to open the preferences window and show the further options. Also fixed a horrendeously subtle bug when trying to update the FileSystemModel - stupid race conditions

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
7 edited

Legend:

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

    r6622 r6637  
    328328        if(job_queue.size() > 0) {
    329329        int index = 0;
    330         while(index < job_queue.size()) {
     330        while(job_queue.size() > 0 && index < job_queue.size()) {
    331331            // Get the first job that isn't stopped.
    332332            job = (Job) job_queue.get(index);
     
    346346            // And if the user has requested that complete jobs
    347347                // be removed, then remove it from the list.
    348             deleteJob(job);
     348            //deleteJob(job);
    349349            job = null;
    350350            }
  • trunk/gli/src/org/greenstone/gatherer/collection/Job.java

    r6622 r6637  
    4949import org.greenstone.gatherer.file.WorkspaceTreeModel;
    5050import org.greenstone.gatherer.gui.GProgressBar;
     51import org.greenstone.gatherer.util.AppendLineOnlyFileDocument;
    5152import org.greenstone.gatherer.util.GURL;
    5253import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
     
    6667    private boolean quiet;
    6768
     69    private AppendLineOnlyFileDocument download_log;
     70
    6871    private GProgressBar progress;
    6972
     
    97100    // this.model = model;
    98101
     102    String log_filename = Utility.getLogDir(null) + "wget" + initial.hashCode() + ".log";
     103    File log_file = new File(log_filename);
     104    if(log_file.exists()) {
     105        log_file.delete();
     106    }
     107    File parent_log_file = log_file.getParentFile();
     108    parent_log_file.mkdirs();
     109    parent_log_file = null;
     110    log_file = null;
     111
     112    System.err.println("Creating the log file:" + log_filename);
     113
    99114    this.debug = debug;
     115    this.download_log = new AppendLineOnlyFileDocument(log_filename, false);
    100116    this.no_parents = no_parents;
    101117    this.other_hosts = other_hosts;
     
    130146    if(event.getSource() == progress.action) {
    131147        previous_state = state;
     148        state = RUNNING;
     149        mummy.resumeThread();
     150    }
     151    else if (event.getSource() == progress.cancel) {
    132152        if(state == RUNNING) {
    133         state = PAUSED;
     153        previous_state = state;
     154        state = STOPPED; // Should already be stopped.
    134155        }
    135156        else {
    136         state = RUNNING;
    137         mummy.resumeThread();
    138         }
    139     }
    140     else if (event.getSource() == progress.cancel) {
    141         state = STOPPED; // Should already be stopped.
    142         mummy.deleteJob(this);
     157        mummy.deleteJob(this);
     158        }
    143159    }
    144160    }
     
    221237        if(user_pass.indexOf("@") != -1) {
    222238        // Write the use proxy command
    223         command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=\"" + user_pass.substring(0, user_pass.indexOf("@")) + "\" --proxy-passwd=*** -Y on ";
     239        command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=" + user_pass.substring(0, user_pass.indexOf("@")) + " --proxy-passwd=" + user_pass.substring(user_pass.indexOf("@") + 1) + " -Y on ";
    224240
    225241        }
     
    262278        String line;
    263279        boolean ignore_for_robots = false;
    264         while ((line = br.readLine()) != null) {
     280        while ((line = br.readLine()) != null && state != STOPPED) {
    265281        Gatherer.println(line);
    266 
     282        download_log.appendLine(line);
    267283        // The first magic special test is to see if we've just
    268284        // asked for the robots.txt file. If so we ignore
     
    337353        }
    338354        }
    339         // Now display final message based on exit value
    340         prcs.waitFor();
     355        if(state == STOPPED) {
     356        isr.close();
     357        prcs.destroy(); // This doesn't always work, but it's worth a try
     358        }
     359        else {
     360        // Now display final message based on exit value
     361        prcs.waitFor();
     362        }
    341363    }
    342364    catch (Exception ioe) {
     
    530552    }
    531553
     554    public AppendLineOnlyFileDocument getLogDocument() {
     555    return download_log;
     556    }
     557
    532558    /**
    533559     * @return Returns the progress bar associated with this job.
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java

    r6622 r6637  
    6969        Gatherer.print("Searching for '" + stale_object + "': ");
    7070        // Locate the fresh node by searching current's children. Remember to ensure that current is mapped.
    71         current.map();
     71        current.unmap();
    7272        boolean found = false;
    7373
  • trunk/gli/src/org/greenstone/gatherer/gui/GProgressBar.java

    r6622 r6637  
    4545import org.greenstone.gatherer.collection.Job;
    4646import org.greenstone.gatherer.gui.GLIButton;
     47import org.greenstone.gatherer.util.AppendLineOnlyFileDocument;
    4748import org.greenstone.gatherer.util.Utility;
    4849
     
    8283
    8384    public JButton action;
     85    public JButton log_button;
    8486    public JButton cancel;
    8587
     
    135137
    136138    /** @todo - add to dictionary, and rewrite existing tooltip */
     139    log_button = new GLIButton("Mirroring.Job.Log");
     140    log_button.addActionListener(owner);
     141    log_button.addActionListener(this);
     142    log_button.setEnabled(false);
     143    log_button.setMinimumSize(MINIMUM_BUTTON_SIZE);
     144    log_button.setMnemonic(KeyEvent.VK_L);
     145    //Dictionary.setTooltip(log_button, "Mirroring.Job.Stop_Tooltip");
     146
     147    /** @todo - add to dictionary, and rewrite existing tooltip */
    137148    cancel = new GLIButton("Mirroring.Job.Cancel");
    138149    cancel.addActionListener(owner);
     
    146157    inner_pane.add(center_pane, BorderLayout.NORTH);
    147158
    148     button_pane.setLayout(new GridLayout(2,1));
     159    button_pane.setLayout(new GridLayout(3,1));
    149160    button_pane.add(action);
     161    button_pane.add(log_button);
    150162    button_pane.add(cancel);
    151163
     
    158170
    159171    public void actionPerformed(ActionEvent event) {
    160     if(event.getSource() == action) {
     172    Object source = event.getSource();
     173    if(source == action) {
     174        current_action = Job.RUNNING;
     175        action.setEnabled(false);
     176       
     177    }
     178    else if(source == cancel) {
     179        // If we are running, stop.
    161180        if (current_action == Job.RUNNING) {
    162181        current_action = Job.STOPPED;
    163182        action.setEnabled(true);
    164183        }
    165         else {
    166         current_action = Job.RUNNING;
    167         action.setEnabled(false);
    168         }
     184    }
     185    else if(source == log_button) {
     186        LogDialog dialog = new LogDialog(owner.getLogDocument());
     187        dialog.show();
     188        dialog = null;
    169189    }
    170190    }
     
    242262    current_action = Job.RUNNING;
    243263    action.setEnabled(false);
     264    log_button.setEnabled(true);
    244265    if(simple) {
    245266        progress.setIndeterminate(true);
     
    345366    this.updateUI();
    346367    }
     368
     369    static final private Dimension DIALOG_SIZE = new Dimension(640,480);
     370
     371    private class LogDialog
     372    extends JDialog {
     373   
     374    public LogDialog(AppendLineOnlyFileDocument document) {
     375        super(Gatherer.g_man, "Mirroring.Job.Download_Log_Dialog_Title");
     376        setSize(DIALOG_SIZE);
     377        JPanel content_pane = (JPanel) getContentPane();
     378        JTextArea text_area = new JTextArea(document);
     379        JButton button = new GLIButton(Dictionary.get("General.Close"));
     380        // Connection
     381        button.addActionListener(new CloseActionListener());
     382        // Layout
     383        content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     384        content_pane.setLayout(new BorderLayout());
     385        content_pane.add(new JScrollPane(text_area), BorderLayout.CENTER);
     386        content_pane.add(button, BorderLayout.SOUTH);
     387    }
     388
     389    private class CloseActionListener
     390        implements ActionListener {
     391        public void actionPerformed(ActionEvent event) {
     392        LogDialog.this.dispose();
     393        }
     394    }
     395    }
    347396}
  • trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java

    r6622 r6637  
    5151import org.greenstone.gatherer.file.FileNode;
    5252import org.greenstone.gatherer.gui.GLIButton;
     53import org.greenstone.gatherer.gui.Preferences;
    5354import org.greenstone.gatherer.gui.URLField;
    5455import org.greenstone.gatherer.util.StaticStrings;
     
    123124    same_host_checkbox.setSelected(true);
    124125    Dictionary.registerText(same_host_checkbox, "Mirroring.Same_Host");
    125    
    126     /* @todo - add to dictionary */
    127     JLabel further_label = new JLabel("Mirroring.Further_Options");
    128126
    129127    JPanel button_pane = new JPanel();
     128
     129    JButton preferences_button = new GLIButton("Mirroring.Further_Options");
     130    preferences_button.setMnemonic(KeyEvent.VK_P);
     131
    130132    download_button = new GLIButton();
    131     download_button.setMnemonic(KeyEvent.VK_ENTER);
     133    download_button.setEnabled(false);
     134    download_button.setMnemonic(KeyEvent.VK_D);
    132135    Dictionary.registerBoth(download_button, "Mirroring.Download", "Mirroring.Download_Tooltip");
    133136
    134137    // Connect
    135138    download_button.addActionListener(new DownloadButtonListener());
     139    preferences_button.addActionListener(new PreferencesButtonActionListener());
    136140    url_field.getDocument().addDocumentListener(new DownloadButtonEnabler());
    137141
     
    146150    depth_pane.add(depth_combobox);
    147151
    148     details_pane.setLayout(new GridLayout(6,1,0,5));
     152    details_pane.setLayout(new GridLayout(5,1,0,5));
    149153    details_pane.add(url_pane);
    150154    details_pane.add(depth_pane);
     
    152156    details_pane.add(higher_checkbox);
    153157    details_pane.add(same_host_checkbox);
    154     details_pane.add(further_label);
    155158
    156159    button_pane.setLayout(new GridLayout(1,3));
    157     button_pane.add(new JPanel());
     160    button_pane.add(preferences_button);
    158161    button_pane.add(new JPanel());
    159162    button_pane.add(download_button);
     
    352355    }
    353356    }
     357
     358    private class PreferencesButtonActionListener
     359    implements ActionListener {
     360    public void actionPerformed(ActionEvent event) {
     361        new Preferences(Preferences.CONNECTION_PREFS);
     362    }
     363    }
    354364}
  • trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r6622 r6637  
    4646    static final public String ARCPLUG_STR                                = "ArcPlug";
    4747    static final public String ASSIGNED_ATTRIBUTE                         = "assigned";
     48    static final public String ASSOCIATIONS_ELEMENT                       = "Associations";
    4849    static final public String AT_CHARACTER                               = "@";
    4950    static final public String ATTRIBUTE_ELEMENT                          = "Attribute";
     
    9495    static final public String EMPTY_STR                                  = "";
    9596    static final public String ENGLISH_LANGUAGE_STR                       = "en";
     97    static final public String ENTRY_ELEMENT                              = "Entry";
    9698    static final public String ENUM_STR                                   = "enum";
    9799    static final public String EQUALS_CHARACTER                           = "=";
     
    101103    static final public String EXCLAIMATION_CHARACTER                     = "!";
    102104    static final public String EXCLUDE_STR                                = "exclude";
     105    static final public String EXTENSION_ATTRIBUTE                        = "extension";
    103106    static final public String EXTRACTED_METADATA_ELEMENT                 = "XMetadata";
    104107    static final public String EXTRACTED_NAMESPACE                        = "ex.";
     
    234237    static final public String VALUE_ATTRIBUTE                            = "value";
    235238    static final public String VALUE_TREE_ATTRIBUTE                       = "remember_values";
     239    static final public String VERSION_ATTRIBUTE                          = "version";
    236240    static final public String WGET_ARGUMENT                              = "-wget";
    237241    static final public String WGET_OLD_STR                               = "<WGet1.9";
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r6621 r6637  
    633633     */
    634634    public static String getLogDir(String col_dir) {
    635     return col_dir + LOG_DIR;
     635    if(col_dir != null) {
     636        return col_dir + LOG_DIR;
     637    }
     638    else {
     639        return getGLIUserFolder().getAbsolutePath() + File.separator + LOG_DIR;
     640    }
    636641    }
    637642    /** Determine this machines name.
Note: See TracChangeset for help on using the changeset viewer.