alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.javacvs.commands;


import org.openide.util.NbBundle;
import java.io.*;
import java.util.*;
import java.beans.*;
import org.openide.filesystems.FileObject;
import org.netbeans.modules.javacvs.*;
import org.netbeans.lib.cvsclient.event.*;
import org.netbeans.lib.cvsclient.command.log.*;
import org.netbeans.lib.cvsclient.command.*;
import org.netbeans.modules.javacvs.commands.*;
import org.netbeans.modules.javacvs.*;
import org.netbeans.modules.javacvs.customizers.LogParamInput;
import org.netbeans.modules.javacvs.events.*;
/** This class implements the cvs log command.
 *
 * @author mkleint
 */
public class CvsLog extends FileSystemCommand {
    /**
     * Holds value of property defaultBranch.
     */
    private boolean defaultBranch;
    
    /**
     * Holds value of property dateFilter.
     */
    private String dateFilter;
    
    /**
     * Holds value of property headerOnly.
     */
    private boolean headerOnly;
    
    /**
     * Holds value of property noTags.
     */
    private boolean noTags;
    
    /**
     * Holds value of property revisionFilter.
     */
    private String revisionFilter;
    
    /**
     * Holds value of property stateFilter.
     */
    private String stateFilter;
    
    /**
     * Holds value of property userFilter.
     */
    private String userFilter;
    
    /**
     * Holds value of property headerAndDescOnly.
     */
    private boolean headerAndDescOnly;
    
    /**
     * to be recursive is default behaviour of command.
     */
    private boolean recursive = true;
    
    private FsLog logImpl;
    
    /** Creates new CvsLog instance
     */
    public CvsLog(File[] filesToCheck, ClientProvider fs) {
        super(fs);
        setFiles(filesToCheck);
        logImpl = new LogImpl();
    }
    
    /** Creates new CvsLog instance
     */
    public CvsLog() {
        super();
        logImpl = new LogImpl();
    }
    
    public String getName() {
        return NbBundle.getBundle(CvsLog.class).getString("CvsLog.name"); // NOI18N
    }
    
    public CvsCommand getImpl() {
        return logImpl;
    }
    
    public FsLog getLogImpl() {
        return logImpl;
    }
    
    protected void initCommand(boolean commandIsRunning) {
        // here the the commands is initiated just right before running the command
        clearCommandList();
        int dirNum = 0;
        LogCommand command;
        File[] files = new File[getFiles().length];
        System.arraycopy(getFiles(),0,files,0, getFiles().length);
        
        for (int index = 0; index < files.length; index++) {
            if (files[index].isDirectory()) {
                // each directory status command is sent separately..
                //that way just one UI component is run after finish of the command
                command = new LogCommand();
                //              command.setDirectoryCheck(true);
                File[] fls = new File[1];
                fls[0] = files[index];
                command.setFiles(fls);
                setCommandArguments(command);
                toDoCommands.addElement(command);
                files[index] = null;
                dirNum = dirNum + 1;
            }
        }
        // now proceed all single files in one batch.
        if (dirNum == files.length) {
            super.initCommand(commandIsRunning);
            return; // no files to check status on.
        }
        File[] singleFiles = new File[files.length - dirNum];
        int singleIndex = 0;
        for (int ind = 0; ind < files.length; ind++) {
            if (files[ind] != null) {
                singleFiles[singleIndex] = files[ind];
                singleIndex = singleIndex + 1;
            }
        }
        command = new LogCommand();
        //        command.setDirectoryCheck(false);
        command.setFiles(singleFiles);
        setCommandArguments(command);
        toDoCommands.addElement(command);
        // just add oen command to the queue
        super.initCommand(commandIsRunning);
    }
    
    
    protected void beforeEachExecute() {
        super.beforeEachExecute();
    }
    
    protected void afterEachExecute() {
        super.afterEachExecute();
    }
    
    protected void executeFailed(Exception exc) {
        stopCommand();
        super.executeFailed(exc);
    }
    
    /**
     * Called when file status information has been received
     */
    public void fileInfoGenerated(FileInfoEvent e) {
        super.fileInfoGenerated(e);
    }
    
    
    /**
     * return the library command that is considered main command.
     * that one is used for loading from
     */
    protected Class getMainCvsCommand() {
        return LogCommand.class;
    }
    
    /**
     * Getter for property defaultBranch, equals the command-line CVS switch
     * "-b".
     * @return Value of property defaultBranch.
     */
    public boolean isDefaultBranch() {
        return defaultBranch;
    }
    
    /**
     * Setter for property defaultBranch, equals the command-line CVS switch
     * "-b".
     * @param defaultBranch New value of property defaultBranch.
     */
    public void setDefaultBranch(boolean defaultBranch) {
        this.defaultBranch = defaultBranch;
    }
    
