1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.diff; 21 22 import org.netbeans.modules.versioning.system.cvss.FileInformation; 23 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem; 24 import org.netbeans.modules.versioning.system.cvss.FileStatusCache; 25 import org.netbeans.modules.versioning.system.cvss.ExecutorGroup; 26 import org.netbeans.modules.versioning.system.cvss.util.Context; 27 import org.netbeans.modules.versioning.system.cvss.util.Utils; 28 import org.netbeans.modules.versioning.system.cvss.ui.actions.AbstractSystemAction; 29 import org.openide.nodes.Node; 30 31 import java.io.File ; 32 import org.openide.util.NbBundle; 33 34 39 public class DiffAction extends AbstractSystemAction { 40 41 private static final int enabledForStatus = 42 FileInformation.STATUS_LOCAL_CHANGE | 43 FileInformation.STATUS_REMOTE_CHANGE; 44 45 public DiffAction() { 46 setIcon(null); 47 putValue("noIconInMenu", Boolean.TRUE); } 49 50 protected String getBaseName(Node [] activatedNodes) { 51 return "CTL_MenuItem_Diff"; } 53 54 protected boolean enable(Node[] nodes) { 55 return CvsVersioningSystem.getInstance().getFileTableModel(Utils.getCurrentContext(nodes), enabledForStatus).getNodes().length > 0; 56 } 57 58 public void performCvsAction(Node[] nodes) { 59 ExecutorGroup group = new ExecutorGroup(getRunningName(nodes)); 60 group.progress(NbBundle.getMessage(DiffAction.class, "BK1001")); 61 Context context = getContext(nodes); 62 DiffExecutor executor = new DiffExecutor(context, getContextDisplayName(nodes)); 63 FileStatusCache cache = CvsVersioningSystem.getInstance().getStatusCache(); 64 File [] files = context.getFiles(); 65 for (int i = 0; i < files.length; i++) { 66 File file = files[i]; 67 if ((cache.getStatus(file).getStatus() & FileInformation.STATUS_REMOTE_CHANGE) == 0) { 68 executor.showLocalDiff(group); 69 return; 70 } 71 } 72 executor.showRemoteDiff(group); 73 } 74 75 protected boolean asynchronous() { 76 return false; 77 } 78 79 } 80 | Popular Tags |