KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > status > ShowAllChangesAction


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.status;
21
22 import org.netbeans.api.project.*;
23 import org.netbeans.api.project.ui.OpenProjects;
24 import org.netbeans.modules.subversion.ui.actions.*;
25 import org.netbeans.modules.subversion.util.SvnUtils;
26 import org.netbeans.modules.subversion.util.Context;
27 import org.openide.util.NbBundle;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.RequestProcessor;
30 import org.openide.util.actions.SystemAction;
31
32 import javax.swing.*;
33 import java.awt.event.ActionEvent JavaDoc;
34
35 /**
36  * Open the Versioning status view for all projects.
37  *
38  * @author Maros Sandor
39  */

40 public class ShowAllChangesAction extends AbstractAllAction {
41
42     public ShowAllChangesAction() {
43     }
44
45     public String JavaDoc getName() {
46         return NbBundle.getMessage(ShowAllChangesAction.class, "CTL_MenuItem_ShowAllChanges_Label"); // NOI18N
47
}
48
49
50     public void actionPerformed(ActionEvent JavaDoc e) {
51         RequestProcessor.getDefault().post(new Runnable JavaDoc() {
52             public void run() {
53                 async();
54             }
55         });
56     }
57
58     private void async() {
59         try {
60             setEnabled(false);
61             SwingUtilities.invokeLater(new Runnable JavaDoc() {
62                 public void run() {
63                     SvnVersioningTopComponent stc = SvnVersioningTopComponent.getInstance();
64                     stc.setContext(null);
65                     stc.open();
66                 }
67             });
68
69             Project [] projects = OpenProjects.getDefault().getOpenProjects();
70
71             final Context ctx = SvnUtils.getProjectsContext(projects);
72             final String JavaDoc title;
73             if (projects.length == 1) {
74                 Project project = projects[0];
75                 ProjectInformation pinfo = ProjectUtils.getInformation(project);
76                 title = pinfo.getDisplayName();
77             } else {
78                 title = NbBundle.getMessage(ShowAllChangesAction.class, "CTL_ShowAllChanges_WindowTitle", Integer.toString(projects.length)); // NOI18N
79
}
80             SwingUtilities.invokeLater(new Runnable JavaDoc() {
81                 public void run() {
82                     final SvnVersioningTopComponent stc = SvnVersioningTopComponent.getInstance();
83                     stc.setContentTitle(title);
84                     stc.setContext(ctx);
85                     stc.open();
86                     stc.requestActive();
87                     if (shouldPostRefresh()) {
88                         stc.performRefreshAction();
89                     }
90                 }
91             });
92
93         } finally {
94             setEnabled(true);
95         }
96
97     }
98
99     protected boolean shouldPostRefresh() {
100         return true;
101     }
102 }
103
104
Popular Tags