    /**
     * Getter for property dateFilter, equals the command-line CVS switch "-d".
     * @return Value of property dateFilter.
     */
    public String getDateFilter() {
        return dateFilter;
    }
    
    /** Setter for property dateFilter, equals the command-line CVS switch "-d".
     * @param dateFilter New value of property dateFilter.
     */
    public void setDateFilter(String dateFilter) {
        this.dateFilter = dateFilter;
    }
    
    /** Getter for property headerOnly, equals the command-line CVS switch "-h".
     * @return Value of property headerOnly.
     */
    public boolean isHeaderOnly() {
        return headerOnly;
    }
    
    /** Setter for property headerOnly, equals the command-line CVS switch "-h".
     * @param headerOnly New value of property headerOnly.
     */
    public void setHeaderOnly(boolean headerOnly) {
        this.headerOnly = headerOnly;
    }
    
    /** Getter for property noTags, equals the command-line CVS switch "-N".
     * @return Value of property noTags.
     */
    public boolean isNoTags() {
        return noTags;
    }
    
    /** Setter for property noTags, equals the command-line CVS switch "-N".
     * @param noTags New value of property noTags.
     */
    public void setNoTags(boolean noTags) {
        this.noTags = noTags;
    }
    
    /** Getter for property revisionFilter, equals the command-line CVS switch "-r".
     * @return Value of property revisionFilter.
     */
    public String getRevisionFilter() {
        return revisionFilter;
    }
    
    /** Setter for property revisionFilter, equals the command-line CVS switch "-r".
     * @param revisionFilter New value of property revisionFilter.
     * empty string means latest revision of default branch.
     */
    public void setRevisionFilter(String revisionFilter) {
        this.revisionFilter = revisionFilter;
    }
    
    /** Getter for property stateFilter, equals the command-line CVS switch "-s".
     * @return Value of property stateFilter.
     */
    public String getStateFilter() {
        return stateFilter;
    }
    
    /** Setter for property stateFilter, equals the command-line CVS switch "-s".
     * @param stateFilter New value of property stateFilter.
     */
    public void setStateFilter(String stateFilter) {
        this.stateFilter = stateFilter;
    }
    
    /** Getter for property userFilter, equals the command-line CVS switch "-w".
     * @return Value of property userFilter,  empty string means the current user.
     */
    public String getUserFilter() {
        return userFilter;
    }
    
    /** Setter for property userFilter, equals the command-line CVS switch "-w".
     * @param userFilter New value of property userFilter.
     */
    public void setUserFilter(String userFilter) {
        this.userFilter = userFilter;
    }
    
    /** Getter for property headerAndDescOnly, equals the command-line CVS switch "-t".
     * @return Value of property headerAndDescOnly.
     */
    public boolean isHeaderAndDescOnly() {
        return headerAndDescOnly;
    }
    
    /** Setter for property headerAndDescOnly, equals the command-line CVS switch "-t".
     * @param headerAndDescOnly New value of property headerAndDescOnly.
     */
    public void setHeaderAndDescOnly(boolean headerAndDescOnly) {
        this.headerAndDescOnly = headerAndDescOnly;
    }
    
    /** Sets recursive (-R switch) or local (-l switch) behaviour.
     */
    public void setRecursive(boolean recursive) {
        this.recursive = recursive;
    }
    
    /** Returns recursive (-R switch) or local (-l switch) behaviour.
     */
    public boolean isRecursive() {
        return recursive;
    }
    
    public class LogImpl extends FsLog implements FileSystemCommandImpl {
        public LogImpl() {
        }

        public FileSystemCommand getOuterClassInstance() {
            return CvsLog.this;
        }        
        
        /**
         * Getter for property defaultBranch, equals the command-line CVS switch
         * "-b".
         * @return Value of property defaultBranch.
         */
        public boolean isDefaultBranch() {
            return CvsLog.this.isDefaultBranch();
        }
        
        /** Getter for property noTags, equals the command-line CVS switch "-N".
         * @return Value of property noTags.
         */
        public boolean isNoTags() {
            return CvsLog.this.isNoTags();
        }
        
        /** Getter for property headerOnly, equals the command-line CVS switch "-h".
         * @return Value of property headerOnly.
         */
        public boolean isHeaderOnly() {
            return CvsLog.this.isHeaderOnly();
        }
        
        /** Setter for property noTags, equals the command-line CVS switch "-N".
         * @param noTags New value of property noTags.
         */
        public void setNoTags(boolean noTags) {
            CvsLog.this.setNoTags(noTags);
        }
        
        /** Setter for property stateFilter, equals the command-line CVS switch "-s".
         * @param stateFilter New value of property stateFilter.
         */
        public void setStateFilter(String stateFilter) {
            CvsLog.this.setStateFilter(stateFilter);
        }
        
