2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
43
package org.netbeans.core.windows.persistence;
46
import org.netbeans.core.windows.SplitConstraint;
52
* Class of window manager config properties for communication with persistence management.
53
* It keeps data which are read/written from/in .wsmgr xml file.
55
* @author Peter Zavadsky
57
public class WindowManagerConfig {
61
// BEGIN Values specific for initial main window position
62
// Note: Only absolute bounds are saved [x,y,w,h].
64
/** Flag to control horizontal position of main window. If it is true x is
66
public boolean centeredHorizontallySeparated;
68
/** Flag to control vertical position of main window . If it is true y is
70
public boolean centeredVerticallySeparated;
72
/** Horizontal absolute position of main window. */
73
public int xSeparated;
75
/** Vertical absolute position of main window */
76
public int ySeparated;
78
/** Width of main window. -1 means not set. Either width or relative width
80
public int widthSeparated;
82
/** Height of main window. -1 means not set. Either height or relative height
84
public int heightSeparated;
86
/** Relative x of main window. -1 means not set. */
87
public float relativeXSeparated;
89
/** Relative y of main window. -1 means not set. */
90
public float relativeYSeparated;
92
/** Relative width of main window. -1 means not set. */
93
public float relativeWidthSeparated;
95
/** Relative height of main window. -1 means not set. */
96
public float relativeHeightSeparated;
104
// BEGIN Values specific for initial main window position
105
// Note: Only absolute bounds are saved [x,y,w,h].
107
/** Flag to control horizontal position of main window. If it is true x is
109
public boolean centeredHorizontallyJoined;
111
/** Flag to control vertical position of main window . If it is true y is
113
public boolean centeredVerticallyJoined;
115
/** Horizontal absolute position of main window. */
118
/** Vertical absolute position of main window */
121
/** Width of main window. -1 means not set. Either width or relative width
123
public int widthJoined;
125
/** Height of main window. -1 means not set. Either height or relative height
127
public int heightJoined;
129
/** Relative x of main window. -1 means not set. */
130
public float relativeXJoined;
132
/** Relative y of main window. -1 means not set. */
133
public float relativeYJoined;
135
/** Relative width of main window. -1 means not set. */
136
public float relativeWidthJoined;
138
/** Relative height of main window. -1 means not set. */
139
public float relativeHeightJoined;
141
/** Minimum allowed width of main window for computing initial size */
142
public int maximizeIfWidthBelowJoined;
144
/** Minimum allowed height of main window for computing initial size */
145
public int maximizeIfHeightBelowJoined;
149
/** Frame state of main window when in tiled(joined) state.
150
* Possible values are taken from java.awt.Frame:
157
public int mainWindowFrameStateJoined;
158
/** Frame state of main window when in separated state.
159
* Possible values are taken from java.awt.Frame:
166
public int mainWindowFrameStateSeparated;
168
/** State of editor area: 0 = joined, 1 = separated. */
169
public int editorAreaState;
170
/** Constraints of editor area - path in tree model.
171
* List of <code>Item</code>S. */
172
public SplitConstraint[] editorAreaConstraints;
173
/** Bounds of editor area. */
174
public Rectangle editorAreaBounds;
175
/** Relative bounds of editor area. */
176
public Rectangle editorAreaRelativeBounds;
177
/** Frame state of editor area when in separated 'state'.
178
* Possible values are taken from java.awt.Frame:
185
public int editorAreaFrameState;
187
/** Size of screen. */
188
public Dimension screenSize;
189
/** Name of active mode. */
190
public String activeModeName;
191
/** Name of maximized mode (editor). */
192
public String editorMaximizedModeName;
193
/** Name of maximized mode (view). */
194
public String viewMaximizedModeName;
195
/** Name of toolbar configuration. */
196
public String toolbarConfiguration;
197
/** Preferred size of toolbar icons. */
198
public int preferredToolbarIconSize;
199
/** List of <code>ModeConfig</code>S. */
200
public ModeConfig[] modes;
201
/** List of <code>GroupConfig</code>S. */
202
public GroupConfig[] groups;
203
/** List of TopComponent Ids from recent view list. */
204
public String[] tcIdViewList;
206
/** Creates a new instance of WindowManagerConfig */
207
public WindowManagerConfig() {
208
editorAreaConstraints = new SplitConstraint[0];
209
activeModeName = ""; // NOI18N
210
editorMaximizedModeName = ""; // NOI18N
211
viewMaximizedModeName = ""; // NOI18N
212
toolbarConfiguration = ""; // NOI18N
213
modes = new ModeConfig[0];
214
groups = new GroupConfig[0];
215
tcIdViewList = new String[0];
218
public boolean equals (Object obj) {
222
if (!(obj instanceof WindowManagerConfig)) {
225
WindowManagerConfig wmCfg = (WindowManagerConfig) obj;
226
if ((centeredHorizontallySeparated != wmCfg.centeredHorizontallySeparated) ||
227
(centeredVerticallySeparated != wmCfg.centeredVerticallySeparated)) {
230
if ((xSeparated != wmCfg.xSeparated) ||
231
(ySeparated != wmCfg.ySeparated) ||
232
(widthSeparated != wmCfg.widthSeparated) ||
233
(heightSeparated != wmCfg.heightSeparated)) {
236
if ((relativeXSeparated != wmCfg.relativeXSeparated) ||
237
(relativeYSeparated != wmCfg.relativeYSeparated)) {
240
if ((relativeWidthSeparated != wmCfg.relativeWidthSeparated) ||
241
(relativeHeightSeparated != wmCfg.relativeHeightSeparated)) {
245
if ((centeredHorizontallyJoined != wmCfg.centeredHorizontallyJoined) ||
246
(centeredVerticallyJoined != wmCfg.centeredVerticallyJoined)) {
249
if ((xJoined != wmCfg.xJoined) ||
250
(yJoined != wmCfg.yJoined) ||
251
(widthJoined != wmCfg.widthJoined) ||
252
(heightJoined != wmCfg.heightJoined)) {
255
if ((relativeXJoined != wmCfg.relativeXJoined) ||
256
(relativeYJoined != wmCfg.relativeYJoined)) {
259
if ((relativeWidthJoined != wmCfg.relativeWidthJoined) ||
260
(relativeHeightJoined != wmCfg.relativeHeightJoined)) {
263
if ((maximizeIfWidthBelowJoined != wmCfg.maximizeIfWidthBelowJoined) ||
264
(maximizeIfHeightBelowJoined != wmCfg.maximizeIfHeightBelowJoined)) {
268
if (mainWindowFrameStateJoined != wmCfg.mainWindowFrameStateJoined) {
271
if (mainWindowFrameStateSeparated != wmCfg.mainWindowFrameStateSeparated) {
274
if (editorAreaState != wmCfg.editorAreaState) {
277
//Order of editorAreaConstraints array is defined
278
if (editorAreaConstraints.length != wmCfg.editorAreaConstraints.length) {
281
for (int i = 0; i < editorAreaConstraints.length; i++) {
282
if (!editorAreaConstraints[i].equals(wmCfg.editorAreaConstraints[i])) {
286
if ((editorAreaBounds != null) && (wmCfg.editorAreaBounds != null)) {
287
if (!editorAreaBounds.equals(wmCfg.editorAreaBounds)) {
290
} else if ((editorAreaBounds != null) || (wmCfg.editorAreaBounds != null)) {
293
if ((editorAreaRelativeBounds != null) && (wmCfg.editorAreaRelativeBounds != null)) {
294
if (!editorAreaRelativeBounds.equals(wmCfg.editorAreaRelativeBounds)) {
297
} else if ((editorAreaRelativeBounds != null) || (wmCfg.editorAreaRelativeBounds != null)) {
300
if (editorAreaFrameState != wmCfg.editorAreaFrameState) {
303
if ((screenSize != null) && (wmCfg.screenSize != null)) {
304
if (!screenSize.equals(wmCfg.screenSize)) {
307
} else if ((screenSize != null) || (wmCfg.screenSize != null)) {
310
if (!activeModeName.equals(wmCfg.activeModeName)) {
313
if (!editorMaximizedModeName.equals(wmCfg.editorMaximizedModeName)) {
316
if (!viewMaximizedModeName.equals(wmCfg.viewMaximizedModeName)) {
319
if (!toolbarConfiguration.equals(wmCfg.toolbarConfiguration)) {
322
if (preferredToolbarIconSize != wmCfg.preferredToolbarIconSize) {
325
//Order of modes array is NOT defined
326
if (modes.length != wmCfg.modes.length) {
329
for (int i = 0; i < modes.length; i++) {
330
ModeConfig modeCfg = null;
331
for (int j = 0; j < wmCfg.modes.length; j++) {
332
if (modes[i].name.equals(wmCfg.modes[j].name)) {
333
modeCfg = wmCfg.modes[j];
337
if (modeCfg == null) {
340
if (!modes[i].equals(modeCfg)) {
344
//Order of groups array is NOT defined
345
if (groups.length != wmCfg.groups.length) {
348
for (int i = 0; i < groups.length; i++) {
349
GroupConfig groupCfg = null;
350
for (int j = 0; j < wmCfg.groups.length; j++) {
351
if (groups[i].name.equals(wmCfg.groups[j].name)) {
352
groupCfg = wmCfg.groups[j];
356
if (groupCfg == null) {
359
if (!groups[i].equals(groupCfg)) {
363
//Order of tcRefConfigs is defined
364
if (tcIdViewList.length != wmCfg.tcIdViewList.length) {
367
for (int i = 0; i < tcIdViewList.length; i++) {
368
if (!tcIdViewList[i].equals(wmCfg.tcIdViewList[i])) {
375
public int hashCode() {
378
hash = 37 * hash + (centeredHorizontallySeparated ? 0 : 1);
379
hash = 37 * hash + (centeredVerticallySeparated ? 0 : 1);
380
hash = 37 * hash + xSeparated;
381
hash = 37 * hash + ySeparated;
382
hash = 37 * hash + widthSeparated;
383
hash = 37 * hash + heightSeparated;
384
hash = 37 * hash + Float.floatToIntBits(relativeXSeparated);
385
hash = 37 * hash + Float.floatToIntBits(relativeYSeparated);
386
hash = 37 * hash + Float.floatToIntBits(relativeWidthSeparated);
387
hash = 37 * hash + Float.floatToIntBits(relativeHeightSeparated);
389
hash = 37 * hash + (centeredHorizontallyJoined ? 0 : 1);
390
hash = 37 * hash + (centeredVerticallyJoined ? 0 : 1);
391
hash = 37 * hash + xJoined;
392
hash = 37 * hash + yJoined;
393
hash = 37 * hash + widthJoined;
394
hash = 37 * hash + heightJoined;
395
hash = 37 * hash + Float.floatToIntBits(relativeXJoined);
396
hash = 37 * hash + Float.floatToIntBits(relativeYJoined);
397
hash = 37 * hash + Float.floatToIntBits(relativeWidthJoined);
398
hash = 37 * hash + Float.floatToIntBits(relativeHeightJoined);
399
hash = 37 * hash + maximizeIfWidthBelowJoined;
400
hash = 37 * hash + maximizeIfHeightBelowJoined;
402
hash = 37 * hash + mainWindowFrameStateJoined;
403
hash = 37 * hash + mainWindowFrameStateSeparated;
404
hash = 37 * hash + editorAreaState;
405
for (int i = 0; i < editorAreaConstraints.length; i++) {
406
hash = 37 * hash + editorAreaConstraints[i].hashCode();
408
if (editorAreaBounds != null) {
409
hash = 37 * hash + editorAreaBounds.hashCode();
411
if (editorAreaRelativeBounds != null) {
412
hash = 37 * hash + editorAreaRelativeBounds.hashCode();
414
hash = 37 * hash + editorAreaFrameState;
415
if (screenSize != null) {
416
hash = 37 * hash + screenSize.hashCode();
418
hash = 37 * hash + activeModeName.hashCode();
419
hash = 37 * hash + editorMaximizedModeName.hashCode();
420
hash = 37 * hash + viewMaximizedModeName.hashCode();
421
hash = 37 * hash + toolbarConfiguration.hashCode();
422
hash = 37 * hash + preferredToolbarIconSize;
423
for (int i = 0; i < modes.length; i++) {
424
hash = 37 * hash + modes[i].hashCode();
426
for (int i = 0; i < groups.length; i++) {
427
hash = 37 * hash + groups[i].hashCode();
429
for (int i = 0; i < tcIdViewList.length; i++) {
430
hash = 37 * hash + tcIdViewList[i].hashCode();