KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.netbeans.core.multiview.MultiViewHandlerDelegate;
23
24 /**
25  * A handler for the multiview's {@link org.openide.windows.TopComponent}, obtainable via
26  * {@link org.netbeans.core.spi.multiview.MultiViewFactory}, that allows
27  * examination of Component's content and programatic changes in visible/activated elements.
28  * @author mkleint
29  */

30 public final class MultiViewHandler {
31
32     static {
33         AccessorImpl.createAccesor();
34     }
35
36     private MultiViewHandlerDelegate del;
37
38     MultiViewHandler(MultiViewHandlerDelegate delegate) {
39         del = delegate;
40     }
41     /**
42      * Returns the array of <code>MultiViewPerspective</code>s that the {@link org.openide.windows.TopComponent} is composed of.
43      * @return array of defined perspectives.
44      */

45     public MultiViewPerspective[] getPerspectives() {
46         return del.getDescriptions();
47     }
48     
49     /**
50      * Returns the currently selected <code>MultiViewPerspective</code> in the {@link org.openide.windows.TopComponent}.
51      * It's element can be either visible or activated.
52      * @return selected perspective
53      */

54     public MultiViewPerspective getSelectedPerspective() {
55         return del.getSelectedDescription();
56     }
57     
58     /**
59      * returns the MultiViewElement for the given Description if previously created,
60      * otherwise null.
61      */

62 // SHOULD NOT BE USED, ONLY IN EMERGENCY CASE!
63
// public MultiViewPerspectiveComponent getElementForPerspective(MultiViewPerspective desc) {
64
// return del.getElementForDescription(desc);
65
// }
66

67     /**
68      * Requests focus for the <code>MultiViewPerspective</code> passed as parameter, if necessary
69      * will switch from previously selected <code>MultiViewPerspective</code>
70      * @param desc the new active selection
71      */

72     public void requestActive(MultiViewPerspective desc) {
73         del.requestActive(desc);
74     }
75     
76     /**
77      * Changes the visible <code>MultiViewPerspective</code> to the one passed as parameter.
78      * @param desc the new selection
79      *
80      */

81     
82     public void requestVisible(MultiViewPerspective desc) {
83         del.requestVisible(desc);
84     }
85     
86     
87  
88 }
89
Popular Tags