KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > actions > update > UpdateAction


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.versioning.system.cvss.ui.actions.update;
21
22 import org.openide.util.NbBundle;
23 import org.openide.nodes.Node;
24 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem;
25 import org.netbeans.modules.versioning.system.cvss.FileInformation;
26 import org.netbeans.modules.versioning.system.cvss.ExecutorGroup;
27 import org.netbeans.modules.versioning.system.cvss.util.Context;
28 import org.netbeans.modules.versioning.system.cvss.ui.actions.AbstractSystemAction;
29 import org.netbeans.modules.versioning.util.Utils;
30 import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
31 import org.netbeans.lib.cvsclient.command.GlobalOptions;
32
33 import java.io.File JavaDoc;
34
35 /**
36  * Performs the CVS 'update' command on selected nodes.
37  *
38  * @author Maros Sandor
39  */

40 public class UpdateAction extends AbstractSystemAction {
41     
42     protected String JavaDoc getBaseName(Node [] activatedNodes) {
43         return "CTL_MenuItem_Update"; // NOI18N
44
}
45
46     protected int getFileEnabledStatus() {
47         return FileInformation.STATUS_IN_REPOSITORY;
48     }
49
50     protected int getDirectoryEnabledStatus() {
51         return FileInformation.STATUS_MANAGED & ~FileInformation.STATUS_NOTVERSIONED_EXCLUDED & ~FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY;
52     }
53
54     public void performCvsAction(Node[] nodes) {
55
56         ExecutorGroup group = new ExecutorGroup(getRunningName(nodes));
57         group.progress(NbBundle.getMessage(UpdateAction.class, "BK1001"));
58         Context context = getContext(nodes);
59         GlobalOptions options = null;
60         if (context.getExclusions().size() > 0) {
61             options = CvsVersioningSystem.createGlobalOptions();
62             options.setExclusions((File JavaDoc[]) context.getExclusions().toArray(new File JavaDoc[context.getExclusions().size()]));
63         }
64
65         File JavaDoc [][] flatRecursive = Utils.splitFlatOthers(context.getRootFiles());
66
67         if (flatRecursive[0].length > 0) {
68             UpdateCommand cmd = new UpdateCommand();
69             cmd.setDisplayName(NbBundle.getMessage(UpdateAction.class, "BK0001"));
70             cmd.setBuildDirectories(false);
71             cmd.setPruneDirectories(false);
72             cmd.setRecursive(false);
73             cmd.setFiles(flatRecursive[0]);
74             group.addExecutors(UpdateExecutor.splitCommand(cmd, CvsVersioningSystem.getInstance(), options, getContextDisplayName(nodes)));
75         }
76         if (flatRecursive[1].length > 0) {
77             UpdateCommand cmd = new UpdateCommand();
78             cmd.setDisplayName(NbBundle.getMessage(UpdateAction.class, "BK0001"));
79             cmd.setBuildDirectories(true);
80             cmd.setPruneDirectories(true);
81             cmd.setFiles(flatRecursive[1]);
82             group.addExecutors(UpdateExecutor.splitCommand(cmd, CvsVersioningSystem.getInstance(), options, getContextDisplayName(nodes)));
83         }
84         group.execute();
85     }
86
87     protected boolean asynchronous() {
88         return false;
89     }
90     
91 }
92
Popular Tags