KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > multiview > MVElemTopComponent


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.multiview;
21
22 import org.netbeans.core.spi.multiview.MultiViewElementCallback;
23
24 import javax.swing.Action JavaDoc;
25 import javax.swing.JComponent JavaDoc;
26 import javax.swing.JPanel JavaDoc;
27 import javax.swing.JToolBar JavaDoc;
28 import org.netbeans.core.spi.multiview.CloseOperationState;
29 import org.netbeans.core.spi.multiview.MultiViewElement;
30 import org.netbeans.core.spi.multiview.MultiViewFactory;
31 import org.openide.awt.UndoRedo;
32 import org.openide.util.lookup.Lookups;
33 import org.openide.windows.TopComponent;
34
35 /**
36  *
37  * @author mkleint
38  */

39 public class MVElemTopComponent extends TopComponent implements MultiViewElement {
40     private StringBuffer JavaDoc log;
41     public MultiViewElementCallback observer;
42     private transient UndoRedo undoredo;
43     
44     MVElemTopComponent() {
45         resetLog();
46     }
47     
48     
49     public String JavaDoc getLog() {
50         return log.toString();
51     }
52     
53     public void resetLog() {
54         log = new StringBuffer JavaDoc();
55     }
56     
57     public void componentActivated() {
58         super.componentActivated();
59         log.append("componentActivated-");
60         
61     }
62     
63     public void componentClosed() {
64         super.componentClosed();
65         log.append("componentClosed-");
66     }
67     
68     public void componentDeactivated() {
69         super.componentDeactivated();
70         log.append("componentDeactivated-");
71     }
72     
73     public void componentHidden() {
74         super.componentHidden();
75         log.append("componentHidden-");
76     }
77     
78     public void componentOpened() {
79         super.componentOpened();
80         log.append("componentOpened-");
81     }
82     
83     public void componentShowing() {
84         super.componentShowing();
85         log.append("componentShowing-");
86     }
87     
88     
89     public JComponent JavaDoc getToolbarRepresentation() {
90         return new JToolBar JavaDoc();
91     }
92     
93     public javax.swing.JComponent JavaDoc getVisualRepresentation() {
94         return this;
95     }
96     
97     public String JavaDoc preferredID() {
98         return super.preferredID();
99     }
100     
101 // public void removeActionRequestObserver() {
102
// observer = null;
103
// }
104

105     
106     public void setMultiViewCallback (MultiViewElementCallback callback) {
107         this.observer = callback;
108     }
109     
110     public void doRequestActive() {
111         observer.requestActive();
112     }
113
114     public void doRequestVisible() {
115         observer.requestVisible();
116     }
117     
118     public void setUndoRedo(UndoRedo redo) {
119         undoredo = redo;
120     }
121     
122 // public UndoRedo getUndoRedo() {
123
// return undoredo;
124
// }
125

126     public CloseOperationState canCloseElement() {
127         return CloseOperationState.STATE_OK;
128     }
129     
130 }
131
132
Popular Tags