KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > RefreshAction


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 package org.netbeans.modules.xml.catalog;
20
21 import org.openide.nodes.Node;
22 import org.openide.util.HelpCtx;
23 import org.openide.util.actions.CookieAction;
24 import org.openide.awt.StatusDisplayer;
25
26 /**
27  * Action sensitive to the node selection that refreshs children.
28  *
29  * @author Petr Kuzel
30  */

31 final class RefreshAction extends CookieAction {
32
33     /** Serial Version UID */
34     private static final long serialVersionUID =4798470042774935554L;
35
36     protected void performAction (Node[] nodes) {
37         if (nodes == null) return;
38         try {
39             for (int i = 0; i<nodes.length; i++) {
40                 String JavaDoc msg = Util.THIS.getString("MSG_refreshing", nodes[i].getDisplayName());
41                 StatusDisplayer.getDefault().setStatusText(msg);
42                 Refreshable cake = (Refreshable) nodes[i].getCookie(Refreshable.class);
43                 cake.refresh();
44             }
45         } finally {
46             String JavaDoc msg = Util.THIS.getString("MSG_refreshed");
47             StatusDisplayer.getDefault().setStatusText(msg);
48         }
49     }
50
51     public String JavaDoc getName () {
52         return Util.THIS.getString ("LBL_Action");
53     }
54
55     protected String JavaDoc iconResource () {
56         return null;
57     }
58
59     public HelpCtx getHelpCtx () {
60         return new HelpCtx(getClass());
61     }
62
63     protected Class JavaDoc[] cookieClasses() {
64         return new Class JavaDoc[] {Refreshable.class};
65     }
66     
67     protected int mode() {
68         return CookieAction.MODE_ALL;
69     }
70     
71     protected boolean asynchronous() {
72         return false;
73     }
74
75 }
76
Popular Tags