1 19 package org.netbeans.modules.subversion.ui.checkout; 20 21 import java.io.File ; 22 import org.netbeans.modules.subversion.RepositoryFile; 23 import org.netbeans.modules.subversion.Subversion; 24 import org.netbeans.modules.subversion.SvnModuleConfig; 25 import org.netbeans.modules.subversion.client.SvnProgressSupport; 26 import org.netbeans.modules.subversion.client.SvnClient; 27 import org.netbeans.modules.subversion.ui.wizards.*; 28 import org.openide.ErrorManager; 29 import org.openide.filesystems.FileUtil; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 import org.openide.util.actions.CallableSystemAction; 33 import org.tigris.subversion.svnclientadapter.SVNClientException; 34 import org.tigris.subversion.svnclientadapter.SVNUrl; 35 36 40 public final class CheckoutAction extends CallableSystemAction { 41 42 public void performAction() { 43 CheckoutWizard wizard = new CheckoutWizard(); 44 if (!wizard.show()) return; 45 46 final SVNUrl repository = wizard.getRepositoryRoot(); 47 final RepositoryFile[] repositoryFiles = wizard.getRepositoryFiles(); 48 final File file = wizard.getWorkdir(); 49 final boolean atWorkingDirLevel = wizard.isAtWorkingDirLevel(); 50 51 SvnProgressSupport support = new SvnProgressSupport() { 52 public void perform() { 53 final SvnClient client; 54 try { 55 client = Subversion.getInstance().getClient(repository); 56 } catch (SVNClientException ex) { 57 ErrorManager.getDefault().notify(ex); return; 59 } 60 61 try { 62 setDisplayName(java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_Checkout_Progress")); 63 checkout(client, repository, repositoryFiles, file, atWorkingDirLevel, this); 64 } catch (SVNClientException ex) { 65 annotate(ex); 66 return; 67 } 68 if(isCanceled()) { 69 return; 70 } 71 72 setDisplayName(java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_ScanFolders_Progress")); 73 if (SvnModuleConfig.getDefault().getShowCheckoutCompleted()) { 74 String [] folders; 75 if(atWorkingDirLevel) { 76 folders = new String [1]; 77 folders[0] = "."; } else { 79 folders = new String [repositoryFiles.length]; 80 for (int i = 0; i < repositoryFiles.length; i++) { 81 if(isCanceled()) { 82 return; 83 } 84 if(repositoryFiles[i].isRepositoryRoot()) { 85 folders[i] = "."; } else { 87 folders[i] = repositoryFiles[i].getFileUrl().getLastPathSegment(); 88 } 89 } 90 } 91 CheckoutCompleted cc = new CheckoutCompleted(file, folders, true); 92 if(isCanceled()) { 93 return; 94 } 95 cc.scanForProjects(this); 96 } 97 } 98 }; 99 support.start(Subversion.getInstance().getRequestProcessor(repository), repository, java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_Checkout_Progress")); 100 101 } 102 103 public String getName() { 104 return NbBundle.getMessage(CheckoutAction.class, "CTL_CheckoutAction"); } 106 107 protected void initialize() { 108 super.initialize(); 109 putValue("noIconInMenu", Boolean.TRUE); } 111 112 public HelpCtx getHelpCtx() { 113 return HelpCtx.DEFAULT_HELP; 114 } 115 116 protected boolean asynchronous() { 117 return false; 118 } 119 120 public static void checkout(final SvnClient client, 121 final SVNUrl repository, 122 final RepositoryFile[] repositoryFiles, 123 final File workingDir, 124 final boolean atWorkingDirLevel, 125 final SvnProgressSupport support) 126 throws SVNClientException 127 { 128 for (int i = 0; i < repositoryFiles.length; i++) { 129 File destination; 130 if(!atWorkingDirLevel) { 131 destination = new File (workingDir.getAbsolutePath() + 132 "/" + repositoryFiles[i].getName()); destination = FileUtil.normalizeFile(destination); 135 destination.mkdir(); 136 } else { 137 destination = workingDir; 138 } 139 if(support!=null && support.isCanceled()) { 140 return; 141 } 142 client.checkout(repositoryFiles[i].getFileUrl(), destination, repositoryFiles[i].getRevision(), true); 143 if(support!=null && support.isCanceled()) { 144 return; 145 } 146 } 147 } 148 149 } 150 | Popular Tags |