KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > actions > diff > DiffAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 JavaDoc;
32 import org.openide.util.NbBundle;
33
34 /**
35  * Show differencies between the current working copy and repository version we started from.
36  *
37  * @author Maros Sandor
38  */

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); // NOI18N
48
}
49
50     protected String JavaDoc getBaseName(Node [] activatedNodes) {
51         return "CTL_MenuItem_Diff"; // NOI18N
52
}
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 JavaDoc [] files = context.getFiles();
65         for (int i = 0; i < files.length; i++) {
66             File JavaDoc 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