KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > TopComponentGroupImpl


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
21 package org.netbeans.core.windows;
22
23
24 import org.openide.windows.TopComponent;
25 import org.openide.windows.TopComponentGroup;
26
27 import java.util.Iterator JavaDoc;
28 import java.util.Set JavaDoc;
29
30
31 /**
32  * Class representing group of TopComponents. Those TopComponents belong together
33  * in the sense they can be opened or closed at one step.
34  *
35  * @author Peter Zavadsky
36  */

37 public class TopComponentGroupImpl implements TopComponentGroup {
38
39
40     /** Creates a new instance of TopComponentGroup */
41     public TopComponentGroupImpl(String JavaDoc name) {
42         this(name, false);
43     }
44     
45     public TopComponentGroupImpl(String JavaDoc name, boolean opened) {
46         getCentral().createGroupModel(this, name, opened);
47     }
48     
49
50     public void open() {
51         WindowManagerImpl.assertEventDispatchThread();
52         
53         getCentral().openGroup(this);
54     }
55     
56     public void close() {
57         WindowManagerImpl.assertEventDispatchThread();
58         
59         getCentral().closeGroup(this);
60     }
61     
62     public Set JavaDoc<TopComponent> getTopComponents() {
63         return getCentral().getGroupTopComponents(this);
64     }
65
66     
67     public String JavaDoc getName() {
68         return getCentral().getGroupName(this);
69     }
70     
71     public boolean isOpened() {
72         return getCentral().isGroupOpened(this);
73     }
74     
75     public Set JavaDoc<TopComponent> getOpeningSet() {
76         return getCentral().getGroupOpeningTopComponents(this);
77     }
78     
79     public Set JavaDoc getClosingSet() {
80         return getCentral().getGroupClosingTopComponents(this);
81     }
82
83     public boolean addUnloadedTopComponent(String JavaDoc tcID) {
84         return getCentral().addGroupUnloadedTopComponent(this, tcID);
85     }
86     
87     public boolean removeUnloadedTopComponent(String JavaDoc tcID) {
88         return getCentral().removeGroupUnloadedTopComponent(this, tcID);
89     }
90     
91     public boolean addUnloadedOpeningTopComponent(String JavaDoc tcID) {
92         return getCentral().addGroupUnloadedOpeningTopComponent(this, tcID);
93     }
94     
95     public boolean removeUnloadedOpeningTopComponent(String JavaDoc tcID) {
96         return getCentral().removeGroupUnloadedOpeningTopComponent(this, tcID);
97     }
98     
99     public boolean addUnloadedClosingTopComponent(String JavaDoc tcID) {
100         return getCentral().addGroupUnloadedClosingTopComponent(this, tcID);
101     }
102     
103     public boolean removeUnloadedClosingTopComponent(String JavaDoc tcID) {
104         return getCentral().removeGroupUnloadedClosingTopComponent(this, tcID);
105     }
106     
107     // XXX
108
/** Just for persistence management. */
109     public boolean addGroupUnloadedOpenedTopComponent(String JavaDoc tcID) {
110         return getCentral().addGroupUnloadedOpenedTopComponent(this, tcID);
111     }
112     
113     public Set JavaDoc getGroupOpenedTopComponents() {
114         return getCentral().getGroupOpenedTopComponents(this);
115     }
116     
117     // XXX>>
118
public Set JavaDoc<String JavaDoc> getTopComponentsIDs() {
119         return getCentral().getGroupTopComponentsIDs(this);
120     }
121     
122     public Set JavaDoc<String JavaDoc> getOpeningSetIDs() {
123         return getCentral().getGroupOpeningSetIDs(this);
124     }
125     
126     public Set JavaDoc<String JavaDoc> getClosingSetIDs() {
127         return getCentral().getGroupClosingSetIDs(this);
128     }
129     
130     public Set JavaDoc<String JavaDoc> getGroupOpenedTopComponentsIDs() {
131         return getCentral().getGroupOpenedTopComponentsIDs(this);
132     }
133     // XXX<<
134

135     private Central getCentral() {
136         return WindowManagerImpl.getInstance().getCentral();
137     }
138     
139     public String JavaDoc toString() {
140         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
141         for(Iterator JavaDoc it = getTopComponents().iterator(); it.hasNext(); ) {
142             TopComponent tc = (TopComponent)it.next();
143             buff.append("\n\t" + tc.getClass().getName() + "@" + Integer.toHexString(tc.hashCode()) // NOI18N
144
+ "[name=" + tc.getName() // NOI18N
145
+ ", openFlag=" + getOpeningSet().contains(tc) // NOI18N
146
+ ", closeFlag=" + getClosingSet().contains(tc) + "]"); // NOI18N
147
}
148         
149         return super.toString() + "[topComponents=[" + buff.toString() + "\n]]"; // NOI18N
150
}
151
152 }
153
Popular Tags