|
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.netbeans.modules.javacvs.events.*; import org.netbeans.modules.javacvs.customizers.CommitParamInput; import org.netbeans.modules.javacvs.*; import org.netbeans.modules.javacvs.commands.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.modules.javacvs.caching.*; import org.netbeans.lib.cvsclient.command.commit.*; import org.openide.filesystems.FileObject; /** This class implements the cvs commit command. * * @author mkleint */ public class CvsCommit extends CacheUpdatingFsCommand { private CommitCommand command; private HashMap messagesMap = null; /** * The log message used for the commit. */ private String message; /** * Forces the commit of the file(s) even if no changes were done. * the standard behaviour is NOT-TO-BE recursive in this case. */ private boolean forceCommit; /** * The filename for the file that defines the message. */ private String logMessageFromFile; /** * Determines that no module program should run on the server. */ private boolean noModuleProgram; /** Holds value of property toRevisionOrBranch. */ private String toRevisionOrBranch; /** * to be recursive is default behaviour of command. */ private boolean recursive = true; private FsCommit commitImpl; /** Creates new CvsCommit instance. */ public CvsCommit() { super(); commitImpl = new CommitImpl(); } /** Creates new CvsCommit instance. */ public CvsCommit(File[] filesToCommit, ClientProvider fs) { super(fs); setFiles(filesToCommit); commitImpl = new CommitImpl(); } public CvsCommand getImpl() { return commitImpl; } public FsCommit getCommitImpl() { return commitImpl; } public Class getMainCvsCommand() { return CommitCommand.class; } public String getName() { return NbBundle.getBundle(CvsCommit.class).getString("CvsCommit.name"); // NOI18N } protected void initCommand(boolean commandIsRunning) { // here the the commands is initiated just right before running the command clearCommandList(); int dirNum = 0; command = new CommitCommand(); command.setFiles(getFiles()); setCommandArguments(command); toDoCommands.addElement(command); if (getIndividualMessages() != null) { transform(getIndividualMessages()); } super.initCommand(commandIsRunning); } protected void finishedCommand() { fireUpdateCache(); super.finishedCommand(); } protected void executeFailed(Exception exc) { 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 CommitInformation) { CommitInformation info = (CommitInformation)fInfo; updateCache(info); } } super.fileInfoGenerated(e); } /** * Thi smethod performs the tranformation from 1 commit command for all files/dirs to * separate commits for files definied in the map. The keys value of the map * is File object, value member of the map being a String. * The original commit command is moved to the end of the list. * All this is done in order to enable log messages for single files. */ public void transform(HashMap map) { int size = toDoCommands.size(); CommitCommand original = (CommitCommand)toDoCommands.get(size - 1); toDoCommands.clear(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { File info = (File)it.next(); CommitCommand commit = (CommitCommand)original.clone(); File[] commFiles = new File[1]; commFiles[0] = info; commit.setFiles(commFiles); toDoCommands.add(commit); } toDoCommands.add(original); } /** The keys value of the map * is File object, value member of the map being a String. * This map is later used in transform() method to create individual messages * for files. */ public void setIndividualMessages(HashMap map) { messagesMap = map; } public HashMap getIndividualMessages() { return messagesMap; } /** * Returns the filename for the file that defines the message. */ public String getLogMessageFromFile() { return logMessageFromFile; } /** * Sets the filename for the file that defines the message. */ public void setLogMessageFromFile(String logMessageFromFile) { this.logMessageFromFile = logMessageFromFile; } /** * Returns whether no module program should be executed on the server. */ public boolean isNoModuleProgram() { return noModuleProgram; } /** * Sets whether no module program should run on the server */ public void setNoModuleProgram(boolean noModuleProgram) { this.noModuleProgram = noModuleProgram; } /** Getter for property toRevisionOrBranch. * @return Value of property toRevisionOrBranch. */ public String getToRevisionOrBranch() { return toRevisionOrBranch; } /** Setter for property toRevisionOrBranch. * @param toRevisionOrBranch New value of property toRevisionOrBranch. */ public void setToRevisionOrBranch(String toRevBranch) { this.toRevisionOrBranch = toRevBranch; } /** * Returns the commit message. */ public String getMessage() { return message; } /** * Sets the commit message. */ public void setMessage(String message) { this.message = message; } /** * Indicates whether the commit should be forced even if there are no * changes. */ public boolean isForceCommit() { return forceCommit; } /** * Sets whether the commit should be forced even if there are no changes. */ public void setForceCommit(boolean forceCommit) { this.forceCommit = forceCommit; } /** 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 = getMessage(); setMessage(null); retValue = super.getCvsrcEntry(); setMessage(message); return retValue; } public class CommitImpl extends FsCommit implements FileSystemCommandImpl { public CommitImpl() { } public FileSystemCommand getOuterClassInstance() { return CvsCommit.this; } /** 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.