1 19 20 21 package org.netbeans.core.windows.persistence; 22 23 24 import java.awt.Rectangle ; 25 import org.netbeans.core.windows.SplitConstraint; 26 27 import java.util.Iterator ; 28 import java.util.Map ; 29 30 31 37 public class ModeConfig { 38 39 40 public String name; 41 42 43 public int state; 44 45 46 public int kind; 47 48 49 public String side; 50 51 52 public SplitConstraint[] constraints; 53 54 public Rectangle bounds; 56 public Rectangle relativeBounds; 57 58 public int frameState; 59 60 62 public String selectedTopComponentID; 63 64 public boolean permanent = true; 65 66 67 public TCRefConfig[] tcRefConfigs; 68 69 70 public Map <String ,Integer > slideInSizes; 71 72 73 public String previousSelectedTopComponentID; 74 75 76 public ModeConfig() { 77 name = ""; constraints = new SplitConstraint[0]; 79 selectedTopComponentID = ""; tcRefConfigs = new TCRefConfig[0]; 81 previousSelectedTopComponentID = ""; } 83 84 public boolean equals (Object obj) { 85 if (this == obj) { 86 return true; 87 } 88 if (!(obj instanceof ModeConfig)) { 89 return false; 90 } 91 ModeConfig modeCfg = (ModeConfig) obj; 92 if (!name.equals(modeCfg.name)) { 93 return false; 94 } 95 if ((state != modeCfg.state) || (kind != modeCfg.kind)) { 96 return false; 97 } 98 if (null != side && !side.equals( modeCfg.side ) ) { 99 return false; 100 } else if( null == side && null != modeCfg.side ) { 101 return false; 102 } 103 if (constraints.length != modeCfg.constraints.length) { 105 return false; 106 } 107 for (int i = 0; i < constraints.length; i++) { 108 if (!constraints[i].equals(modeCfg.constraints[i])) { 109 return false; 110 } 111 } 112 if ((bounds != null) && (modeCfg.bounds != null)) { 113 if (!bounds.equals(modeCfg.bounds)) { 114 return false; 115 } 116 } else if ((bounds != null) || (modeCfg.bounds != null)) { 117 return false; 118 } 119 if ((relativeBounds != null) && (modeCfg.relativeBounds != null)) { 120 if (!relativeBounds.equals(modeCfg.relativeBounds)) { 121 return false; 122 } 123 } else if ((relativeBounds != null) || (modeCfg.relativeBounds != null)) { 124 return false; 125 } 126 if (frameState != modeCfg.frameState) { 127 return false; 128 } 129 if (!selectedTopComponentID.equals(modeCfg.selectedTopComponentID)) { 130 return false; 131 } 132 if (permanent != modeCfg.permanent) { 133 return false; 134 } 135 if (tcRefConfigs.length != modeCfg.tcRefConfigs.length) { 137 return false; 138 } 139 for (int i = 0; i < tcRefConfigs.length; i++) { 140 if (!tcRefConfigs[i].equals(modeCfg.tcRefConfigs[i])) { 141 return false; 142 } 143 } 144 if( null != slideInSizes && null != modeCfg.slideInSizes ) { 145 if( slideInSizes.size() != modeCfg.slideInSizes.size() ) 146 return false; 147 for (Iterator <String > i=slideInSizes.keySet().iterator(); i.hasNext(); ) { 148 String tcId = i.next(); 149 if( !slideInSizes.get(tcId).equals(modeCfg.slideInSizes.get(tcId)) ) 150 return false; 151 } 152 } else if( null != slideInSizes || null != modeCfg.slideInSizes ) { 153 return false; 154 } 155 if (!previousSelectedTopComponentID.equals(modeCfg.previousSelectedTopComponentID)) { 156 return false; 157 } 158 return true; 159 } 160 161 public int hashCode() { 162 int hash = 17; 163 hash = 37 * hash + name.hashCode(); 164 hash = 37 * hash + state; 165 hash = 37 * hash + kind; 166 if (side != null) { 167 hash = 37 * hash + side.hashCode(); 168 } 169 for (int i = 0; i < constraints.length; i++) { 170 hash = 37 * hash + constraints[i].hashCode(); 171 } 172 if (bounds != null) { 173 hash = 37 * hash + bounds.hashCode(); 174 } 175 if (relativeBounds != null) { 176 hash = 37 * hash + relativeBounds.hashCode(); 177 } 178 hash = 37 * hash + frameState; 179 hash = 37 * hash + selectedTopComponentID.hashCode(); 180 hash = 37 * hash + (permanent ? 0 : 1); 181 for (int i = 0; i < tcRefConfigs.length; i++) { 182 hash = 37 * hash + tcRefConfigs[i].hashCode(); 183 } 184 if( null != slideInSizes ) { 185 for (Iterator <String > i=slideInSizes.keySet().iterator(); i.hasNext(); ) { 186 Object key = i.next(); 187 hash = 37 * hash + key.hashCode(); 188 hash = 37 * hash + slideInSizes.get(key).hashCode(); 189 } 190 } 191 hash = 37 * hash + previousSelectedTopComponentID.hashCode(); 192 return hash; 193 } 194 195 } 196 | Popular Tags |