KickJava   Java API By Example, From Geeks To Geeks.

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


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.openide.awt.UndoRedo;
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 Dafe Simonek, Milos Kleint
33  */

34 public interface MultiViewElement {
35
36     /** Returns Swing visual representation of this multi view element. Should be relatively fast
37      * and always return the same component.
38      */

39     JComponent JavaDoc getVisualRepresentation ();
40     
41     /**
42      * Returns the visual component with the multi view element's toolbar.Should be relatively fast as it's called
43      * everytime the current perspective is switched.
44      */

45     JComponent JavaDoc getToolbarRepresentation ();
46     
47     /**
48      * Gets the actions which will appear in the popup menu of this component.
49      * <p>Subclasses are encouraged to use add the default TopComponent actions to
50      * the array of their own. These are accessible by calling MultiViewElementCallback.createDefaultActions()
51      *<pre>
52      * <code>
53      * public Action[] getActions() {
54      * Action[] retValue;
55      * // the multiviewObserver was passed to the element in setMultiViewCallback() method.
56      * if (multiViewObserver != null) {
57      * retValue = multiViewObserver.createDefaultActions();
58      * // add you own custom actions here..
59      * } else {
60      * // fallback..
61      * retValue = super.getActions();
62      * }
63      * return retValue;
64      * }
65      * </code>
66      *</pre>
67      * @return array of actions for this component
68      */

69     Action JavaDoc[] getActions();
70
71     /**
72      * Lookup for the MultiViewElement. Will become part of the TopComponent's lookup.
73      * @return the lookup to use when the MultiViewElement is active.
74      */

75     Lookup getLookup();
76     
77     
78     /** Called only when enclosing multi view top component was closed before and
79      * now is opened again for the first time. The intent is to
80      * provide subclasses information about multi view TopComponent's life cycle.
81      * Subclasses will usually perform initializing tasks here.
82      */

83     void componentOpened();
84     
85     /** Called only when multi view top component was closed. The intent is
86      * to provide subclasses information about TopComponent's life cycle.
87      * Subclasses will usually perform cleaning tasks here.
88      */

89     void componentClosed();
90
91     /** Called when this MultiViewElement is about to be shown.
92      * That can happen when switching the current perspective/view or when the topcomonent itself is shown for the first time.
93      */

94     void componentShowing();
95     
96     /** Called when this MultiViewElement was hidden. This happens when other view replaces this one as the selected view or
97      * when the whole topcomponent gets hidden (eg. when user selects anothe topcomponent in the current mode).
98      */

99     void componentHidden();
100     
101     /** Called when this multi view element is activated.
102     * This happens when the parent window of this component gets focus
103     * (and this component is the preferred one in it), <em>or</em> when
104     * this component is selected in its window (and its window was already focused).
105     */

106     void componentActivated ();
107
108     /** Called when this multi view element is deactivated.
109     * This happens when the parent window of this component loses focus
110     * (and this component is the preferred one in the parent),
111     * <em>or</em> when this component loses preference in the parent window
112     * (and the parent window is focussed).
113     */

114     void componentDeactivated ();
115     
116     /**
117      * UndoRedo support,
118      * Get the undo/redo support for this element.
119      *
120      * @return undoable edit for this component, null if not implemented.
121      */

122     UndoRedo getUndoRedo();
123     
124
125     /**
126      * Use the passed in callback instance for manipulating the enclosing multiview component, keep the instance around
127      * during lifecycle of the component if you want to automatically switch to this component etc.
128      * The enclosing window enviroment attaches the callback right after creating
129      * the element from the description.
130      * Same applies for deserialization of MultiViewTopComponent, thus MultiViewElement
131      * implementors shall not attempt to serialize the passed instance.
132      */

133     void setMultiViewCallback (MultiViewElementCallback callback);
134     
135     /**
136      * Element decides if it can be safely closed. The element shall just return a value
137      * (created by MultiViewFactory.createCloseState() factory method),
138      * not open any UI, that is a semantical difference from TopComponent.canClose().
139      * The CloseOperationHandler is the centralized place to show dialogs to the user.
140      * In cases when the element is consistent, just return CloseOperationState.STATE_OK.
141      */

142     CloseOperationState canCloseElement();
143     
144    
145 }
Popular Tags