/* * * Perforce/JBuilder Opentool * Copyright (C) 2001 David Freels * * 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 //Java import java.util.Vector; import com.borland.primetime.ide.Browser; import com.borland.primetime.ide.BrowserAction; import com.borland.primetime.node.Node; import com.dafreels.opentools.Main; import com.dafreels.opentools.MessageWriter; import com.dafreels.opentools.actions.ui.SubmitDialog; import com.dafreels.opentools.properties.PerforceGroup; //Perforce VCS 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: * Description: * Copyright: Copyright (c) 2001 * Company: DF Systems * @author David Freels * @version 1.0 */ public class SubmitAction extends BrowserAction { private final static String newLine = System.getProperty("line.separator"); private SubmitDialog _sd; public SubmitAction() { super("Submit"); setLongText("Submit Changelist"); super.setSmallIcon(ActionImages.P4_SUBMIT); } public void actionPerformed(Browser browser) { Node[] nodes = browser.getProjectView().getSelectedNodes(browser.getActiveProject()); //Get a list of the selected nodes if ( submit(null) ) { //Force JBuilder to check the file status Main.refreshNodes(nodes); } } public boolean submit(String changeNumber) { return submit(changeNumber, null); } public boolean submit(String changeNumber, java.util.List filesToSubmit) { //Get the change list StringBuffer changeList = new StringBuffer("change -o "); if ( changeNumber != null ) { //changeList.append(" -c"); changeList.append(changeNumber); } else { // default change list //changeList.append(" -c"); //changeList.append("default"); } CommandTool.runCommand(new Command(changeList.toString()), false, false, false, Main.m_props); String cl = CommandTool.getOutput(); MessageFormatter formatter = MessageFormatter.getInstance(); String message; /* while( (message = formatter.getNextMessage()) != null) { Browser.getActiveBrowser().getMessageView().addMessage(Main.PERFORCEMESSAGES, new Message(message)); } */ //Browser.getActiveBrowser().getMessageView().addMessage(Main.PERFORCEMESSAGES, // new Message(cl)); java.util.Vector data = new java.util.Vector(); java.util.Vector files = new java.util.Vector(); java.util.Vector dataInteg = new java.util.Vector(); //Create a file list String tmp = ""; //while(cl.indexOf(newLine) != -1) //Get a list of files int idx; StringBuffer desc = new StringBuffer(); while( (tmp = formatter.getNextMessage()) != null) { data = new java.util.Vector(); //tmp = cl.substring(0, cl.indexOf(newLine)); //cl = cl.substring(cl.indexOf(newLine) + newLine.length()); if ( tmp.startsWith("Description:")) { while ( (tmp = formatter.getNextMessage()) != null ) { if ( tmp.startsWith("Files:")) { break; } desc.append(tmp); desc.append('\n'); } continue; } tmp = tmp.trim(); if((idx = tmp.lastIndexOf("//")) != -1) { tmp = tmp.substring(idx);//tmp.lastIndexOf("//")); } if((idx = tmp.indexOf("#")) > -1) { tmp = tmp.substring(0, idx); //tmp.indexOf("#")); } tmp = tmp.trim(); if(!dataInteg.contains(tmp) && tmp.indexOf("//") == 0) { if ( filesToSubmit != null ) { if ( filesToSubmit.contains(tmp)) { data.add(new Boolean("true")); } else { data.add(new Boolean("false")); } } else { data.add(new Boolean("true")); } tmp = tmp.trim(); data.add(tmp); dataInteg.add(tmp); files.add(data); } } //This is no longer needed dataInteg = null; tmp = null; if ( _sd == null ) { _sd= new SubmitDialog(Browser.getActiveBrowser(), "Perforce Change Specification", false); } //Displat the dialog _sd.showSubmit(changeNumber, files, desc.toString().trim()); //Return if the user clicks cancel if(!_sd.getState()) { return false; } // should we reopen the files? do we relock them? how to efficiently? boolean reopenFiles = _sd.getReopenFiles(); //Create the changeList changeList.setLength(0); changeList.append("Change: "); changeList.append(_sd.getChangeNumber()); changeList.append(newLine); changeList.append(" "+newLine); changeList.append("Client: "+PerforceGroup.CLIENTSPEC.getValue(Browser.getActiveBrowser().getActiveProject())+newLine); changeList.append(" "+newLine); changeList.append("User: "+PerforceGroup.USERNAME.getValue(Browser.getActiveBrowser().getActiveProject())+newLine); changeList.append(" "+newLine); changeList.append("Status: "); changeList.append(_sd.getStatus()); changeList.append(newLine); changeList.append(" "+newLine); changeList.append("Description: "+newLine); //Add the description given by the user changeList.append(_sd.getDescription()); changeList.append(" "+newLine); changeList.append("Files: "+newLine); //Get the files list from the dialog files = _sd.getFiles(); Vector v; //Add the files to the changeList for(int i = 0; i < files.size(); i++) { v = (Vector) files.elementAt(i); changeList.append("\t"+v.elementAt(1)+newLine); } //Create the command StringBuffer sb = new StringBuffer("submit -i"); //Run the command CommandTool.runCommand(new Command(sb.toString()), true, true, false, Main.m_props); while(!CommandTool.isStreamReady()) { //do nothing } System.out.println(changeList.toString()); CommandTool.writeToOut(changeList.toString()); //Output the p4 messages boolean errors = MessageFormatter.getInstance().getErrorMessageCount() > 0; MessageWriter.outputErrorMessages(MessageFormatter.getInstance()); //if ( Main.m_props.showOutput()) if ( errors || Main.m_props.showOutput()) { MessageWriter.outputMessages(MessageFormatter.getInstance()); } if ( reopenFiles ) { com.dafreels.vcs.command.Command cmd = new com.dafreels.vcs.command.Command(com.dafreels.vcs.command.Command.EDIT); for(int i = 0; i < files.size(); i++) { v = (Vector) files.elementAt(i); cmd.addPath(v.elementAt(1).toString()); } CommandTool.runCommand(cmd, Main.m_props); MessageWriter.outputErrorMessages(MessageFormatter.getInstance()); if ( Main.m_props.showOutput()) { MessageWriter.outputMessages(MessageFormatter.getInstance()); } } return true; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 4090 | David Freels |
Fixed bug where paths with spaces would not work. Also checked in new code or JBuilderX. |
||
#9 | 3651 | David Freels | Remove file extension limitations. | ||
#8 | 2994 | Mark E. Ackerman |
changed for version 1.0.7. Added display of submitted changelists, redo sync, updated icons, misc bug fixes and improvements. |
||
#7 | 1873 | Mark E. Ackerman | Version 1.0 build. | ||
#6 | 1703 | Mark E. Ackerman |
fix for sync and preview to handle multiple source paths. moved all image stuff to the vcs branch. added some more icons to the menu v0.9.5 |
||
#5 | 1640 | Mark E. Ackerman |
added diff action, unlock action, status dialog, file history with detail, fixed stretching of submit dialog. added diff to submit dialog. added icons to the popup menu. added status line message for most actions. added confirm to revert action. added displaying of error messages from p4 command. added About Open tool support. added option on Perforce Page to not display output from p4 command. added version info on the PerforcePage. some other misc fixes and changes. changed version number to 0.9.3 |
||
#4 | 1624 | David Freels | Add patches and created new build files. | ||
#3 | 1445 | David Freels | Refreshing source tree. | ||
#2 | 1429 | David Freels | New packaging and bug fixes. | ||
#1 | 940 | David Freels | Initial revision | ||
//guest/david_freels/p4ot/src/com/dafreels/opentools/actions/SubmitAction.java | |||||
#1 | 934 | David Freels | Initial revision |