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.netbeans.modules.javacvs.*;
import org.netbeans.modules.javacvs.commands.*;
import org.netbeans.modules.javacvs.events.*;
import org.netbeans.modules.javacvs.customizers.TagParamInput;

import org.netbeans.lib.cvsclient.event.*;
import org.netbeans.lib.cvsclient.command.tag.*;
import org.netbeans.lib.cvsclient.command.*;
import org.netbeans.modules.javacvs.caching.*;
import org.openide.filesystems.FileObject;



/** This class implements the cvs tag command.
 * @author mkleint
 */
public class CvsTag extends CacheUpdatingFsCommand {
    
    TagCommand command;
    
    private boolean checkThatUnmodified;

    private boolean deleteTag;

    private boolean makeBranchTag;

    private boolean overrideExistingTag;

    private String tag;

    private String tagByDate;

    private String tagByRevision;
    
    /**
     * to be recursive is default behaviour of command.
     */
    private boolean recursive = true;
    
    private TagImpl tagImpl;
    
    /** Creates new CvsTag instance.
     */    
    public CvsTag() {
        super();
        tagImpl = new TagImpl();
    }
    
    /** Creates new CvsTag instance.
     */
    public CvsTag(File[] filesToUpdate, ClientProvider fs) {
        super(fs);
        setFiles(filesToUpdate);
        tagImpl = new TagImpl();
    }
    
    public CvsCommand getImpl() {
        return tagImpl;
    }    
    
    public FsTag getTagImpl() {
        return tagImpl;
    }
    
    public String getName() {
        return NbBundle.getBundle(CvsTag.class).getString("CvsTag.name"); // NOI18N
    }

    
    
    protected void initCommand(boolean commandIsRunning) {
        // here the the commands is initiated just right before running the command
        clearCommandList();
        command = new TagCommand();
        command.setFiles(getFiles());
        setCommandArguments(command);
        toDoCommands.addElement(command);
        super.initCommand(commandIsRunning);
    }

    /**
     * return the library command that is considered main command.
     * that one is used for loading from
     */
    protected Class getMainCvsCommand() {
        return TagCommand.class;
    }

    protected void finishedCommand() {
        // called when the communication with server ends and the command thread is about to end..
        // used for calling visualizer stuff..
        fireUpdateCache();
        super.finishedCommand();
    }
    
    protected void executeFailed(Exception exc) {
        // do refresh.. refresh or recursive refresh, depending on getRecursive()
        // TODO needs some optimizing..
        fireUpdateCache();        
        super.executeFailed(exc);
    }
    
    
    /** Called when file status information has been received
     */
    public void fileInfoGenerated(FileInfoEvent e) {
        FileInfoContainer fInfo = e.getInfoContainer();
        if (fInfo != null) {
            if (fInfo instanceof DefaultFileInfoContainer) {
                DefaultFileInfoContainer info = (DefaultFileInfoContainer)fInfo;
                updateCache(info);
            }
        }
        super.fileInfoGenerated(e);
    }
    
    /** Returns true if checking for unmodified files is enabled. (-c switch)
     */
    public boolean isCheckThatUnmodified()
    {
        return checkThatUnmodified;
    }

    /** Enables the check for unmodified files. (-c)
     */
    public void setCheckThatUnmodified(boolean checkThatUnmodified)
    {
        this.checkThatUnmodified = checkThatUnmodified;
    }

    /** Returnes true if the tag should be deleted (-d switch)
     */
    public boolean isDeleteTag()
    {
        return deleteTag;
    }

    /** Sets whether the tag should be deleted (true) (-d switch)
     */
    public void setDeleteTag(boolean deleteTag)
    {
        this.deleteTag = deleteTag;
    }

    /** Returns true if the tag should be a branch tag. (-b switch)
     */
    public boolean isMakeBranchTag()
    {
        return makeBranchTag;
    }

    /** Sets whether the tag should be a branch tag. (-b switch)
     */
    public void setMakeBranchTag(boolean makeBranchTag)
    {
        this.makeBranchTag = makeBranchTag;
    }

    /** Returns true to indicate that existing tag will be overridden. (-f switch)
     */
    public boolean isOverrideExistingTag()
    {
        return overrideExistingTag;
    }

    /** Sets whether existing tags should be overridden. (-f switch)
     */
    public void setOverrideExistingTag(boolean overrideExistingTag)
    {
        this.overrideExistingTag = overrideExistingTag;
    }

    /** Returns the tag that should be added or deleted.
     */
    public String getTag()
    {
        return tag;
    }

    /** Sets the tag that should be added or deleted.
     */
    public void setTag(String tag)
    {
        this.tag = tag;
    }

    /** Returns the latest date of a revision to be tagged. (-D switch)
     * @return date value. the latest Revision not later ten date is tagged.
     */
    public String getTagByDate()
    {
        return tagByDate;
    }

