Changeset 8595
- Timestamp:
- 2004-11-18T11:56:29+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r8576 r8595 68 68 */ 69 69 public FileManager() { 70 queue = new FileQueue( false);70 queue = new FileQueue(); 71 71 queue.start(); 72 72 } -
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r8576 r8595 40 40 import org.greenstone.gatherer.metadata.MetadataValue; 41 41 import org.greenstone.gatherer.metadata.MetadataXMLFileManager; 42 import org.greenstone.gatherer.util.ArrayTools;43 42 import org.greenstone.gatherer.util.DragComponent; 44 43 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; … … 51 50 public class FileQueue 52 51 extends Thread 53 implements TreeSelectionListener{52 { 54 53 /** When someone requests the movement queue to be dumped this cancel flag is set to true. */ 55 54 private boolean cancel_action = false; 56 /** A temporary mapping from currently existing FileNode folder to their equivelent FileNode folder within the undo managers tree. */57 private HashMap completed_folder_mappings = new HashMap();58 55 59 56 /** The button which controls the stopping of the file queue. */ 60 57 private JButton stop_button = null; 61 58 62 /** true to cause this file queue to return from run() as soon as there are no jobs left on the queue. Useful for undo jobs which must occur before a specific action. */63 private boolean return_immediately = false;64 /** We are only allowed to wait under specific circumstances. */65 /* private boolean wait_allowed = true; */66 59 /** true if the user has selected yes to all from a file 'clash' dialog. */ 67 60 private boolean yes_to_all = false; 68 /** A temporary mapping from currently existing FileNodes to the potential FileNode folder within the undo managers tree. */69 private HashMap recycle_folder_mappings = new HashMap();70 61 /** A label explaining the current moving files status. */ 71 62 private JLabel file_status = null; 72 63 /** A list containing a queue of waiting movement jobs. */ 73 private ArrayList queue ;64 private ArrayList queue = null; 74 65 /** A progress bar which shows how many bytes, out of the total size of bytes, has been moved. */ 75 66 private LongProgressBar progress = null; 76 /** The last piece of text shown on the file status label, just incase we are displaying a very temporary message. */ 77 private String previous = null; 67 68 78 69 /** Constructor. 79 * @param return_immediately true to cause this file queue to return from run() as soon as there are no jobs left on the queue. 80 * @see org.greenstone.gatherer.Configuration 81 * @see org.greenstone.gatherer.gui.Coloring 82 * @see org.greenstone.gatherer.gui.LongProgressBar 83 */ 84 public FileQueue(boolean return_immediately) { 85 this.return_immediately = return_immediately; 70 */ 71 public FileQueue() { 86 72 this.queue = new ArrayList(); 87 String args[] = new String[2];88 args[0] = "0";89 args[1] = "0";90 73 file_status = new JLabel(); 91 Dictionary.setText(file_status, "FileActions. Selected", args);74 Dictionary.setText(file_status, "FileActions.No_Activity"); 92 75 progress = new LongProgressBar(); 93 76 progress.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); … … 95 78 progress.setString(Dictionary.get("FileActions.No_Activity")); 96 79 progress.setStringPainted(true); 97 args = null;98 80 } 99 81 … … 381 363 if(job.undoable) { 382 364 job.undoable = false; 383 if(job.type == FileJob.COPY) {384 // A copy is undone with a delete, so it doesn't really matter where the file originally came from (we're not moving it back there, but into the recycle bin). You may also notice we don't make use of the target parent record. This is because no undo action needs this information, and even if it did it could simply ask for records parent!385 // Gatherer.c_man.undo.addUndo(job.ID(), UndoManager.FILE_COPY, null, null, job.target, new_record, job.undo);386 }387 else {388 // Movements however do need a source and source parent so the file can be moved back to the correct place.389 // Gatherer.c_man.undo.addUndo(job.ID(), UndoManager.FILE_MOVE, job.source, (FileNode)origin_node.getParent(), job.target, new_record, job.undo);390 }391 365 } 392 366 new_record = null; … … 408 382 if(job.undoable) { 409 383 job.undoable = false; 410 if(job.type == FileJob.COPY) {411 // A copy is undone with a delete, so it doesn't really matter where the file originally came from (we're not moving it back there, but into the recycle bin). You may also notice we don't make use of the target parent record. This is because no undo action needs this information, and even if it did it could simply ask for records parent!412 }413 else {414 // Movements however do need a source and source parent so the file can be moved back to the correct place.415 }416 384 } 417 385 } … … 517 485 // Else the source is a directory and it has children remaining 518 486 else if(child_list != null && child_list.length > 0) { 519 ///ystem.err.print("Nonempty directory -> ");520 ///atherer.println("Directory is non-empty. Remove children first.");521 487 FileNode recycle_folder_record = null; 522 488 // Don't worry about all this for true file move actions. 523 489 if(job.type == FileJob.DELETE) { 524 490 // queue all of its children, (both filtered and non-filtered), but for deleting only. Don't queue jobs for a current move event, as they would be queued as part of copying. I have no idea way, per sec, however the children within the origin node are always invalid during deletion (there are several copies of some nodes?!?). I'll check that each child is only added once. 525 ///ystem.err.println("Directory has " + origin_node.getChildCount() + " children.");526 ///ystem.err.println("Directory actually has " + child_list.length + " children.");527 491 origin_node.refresh(); 528 ///atherer.println("Directory has " + origin_node.getChildCount() + " children.");529 ///atherer.println("Directory actually has " + child_list.length + " children.");530 492 for(int i = 0; i < origin_node.size(); i++) { 531 493 FileNode child_record = (FileNode) origin_node.get(i); 532 494 ///atherer.println("Queuing: " + child_record); 533 495 addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, job.undo, false, false, position); 534 //if(recycle_folder_record != null) {535 // recycle_folder_mappings.put(child_record, recycle_folder_record);536 //}537 496 } 538 497 } … … 579 538 progress.setString(Dictionary.get("FileActions.No_Activity")); 580 539 yes_to_all = false; 581 completed_folder_mappings.clear();582 recycle_folder_mappings.clear();583 584 // Now wait if applicable.585 if(return_immediately) {586 return;587 }588 ///ystem.err.println("Waiting");589 540 wait(); 590 541 } … … 604 555 } 605 556 606 /** Called when the user makes some selection in one of the trees we are listening to. From this we update the status details. */607 public void valueChanged(TreeSelectionEvent event) {608 JTree tree = (JTree) event.getSource();609 if(tree.getSelectionCount() > 0) {610 TreePath selection[] = tree.getSelectionPaths();611 int file_count = 0;612 int dir_count = 0;613 for(int i = 0; i < selection.length; i++) {614 TreeNode record = (TreeNode) selection[i].getLastPathComponent();615 if(record.isLeaf()) {616 file_count++;617 }618 else {619 dir_count++;620 }621 record = null;622 }623 selection = null;624 }625 tree = null;626 }627 557 628 558 synchronized private void clearJobs() { -
trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java
r8588 r8595 199 199 FileNode node = (FileNode) collection_tree.getModel().getRoot(); 200 200 Gatherer.f_man.newFolder(collection_tree, node); 201 //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.No_Parent_For_New_Folder"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);202 201 } 203 202 } … … 234 233 workspace_tree.addMouseListener(Gatherer.g_man.foa_listener); 235 234 workspace_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener); 236 workspace_tree.addTreeSelectionListener(file_queue);237 235 workspace_tree.putClientProperty("JTree.lineStyle", "Angled"); 238 236 workspace_tree.setBackgroundNonSelectionColor(Configuration.getColor("coloring.workspace_tree_background", false)); … … 255 253 collection_pane.setSize(TREE_SIZE); 256 254 257 //args = new String[1];258 //args[0] = Dictionary.get("Collection.No_Collection");259 255 collection_label = new JLabel(); 260 256 collection_label.setOpaque(true); … … 262 258 263 259 collection = Gatherer.c_man.getRecordSet(); 264 if (collection != null) {260 if (collection != null) { 265 261 collection_tree = new DragTree(Utility.COLLECTION_TREE, collection, null, true); 266 262 collection_tree.setEnabled(true); … … 275 271 collection_tree.addMouseListener(mouse_listener); 276 272 collection_tree.addMouseListener(Gatherer.g_man.foa_listener); 277 collection_tree.addTreeSelectionListener(file_queue);278 273 collection_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener); 279 274 collection_tree.putClientProperty("JTree.lineStyle", "Angled"); … … 283 278 collection_tree.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false)); 284 279 collection_tree.setRootVisible(false); 285 //collection_tree.setRootVisible(true);286 280 287 281 collection_scroll = new JScrollPane(collection_tree); 288 282 289 283 collection_filter = Gatherer.g_man.getFilter(collection_tree); 290 if (collection != null) {284 if (collection != null) { 291 285 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 292 286 } … … 306 300 307 301 JPanel file_pane = new JPanel(); 308 //file_pane.setBackground(Color.white);309 //JPanel job_pane = new JPanel();310 //job_pane.setBackground(Color.white);311 302 JPanel progress_pane = new JPanel(); 312 //progress_pane.setBackground(Color.white);313 303 JLabel file_status = file_queue.getFileStatus(); 314 //JLabel job_status = job_queue.getJobStatus();315 304 316 305 JProgressBar progress_bar = file_queue.getProgressBar(); … … 341 330 tree_pane.setDividerLocation(TREE_SIZE.width - 10); 342 331 343 //job_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));344 //job_pane.setLayout(new BorderLayout());345 //job_pane.add(job_status, BorderLayout.CENTER);346 347 332 file_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); 348 333 file_pane.setLayout(new BorderLayout()); … … 356 341 inner_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10,10,10,10), BorderFactory.createLoweredBevelBorder())); 357 342 inner_pane.setLayout(new GridLayout(2,1)); 358 //inner_pane.add(job_pane);359 343 inner_pane.add(file_pane); 360 344 inner_pane.add(progress_pane); … … 364 348 365 349 control_pane.setLayout(new BorderLayout()); 366 //control_pane.add(new_folder, BorderLayout.WEST);367 350 control_pane.add(inner_pane, BorderLayout.CENTER); 368 351 control_pane.add(button_pane, BorderLayout.EAST);
Note:
See TracChangeset
for help on using the changeset viewer.