KickJava   Java API By Example, From Geeks To Geeks.

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


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.netbeans.core.windows.persistence.GroupConfig;
25 import org.netbeans.core.windows.persistence.ModeConfig;
26 import org.netbeans.core.windows.persistence.TCRefConfig;
27 import org.netbeans.core.windows.persistence.WindowManagerConfig;
28
29 import java.awt.*;
30 import java.util.ArrayList JavaDoc;
31 import java.util.List JavaDoc;
32
33
34 /**
35  * Factory which can produce winsys configuration (<code>WindowManagerConfig</code>).
36  * Used as a fallback configuration in case of persistence problems.
37  *
38  * @author Peter Zavadsky
39  */

40 abstract class ConfigFactory {
41
42     // For shorten names.
43
private static final int VERTICAL = Constants.VERTICAL;
44     private static final int HORIZONTAL = Constants.HORIZONTAL;
45     
46     /** Creates a new instance of Defaults */
47     private ConfigFactory() {
48     }
49     
50     
51     public static WindowManagerConfig createDefaultConfig() {
52         WindowManagerConfig wmc = new WindowManagerConfig();
53         wmc.xJoined = 100;
54         wmc.yJoined = 100;
55         wmc.widthJoined = 800;
56         wmc.heightJoined = 600;
57         wmc.relativeXJoined = -1;
58         wmc.relativeYJoined = -1;
59         wmc.relativeWidthJoined = -1;
60         wmc.relativeHeightJoined = -1;
61         wmc.centeredHorizontallyJoined = false;
62         wmc.centeredVerticallyJoined = false;
63         wmc.maximizeIfWidthBelowJoined = -1;
64         wmc.maximizeIfHeightBelowJoined = -1;
65         
66         wmc.editorAreaState = Constants.EDITOR_AREA_JOINED;
67         wmc.editorAreaConstraints = createDefaultEditorAreaConstraints();
68         wmc.editorAreaBounds = null;
69         wmc.editorAreaRelativeBounds = null;
70         
71         wmc.screenSize = new Dimension(1024, 750);
72         wmc.activeModeName = "editor"; // NOI18N
73
wmc.editorMaximizedModeName = "";
74         wmc.viewMaximizedModeName = "";
75         wmc.toolbarConfiguration = "Standard"; // NOI18N
76
wmc.preferredToolbarIconSize = 24;
77         wmc.modes = createDefaultModeConfigs();
78         wmc.groups = createDefaultGroupConfigs();
79         return wmc;
80     }
81     
82     /** @return list of <code>Item</code>S as constraints */
83     private static SplitConstraint[] createDefaultEditorAreaConstraints() {
84         return new SplitConstraint[] {
85             new SplitConstraint(HORIZONTAL, 1, 0.75D),
86             new SplitConstraint(VERTICAL, 0, 0.75D),
87             new SplitConstraint(HORIZONTAL, 0, 0.75D)
88         };
89     }
90     
91     /** @return list of <code>ModeConfig</code>S. */
92     private static ModeConfig[] createDefaultModeConfigs() {
93         List JavaDoc<ModeConfig> l = new ArrayList JavaDoc<ModeConfig>();
94         l.add(createDefaultExplorerModeConfig());
95         l.add(createDefaultPropertiesModeConfig());
96         l.add(createDefaultEditorModeConfig());
97         l.add(createDefaultOutputModeConfig());
98         l.add(createDefaultFormModeConfig());
99         return l.toArray(new ModeConfig[0]);
100     }
101     
102     private static ModeConfig createDefaultExplorerModeConfig() {
103         ModeConfig mc = new ModeConfig();
104         mc.name = "explorer"; // NOI18N
105
mc.bounds = null;
106         mc.relativeBounds = null;
107         mc.frameState = -1;
108         mc.state = Constants.MODE_STATE_JOINED;
109         mc.kind = Constants.MODE_KIND_VIEW;
110         mc.constraints = createDefaultExplorerConstraints();
111         mc.selectedTopComponentID = "runtime"; // NOI18N
112
mc.permanent = true;
113         mc.tcRefConfigs = createDefaultExplorerTCRefConfigs();
114         return mc;
115     }
116
117     /** @return list of <code>Item</code>S */
118     private static SplitConstraint[] createDefaultExplorerConstraints() {
119         return new SplitConstraint[] {
120             new SplitConstraint(HORIZONTAL, 0, 0.30D),
121             new SplitConstraint(VERTICAL, 0, 0.70D)
122         };
123     }
124     
125     private static TCRefConfig[] createDefaultExplorerTCRefConfigs() {
126         List JavaDoc<TCRefConfig> tcRefConfigs = new ArrayList JavaDoc<TCRefConfig>();
127         tcRefConfigs.add(createDefaultRuntimeTCRefConfig());
128         return tcRefConfigs.toArray(new TCRefConfig[0]);
129     }
130
131     private static TCRefConfig createDefaultRuntimeTCRefConfig() {
132         TCRefConfig tcrc = new TCRefConfig();
133         tcrc.tc_id = "runtime"; // NOI18N
134
tcrc.opened = true;
135         return tcrc;
136     }
137     
138     private static ModeConfig createDefaultPropertiesModeConfig() {
139         ModeConfig mc = new ModeConfig();
140         mc.name = "properties"; // NOI18N
141
mc.bounds = null;
142         mc.relativeBounds = null;
143         mc.frameState = -1;
144         mc.state = Constants.MODE_STATE_JOINED;
145         mc.kind = Constants.MODE_KIND_VIEW;
146         mc.constraints = createDefaultPropertiesConstraints();
147         mc.selectedTopComponentID = "properties"; // NOI18N
148
mc.permanent = true;
149         mc.tcRefConfigs = createDefaultPropertiesTCRefConfigs();
150         return mc;
151     }
152     
153     /** @return list of <code>Item</code>S */
154     private static SplitConstraint[] createDefaultPropertiesConstraints() {
155         return new SplitConstraint[] {
156             new SplitConstraint(HORIZONTAL, 0, 0.30D),
157             new SplitConstraint(VERTICAL, 1, 0.30D)
158         };
159     }
160     
161     private static TCRefConfig[] createDefaultPropertiesTCRefConfigs() {
162         List JavaDoc<TCRefConfig> tcRefConfigs = new ArrayList JavaDoc<TCRefConfig>();
163         tcRefConfigs.add(createDefaultPropertiesTCRefConfig());
164         return tcRefConfigs.toArray(new TCRefConfig[0]);
165     }
166
167     private static TCRefConfig createDefaultPropertiesTCRefConfig() {
168         TCRefConfig tcrc = new TCRefConfig();
169         tcrc.tc_id = "properties"; // NOI18N
170
tcrc.opened = true;
171         return tcrc;
172     }
173     
174     private static ModeConfig createDefaultEditorModeConfig() {
175         ModeConfig mc = new ModeConfig();
176         mc.name = "editor";
177         mc.bounds = null;
178         mc.relativeBounds = null;
179         mc.frameState = -1;
180         mc.state = Constants.MODE_STATE_JOINED;
181         mc.kind = Constants.MODE_KIND_EDITOR;
182         mc.constraints = createDefaultEditorConstraints();
183         mc.selectedTopComponentID = null;
184         mc.permanent = true;
185         mc.tcRefConfigs = createDefaultEditorTCRefConfigs();
186         return mc;
187     }
188
189     /** @return list of <code>Item</code>S */
190     private static SplitConstraint[] createDefaultEditorConstraints() {
191         return new SplitConstraint[] {};
192     }
193     
194     private static TCRefConfig[] createDefaultEditorTCRefConfigs() {
195         List JavaDoc<TCRefConfig> tcRefConfigs = new ArrayList JavaDoc<TCRefConfig>();
196         tcRefConfigs.add(createDefaultWelcomeTCRefConfig());
197         return tcRefConfigs.toArray(new TCRefConfig[0]);
198     }
199
200     private static TCRefConfig createDefaultWelcomeTCRefConfig() {
201         TCRefConfig tcrc = new TCRefConfig();
202         tcrc.tc_id = "Welcome"; // NOI18N
203
tcrc.opened = true;
204         return tcrc;
205     }
206
207     private static ModeConfig createDefaultOutputModeConfig() {
208         ModeConfig mc = new ModeConfig();
209         mc.name = "output";
210         mc.bounds = null;
211         mc.relativeBounds = null;
212         mc.frameState = -1;
213         mc.state = Constants.MODE_STATE_JOINED;
214         mc.kind = Constants.MODE_KIND_VIEW;
215         mc.constraints = createDefaultOutputConstraints();
216         mc.selectedTopComponentID = null;
217         mc.permanent = true;
218         mc.tcRefConfigs = createDefaultOutputTCRefConfigs();
219         return mc;
220     }
221     
222     /** @return list of <code>Item</code>S */
223     private static SplitConstraint[] createDefaultOutputConstraints() {
224         return new SplitConstraint[] {
225             new SplitConstraint(HORIZONTAL, 1, 0.70D),
226             new SplitConstraint(VERTICAL, 1, 0.20D),
227             new SplitConstraint(HORIZONTAL, 0, 0.80D)
228         };
229     }
230     
231     private static TCRefConfig[] createDefaultOutputTCRefConfigs() {
232         List JavaDoc<TCRefConfig> tcRefConfigs = new ArrayList JavaDoc<TCRefConfig>();
233         tcRefConfigs.add(createDefaultOutputTCRefConfig());
234         return tcRefConfigs.toArray(new TCRefConfig[0]);
235     }
236
237     private static TCRefConfig createDefaultOutputTCRefConfig() {
238         TCRefConfig tcrc = new TCRefConfig();
239         tcrc.tc_id = "output"; // NOI18N
240
tcrc.opened = true;
241         return tcrc;
242     }
243     
244     private static ModeConfig createDefaultFormModeConfig() {
245         ModeConfig mc = new ModeConfig();
246         mc.name = "Form";
247         mc.bounds = null;
248         mc.relativeBounds = null;
249         mc.frameState = -1;
250         mc.state = Constants.MODE_STATE_JOINED;
251         mc.kind = Constants.MODE_KIND_VIEW;
252         mc.constraints = createDefaultFormConstraints();
253         mc.selectedTopComponentID = "ComponentInspector"; // NOI18N
254
mc.permanent = true;
255         mc.tcRefConfigs = createDefaultFormTCRefConfigs();
256         return mc;
257     }
258
259     /** @return list of <code>Item</code>S */
260     private static SplitConstraint[] createDefaultFormConstraints() {
261         return new SplitConstraint[] {
262             new SplitConstraint(HORIZONTAL, 1, 0.70D),
263             new SplitConstraint(VERTICAL, 0, 0.80D),
264             new SplitConstraint(HORIZONTAL, 1, 0.50D)
265         };
266     }
267     
268     private static TCRefConfig[] createDefaultFormTCRefConfigs() {
269         List JavaDoc<TCRefConfig> tcRefConfigs = new ArrayList JavaDoc<TCRefConfig>();
270         tcRefConfigs.add(createDefaultComponentInspectorTCRefConfig());
271         tcRefConfigs.add(createDefaultComponentPaletteTCRefConfig());
272         return tcRefConfigs.toArray(new TCRefConfig[0]);
273     }
274
275     private static TCRefConfig createDefaultComponentInspectorTCRefConfig() {
276         TCRefConfig tcrc = new TCRefConfig();
277         tcrc.tc_id = "ComponentInspector"; // NOI18N
278
tcrc.opened = true;
279         return tcrc;
280     }
281
282     private static TCRefConfig createDefaultComponentPaletteTCRefConfig() {
283         TCRefConfig tcrc = new TCRefConfig();
284         tcrc.tc_id = "CommonPalette"; // NOI18N
285
tcrc.opened = true;
286         tcrc.dockedInMaximizedMode = true;
287         return tcrc;
288     }
289     
290
291     /** @return list of <code>GroupConfig</code>S. */
292     private static GroupConfig[] createDefaultGroupConfigs() {
293         List JavaDoc<GroupConfig> l = new ArrayList JavaDoc<GroupConfig>();
294         // TODO
295
return l.toArray(new GroupConfig[0]);
296     }
297
298
299 }
300
Popular Tags