|
What this is
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.customizers.UpdateParamInput; import org.netbeans.modules.javacvs.*; import org.netbeans.modules.javacvs.events.*; import org.netbeans.modules.javacvs.commands.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.command.update.*; import org.netbeans.lib.cvsclient.command.DefaultFileInfoContainer; import org.netbeans.lib.cvsclient.command.checkout.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.modules.javacvs.caching.*; /** this class implements the cvs update command. * @author mkleint */ public class CvsUpdate extends CacheUpdatingFsCommand { UpdateCommand command; /** first of the 2 possible -j switches that merge 2 different revisions. * If only this property is set, the current working file is merged * with the specified one. */ private String mergeRevision1; /** * Use this keyword substitution for the command. * does not include the -k switch part. */ private KeywordSubstitutionOptions keywordSubst; /** Second of the 2 possible -j switches that merge 2 different revisions. * Assumes the first -j switch (mergeRevision1 property is set). * Then the update commands merges the sources of these 2 revisons specified * by the -j switches. */ private String mergeRevision2; /** * Whether to prune directories, i.e. remove any directories that do not * contain any files. This is the -P option in command-line CVS) */ private boolean pruneDirectories; /** * Determines whether to get a clean copy from the server. * This overrides even locally modified files. */ private boolean cleanCopy; /** * Determines wheather the output of the command is processed on standard output. * Default is false. If true, nothing is done to local working files. */ private boolean pipeToOutput; /** * Resets any sticky tags/dates/options imposed on the updated file(s). */ private boolean resetStickyOnes; /** * Whether to build directories, like checkout does (this is the -d option * in command-line CVS) */ private boolean buildDirectories; /** * Equals the -r switch of command-line cvs. */ private String updateByRevision; /** * equals the -D switch of command line cvs. */ private String updateByDate; /** * Use head revision if a revision meeting criteria set by switches -r/-D * (tag/date) is not found. */ private boolean useHeadIfNotFound; /** * to be recursive is default behaviour of command. */ private boolean recursive = true; private UpdateImpl updateImpl; /** Creates new CvsUpdate instance. */ public CvsUpdate() { super(); updateImpl = new UpdateImpl(); } /** Creates new CvsUpdate instance. */ public CvsUpdate(File[] filesToUpdate, ClientProvider fs) { super(fs); setFiles(filesToUpdate); updateImpl = new UpdateImpl(); } public CvsCommand getImpl() { return updateImpl; } public FsUpdate getUpdateImpl() { return updateImpl; } public String getName() { return NbBundle.getBundle(CvsUpdate.class).getString("CvsUpdate.name"); //NOI18N } protected Class getMainCvsCommand() { return UpdateCommand.class; } /** if no param input was set before staring the command, * the default defined in this method is used */ protected void initCommand(boolean commandIsRunning) { // here the the commands is initiated just right before running the command clearCommandList(); command = new UpdateCommand(); command.setFiles(getFiles()); setCommandArguments(command); toDoCommands.addElement(command); super.initCommand(commandIsRunning); if (isResetStickyOnes() || getUpdateByDate() != null || getUpdateByRevision() != null) { setFullEntriesUpdate(true); prepareCache(getFiles(), isRecursive()); } lockFilesToBeModified(getFiles(), isRecursive()); } protected void finishedCommand() { // called when the communication with server ends and the command thread is about to end.. // used for calling visualizer stuff.. fireUpdateCache(); unlockFilesToBeModified(); super.finishedCommand(); } protected void executeFailed(Exception exc) { // do refresh.. refresh or recursive refresh, depending on getRecursive() // TODO needs some optimizing.. fireUpdateCache(); unlockFilesToBeModified(); super.executeFailed(exc); } /** * Called when file status information has been received */ public void fileInfoGenerated(FileInfoEvent e) { FileInfoContainer fInfo = e.getInfoContainer(); if (fInfo != null) { if (!getGlobalOptions().isDoNoChanges()) { if (fInfo instanceof DefaultFileInfoContainer) { DefaultFileInfoContainer info = (DefaultFileInfoContainer)fInfo; updateCache(info); } } } super.fileInfoGenerated(e); } /** Getter for property mergeRevision1. * @return Value of property mergeRevision1. */ public String getMergeRevision1() { return mergeRevision1; } /** Setter for property mergeRevision1. * @param mergeRevision1 New value of property mergeRevision1. */ public void setMergeRevision1(String mergeRevision1) { this.mergeRevision1 = mergeRevision1; } /** Getter for property mergeRevision2. * @return Value of property mergeRevision2. */ public String getMergeRevision2() { return mergeRevision2; } /** Setter for property mergeRevision2. * @param mergeRevision2 New value of property mergeRevision2. */ public void setMergeRevision2(String mergeRevision2) { this.mergeRevision2 = mergeRevision2; } /** * Getter for property pipeToOutput. * @return Value of property pipeToOutput. */ public boolean isPipeToOutput() { return pipeToOutput; } /** * Setter for property pipeToOutput. * @param pipeToOutput New value of property pipeToOutput. */ public void setPipeToOutput(boolean pipeToOutput) { this.pipeToOutput = pipeToOutput; } /** * Getter for property resetStickyOnes. * @return Value of property resetStickyOnes. */ public boolean isResetStickyOnes() { return resetStickyOnes; } /** * Setter for property resetStickyOnes. * @param resetStickyOnes New value of property resetStickyOnes. */ public void setResetStickyOnes(boolean resetStickyOnes) { this.resetStickyOnes = resetStickyOnes; } /** * Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return useHeadIfNotFound; } /** * Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property updateByDate. * @return Value of property updateByDate. */ public String getUpdateByDate() { return updateByDate; } /** * Setter for property updateByDate. * @param updateByDate New value of property updateByDate. */ public void setUpdateByDate(String updateByDate) { this.updateByDate = updateByDate; } /** * Getter for property updateByRevision. * @return Value of property updateByRevision. */ public String getUpdateByRevision() { return updateByRevision; } /** * Setter for property updateByRevision. * @param updateByRevision New value of property updateByRevision. */ public void setUpdateByRevision(String updateByRevision) { this.updateByRevision = updateByRevision; } /** * Getter for property keywordSubst. * @return Value of property keywordSubst. */ public KeywordSubstitutionOptions getKeywordSubst() { return keywordSubst; } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(KeywordSubstitutionOptions keywordSubst) { this.keywordSubst = keywordSubst; } /** Set whether to build directories. This is the -d option in command-line * CVS. */ public void setBuildDirectories(boolean buildDirectories) { this.buildDirectories = buildDirectories; } /** * Get whether to build directories. * @return true if directories are to be built, false otherwise */ public boolean isBuildDirectories() { return buildDirectories; } /** * Sets whether to get a clean copy from the server. * Even locally modified files will not merged but overridden. * This is the -C option in the command-line CVS. */ public void setCleanCopy(boolean cleanCopy) { this.cleanCopy = cleanCopy; } /** * Returns whether to get a clean copy from the server. */ public boolean isCleanCopy() { return cleanCopy; } /** * Set whether to prune directories. This is the -P option in the command- * line CVS. */ public void setPruneDirectories(boolean pruneDirectories) { this.pruneDirectories = pruneDirectories; } /** * Get whether to prune directories. * @return true if directories should be removed if they contain no files, * false otherwise. */ public boolean isPruneDirectories() { return pruneDirectories; } /** 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; } protected void fireUpdateCache() { super.fireUpdateCache(); } public class UpdateImpl extends FsUpdate implements FileSystemCommandImpl { public UpdateImpl() { } public FileSystemCommand getOuterClassInstance() { return CvsUpdate.this; } /** Set whether to build directories. This is the -d option in command-line * CVS. */ public void setBuildDirectories(boolean buildDirectories) { CvsUpdate.this.setBuildDirectories(buildDirectories); } /** Returns recursive (-R switch) or local (-l switch) behaviour. */ public boolean isRecursive() { return CvsUpdate.this.isRecursive(); } public void addCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) { CvsUpdate.this.addCommandErrorListener(commErrListener); } public void removeCommandErrorListener(org.netbeans.modules.javacvs.events.CommandErrorListener commErrListener) { CvsUpdate.this.removeCommandErrorListener(commErrListener); } /** * Getter for property updateByRevision. * @return Value of property updateByRevision. */ public String getUpdateByRevision() { return CvsUpdate.this.getUpdateByRevision(); } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(KeywordSubstitutionOptions keywordSubst) { CvsUpdate.this.setKeywordSubst(keywordSubst); } /** * Setter for property resetStickyOnes. * @param resetStickyOnes New value of property resetStickyOnes. */ public void setResetStickyOnes(boolean resetStickyOnes) { CvsUpdate.this.setResetStickyOnes(resetStickyOnes); } /** * Sets whether to get a clean copy from the server. * Even locally modified files will not merged but overridden. * This is the -C option in the command-line CVS. */ public void setCleanCopy(boolean cleanCopy) { CvsUpdate.this.setCleanCopy(cleanCopy); } /** * Returns whether to get a clean copy from the server. */ public boolean isCleanCopy() { return CvsUpdate.this.isCleanCopy(); } /** * Getter for property pipeToOutput. * @return Value of property pipeToOutput. */ public boolean isPipeToOutput() { return CvsUpdate.this.isPipeToOutput(); } /** * Setter for property updateByDate. * @param updateByDate New value of property updateByDate. */ public void setUpdateByDate(String updateByDate) { CvsUpdate.this.setUpdateByDate(updateByDate); } /** Sets recursive (-R switch) or local (-l switch) behaviour. */ public void setRecursive(boolean recursive) { CvsUpdate.this.setRecursive(recursive); } /** Add a CommandDisplayerListener to the FilesystemCommand. * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.