KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > actions > CssRuleNavigationAction


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  * CssRuleListAction.java
22  *
23  * Created on February 01, 2005, 4:49 PM
24  */

25
26 package org.netbeans.modules.css.actions;
27
28
29 import java.awt.BorderLayout JavaDoc;
30 import javax.swing.JLabel JavaDoc;
31 import javax.swing.JPanel JavaDoc;
32 import org.openide.nodes.Node;
33 import org.openide.explorer.ExplorerManager;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.NbBundle;
36 import org.openide.util.actions.CookieAction;
37
38
39 /**
40  * Action to present the list of CSS classes in the CSS editor toolbar
41  * @author Winston Prakash
42  * @version 1.0
43  */

44 public class CssRuleNavigationAction extends CookieAction {
45
46     /**
47      * Cookies required for this action to be activated.
48      */

49     private static final Class JavaDoc[] REQUIRED_COOKIES = new Class JavaDoc[] {
50         //SourceCookie.Editor.class
51
};
52
53
54     public HelpCtx getHelpCtx() {
55         return HelpCtx.DEFAULT_HELP;
56     }
57
58     /**
59      * Return the display name for the action.
60      */

61     public String JavaDoc getName() {
62         return NbBundle.getMessage(CssRuleNavigationAction.class, "RULE_LIST_ACTION");
63     }
64
65     /**
66      * The action accepts only one node with a java source on it.
67      */

68     protected int mode() {
69         return MODE_EXACTLY_ONE;
70     }
71
72     protected Class JavaDoc[] cookieClasses() {
73         return REQUIRED_COOKIES;
74     }
75
76     /**
77      * Perform the Action
78      */

79     protected void performAction(Node[] activatedNodes) {
80         // Do nothing. Toobar presenter will take care
81
}
82
83     public java.awt.Component JavaDoc getToolbarPresenter() {
84         java.awt.Component JavaDoc c = new ToolbarPresenter();
85         return c;
86     }
87
88     private static class ToolbarPresenter extends JPanel JavaDoc{
89
90         private static final int FIXED_WIDTH = 200;
91
92         CssRuleNavigationView explorerView;
93         JLabel JavaDoc comboLabel;
94         ExplorerManager manager;
95
96         ToolbarPresenter() {
97             initComponents();
98         }
99
100         private void initComponents() {
101             setLayout(new BorderLayout JavaDoc(2,0));
102
103             explorerView = new CssRuleNavigationView();
104
105             comboLabel = new JLabel JavaDoc();
106             comboLabel.setLabelFor(explorerView);
107
108             add(explorerView, BorderLayout.CENTER);
109             add(comboLabel, BorderLayout.WEST);
110         }
111
112         public java.awt.Dimension JavaDoc getMinimumSize() {
113             // minimum width to prevent excessive horizontal shrinking
114
return new java.awt.Dimension JavaDoc(FIXED_WIDTH, getPreferredSize().height);
115         }
116
117         public java.awt.Dimension JavaDoc getMaximumSize() {
118             // minimum width to prevent moving of the remaining contents of the toolbar
119
return new java.awt.Dimension JavaDoc(FIXED_WIDTH, getPreferredSize().height);
120         }
121
122     }
123 }
124
Popular Tags