Changeset 10659
- Timestamp:
- 2005-09-27T17:32:23+12:00 (18 years ago)
- Location:
- trunk/gli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/classes/dictionary.properties
r10638 r10659 463 463 WriteCDImagePrompt.Instructions:Export one or more collections to a self-installing Windows CD/DVD (although this works on any platform, the CD/DVD that is created only runs under Windows). 464 464 WriteCDImagePrompt.Progress_Label:Copying Files. This could take some time... 465 WriteCDImagePrompt.Size_Label:Estimated size: 465 466 WriteCDImagePrompt.Successful_Export:The collections ({0}) have been exported. 466 467 WriteCDImagePrompt.Successful_Title:Export Complete -
trunk/gli/src/org/greenstone/gatherer/gui/WriteCDImagePrompt.java
r10370 r10659 49 49 import org.greenstone.gatherer.LocalGreenstone; 50 50 import org.greenstone.gatherer.collection.BasicCollectionConfiguration; 51 import org.greenstone.gatherer.collection.CollectionManager; 51 52 import org.greenstone.gatherer.shell.GShell; 52 53 import org.greenstone.gatherer.shell.GShellEvent; … … 90 91 /** A string array used to pass arguments to the phrase retrieval method. */ 91 92 private JTextField title_field = null; 93 private JTextField estimated_size_field = null; 92 94 private JLabel title_label = null; 95 private JLabel estimated_size_label = null; 93 96 private String args[] = null; 94 97 private String cd_title = null; … … 99 102 /** the error message if any */ 100 103 private StringBuffer error_message = null; 104 /** This is the size of the exported stuff on its own (no collections). */ 105 private long total_exported_size = 52000000; 101 106 /** The size of the export prompt screen. */ 102 107 public static final Dimension SIZE = new Dimension(500, 500); … … 138 143 title_label = new JLabel(); 139 144 Dictionary.setText(title_label, "WriteCDImagePrompt.CD_Name"); 145 146 estimated_size_field = new JTextField(); 147 estimated_size_field.setEditable(false); 148 estimated_size_field.setText(Utility.formatFileLength(total_exported_size)); 149 estimated_size_field.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); 150 estimated_size_label = new JLabel(); 151 Dictionary.setText(estimated_size_label, "WriteCDImagePrompt.Size_Label"); 152 140 153 scanForCollections(); 141 154 list.setListData(all_collections); … … 206 219 207 220 // Lower pane 221 JPanel estimated_size_pane = new JPanel(new BorderLayout()); 222 estimated_size_pane.add(estimated_size_label, BorderLayout.WEST); 223 estimated_size_pane.add(estimated_size_field, BorderLayout.CENTER); 224 estimated_size_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); 225 208 226 JPanel button_pane = new JPanel(new GridLayout(1, 2)); 209 227 button_pane.add(ok_button); … … 212 230 213 231 JPanel lower_pane = new JPanel(new BorderLayout()); 232 lower_pane.add(estimated_size_pane, BorderLayout.NORTH); 214 233 lower_pane.add(button_pane, BorderLayout.SOUTH); 215 234 lower_pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); … … 424 443 public void valueChanged(ListSelectionEvent event) 425 444 { 445 // Wait for things to settle down a bit 446 if (event.getValueIsAdjusting()) { 447 return; 448 } 449 426 450 // Can only export when something is ticked 427 451 ok_button.setEnabled(!list.isNothingTicked()); … … 440 464 Dictionary.setText(details_textarea, "DeleteCollectionPrompt.Details", args); 441 465 details_textarea.setCaretPosition(0); 466 467 // Find the size of the "etc", "images" and "index" directories of the collection 468 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection.getShortName()); 469 File etc_directory = new File(collection_directory_path + "etc"); 470 File images_directory = new File(collection_directory_path + "images"); 471 File index_directory = new File(collection_directory_path + "index"); 472 long collection_size_built = getFileSize(etc_directory) + getFileSize(images_directory) + getFileSize(index_directory); 473 474 // Add/subtract it from the total, depending on whether the collection has just been ticked/unticked 475 if (((CheckListEntry) list.getSelectedValue()).isSelected()) { 476 total_exported_size += collection_size_built; 477 } 478 else { 479 total_exported_size -= collection_size_built; 480 } 481 482 // Update the size field 483 estimated_size_field.setText(Utility.formatFileLength(total_exported_size)); 484 } 485 486 487 private long getFileSize(File file) 488 { 489 long file_size = 0; 490 491 // Directory case 492 if (file.isDirectory()) { 493 File files[] = file.listFiles(); 494 for (int i = 0; i < files.length; i++) { 495 file_size += getFileSize(files[i]); 496 } 497 } 498 // File case 499 else { 500 file_size = file.length(); 501 } 502 503 return file_size; 442 504 } 443 505 }
Note:
See TracChangeset
for help on using the changeset viewer.