KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > util > actions > Presenter


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.openide.util.actions;
20
21 import java.awt.Component JavaDoc;
22
23 import javax.swing.*;
24
25
26 /** Provides a presentation feature for an action.
27 * Each {@link SystemAction action} that wants to offer a kind of presentation of itself
28 * to the user should implement one of the inner interfaces.
29 * <P>
30 * For example to be presented in popup menu, an action should
31 * implement {@link Presenter.Popup}.
32 * <p> Normally actions should implement both {@link Presenter.Menu} and
33 * {@link Presenter.Popup} together and return the same menu item for each.
34 * <p><em>Note:</em> implementing these interfaces yourself means that you want to
35 * provide some sort of unusual display format, e.g. a submenu!
36 * Most people will simply want to use a subclass of {@link CallableSystemAction}
37 * and use the default implementations of all three interfaces, according to
38 * {@link SystemAction#getName} and {@link SystemAction#iconResource}.
39 *
40 * @author Jaroslav Tulach
41 */

42 public interface Presenter {
43     /** The presenter interface for presenting an action in a menu.
44     */

45     public interface Menu extends Presenter {
46         /** Get a menu item that can present this action in a {@link javax.swing.JMenu}.
47          * If your menu content is dynamic in nature, consider using <a HREF="@org-openide-awt@/org/openide/awt/DynamicMenuContent.html">DynamicMenuContent</a>
48          * @return the representation for this action
49          */

50         public JMenuItem getMenuPresenter();
51     }
52
53     /** The presenter interface for presenting an action in a popup menu.
54     */

55     public interface Popup extends Presenter {
56         /** Get a menu item that can present this action in a {@link javax.swing.JPopupMenu}.
57          * If your menu content is dynamic in nature, consider using <a HREF="@org-openide-awt@/org/openide/awt/DynamicMenuContent.html">DynamicMenuContent</a>
58         * @return the representation for this action
59         */

60         public JMenuItem getPopupPresenter();
61     }
62
63     /** The presenter interface for presenting an action in a toolbar.
64     */

65     public interface Toolbar extends Presenter {
66         /** Get a component that can present this action in a {@link javax.swing.JToolBar}.
67         * @return the representation for this action
68         */

69         public Component JavaDoc getToolbarPresenter();
70     }
71 }
72
Popular Tags