    /**
     * Sets the latest date of a revision to be tagged. (-D switch)
     * @param tagDate New value of property tagDate.
     */
    public void setTagByDate(String tagDate)
    {
        tagByDate = tagDate;
    }

    /** Sets the latest date of a revision to be tagged. Can be both a number and a tag. (-r switch)
     * @return Value of property tagRevision.
     */
    public String getTagByRevision()
    {
        return tagByRevision;
    }

    /** Sets the latest date of a revision to be tagged. Can be both a number and a tag. (-r switch)
     * @param tagRevision New value of property tagRevision.
     */
    public void setTagByRevision(String tagRevision)
    {
        tagByRevision = tagRevision;
    }    
    
    /** 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 String getCvsrcEntry() {
        String retValue;
        String message = getTag();
        setTag(null);
        retValue = super.getCvsrcEntry();
        setTag(message);
        return retValue;
    }        
    
    public class TagImpl extends FsTag implements FileSystemCommandImpl {
        public TagImpl() {
        }

        public FileSystemCommand getOuterClassInstance() {
            return CvsTag.this;
        }        
        /** Returns true to indicate that existing tag will be overridden. (-f switch)
         */
        public boolean isOverrideExistingTag() {
            return CvsTag.this.isOverrideExistingTag();
        }
        
        public void removeCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) {
            CvsTag.this.removeCommandErrorListener(commErrListener);
        }
        
        /** Sets whether the tag should be a branch tag. (-b switch)
         */
        public void setMakeBranchTag(boolean makeBranchTag) {
            CvsTag.this.setMakeBranchTag(makeBranchTag);
        }
        
        /** Sets the tag that should be added or deleted.
         */
        public void setTag(String tag) {
            CvsTag.this.setTag(tag);
        }
        
        public void addCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) {
            CvsTag.this.addCommandErrorListener(commErrListener);
        }
        
        /** Returns true if checking for unmodified files is enabled. (-c switch)
         */
        public boolean isCheckThatUnmodified() {
            return CvsTag.this.isCheckThatUnmodified();
        }
        
        /** Returns the tag that should be added or deleted.
         */
        public String getTag() {
            return CvsTag.this.getTag();
        }
        
        /** 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 CvsTag.this.clone();
        }
        
        /** Sets whether existing tags should be overridden. (-f switch)
         */
        public void setOverrideExistingTag(boolean overrideExistingTag) {
            CvsTag.this.setOverrideExistingTag(overrideExistingTag);
        }
        
        /** Sets recursive (-R switch) or local (-l switch) behaviour.
         */
        public void setRecursive(boolean recursive) {
            CvsTag.this.setRecursive(recursive);
        }
        
        /** Starts the thread with the command - executes the run() method.
         */
        public void startCommand() {
            CvsTag.this.startCommand();
        }
        
        /** Sets whether the tag should be deleted (true) (-d switch)
         */
        public void setDeleteTag(boolean deleteTag) {
            CvsTag.this.setDeleteTag(deleteTag);
        }
        
        /** Sets the latest date of a revision to be tagged. Can be both a number and a tag. (-r switch)
         * @return Value of property tagRevision.
         */
        public String getTagByRevision() {
            return CvsTag.this.getTagByRevision();
        }
        
        /** Returns true if the tag should be a branch tag. (-b switch)
         */
        public boolean isMakeBranchTag() {
            return CvsTag.this.isMakeBranchTag();
        }
        
        /** Enables the check for unmodified files. (-c)
         */
        public void setCheckThatUnmodified(boolean checkThatUnmodified) {
            CvsTag.this.setCheckThatUnmodified(checkThatUnmodified);
        }
        
        /** Returns the latest date of a revision to be tagged. (-D switch)
         * @return date value. the latest Revision not later ten date is tagged.
         */
        public String getTagByDate() {
            return CvsTag.this.getTagByDate();
        }
        
        /** 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) {
            CvsTag.this.removeDisplayerListener(listener);
        }
        
        /**
         * Sets the latest date of a revision to be tagged. (-D switch)
         * @param tagDate New value of property tagDate.
         */
        public void setTagByDate(String tagDate) {
            CvsTag.this.setTagByDate(tagDate);
        }
        
        /** 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) { CvsTag.this.addDisplayerListener(listener); } /** Returns recursive (-R switch) or local (-l switch) behaviour. */ public boolean isRecursive() { return CvsTag.this.isRecursive(); } /** Sets the latest date of a revision to be tagged. Can be both a number and a tag. (-r switch) * @param tagRevision New value of property tagRevision. */ public void setTagByRevision(String tagRevision) { CvsTag.this.setTagByRevision(tagRevision); } public void setFileObjects(FileObject[] fileObjects) { CvsTag.this.setFileObjects(fileObjects); } /** Returnes true if the tag should be deleted (-d switch) */ public boolean isDeleteTag() { return CvsTag.this.isDeleteTag(); } public FsGlobalOptions getGlobalOptions() { FsGlobalOptions retValue; retValue = new FsGlobalOptionsImpl(CvsTag.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.