KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > 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.subversion.ui.diff;
21
22 import java.util.*;
23
24 import org.netbeans.modules.subversion.ui.actions.ContextAction;
25 import org.netbeans.modules.subversion.util.Context;
26 import org.netbeans.modules.subversion.util.SvnUtils;
27 import org.netbeans.modules.subversion.*;
28 import java.io.File JavaDoc;
29
30 import org.openide.nodes.Node;
31 import org.openide.util.*;
32
33 /**
34  * Diff action shows local changes
35  *
36  * @author Petr Kuzel
37  */

38 public class DiffAction extends ContextAction {
39
40     protected String JavaDoc getBaseName(Node[] nodes) {
41         return "CTL_MenuItem_Diff"; // NOI18N
42
}
43
44     protected boolean enable(Node[] nodes) {
45         Context ctx = SvnUtils.getCurrentContext(nodes);
46         return SvnUtils.getModifiedFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE).length > 0;
47     }
48     
49     public static void diff(Context ctx, int type, String JavaDoc contextName) {
50         
51         DiffMainPanel panel = new DiffMainPanel(ctx, type, contextName); // spawns bacground DiffPrepareTask
52
DiffTopComponent tc = new DiffTopComponent(panel);
53         tc.setName(NbBundle.getMessage(DiffAction.class, "CTL_DiffPanel_Title", contextName)); // NOI18N
54
tc.open();
55         tc.requestActive();
56     }
57
58     public static void diff(File JavaDoc file, String JavaDoc rev1, String JavaDoc rev2) {
59         DiffMainPanel panel = new DiffMainPanel(file, rev1, rev2); // spawns bacground DiffPrepareTask
60
DiffTopComponent tc = new DiffTopComponent(panel);
61         tc.setName(NbBundle.getMessage(DiffAction.class, "CTL_DiffPanel_Title", file.getName())); // NOI18N
62
tc.open();
63         tc.requestActive();
64     }
65     
66     protected void performContextAction(Node[] nodes) {
67         Context ctx = getContext(nodes);
68         String JavaDoc contextName = getContextDisplayName(nodes);
69         diff(ctx, Setup.DIFFTYPE_LOCAL, contextName);
70     }
71    
72 }
73
Popular Tags