KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > persistence > WindowManagerConfig


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.persistence;
22
23
24 import org.netbeans.core.windows.SplitConstraint;
25
26 import java.awt.*;
27
28
29 /**
30  * Class of window manager config properties for communication with persistence management.
31  * It keeps data which are read/written from/in .wsmgr xml file.
32  *
33  * @author Peter Zavadsky
34  */

35 public class WindowManagerConfig {
36     /////////////////////
37
// SEPARATED STATE
38
//////////
39
// BEGIN Values specific for initial main window position
40
// Note: Only absolute bounds are saved [x,y,w,h].
41
//////////
42
/** Flag to control horizontal position of main window. If it is true x is
43      undefined. */

44     public boolean centeredHorizontallySeparated;
45     
46     /** Flag to control vertical position of main window . If it is true y is
47      undefined. */

48     public boolean centeredVerticallySeparated;
49     
50     /** Horizontal absolute position of main window. */
51     public int xSeparated;
52     
53     /** Vertical absolute position of main window */
54     public int ySeparated;
55     
56     /** Width of main window. -1 means not set. Either width or relative width
57      should be set. */

58     public int widthSeparated;
59     
60     /** Height of main window. -1 means not set. Either height or relative height
61      should be set. */

62     public int heightSeparated;
63     
64     /** Relative x of main window. -1 means not set. */
65     public float relativeXSeparated;
66     
67     /** Relative y of main window. -1 means not set. */
68     public float relativeYSeparated;
69     
70     /** Relative width of main window. -1 means not set. */
71     public float relativeWidthSeparated;
72     
73     /** Relative height of main window. -1 means not set. */
74     public float relativeHeightSeparated;
75     //////////
76
// END
77
//////////
78

79     //////////////
80
// JOINED STATE
81
//////////
82
// BEGIN Values specific for initial main window position
83
// Note: Only absolute bounds are saved [x,y,w,h].
84
//////////
85
/** Flag to control horizontal position of main window. If it is true x is
86      undefined. */

87     public boolean centeredHorizontallyJoined;
88     
89     /** Flag to control vertical position of main window . If it is true y is
90      undefined. */

91     public boolean centeredVerticallyJoined;
92     
93     /** Horizontal absolute position of main window. */
94     public int xJoined;
95     
96     /** Vertical absolute position of main window */
97     public int yJoined;
98     
99     /** Width of main window. -1 means not set. Either width or relative width
100      should be set. */

101     public int widthJoined;
102     
103     /** Height of main window. -1 means not set. Either height or relative height
104      should be set. */

105     public int heightJoined;
106     
107     /** Relative x of main window. -1 means not set. */
108     public float relativeXJoined;
109     
110     /** Relative y of main window. -1 means not set. */
111     public float relativeYJoined;
112     
113     /** Relative width of main window. -1 means not set. */
114     public float relativeWidthJoined;
115     
116     /** Relative height of main window. -1 means not set. */
117     public float relativeHeightJoined;
118     
119     /** Minimum allowed width of main window for computing initial size */
120     public int maximizeIfWidthBelowJoined;
121     
122     /** Minimum allowed height of main window for computing initial size */
123     public int maximizeIfHeightBelowJoined;
124     //////////
125
// END
126
//////////
127
/** Frame state of main window when in tiled(joined) state.
128      * Possible values are taken from java.awt.Frame:
129      * NORMAL
130      * ICONIFIED
131      * MAXIMIZED_HORIZ
132      * MAXIMIZED_VERT
133      * MAXIMIZED_BOTH
134      */

135     public int mainWindowFrameStateJoined;
136     /** Frame state of main window when in separated state.
137      * Possible values are taken from java.awt.Frame:
138      * NORMAL
139      * ICONIFIED
140      * MAXIMIZED_HORIZ
141      * MAXIMIZED_VERT
142      * MAXIMIZED_BOTH
143      */

144     public int mainWindowFrameStateSeparated;
145     
146     /** State of editor area: 0 = joined, 1 = separated. */
147     public int editorAreaState;
148     /** Constraints of editor area - path in tree model.
149      * List of <code>Item</code>S. */

150     public SplitConstraint[] editorAreaConstraints;
151     /** Bounds of editor area. */
152     public Rectangle editorAreaBounds;
153     /** Relative bounds of editor area. */
154     public Rectangle editorAreaRelativeBounds;
155     /** Frame state of editor area when in separated 'state'.
156      * Possible values are taken from java.awt.Frame:
157      * NORMAL
158      * ICONIFIED
159      * MAXIMIZED_HORIZ
160      * MAXIMIZED_VERT
161      * MAXIMIZED_BOTH
162      */

163     public int editorAreaFrameState;
164
165     /** Size of screen. */
166     public Dimension screenSize;
167     /** Name of active mode. */
168     public String JavaDoc activeModeName;
169     /** Name of maximized mode (editor). */
170     public String JavaDoc editorMaximizedModeName;
171     /** Name of maximized mode (view). */
172     public String JavaDoc viewMaximizedModeName;
173     /** Name of toolbar configuration. */
174     public String JavaDoc toolbarConfiguration;
175     /** Preferred size of toolbar icons. */
176     public int preferredToolbarIconSize;
177     /** List of <code>ModeConfig</code>S. */
178     public ModeConfig[] modes;
179     /** List of <code>GroupConfig</code>S. */
180     public GroupConfig[] groups;
181     /** List of TopComponent Ids from recent view list. */
182     public String JavaDoc[] tcIdViewList;
183     
184     /** Creates a new instance of WindowManagerConfig */
185     public WindowManagerConfig() {
186         editorAreaConstraints = new SplitConstraint[0];
187         activeModeName = ""; // NOI18N
188
editorMaximizedModeName = ""; // NOI18N
189
viewMaximizedModeName = ""; // NOI18N
190
toolbarConfiguration = ""; // NOI18N
191
modes = new ModeConfig[0];
192         groups = new GroupConfig[0];
193         tcIdViewList = new String JavaDoc[0];
194     }
195     
196     public boolean equals (Object JavaDoc obj) {
197         if (this == obj) {
198             return true;
199         }
200         if (!(obj instanceof WindowManagerConfig)) {
201             return false;
202         }
203         WindowManagerConfig wmCfg = (WindowManagerConfig) obj;
204         if ((centeredHorizontallySeparated != wmCfg.centeredHorizontallySeparated) ||
205             (centeredVerticallySeparated != wmCfg.centeredVerticallySeparated)) {
206             return false;
207         }
208         if ((xSeparated != wmCfg.xSeparated) ||
209             (ySeparated != wmCfg.ySeparated) ||
210             (widthSeparated != wmCfg.widthSeparated) ||
211             (heightSeparated != wmCfg.heightSeparated)) {
212             return false;
213         }
214         if ((relativeXSeparated != wmCfg.relativeXSeparated) ||
215             (relativeYSeparated != wmCfg.relativeYSeparated)) {
216             return false;
217         }
218         if ((relativeWidthSeparated != wmCfg.relativeWidthSeparated) ||
219             (relativeHeightSeparated != wmCfg.relativeHeightSeparated)) {
220             return false;
221         }
222         
223         if ((centeredHorizontallyJoined != wmCfg.centeredHorizontallyJoined) ||
224             (centeredVerticallyJoined != wmCfg.centeredVerticallyJoined)) {
225             return false;
226         }
227         if ((xJoined != wmCfg.xJoined) ||
228             (yJoined != wmCfg.yJoined) ||
229             (widthJoined != wmCfg.widthJoined) ||
230             (heightJoined != wmCfg.heightJoined)) {
231             return false;
232         }
233         if ((relativeXJoined != wmCfg.relativeXJoined) ||
234             (relativeYJoined != wmCfg.relativeYJoined)) {
235             return false;
236         }
237         if ((relativeWidthJoined != wmCfg.relativeWidthJoined) ||
238             (relativeHeightJoined != wmCfg.relativeHeightJoined)) {
239             return false;
240         }
241         if ((maximizeIfWidthBelowJoined != wmCfg.maximizeIfWidthBelowJoined) ||
242             (maximizeIfHeightBelowJoined != wmCfg.maximizeIfHeightBelowJoined)) {
243             return false;
244         }
245         
246         if (mainWindowFrameStateJoined != wmCfg.mainWindowFrameStateJoined) {
247             return false;
248         }
249         if (mainWindowFrameStateSeparated != wmCfg.mainWindowFrameStateSeparated) {
250             return false;
251         }
252         if (editorAreaState != wmCfg.editorAreaState) {
253             return false;
254         }
255         //Order of editorAreaConstraints array is defined
256
if (editorAreaConstraints.length != wmCfg.editorAreaConstraints.length) {
257             return false;
258         }
259         for (int i = 0; i < editorAreaConstraints.length; i++) {
260             if (!editorAreaConstraints[i].equals(wmCfg.editorAreaConstraints[i])) {
261                 return false;
262             }
263         }
264         if ((editorAreaBounds != null) && (wmCfg.editorAreaBounds != null)) {
265             if (!editorAreaBounds.equals(wmCfg.editorAreaBounds)) {
266                 return false;
267             }
268         } else if ((editorAreaBounds != null) || (wmCfg.editorAreaBounds != null)) {
269             return false;
270         }
271         if ((editorAreaRelativeBounds != null) && (wmCfg.editorAreaRelativeBounds != null)) {
272             if (!editorAreaRelativeBounds.equals(wmCfg.editorAreaRelativeBounds)) {
273                 return false;
274             }
275         } else if ((editorAreaRelativeBounds != null) || (wmCfg.editorAreaRelativeBounds != null)) {
276             return false;
277         }
278         if (editorAreaFrameState != wmCfg.editorAreaFrameState) {
279             return false;
280         }
281         if ((screenSize != null) && (wmCfg.screenSize != null)) {
282             if (!screenSize.equals(wmCfg.screenSize)) {
283                 return false;
284             }
285         } else if ((screenSize != null) || (wmCfg.screenSize != null)) {
286             return false;
287         }
288         if (!activeModeName.equals(wmCfg.activeModeName)) {
289             return false;
290         }
291         if (!editorMaximizedModeName.equals(wmCfg.editorMaximizedModeName)) {
292             return false;
293         }
294         if (!viewMaximizedModeName.equals(wmCfg.viewMaximizedModeName)) {
295             return false;
296         }
297         if (!toolbarConfiguration.equals(wmCfg.toolbarConfiguration)) {
298             return false;
299         }
300         if (preferredToolbarIconSize != wmCfg.preferredToolbarIconSize) {
301             return false;
302         }
303         //Order of modes array is NOT defined
304
if (modes.length != wmCfg.modes.length) {
305             return false;
306         }
307         for (int i = 0; i < modes.length; i++) {
308             ModeConfig modeCfg = null;
309             for (int j = 0; j < wmCfg.modes.length; j++) {
310                 if (modes[i].name.equals(wmCfg.modes[j].name)) {
311                     modeCfg = wmCfg.modes[j];
312                     break;
313                 }
314             }
315             if (modeCfg == null) {
316                 return false;
317             }
318             if (!modes[i].equals(modeCfg)) {
319                 return false;
320             }
321         }
322         //Order of groups array is NOT defined
323
if (groups.length != wmCfg.groups.length) {
324             return false;
325         }
326         for (int i = 0; i < groups.length; i++) {
327             GroupConfig groupCfg = null;
328             for (int j = 0; j < wmCfg.groups.length; j++) {
329                 if (groups[i].name.equals(wmCfg.groups[j].name)) {
330                     groupCfg = wmCfg.groups[j];
331                     break;
332                 }
333             }
334             if (groupCfg == null) {
335                 return false;
336             }
337             if (!groups[i].equals(groupCfg)) {
338                 return false;
339             }
340         }
341         //Order of tcRefConfigs is defined
342
if (tcIdViewList.length != wmCfg.tcIdViewList.length) {
343             return false;
344         }
345         for (int i = 0; i < tcIdViewList.length; i++) {
346             if (!tcIdViewList[i].equals(wmCfg.tcIdViewList[i])) {
347                 return false;
348             }
349         }
350         return true;
351     }
352     
353     public int hashCode() {
354         int hash = 17;
355         
356         hash = 37 * hash + (centeredHorizontallySeparated ? 0 : 1);
357         hash = 37 * hash + (centeredVerticallySeparated ? 0 : 1);
358         hash = 37 * hash + xSeparated;
359         hash = 37 * hash + ySeparated;
360         hash = 37 * hash + widthSeparated;
361         hash = 37 * hash + heightSeparated;
362         hash = 37 * hash + Float.floatToIntBits(relativeXSeparated);
363         hash = 37 * hash + Float.floatToIntBits(relativeYSeparated);
364         hash = 37 * hash + Float.floatToIntBits(relativeWidthSeparated);
365         hash = 37 * hash + Float.floatToIntBits(relativeHeightSeparated);
366         
367         hash = 37 * hash + (centeredHorizontallyJoined ? 0 : 1);
368         hash = 37 * hash + (centeredVerticallyJoined ? 0 : 1);
369         hash = 37 * hash + xJoined;
370         hash = 37 * hash + yJoined;
371         hash = 37 * hash + widthJoined;
372         hash = 37 * hash + heightJoined;
373         hash = 37 * hash + Float.floatToIntBits(relativeXJoined);
374         hash = 37 * hash + Float.floatToIntBits(relativeYJoined);
375         hash = 37 * hash + Float.floatToIntBits(relativeWidthJoined);
376         hash = 37 * hash + Float.floatToIntBits(relativeHeightJoined);
377         hash = 37 * hash + maximizeIfWidthBelowJoined;
378         hash = 37 * hash + maximizeIfHeightBelowJoined;
379
380         hash = 37 * hash + mainWindowFrameStateJoined;
381         hash = 37 * hash + mainWindowFrameStateSeparated;
382         hash = 37 * hash + editorAreaState;
383         for (int i = 0; i < editorAreaConstraints.length; i++) {
384             hash = 37 * hash + editorAreaConstraints[i].hashCode();
385         }
386         if (editorAreaBounds != null) {
387             hash = 37 * hash + editorAreaBounds.hashCode();
388         }
389         if (editorAreaRelativeBounds != null) {
390             hash = 37 * hash + editorAreaRelativeBounds.hashCode();
391         }
392         hash = 37 * hash + editorAreaFrameState;
393         if (screenSize != null) {
394             hash = 37 * hash + screenSize.hashCode();
395         }
396         hash = 37 * hash + activeModeName.hashCode();
397         hash = 37 * hash + editorMaximizedModeName.hashCode();
398         hash = 37 * hash + viewMaximizedModeName.hashCode();
399         hash = 37 * hash + toolbarConfiguration.hashCode();
400         hash = 37 * hash + preferredToolbarIconSize;
401         for (int i = 0; i < modes.length; i++) {
402             hash = 37 * hash + modes[i].hashCode();
403         }
404         for (int i = 0; i < groups.length; i++) {
405             hash = 37 * hash + groups[i].hashCode();
406         }
407         for (int i = 0; i < tcIdViewList.length; i++) {
408             hash = 37 * hash + tcIdViewList[i].hashCode();
409         }
410         return hash;
411     }
412     
413 }
414
Popular Tags