KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > api > multiview > MultiViewPerspectiveComponent


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.core.api.multiview;
21
22 import java.util.TooManyListenersException JavaDoc;
23 import javax.swing.Action JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import javax.swing.JToolBar JavaDoc;
26 import org.netbeans.core.spi.multiview.MultiViewElement;
27 import org.openide.util.Lookup;
28
29 /** View element for multi view, provides the UI components to the multiview component.
30  * Gets notified by the enclosing component about the changes in the lifecycle.
31  *
32  * @author Milos Kleint
33  */

34
35 // IS NOT PUBLIC, SHOULD NOT BE USED, ONLY IN EMERGENCY CASE!
36
final class MultiViewPerspectiveComponent {
37
38     static {
39         AccessorImpl.createAccesor();
40     }
41     
42     private MultiViewElement element;
43     
44     MultiViewPerspectiveComponent(MultiViewElement elem) {
45         element = elem;
46     }
47     
48     // package private, access through Accessor
49
MultiViewElement getElement() {
50         return element;
51     }
52
53     /** Returns Swing visual representation of this multi view element. Should be relatively fast
54      * and always return the same component.
55      */

56     public JComponent JavaDoc getVisualRepresentation () {
57         return element.getVisualRepresentation();
58     }
59     
60     /**
61      * Returns the visual component with the multi view element's toolbar.Should be relatively fast as it's called
62      * everytime the current perspective is switched.
63      */

64     public JComponent JavaDoc getToolbarRepresentation () {
65         return element.getToolbarRepresentation();
66     }
67     
68     /** Gets the actions which will appear in the popup menu of this component.
69      * <p>Subclasses are encouraged to use add the default TopComponent actions to
70      * the array of their own. These are accessible by calling MultiViewElementCallback.createDefaultActions()
71      * @return array of actions for this component
72      */

73     public Action JavaDoc[] getActions() {
74         return element.getActions();
75     }
76
77     /**
78      * Lookup for the MultiViewElement. Will become part of the TopComponent's lookup.
79      * @return the lookup to use when the MultiViewElement is active.
80      */

81     public Lookup getLookup() {
82         return element.getLookup();
83     }
84     
85    
86 }
Popular Tags