1 19 20 package org.netbeans.modules.subversion.ui.status; 21 22 import java.io.File ; 23 import org.netbeans.modules.subversion.util.*; 24 import org.netbeans.modules.subversion.util.Context; 25 import org.netbeans.modules.subversion.FileInformation; 26 import org.netbeans.modules.subversion.FileStatusCache; 27 import org.netbeans.modules.subversion.Subversion; 28 import org.netbeans.modules.subversion.client.SvnClient; 29 import org.netbeans.modules.subversion.client.SvnProgressSupport; 30 import org.netbeans.modules.subversion.ui.actions.ContextAction; 31 import org.openide.ErrorManager; 32 import org.openide.nodes.Node; 33 import org.tigris.subversion.svnclientadapter.ISVNStatus; 34 import org.tigris.subversion.svnclientadapter.SVNClientException; 35 import org.tigris.subversion.svnclientadapter.SVNStatusKind; 36 37 43 public class StatusAction extends ContextAction { 44 45 private static final int enabledForStatus = FileInformation.STATUS_MANAGED; 46 47 protected String getBaseName(Node[] nodes) { 48 return "CTL_MenuItem_ShowChanges"; } 50 51 protected int getFileEnabledStatus() { 52 return enabledForStatus; 53 } 54 55 public void performContextAction(Node[] nodes) { 56 Context ctx = SvnUtils.getCurrentContext(nodes); 57 final SvnVersioningTopComponent stc = SvnVersioningTopComponent.getInstance(); 58 stc.setContentTitle(getContextDisplayName(nodes)); 59 stc.setContext(ctx); 60 stc.open(); 61 stc.requestActive(); 62 stc.performRefreshAction(); 63 } 64 65 68 public static void executeStatus(final Context context, SvnProgressSupport support) { 69 70 if (context == null || context.getRoots().size() == 0) { 71 return; 72 } 73 74 try { 75 SvnClient client; 76 try { 77 client = Subversion.getInstance().getClient(context, support); 78 } catch (SVNClientException ex) { 79 ErrorManager.getDefault().notify(ex); 80 return; 81 } 82 83 Subversion.getInstance().getStatusCache().refreshCached(context); 84 File [] roots = context.getRootFiles(); 85 for (int i=0; i<roots.length; i++) { 86 if(support.isCanceled()) { 87 return; 88 } 89 File root = roots[i]; 90 ISVNStatus[] statuses = client.getStatus(root, true, false, true); if(support.isCanceled()) { 92 return; 93 } 94 95 for (int s = 0; s < statuses.length; s++) { 96 if(support.isCanceled()) { 97 return; 98 } 99 ISVNStatus status = statuses[s]; 100 FileStatusCache cache = Subversion.getInstance().getStatusCache(); 101 File file = status.getFile(); 102 SVNStatusKind kind = status.getRepositoryTextStatus(); 103 cache.refresh(file, status); 105 } 106 } 107 } catch (SVNClientException ex) { 108 support.annotate(ex); 109 } 110 } 111 } | Popular Tags |