package com.jbase.jbuilder5vcs; // Borland import import com.borland.primetime.ide.ContextActionProvider; import com.borland.primetime.ide.ProjectView; import com.borland.primetime.actions.DelegateHandler; import com.borland.primetime.teamdev.vcs.VCS; import com.borland.primetime.teamdev.vcs.RevisionInfo; import com.borland.primetime.teamdev.vcs.DeleteDialogInterface; import com.borland.primetime.teamdev.vcs.VCSFactory; import com.borland.primetime.teamdev.frontend.VCSBrowserContextActionProvider; import com.borland.primetime.properties.PropertyPage; import com.borland.primetime.node.Node; import com.borland.primetime.node.Project; import com.borland.primetime.ide.Browser; import com.borland.primetime.ide.BrowserIcons; import com.borland.primetime.vfs.Url; import com.borland.primetime.actions.ActionGroup; import com.borland.jbuilder.node.JBProject; import com.borland.primetime.teamdev.vcs.VCSFileInfo; import com.borland.primetime.util.runner.OutputRunnerListener; // java import import java.util.Vector; import java.util.Map; import java.util.List; import javax.swing.Icon; import java.io.File; import java.util.Set; import javax.swing.JOptionPane; /** * Title: jBuilder/Perforce<br> * Description: For integrate perforce on jBuilder, This is the start class. It implement * the VCS class from jBuilder. It implement DelegateHandler too, but it's just<br> * for some tests. * <DL><DT><b>Company:</b></DT><DD>jBase.</DD></DL> * @author <a href="mailto:nicolasj@jbase.com">Nicolas Jorand</a> * @version 1.0 * @since JDK 1.3 */ public class PerforceVCS extends VCS { // Properties key will be store on the project. public static final String PROP_P4 = "PerforceVCS"; public static final String PROP_PATH = "PerforceVCS_path"; public static final String PROP_CLIENT = "PerforceVCS_client"; public static final String PROP_CLIENT_DEFAULT = "PerforceVCS_clientUseDefault"; public static final String PROP_USER = "PerforceVCS_user"; public static final String PROP_USER_DEFAULT = "PerforceVCS_userUseDefault"; public static final String PROP_PASSWORD = "PerforceVCS_password"; // @todo Encrypt this data public static final String PROP_HOST = "PerforceVCS_host"; public static final String PROP_PORT = "PerforceVCS_port"; public static final String PROP_PORT_DEFAULT = "PerforceVCS_portUseDefault"; public static final String PROP_ISNEW = "PerforceVCS_isnew"; public boolean connected; private P4Cmd _oP4; // The class for call P4 command public PerforceVCS() { try { initClass(); } catch(Exception e) { e.printStackTrace(); connected = false; } } /** * Register the PerforceVCS with the VCS Factory. This will make the class available * in the Team drop-down list. */ public static void initOpenTool( byte major, byte minor ) { // VCS support was added starting from JBuilder 4 if ( major < 4) { System.out.println("!!!!!!!!!!!jBuilder5vcs.jar -> This openTools is designed for jBuilder5, current version of jBuilder:"+major+"."+minor+" !!!!!!!!!!!"); return; } VCSFactory.addVCS(new PerforceVCS()); // Add a new menu context on the project view, it exist only if just the project menu is selected ProjectView.registerContextActionProvider(new ContextActionProvider() { public javax.swing.Action getContextAction(Browser browser, Node[] nodes) { ActionGroup aGroup = null; if (browser.getActiveProject() != null) { if (nodes.length == 1 && nodes[0] instanceof JBProject ){ aGroup = Actions.getP4ContextMenu(); } } return (aGroup); } }); } /** * Return the property page to display when the user clicks on the Team tab. */ public PropertyPage getProjectConfigPage(JBProject project) { return( new jPropertyPage(project) ); } /** * Retrun true, if the file passed in parameter are on P4 * nDepotPending -> On P4, a file should be on the depot or on a pending list. */ public boolean isUnderVCS(Url url, int nDepotPending) { return _oP4.isOnVCS(url, Browser.getActiveBrowser().getActiveProject(), nDepotPending); } /** * The methode inherite of VCS, it's overload for add the depot or pending * list. By default it look on Depot list */ public boolean isUnderVCS(Url url) { return isUnderVCS(url,Actions.ON_DEPOT_LIST); } public boolean isBinary(Url url) { String extensions = ".gif|.jpg|.jpeg|.jar|.zip|.au|.wav|.midi"; return extensions.indexOf(url.getFileExtension()) != -1; } public String getName() { return this.PROP_P4; } public String getDescription() { return "Implementation of Perforce"; } public Icon getVCSIcon() { return BrowserIcons.ICON_FOLDER; } /** * The menu will be appear on the Team Menu of jBuilder */ public ActionGroup getVCSProjectMenuGroup() { return Actions.getP4Menu(); } public ActionGroup getVCSFileMenuGroup() { return null; } /** * Return the list of actions that will be presented in the context menu in the * project pane. */ public ActionGroup getVCSContextMenuGroup() { return(Actions.getP4ContextMenu()); } /** * Add file(s) on Pending list of P4, */ public String addFile(Node[] workFiles) throws P4ErrorApplication,P4ErrorConnection{ // add file on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.add(workFiles); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Add file(s) on Pending list of P4, file come from VCSBrowser */ public String addFile(Set workFiles, Project prj) throws P4ErrorApplication,P4ErrorConnection{ // add file on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.add(workFiles, prj); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Revert file(s) on Pending list of P4, */ public String revertFile(Node[] workFiles) throws P4ErrorApplication,P4ErrorConnection{ // revert file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.revert(workFiles); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Revert file(s) on Pending list of P4, file come from VCSBrowser */ public String revertFile(Set workFiles, Project prj) throws P4ErrorApplication,P4ErrorConnection{ // revert file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.revert(workFiles,prj); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Synchronize file(s) from depot of P4, */ public String syncFile(Node[] workFiles) throws P4ErrorApplication,P4ErrorConnection { // synchronize file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.sync(workFiles); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Synchronize file(s) from depot of P4, file come from VCSBrowser */ public String syncFile(Set workFiles, Project prj) throws P4ErrorApplication,P4ErrorConnection { // synchronize file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.sync(workFiles,prj); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Pass file(s) from depot to default pending list of P4, */ public String editFile(Node[] workFiles) throws P4ErrorApplication,P4ErrorConnection{ // edit file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.edit(workFiles); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Pass file(s) from depot to default pending list of P4, file come from VCSBrowser */ public String editFile(Set workFiles, Project prj) throws P4ErrorApplication,P4ErrorConnection{ // editFile file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.edit(workFiles,prj); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Pass file(s) from default pending list to depot of P4, if some files must be * merge, the user must be launch P4 for make manualy merge. */ public String submitFile(Node[] workFiles,String sDescription) throws P4ErrorApplication,P4ErrorConnection{ // submit file(s) on P4 // Set the object atribute connected dependency the response of P4 String sReturn = null; try{ sReturn = _oP4.submit(workFiles, sDescription ); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * For commit file from the VCSBrowser */ public String commitFile(Set workFiles,OutputRunnerListener outRunner, Project prj) throws P4ErrorApplication,P4ErrorConnection{ String sReturn = null; try{ sReturn = _oP4.commit(workFiles,outRunner, prj); connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } return sReturn; } /** * Get the project status from the current P4cmd */ public Map getProjectStatus(Project project) { return _oP4.getStatus(project); } /** * Try to connect to P4 */ public void connect() throws P4ErrorConnection { // Set the object atribute connected dependency the response of P4 try{ if (_oP4.connect()) connected = true; }catch(P4ErrorConnection e){ connected = false; throw e; } } /** * Set the menu enable for the configuration of Perfoce. */ public boolean isConfigureVCSMenuEnabled(){ return true; } /** * This is a test for create my refresh action, but it doesn't work ;-( */ public javax.swing.Action getAction(com.borland.primetime.actions.DelegateAction delegate) { if (delegate == com.borland.primetime.ide.Browser.DELEGATE_Refresh) { return Actions.ACTION_Refresh; } return null; } /** * NOT USED */ public Vector getRevisions(Url url) { // NOT USED return null; } /** * NOT USED */ public byte[] getSource(Url url, RevisionInfo rev) { //NOT USED return new byte[0]; } /** * NOT USED */ public VCSBrowserContextActionProvider getVCSBrowserContextActionProvider() { return null; } /** * NOT USED */ public DeleteDialogInterface getDeleteDialog() { // NOT USED return null; } /** * NOT USED */ public static File getRepositoryPath() { // NOT USED return null; } /** * NOT USED */ public static String getFileNameInRepository( File sourceFile ) { // NOT USED return null; } /** * Create a instance of P4Cmd, when this instance will be create, * a request to P4 is lanch for get informations (Depot name, Root Name, create the list of file on depot, ...) */ private void initClass() throws Exception { _oP4 = new P4Cmd(); // Check if the connection with P4 is OK if (_oP4.isConnected()) connected = true; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 1072 | rmg |
Integrate the "jBuilder5VCS" frmo Nicolas Jorand into //public; Plan is to add some top-level documentation before linking it into the "roadmap", or making any sort of general public announcement. |
||
//guest/nicolas_jorand/jBuilder5VCS/src/com/jbase/jbuilder5vcs/PerforceVCS.java | |||||
#1 | 939 | nicolas_jorand | First input of perforce integration for jBuilder5 |