KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > refactoring > query > actions > FindUnusedAction


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 /*
21  * FindUnusedAction.java
22  *
23  * Created on July 12, 2006, 3:53 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.refactoring.query.actions;
30
31 import java.io.IOException JavaDoc;
32 import org.netbeans.modules.xml.schema.refactoring.query.QueryUnusedGlobals;
33 import org.netbeans.modules.xml.schema.refactoring.ui.QueryPanel;
34 import org.netbeans.modules.xml.schema.ui.basic.SchemaModelCookie;
35 import org.openide.ErrorManager;
36 import org.openide.loaders.DataObject;
37 import org.openide.nodes.Node;
38 import org.openide.util.HelpCtx;
39 import org.openide.util.NbBundle;
40 import org.openide.util.actions.CookieAction;
41
42 /**
43  *
44  * @author Jeri Lockhart
45  */

46 public class FindUnusedAction extends CookieAction{
47     
48     /** Creates a new instance of FindUnusedAction */
49     public FindUnusedAction() {
50     }
51
52     protected void performAction(Node[] node) {
53         try {
54             assert node.length==1:
55                 "Length of nodes array should be 1";
56             DataObject dobj = (DataObject)node[0].getCookie(DataObject.class);
57             SchemaModelCookie modelCookie = (SchemaModelCookie)dobj.getCookie(SchemaModelCookie.class);
58             QueryUnusedGlobals query = new QueryUnusedGlobals(modelCookie.getModel());
59             new QueryPanel(query);
60         } catch (IOException JavaDoc ex) {
61             ErrorManager.getDefault().notify( ex);
62         }
63         
64     }
65
66     public String JavaDoc getName() {
67         return NbBundle.getMessage(FindUnusedAction.class,"LBL_Find_Unused");
68     }
69
70     public HelpCtx getHelpCtx() {
71         return HelpCtx.DEFAULT_HELP;
72     }
73
74     protected boolean asynchronous() {
75         return false;
76     }
77     
78     protected int mode() {
79     return CookieAction.MODE_EXACTLY_ONE;
80     }
81     
82     protected Class JavaDoc[] cookieClasses() {
83     return new Class JavaDoc[] {SchemaModelCookie.class};
84     }
85 }
86
Popular Tags