KickJava   Java API By Example, From Geeks To Geeks.

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


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
34 /**
35  *
36  * @author mkleint
37  */

38 public class MVElem implements MultiViewElement {
39     private StringBuffer JavaDoc log;
40     private Action JavaDoc[] actions;
41     public MultiViewElementCallback observer;
42     private JPanel JavaDoc visualRepre;
43     private transient UndoRedo undoredo;
44     
45     MVElem() {
46         this(new Action JavaDoc[0]);
47     }
48     
49     MVElem(Action JavaDoc[] actions) {
50         log = new StringBuffer JavaDoc();
51         this.actions = actions;
52         visualRepre = new JPanel JavaDoc();
53     }
54     
55     public String JavaDoc getLog() {
56         return log.toString();
57     }
58     
59     public void resetLog() {
60         log = new StringBuffer JavaDoc();
61     }
62     
63     public void componentActivated() {
64         log.append("componentActivated-");
65         
66     }
67     
68     public void componentClosed() {
69         log.append("componentClosed-");
70     }
71     
72     public void componentDeactivated() {
73         log.append("componentDeactivated-");
74     }
75     
76     public void componentHidden() {
77         log.append("componentHidden-");
78     }
79     
80     public void componentOpened() {
81         log.append("componentOpened-");
82     }
83     
84     public void componentShowing() {
85         log.append("componentShowing-");
86     }
87     
88     public javax.swing.Action JavaDoc[] getActions() {
89         return actions;
90     }
91     
92     public org.openide.util.Lookup getLookup() {
93         return Lookups.fixed(new Object JavaDoc[] {this});
94     }
95     
96     public JComponent JavaDoc getToolbarRepresentation() {
97         return new JToolBar JavaDoc();
98     }
99     
100     public javax.swing.JComponent JavaDoc getVisualRepresentation() {
101         return visualRepre;
102     }
103     
104     public String JavaDoc preferredID() {
105         return "test";
106     }
107     
108 // public void removeActionRequestObserver() {
109
// observer = null;
110
// }
111

112     
113     public void setMultiViewCallback (MultiViewElementCallback callback) {
114         this.observer = callback;
115     }
116     
117     public void doRequestActive() {
118         observer.requestActive();
119     }
120
121     public void doRequestVisible() {
122         observer.requestVisible();
123     }
124     
125     public void setUndoRedo(UndoRedo redo) {
126         undoredo = redo;
127     }
128     
129     public UndoRedo getUndoRedo() {
130         return undoredo;
131     }
132     
133     public CloseOperationState canCloseElement() {
134         return CloseOperationState.STATE_OK;
135     }
136     
137 }
138
139
Popular Tags