Changeset 8599


Ignore:
Timestamp:
2004-11-18T15:16:13+13:00 (19 years ago)
Author:
mdewsnip
Message:

Extracted the last of the undo functionality.

Location:
trunk/gli/src/org/greenstone/gatherer/file
Files:
3 edited

Legend:

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

    r8243 r8599  
    3939
    4040    public boolean folder_level = false;
    41     /** true if this should generate an undo event, false for a redo one. */
    42     public boolean undo = true;
    43     /** true if this job should generate an undo event of any kind. */
    44     public boolean undoable = false;
    4541    /** The type of this movement as an byte. */
    4642    public byte type = 0;
     
    6965     * @param dest The files new FileNode parent within the target.
    7066     * @param type The type of this movement as an int, either COPY or DELETE.
    71      * @param undo true if this job some create an undo job when actioned, false for a redo job.
    72      * @param undoable true if this job can generate undo or redo jobs, false otherwise.
    7367     */
    74     public FileJob(long id, DragComponent source, FileNode orig, DragComponent target, FileNode dest, byte type, boolean undo, boolean undoable) {
     68    public FileJob(long id, DragComponent source, FileNode orig, DragComponent target, FileNode dest, byte type) {
    7569    this.id = id;
    7670    this.source = source;
    7771    this.target = target;
    7872    this.type = type;
    79     this.undo = undo;
    80     this.undoable = undoable;
    8173    ///ystem.err.println("New Job: " + type + ", " + source + ", " + target);
    8274    // Dont store FileNodes which can go stale. Store paths instead, which are used to locate current 'fresh' versions of nodes.
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r8595 r8599  
    190190        // Queue the job(s) (this may fail if we are asked to delete a read only file)
    191191        for (int i = 0; i < source_nodes.length; i++) {
    192             queue.addJob(id, source, source_nodes[i], target, target_node, type, true, true, true);
     192            queue.addJob(id, source, source_nodes[i], target, target_node, type, true);
    193193        }
    194194        }
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r8598 r8599  
    9494     * @param parent The files new FileNode parent within the target.
    9595     * @param type The type of this movement as an int, either COPY or DELETE.
    96      * @param undo true if this job should generate undo jobs, false for redo ones.
    97      * @param undoable true if this job can generate undo or redo jobs at all, false otherwise.
    98      */
    99     public void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean undo, boolean undoable, boolean folder_level) {
    100     addJob(id, source, child, target, parent, type, undo, undoable, folder_level, -1);
    101     }
    102 
    103     synchronized private void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean undo, boolean undoable, boolean folder_level, int position) {
    104     FileJob job = new FileJob(id, source, child, target, parent, type, undo, undoable);
     96     */
     97    public void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean folder_level) {
     98    addJob(id, source, child, target, parent, type, folder_level, -1);
     99    }
     100
     101    synchronized private void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean folder_level, int position) {
     102    FileJob job = new FileJob(id, source, child, target, parent, type);
    105103    job.folder_level = folder_level;
    106104        DebugStream.println("Adding job: " + job);
     
    186184        // Retrieve the next job
    187185        int position = queue.size() - 1;
    188         FileJob job = removeJob(position);
     186        FileJob job = null;
     187        if (position >= 0) {
     188            job = (FileJob) queue.remove(position);
     189        }
     190
    189191        if (job != null) {
    190192            ///ystem.err.println("Found job: " + job);
     
    357359                    SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, new_record);
    358360                    new_node = new_record;
    359                    
    360                     // create undo job
    361                     if(job.undoable) {
    362                         job.undoable = false;
    363                     }
    364361                    new_record = null;
    365362                    }
     
    369366                    // create new record
    370367                    FileNode directory_record = new FileNode(target_file);
    371                     ///ystem.err.println("Directory record = " + directory_record + " (" + target_file.getAbsolutePath() + ")");
    372368                    SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, directory_record);
    373369                    // Why is this not happening eh?
     
    377373                    target_file.mkdirs();
    378374                    new_node = directory_record;
    379                     // create undo job
    380                     if(job.undoable) {
    381                         job.undoable = false;
    382                     }
    383375                    }
    384376                    // Else inform the users that a directory already exists and files will be copied into it
     
    398390                    for(int i = 0; i < origin_node.getChildCount(); i++) {
    399391                    child_record = (FileNode) origin_node.getChildAt(i);
    400                     addJob(job.ID(), job.source, child_record, job.target, directory_record, job.type, job.undo, false, false, position);
     392                    addJob(job.ID(), job.source, child_record, job.target, directory_record, job.type, false, position);
    401393                    }
    402394                    child_record = null;
     
    486478                    FileNode child_record = (FileNode) origin_node.get(i);
    487479                    ///atherer.println("Queuing: " + child_record);
    488                     addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, job.undo, false, false, position);
     480                    addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, false, position);
    489481                } 
    490482                }
     
    666658    }
    667659    }
    668 
    669 
    670     private FileJob removeJob(int position) {
    671     FileJob job = null;
    672     if(queue.size() > 0) {
    673         job = (FileJob) queue.remove(position);
    674     }
    675     return job;
    676     }
    677660}
Note: See TracChangeset for help on using the changeset viewer.