KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > actions > tag > TagExecutor


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.tag;
21
22 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem;
23 import org.netbeans.modules.versioning.system.cvss.FileStatusCache;
24 import org.netbeans.modules.versioning.system.cvss.ExecutorSupport;
25 import org.netbeans.modules.versioning.system.cvss.ClientRuntime;
26 import org.netbeans.lib.cvsclient.command.GlobalOptions;
27 import org.netbeans.lib.cvsclient.command.DefaultFileInfoContainer;
28 import org.netbeans.lib.cvsclient.command.Command;
29 import org.netbeans.lib.cvsclient.command.tag.TagCommand;
30 import org.openide.ErrorManager;
31 import org.openide.util.NbBundle;
32
33 import java.util.*;
34 import java.io.File JavaDoc;
35 import java.io.IOException JavaDoc;
36
37 /**
38  * Executes a given 'tag' command and refreshes file statuses.
39  *
40  * @author Maros Sandor
41  */

42 public class TagExecutor extends ExecutorSupport {
43     
44     /**
45      * Splits the original command into more commands if the original
46      * command would execute on incompatible files.
47      * See {@link #prepareBasicCommand(org.netbeans.lib.cvsclient.command.BasicCommand)}
48      * for more information.
49      *
50      * @param cmd command to execute
51      * @param cvs CVS engine to use
52      * @param options global option for the command
53      * @return array of executors that will execute the command (or array of splitted commands)
54      */

55     public static TagExecutor [] splitCommand(TagCommand cmd, CvsVersioningSystem cvs, GlobalOptions options) {
56         Command [] cmds = new org.netbeans.lib.cvsclient.command.Command[0];
57         if (cmd.getDisplayName() == null) cmd.setDisplayName(NbBundle.getMessage(TagExecutor.class, "MSG_TagExecutor_CmdDisplayName"));
58         try {
59             cmds = prepareBasicCommand(cmd);
60         } catch (IOException JavaDoc e) {
61             ErrorManager.getDefault().notify(e);
62             return null;
63         }
64         TagExecutor [] executors = new TagExecutor[cmds.length];
65         for (int i = 0; i < cmds.length; i++) {
66             Command command = cmds[i];
67             executors[i] = new TagExecutor(cvs, (TagCommand) command, options);
68         }
69         return executors;
70     }
71
72     private TagExecutor(CvsVersioningSystem cvs, TagCommand cmd, GlobalOptions options) {
73         super(cvs, cmd, options);
74     }
75
76     protected void commandFinished(ClientRuntime.Result result) {
77         
78         Set parents = new HashSet();
79         for (Iterator i = toRefresh.iterator(); i.hasNext();) {
80             DefaultFileInfoContainer info = (DefaultFileInfoContainer) i.next();
81             File JavaDoc file = info.getFile();
82             cache.refreshCached(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
83             parents.add(file.getParentFile());
84         }
85         toRefresh.clear();
86         
87         for (Iterator i = parents.iterator(); i.hasNext();) {
88             File JavaDoc dir = (File JavaDoc) i.next();
89             cache.refreshCached(dir, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
90         }
91     }
92 }
93
Popular Tags