KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > syntax > XMLViewActions


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.xml.text.syntax;
21
22 import java.util.*;
23 import org.netbeans.modules.xml.core.actions.CollectSystemAction;
24 import org.openide.actions.OpenAction;
25 import org.openide.actions.ViewAction;
26 import org.openide.modules.*;
27 import org.openide.util.*;
28 import org.openide.util.actions.SystemAction;
29
30 /**
31  * Represents a list of optional (enableness driven) actions.
32  * Possible actions are hardcoded in {@link #getPossibleActions()}.
33  *
34  * @author Libor Kramolis
35  */

36 final class XMLViewActions extends CollectSystemAction {
37
38     /** Serial Version UID */
39     private static final long serialVersionUID = 8223872687291078210L;
40
41     /**
42      */

43     protected final Class JavaDoc getActionLookClass () {
44         // will not be called because rewritten getPossibleActions by subclasses
45
return null;
46     }
47
48     protected Collection getPossibleActions () {
49         Collection actions = new Vector(2);
50         
51         // XXX #48712 heuristics: enable open action only if tree editor installed
52
boolean visualEditorInstalled = false;
53         Lookup lookup = Lookup.getDefault();
54         Lookup.Template t = new Lookup.Template(ModuleInfo.class);
55         Iterator it = lookup.lookup(t).allInstances().iterator();
56         while (it.hasNext()) {
57             ModuleInfo next = (ModuleInfo) it.next();
58             if (next.getCodeNameBase().equals("org.netbeans.modules.xml.tree") && next.isEnabled()) { // NOI18N
59
visualEditorInstalled = true;
60                 break;
61             }
62         }
63         if (visualEditorInstalled) {
64             actions.add (SystemAction.get (OpenAction.class));
65         }
66         actions.add (SystemAction.get (ViewAction.class));
67         return actions;
68     }
69
70
71     /* Do nothing.
72      * This action itself does nothing, it only presents other actions.
73      * @param ev ignored
74      */

75     public void actionPerformed (java.awt.event.ActionEvent JavaDoc e) {
76     }
77
78
79     /* Getter for name
80      */

81     public String JavaDoc getName () {
82         return Util.THIS.getString ("NAME_WeakXMLActions");
83     }
84
85     /* Getter for help.
86      */

87     public HelpCtx getHelpCtx () {
88         return new HelpCtx (XMLViewActions.class);
89     }
90
91 }
92
Popular Tags