KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.JComponent JavaDoc;
23 import javax.swing.JToolBar JavaDoc;
24 import javax.swing.text.Document JavaDoc;
25 import org.openide.text.CloneableEditor;
26 import org.openide.text.CloneableEditorSupport;
27 import org.openide.text.NbDocument;
28
29 /**
30  * @author mkleint
31  */

32 abstract class MultiViewCloneableEditor extends CloneableEditor implements MultiViewElement {
33
34     private static final long serialVersionUID =-3126744316644172415L;
35
36     private transient MultiViewElementCallback multiViewObserver;
37     private transient JToolBar JavaDoc bar;
38     
39     /** Creates a new instance of MultiViewClonableEditor */
40     public MultiViewCloneableEditor() {
41         this(null);
42     }
43     
44     public MultiViewCloneableEditor(CloneableEditorSupport support) {
45         super(support);
46     }
47     
48     public JComponent JavaDoc getToolbarRepresentation() {
49         Document JavaDoc doc = getEditorPane().getDocument();
50         if (doc instanceof NbDocument.CustomToolbar) {
51             if (bar == null) {
52                 bar = ((NbDocument.CustomToolbar)doc).createToolbar(getEditorPane());
53             }
54             return bar;
55         }
56         return null;
57     }
58     
59     public javax.swing.JComponent JavaDoc getVisualRepresentation() {
60         return this;
61     }
62     
63     public final void setMultiViewCallback(MultiViewElementCallback callback) {
64         multiViewObserver = callback;
65     }
66     
67     protected final MultiViewElementCallback getElementObserver() {
68         return multiViewObserver;
69     }
70     
71     public void componentActivated() {
72         super.componentActivated();
73     }
74     
75     public void componentClosed() {
76         super.componentClosed();
77     }
78     
79     public void componentDeactivated() {
80         super.componentDeactivated();
81     }
82     
83     public void componentHidden() {
84         super.componentHidden();
85     }
86     
87     public void componentOpened() {
88         super.componentOpened();
89     }
90     
91     public void componentShowing() {
92         if (multiViewObserver != null) {
93             updateName();
94         }
95         super.componentShowing();
96     }
97     
98     public javax.swing.Action JavaDoc[] getActions() {
99         return super.getActions();
100     }
101     
102     public org.openide.util.Lookup getLookup() {
103         return super.getLookup();
104     }
105     
106     public String JavaDoc preferredID() {
107         return super.preferredID();
108     }
109     
110     
111     public void requestVisible() {
112         if (multiViewObserver != null) {
113             multiViewObserver.requestVisible();
114         } else {
115             super.requestVisible();
116         }
117     }
118     
119     public void requestActive() {
120         if (multiViewObserver != null) {
121             multiViewObserver.requestActive();
122         } else {
123             super.requestActive();
124         }
125     }
126     
127     
128     public void updateName() {
129         super.updateName();
130         if (multiViewObserver != null) {
131             multiViewObserver.updateTitle(getDisplayName());
132         }
133     }
134     
135     public void open() {
136         if (multiViewObserver != null) {
137             multiViewObserver.requestVisible();
138         } else {
139             super.open();
140         }
141         
142     }
143     
144     public CloseOperationState canCloseElement() {
145         throw new IllegalStateException JavaDoc("Not implemented yet.");
146 // return CloseOperationState.STATE_OK;
147
}
148     
149 }
150
Popular Tags