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 java.awt.Rectangle;
47
import org.netbeans.core.windows.SplitConstraint;
49
import java.util.Iterator;
54
* Class of mode config properties for communication with persistence management.
55
* It keeps data which are read/written from/in .wsmode xml file.
57
* @author Peter Zavadsky
59
public class ModeConfig {
61
/** Name of mode. Supposed to be internally for mode identification. */
64
/** State of mode: 0 = split, 1 = separate. */
67
/** Kind of mode: 0 = editor, 1 = view, 2 - sliding */
70
/** side for sliding kind*/
73
/** Constraints of mode - path in tree model */
74
public SplitConstraint[] constraints;
76
//Part for separate state
77
public Rectangle bounds;
78
public Rectangle relativeBounds;
80
public int frameState;
83
/** Id of selected top component. */
84
public String selectedTopComponentID;
86
public boolean permanent = true;
88
/** Array of TCRefConfigs. */
89
public TCRefConfig[] tcRefConfigs;
91
/** TopComponent ID -> slided-in size (width or height) - applies to sliding modes only*/
92
public Map<String,Integer> slideInSizes;
94
/** ID of top component that was selected before switching to/from maximized mode */
95
public String previousSelectedTopComponentID;
97
/** Creates a new instance of ModeConfig */
100
constraints = new SplitConstraint[0];
101
selectedTopComponentID = ""; // NOI18N
102
tcRefConfigs = new TCRefConfig[0];
103
previousSelectedTopComponentID = ""; // NOI18N
106
public boolean equals (Object obj) {
110
if (!(obj instanceof ModeConfig)) {
113
ModeConfig modeCfg = (ModeConfig) obj;
114
if (!name.equals(modeCfg.name)) {
117
if ((state != modeCfg.state) || (kind != modeCfg.kind)) {
120
if (null != side && !side.equals( modeCfg.side ) ) {
122
} else if( null == side && null != modeCfg.side ) {
125
//Order of constraints array is defined
126
if (constraints.length != modeCfg.constraints.length) {
129
for (int i = 0; i < constraints.length; i++) {
130
if (!constraints[i].equals(modeCfg.constraints[i])) {
134
if ((bounds != null) && (modeCfg.bounds != null)) {
135
if (!bounds.equals(modeCfg.bounds)) {
138
} else if ((bounds != null) || (modeCfg.bounds != null)) {
141
if ((relativeBounds != null) && (modeCfg.relativeBounds != null)) {
142
if (!relativeBounds.equals(modeCfg.relativeBounds)) {
145
} else if ((relativeBounds != null) || (modeCfg.relativeBounds != null)) {
148
if (frameState != modeCfg.frameState) {
151
if (!selectedTopComponentID.equals(modeCfg.selectedTopComponentID)) {
154
if (permanent != modeCfg.permanent) {
157
//Order of tcRefConfigs is defined
158
if (tcRefConfigs.length != modeCfg.tcRefConfigs.length) {
161
for (int i = 0; i < tcRefConfigs.length; i++) {
162
if (!tcRefConfigs[i].equals(modeCfg.tcRefConfigs[i])) {
166
if( null != slideInSizes && null != modeCfg.slideInSizes ) {
167
if( slideInSizes.size() != modeCfg.slideInSizes.size() )
169
for (Iterator<String> i=slideInSizes.keySet().iterator(); i.hasNext(); ) {
170
String tcId = i.next();
171
if( !slideInSizes.get(tcId).equals(modeCfg.slideInSizes.get(tcId)) )
174
} else if( null != slideInSizes || null != modeCfg.slideInSizes ) {
177
if (!previousSelectedTopComponentID.equals(modeCfg.previousSelectedTopComponentID)) {
183
public int hashCode() {
185
hash = 37 * hash + name.hashCode();
186
hash = 37 * hash + state;
187
hash = 37 * hash + kind;
189
hash = 37 * hash + side.hashCode();
191
for (int i = 0; i < constraints.length; i++) {
192
hash = 37 * hash + constraints[i].hashCode();
194
if (bounds != null) {
195
hash = 37 * hash + bounds.hashCode();
197
if (relativeBounds != null) {
198
hash = 37 * hash + relativeBounds.hashCode();
200
hash = 37 * hash + frameState;
201
hash = 37 * hash + selectedTopComponentID.hashCode();
202
hash = 37 * hash + (permanent ? 0 : 1);
203
for (int i = 0; i < tcRefConfigs.length; i++) {
204
hash = 37 * hash + tcRefConfigs[i].hashCode();
206
if( null != slideInSizes ) {
207
for (Iterator<String> i=slideInSizes.keySet().iterator(); i.hasNext(); ) {
208
Object key = i.next();
209
hash = 37 * hash + key.hashCode();
210
hash = 37 * hash + slideInSizes.get(key).hashCode();
213
hash = 37 * hash + previousSelectedTopComponentID.hashCode();