KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > spi > multiview > MultiViewElementCallback


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.spi.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.multiview.MultiViewElementCallbackDelegate;
27 import org.openide.util.Lookup;
28 import org.openide.windows.TopComponent;
29
30
31     /** Requester type of class, allowing implementors of MultiViewElement
32      * to send requests back to enclosing component and window system. Enclosing
33      * component or other part of window system will set the instance of this class to elements upon
34      * instantiation or deserialization of the element to receive requests properly.
35      * Implementors of MultiViewElement shall not attempt to serialize
36      * the passed callback instance.
37      *
38      */

39     public final class MultiViewElementCallback {
40         
41         static {
42             AccessorImpl.createAccesor();
43         }
44         
45         private MultiViewElementCallbackDelegate delegate;
46         
47         MultiViewElementCallback(MultiViewElementCallbackDelegate del) {
48             delegate = del;
49         }
50         
51         /** Activates this multi view element in enclosing multi view component
52          * context, if enclosing multi view top component is opened.
53          */

54         public void requestActive() {
55             delegate.requestActive();
56         }
57
58         /** Selects this multi view element in enclosing component context,
59          * if component is opened, but does not activate it
60          * unless enclosing component is in active mode already.
61          */

62         public void requestVisible () {
63             delegate.requestVisible();
64         }
65         
66         /**
67          * Creates the default TopComponent actions as defined by the Window System.
68          * Should be used by the element when constructing it's own getActions() return value.
69          */

70         public Action JavaDoc[] createDefaultActions() {
71             return delegate.createDefaultActions();
72         }
73         
74         /**
75          * Update the multiview's topcomponent title.
76          */

77         public void updateTitle(String JavaDoc title) {
78             delegate.updateTitle(title);
79         }
80         
81         /**
82          * Element can check if it's currently the selected element.
83          */

84         public boolean isSelectedElement() {
85             return delegate.isSelectedElement();
86         }
87         
88         /**
89          * Returns the enclosing Multiview's topcomponent.
90          */

91         public TopComponent getTopComponent() {
92             return delegate.getTopComponent();
93         }
94         
95     } // end of ActionRequestListener
96

97
Popular Tags