Changeset 6637
- Timestamp:
- 2004-01-28T14:44:44+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/WGet.java
r6622 r6637 328 328 if(job_queue.size() > 0) { 329 329 int index = 0; 330 while( index < job_queue.size()) {330 while(job_queue.size() > 0 && index < job_queue.size()) { 331 331 // Get the first job that isn't stopped. 332 332 job = (Job) job_queue.get(index); … … 346 346 // And if the user has requested that complete jobs 347 347 // be removed, then remove it from the list. 348 deleteJob(job);348 //deleteJob(job); 349 349 job = null; 350 350 } -
trunk/gli/src/org/greenstone/gatherer/collection/Job.java
r6622 r6637 49 49 import org.greenstone.gatherer.file.WorkspaceTreeModel; 50 50 import org.greenstone.gatherer.gui.GProgressBar; 51 import org.greenstone.gatherer.util.AppendLineOnlyFileDocument; 51 52 import org.greenstone.gatherer.util.GURL; 52 53 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; … … 66 67 private boolean quiet; 67 68 69 private AppendLineOnlyFileDocument download_log; 70 68 71 private GProgressBar progress; 69 72 … … 97 100 // this.model = model; 98 101 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 99 114 this.debug = debug; 115 this.download_log = new AppendLineOnlyFileDocument(log_filename, false); 100 116 this.no_parents = no_parents; 101 117 this.other_hosts = other_hosts; … … 130 146 if(event.getSource() == progress.action) { 131 147 previous_state = state; 148 state = RUNNING; 149 mummy.resumeThread(); 150 } 151 else if (event.getSource() == progress.cancel) { 132 152 if(state == RUNNING) { 133 state = PAUSED; 153 previous_state = state; 154 state = STOPPED; // Should already be stopped. 134 155 } 135 156 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 } 143 159 } 144 160 } … … 221 237 if(user_pass.indexOf("@") != -1) { 222 238 // 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 "; 224 240 225 241 } … … 262 278 String line; 263 279 boolean ignore_for_robots = false; 264 while ((line = br.readLine()) != null ) {280 while ((line = br.readLine()) != null && state != STOPPED) { 265 281 Gatherer.println(line); 266 282 download_log.appendLine(line); 267 283 // The first magic special test is to see if we've just 268 284 // asked for the robots.txt file. If so we ignore … … 337 353 } 338 354 } 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 } 341 363 } 342 364 catch (Exception ioe) { … … 530 552 } 531 553 554 public AppendLineOnlyFileDocument getLogDocument() { 555 return download_log; 556 } 557 532 558 /** 533 559 * @return Returns the progress bar associated with this job. -
trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java
r6622 r6637 69 69 Gatherer.print("Searching for '" + stale_object + "': "); 70 70 // Locate the fresh node by searching current's children. Remember to ensure that current is mapped. 71 current. map();71 current.unmap(); 72 72 boolean found = false; 73 73 -
trunk/gli/src/org/greenstone/gatherer/gui/GProgressBar.java
r6622 r6637 45 45 import org.greenstone.gatherer.collection.Job; 46 46 import org.greenstone.gatherer.gui.GLIButton; 47 import org.greenstone.gatherer.util.AppendLineOnlyFileDocument; 47 48 import org.greenstone.gatherer.util.Utility; 48 49 … … 82 83 83 84 public JButton action; 85 public JButton log_button; 84 86 public JButton cancel; 85 87 … … 135 137 136 138 /** @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 */ 137 148 cancel = new GLIButton("Mirroring.Job.Cancel"); 138 149 cancel.addActionListener(owner); … … 146 157 inner_pane.add(center_pane, BorderLayout.NORTH); 147 158 148 button_pane.setLayout(new GridLayout( 2,1));159 button_pane.setLayout(new GridLayout(3,1)); 149 160 button_pane.add(action); 161 button_pane.add(log_button); 150 162 button_pane.add(cancel); 151 163 … … 158 170 159 171 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. 161 180 if (current_action == Job.RUNNING) { 162 181 current_action = Job.STOPPED; 163 182 action.setEnabled(true); 164 183 } 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; 169 189 } 170 190 } … … 242 262 current_action = Job.RUNNING; 243 263 action.setEnabled(false); 264 log_button.setEnabled(true); 244 265 if(simple) { 245 266 progress.setIndeterminate(true); … … 345 366 this.updateUI(); 346 367 } 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 } 347 396 } -
trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java
r6622 r6637 51 51 import org.greenstone.gatherer.file.FileNode; 52 52 import org.greenstone.gatherer.gui.GLIButton; 53 import org.greenstone.gatherer.gui.Preferences; 53 54 import org.greenstone.gatherer.gui.URLField; 54 55 import org.greenstone.gatherer.util.StaticStrings; … … 123 124 same_host_checkbox.setSelected(true); 124 125 Dictionary.registerText(same_host_checkbox, "Mirroring.Same_Host"); 125 126 /* @todo - add to dictionary */127 JLabel further_label = new JLabel("Mirroring.Further_Options");128 126 129 127 JPanel button_pane = new JPanel(); 128 129 JButton preferences_button = new GLIButton("Mirroring.Further_Options"); 130 preferences_button.setMnemonic(KeyEvent.VK_P); 131 130 132 download_button = new GLIButton(); 131 download_button.setMnemonic(KeyEvent.VK_ENTER); 133 download_button.setEnabled(false); 134 download_button.setMnemonic(KeyEvent.VK_D); 132 135 Dictionary.registerBoth(download_button, "Mirroring.Download", "Mirroring.Download_Tooltip"); 133 136 134 137 // Connect 135 138 download_button.addActionListener(new DownloadButtonListener()); 139 preferences_button.addActionListener(new PreferencesButtonActionListener()); 136 140 url_field.getDocument().addDocumentListener(new DownloadButtonEnabler()); 137 141 … … 146 150 depth_pane.add(depth_combobox); 147 151 148 details_pane.setLayout(new GridLayout( 6,1,0,5));152 details_pane.setLayout(new GridLayout(5,1,0,5)); 149 153 details_pane.add(url_pane); 150 154 details_pane.add(depth_pane); … … 152 156 details_pane.add(higher_checkbox); 153 157 details_pane.add(same_host_checkbox); 154 details_pane.add(further_label);155 158 156 159 button_pane.setLayout(new GridLayout(1,3)); 157 button_pane.add( new JPanel());160 button_pane.add(preferences_button); 158 161 button_pane.add(new JPanel()); 159 162 button_pane.add(download_button); … … 352 355 } 353 356 } 357 358 private class PreferencesButtonActionListener 359 implements ActionListener { 360 public void actionPerformed(ActionEvent event) { 361 new Preferences(Preferences.CONNECTION_PREFS); 362 } 363 } 354 364 } -
trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java
r6622 r6637 46 46 static final public String ARCPLUG_STR = "ArcPlug"; 47 47 static final public String ASSIGNED_ATTRIBUTE = "assigned"; 48 static final public String ASSOCIATIONS_ELEMENT = "Associations"; 48 49 static final public String AT_CHARACTER = "@"; 49 50 static final public String ATTRIBUTE_ELEMENT = "Attribute"; … … 94 95 static final public String EMPTY_STR = ""; 95 96 static final public String ENGLISH_LANGUAGE_STR = "en"; 97 static final public String ENTRY_ELEMENT = "Entry"; 96 98 static final public String ENUM_STR = "enum"; 97 99 static final public String EQUALS_CHARACTER = "="; … … 101 103 static final public String EXCLAIMATION_CHARACTER = "!"; 102 104 static final public String EXCLUDE_STR = "exclude"; 105 static final public String EXTENSION_ATTRIBUTE = "extension"; 103 106 static final public String EXTRACTED_METADATA_ELEMENT = "XMetadata"; 104 107 static final public String EXTRACTED_NAMESPACE = "ex."; … … 234 237 static final public String VALUE_ATTRIBUTE = "value"; 235 238 static final public String VALUE_TREE_ATTRIBUTE = "remember_values"; 239 static final public String VERSION_ATTRIBUTE = "version"; 236 240 static final public String WGET_ARGUMENT = "-wget"; 237 241 static final public String WGET_OLD_STR = "<WGet1.9"; -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r6621 r6637 633 633 */ 634 634 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 } 636 641 } 637 642 /** Determine this machines name.
Note:
See TracChangeset
for help on using the changeset viewer.