KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > commit > ConflictResolvedAction


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.commit;
21
22 import java.io.*;
23 import org.netbeans.modules.subversion.*;
24 import org.netbeans.modules.subversion.client.*;
25 import org.netbeans.modules.subversion.ui.actions.ContextAction;
26 import org.netbeans.modules.subversion.util.*;
27 import org.openide.*;
28 import org.openide.filesystems.*;
29 import org.openide.nodes.Node;
30 import org.openide.util.RequestProcessor;
31 import org.tigris.subversion.svnclientadapter.*;
32
33 /**
34  * Represnts <tt>svn resolved</tt> command.
35  *
36  * @author Petr Kuzel
37  */

38 public class ConflictResolvedAction extends ContextAction {
39     
40     protected String JavaDoc getBaseName(Node[] activatedNodes) {
41         return "resolve"; // NOI18N
42
}
43
44     protected int getFileEnabledStatus() {
45         return FileInformation.STATUS_VERSIONED_CONFLICT;
46     }
47
48     protected int getDirectoryEnabledStatus() {
49         return 0;
50     }
51
52     protected void performContextAction(Node[] nodes) {
53         final Context ctx = getContext(nodes);
54         final File[] files = ctx.getFiles();
55
56         ProgressSupport support = new ContextAction.ProgressSupport(this, nodes) {
57             public void perform() {
58
59                 SvnClient client = null;
60                 try {
61                     client = Subversion.getInstance().getClient(ctx, this);
62                 } catch (SVNClientException ex) {
63                     ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
64                     ErrorManager.getDefault().notify(ErrorManager.USER, ex);
65                 }
66
67                 if (client == null) {
68                     return;
69                 }
70                 
71                 for (int i = 0; i<files.length; i++) {
72                     if(isCanceled()) {
73                         return;
74                     }
75                     File file = files[i];
76                     ConflictResolvedAction.perform(file, client);
77                 }
78             }
79         };
80         support.start(createRequestProcessor(nodes));
81     }
82
83
84     /** Marks as resolved or shows error dialog. */
85     public static void perform(File file) {
86         SvnClient client = null;
87         try {
88             client = Subversion.getInstance().getClient(file);
89             perform(file, client);
90         } catch (SVNClientException ex) {
91             ExceptionHandler eh = new ExceptionHandler (ex);
92             eh.notifyException();
93         }
94     }
95
96     private static void perform(File file, SvnClient client) {
97         FileStatusCache cache = Subversion.getInstance().getStatusCache();
98
99         try {
100             client.resolved(file);
101             cache.refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
102
103             // auxiliary files disappear, synch with FS
104
File parent = file.getParentFile();
105             if (parent != null) {
106                 FileObject folder = FileUtil.toFileObject(parent);
107                 if (folder != null) {
108                     folder.refresh();
109                 }
110             }
111         } catch (SVNClientException ex) {
112             ExceptionHandler eh = new ExceptionHandler (ex);
113             eh.notifyException();
114         }
115     }
116
117 }
118
Popular Tags