        /** Setter for property headerAndDescOnly, equals the command-line CVS switch "-t".
         * @param headerAndDescOnly New value of property headerAndDescOnly.
         */
        public void setHeaderAndDescOnly(boolean headerAndDescOnly) {
            CvsLog.this.setHeaderAndDescOnly(headerAndDescOnly);
        }
        
        /** Setter for property revisionFilter, equals the command-line CVS switch "-r".
         * @param revisionFilter New value of property revisionFilter.
         * empty string means latest revision of default branch.
         */
        public void setRevisionFilter(String revisionFilter) {
            CvsLog.this.setRevisionFilter(revisionFilter);
        }
        
        /** Getter for property userFilter, equals the command-line CVS switch "-w".
         * @return Value of property userFilter,  empty string means the current user.
         */
        public String getUserFilter() {
            return CvsLog.this.getUserFilter();
        }
        
        /** Getter for property headerAndDescOnly, equals the command-line CVS switch "-t".
         * @return Value of property headerAndDescOnly.
         */
        public boolean isHeaderAndDescOnly() {
            return CvsLog.this.isHeaderAndDescOnly();
        }
        
        /** Sets recursive (-R switch) or local (-l switch) behaviour.
         */
        public void setRecursive(boolean recursive) {
            CvsLog.this.setRecursive(recursive);
        }
        
        /** Setter for property dateFilter, equals the command-line CVS switch "-d".
         * @param dateFilter New value of property dateFilter.
         */
        public void setDateFilter(String dateFilter) {
            CvsLog.this.setDateFilter(dateFilter);
        }
        
        /**
         * Getter for property dateFilter, equals the command-line CVS switch "-d".
         * @return Value of property dateFilter.
         */
        public String getDateFilter() {
            return CvsLog.this.getDateFilter();
        }
        
        /** Getter for property revisionFilter, equals the command-line CVS switch "-r".
         * @return Value of property revisionFilter.
         */
        public String getRevisionFilter() {
            return CvsLog.this.getRevisionFilter();
        }
        
        /** Getter for property stateFilter, equals the command-line CVS switch "-s".
         * @return Value of property stateFilter.
         */
        public String getStateFilter() {
            return CvsLog.this.getStateFilter();
        }
        
        /** Returns recursive (-R switch) or local (-l switch) behaviour.
         */
        public boolean isRecursive() {
            return CvsLog.this.isRecursive();
        }
        
        /** Setter for property userFilter, equals the command-line CVS switch "-w".
         * @param userFilter New value of property userFilter.
         */
        public void setUserFilter(String userFilter) {
            CvsLog.this.setUserFilter(userFilter);
        }
        
        /** Setter for property headerOnly, equals the command-line CVS switch "-h".
         * @param headerOnly New value of property headerOnly.
         */
        public void setHeaderOnly(boolean headerOnly) {
            CvsLog.this.setHeaderOnly(headerOnly);
        }
        
        /**
         * Setter for property defaultBranch, equals the command-line CVS switch
         * "-b".
         * @param defaultBranch New value of property defaultBranch.
         */
        public void setDefaultBranch(boolean defaultBranch) {
            CvsLog.this.setDefaultBranch(defaultBranch);
        }
        
        public void setFileObjects(FileObject[] fileObjects) {
            CvsLog.this.setFileObjects(fileObjects);
        }
        
        public void addCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) {
            CvsLog.this.addCommandErrorListener(commErrListener);
        }
        
        /** Clones the instance of the command.
         * @return Returns the cloned object.
         * @throws CloneNotSupportedException if clone is not supported by subclasses, it throws CloneNotSupportedException
         */
        public Object clone() throws CloneNotSupportedException {
            return new LogImpl();
        }
        
        /** Add a CommandDisplayerListener to the FilesystemCommand.
         * 
All UI communication and display of output should be handled via the CommandDisplayerListeners. * * @param listener The listener to add. * */ public void addDisplayerListener(CommandDisplayerListener listener) { CvsLog.this.addDisplayerListener(listener); } /** Removes a CommandDisplayerListener from the FilesystemCommand. * All the listeners are removed once the command ends. * * @param listener the listener to remove */ public void removeDisplayerListener(CommandDisplayerListener listener) { CvsLog.this.removeDisplayerListener(listener); } public void removeCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) { CvsLog.this.removeCommandErrorListener(commErrListener); } /** Starts the thread with the command - executes the run() method. */ public void startCommand() { CvsLog.this.startCommand(); } public FsGlobalOptions getGlobalOptions() { FsGlobalOptions retValue; retValue = new FsGlobalOptionsImpl(CvsLog.this.getGlobalOptions()); return retValue; } } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.