/* * * Perforce/JBuilder Opentool * Copyright (C) 2002 Mark Ackerman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package com.dafreels.opentools.actions; //JBuilder import com.borland.primetime.ide.Browser; import com.borland.primetime.node.Node; import com.dafreels.opentools.Main; import com.dafreels.vcs.command.Command; import com.dafreels.vcs.command.CommandTool; import com.dafreels.vcs.command.MessageFormatter; import com.dafreels.vcs.util.ActionImages; /** * Title: Perforce OpenTools * Description: run the Perforce diff command on file(s) * Copyright: Copyright (c) 2002 * Company: * @author Mark Ackerman * @version 1.0 */ public class DiffAction extends PerforceAction { private static boolean _firstTime = true; private static boolean _p4DiffSet = false; public DiffAction(boolean onFileTabMenu) { super( "Diff", "Diff client file against Depot file", ActionImages.P4_DIFF, onFileTabMenu); ; } public void actionPerformed(Browser browser) { if (_firstTime) { // check to see if the P4DIFF variable is set. checkForDiff(); } com.dafreels.vcs.command.Command cmd = new com.dafreels.vcs.command.Command( com.dafreels.vcs.command.Command.DIFF); Node[] nodes = getSelectedNodes(browser, cmd); /* //Get a list of the selected nodes Node[] nodes = browser.getProjectView().getSelectedNodes(browser.getActiveProject()); StringBuffer sb = new StringBuffer("diff -f "); String tempFileName = ""; for(int i = 0; i < nodes.length; i++) { tempFileName = ((FileNode)nodes[i]).getLongDisplayName(); if(m_reg.validateFile(tempFileName)) { sb.append(tempFileName+" "); } } */ if (cmd.getPathCount() == 0) { return; } runCommand(browser, cmd); /* //Run the command CommandTool.runCommand(sb.toString(), Main.m_props); //Output the p4 error messages MessageWriter.outputErrorMessages(MessageFormatter.getInstance()); if ( Main.m_props.showOutput() || !_p4DiffSet ) { //Output the p4 messages MessageWriter.outputMessages(MessageFormatter.getInstance()); } // how to tell if the files are the same and tell the user? */ //Force JBuilder to check the file status if (nodes != null) { Main.refreshNodes(nodes); } } /** * check to set if the P4DIFF variable is set */ private void checkForDiff() { String cmd = "set"; CommandTool.runCommand(new Command(cmd), Main.m_props); MessageFormatter formatter = MessageFormatter.getInstance(); String msg; while ((msg = formatter.getNextMessage()) != null) { if (msg.startsWith("P4DIFF")) { _p4DiffSet = true; break; } } _firstTime = false; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 4090 | David Freels |
Fixed bug where paths with spaces would not work. Also checked in new code or JBuilderX. |