1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.selectors; 21 22 import org.openide.ErrorManager; 23 import org.openide.filesystems.FileUtil; 24 import org.netbeans.lib.cvsclient.Client; 25 import org.netbeans.lib.cvsclient.CVSRoot; 26 import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; 27 import org.netbeans.lib.cvsclient.connection.Connection; 28 import org.netbeans.modules.versioning.system.cvss.ClientRuntime; 29 30 import java.io.File ; 31 import java.io.IOException ; 32 33 38 public final class Kit implements Client.Factory { 39 40 private CVSRoot factory_cvsRoot; 41 42 43 private Kit(CVSRoot factory_cvsRoot) { 44 this.factory_cvsRoot = factory_cvsRoot; 45 } 46 47 public static File createTmpFolder() { 48 String tmpDir = System.getProperty("java.io.tmpdir"); File tmpFolder = new File (tmpDir); 50 File checkoutFolder = null; 51 try { 52 File tmp = File.createTempFile("checkout", "", tmpFolder); if (tmp.delete() == false) { 55 return checkoutFolder; 56 } 57 if (tmp.mkdirs() == false) { 58 return checkoutFolder; 59 } 60 tmp.deleteOnExit(); 61 checkoutFolder = FileUtil.normalizeFile(tmp); 62 } catch (IOException e) { 63 ErrorManager err = ErrorManager.getDefault(); 64 err.annotate(e, org.openide.util.NbBundle.getMessage(Kit.class, "BK2018")); 65 err.notify(e); 66 } 67 return checkoutFolder; 68 } 69 70 public static void deleteRecursively(File file) { 71 if (file == null) return; 72 if (file.isDirectory()) { 73 File [] files = file.listFiles(); 74 for (int i = 0; i < files.length; i++) { 75 File next = files[i]; 76 deleteRecursively(next); } 78 file.delete(); 79 } 80 } 81 82 83 public static Client createClient(CVSRoot cvsRoot) { 84 Connection connection = ClientRuntime.setupConnection(cvsRoot); 85 Client client = new Client(connection, new StandardAdminHandler()); 86 return client; 87 } 88 89 public static Client.Factory createClientFactory(CVSRoot cvsRoot) { 90 return new Kit(cvsRoot); 91 } 92 93 public Client createClient() { 94 return createClient(factory_cvsRoot); 95 } 96 } 97 | Popular Tags |