Revision 8190 trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/SingletonWindowSupport.java

View differences:

SingletonWindowSupport.java
95 95
	 * @throws SingletonDialogAlreadyShownException DOCUMENT ME!
96 96
	 */
97 97
	public boolean registerWindow(Class windowClass, Object model, WindowInfo wi) {
98
		//Se comprueba si la vista est? siendo mostrada
99
		SingletonViewInfo svi = new SingletonViewInfo(windowClass, model);
98
		//Se comprueba si la ventana est? siendo mostrada
99
		SingletonWindowInfo swi = new SingletonWindowInfo(windowClass, model);
100 100

  
101
		if (contentWindowInfo.containsKey(svi)) {
101
		if (contentWindowInfo.containsKey(swi)) {
102 102
			if (wi.isModal()) {
103 103
				throw new SingletonDialogAlreadyShownException();
104 104
			}
105 105

  
106
			wi.setWindowInfo((WindowInfo)contentWindowInfo.get(svi));
106
			wi.setWindowInfo((WindowInfo)contentWindowInfo.get(swi));
107 107
			
108 108
			return true;
109 109
		} else {
110
			//La vista singleton no estaba mostrada
110
			//La ventana singleton no estaba mostrada
111 111
			//Se asocia el modelo con la vista
112
			contentWindowInfo.put(svi, wi);
112
			contentWindowInfo.put(swi, wi);
113 113
			return false;
114 114
		}
115 115
	}
116 116

  
117
	public void openSingletonView(SingletonWindow sv, JComponent frame){
118
		SingletonViewInfo svi = new SingletonViewInfo(sv.getClass(), sv.getWindowModel());
119
		contentFrame.put(svi, frame);
117
	public void openSingletonWindow(SingletonWindow sw, JComponent frame){
118
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
119
		contentFrame.put(swi, frame);
120 120
	}
121 121
	
122 122
	public boolean contains(SingletonWindow sw){
123
		SingletonViewInfo svi = new SingletonViewInfo(sw.getClass(), sw.getWindowModel());
124
		return contentFrame.containsKey(svi);
123
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
124
		return contentFrame.containsKey(swi);
125 125
	}
126 126
	
127 127
	/**
128 128
	 * DOCUMENT ME!
129 129
	 *
130
	 * @param s
130
	 * @param sw
131 131
	 */
132
	public void closeView(SingletonWindow s) {
133
		SingletonViewInfo svi = new SingletonViewInfo(s.getClass(), s.getWindowModel());
134
		WindowInfo viewInfo = (WindowInfo) contentWindowInfo.get(svi);
135
		JInternalFrame c = (JInternalFrame) contentFrame.get(svi); 
132
	public void closeWindow(SingletonWindow sw) {
133
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
134
		WindowInfo viewInfo = (WindowInfo) contentWindowInfo.get(swi);
135
		JInternalFrame c = (JInternalFrame) contentFrame.get(swi); 
136 136
		viewInfo.setWidth(c.getWidth());
137 137
		viewInfo.setHeight(c.getHeight());
138 138
		viewInfo.setX(c.getX());
139 139
		viewInfo.setY(c.getY());
140 140
		viewInfo.setClosed(true);
141 141
        
142
		contentFrame.remove(svi);
142
		contentFrame.remove(swi);
143 143
	}
144 144
	
145 145
	/**
......
148 148
	 *
149 149
	 * @author Fernando Gonz?lez Cort?s
150 150
	 */
151
	public class SingletonViewInfo {
151
	public class SingletonWindowInfo {
152 152
		
153 153
		public int id;
154 154
		
......
164 164
		 * @param clase Clase de la vista
165 165
		 * @param modelo Modelo que representa la vista
166 166
		 */
167
		public SingletonViewInfo(Class clase, Object modelo) {
167
		public SingletonWindowInfo(Class clase, Object modelo) {
168 168
			this.clase = clase;
169 169
			this.modelo = modelo;
170 170
			this.id = singletonViewInfoID;
......
175 175
		 * @see java.lang.Object#equals(java.lang.Object)
176 176
		 */
177 177
		public boolean equals(Object obj) {
178
			if (obj.getClass() != SingletonViewInfo.class) {
178
			if (obj.getClass() != SingletonWindowInfo.class) {
179 179
				throw new IllegalArgumentException();
180 180
			}
181 181

  
182
			SingletonViewInfo s = (SingletonViewInfo) obj;
182
			SingletonWindowInfo s = (SingletonWindowInfo) obj;
183 183

  
184 184
			if ((clase == s.clase) && (modelo == s.modelo)) {
185 185
				return true;
......
189 189
		}
190 190
	}
191 191

  
192
	private JInternalFrame getFrame(SingletonViewInfo svi){
192
	private JInternalFrame getFrame(SingletonWindowInfo svi){
193 193
		WindowInfo vi = (WindowInfo) contentWindowInfo.get(svi);
194 194
		return (JInternalFrame) contentFrame.get(svi);
195 195
	}
196 196
	
197 197
	public JInternalFrame getFrame(Class viewClass, Object model){
198
		SingletonViewInfo svi = new SingletonViewInfo(viewClass, model);
198
		SingletonWindowInfo svi = new SingletonWindowInfo(viewClass, model);
199 199
		return getFrame(svi);
200 200
	}
201 201

  
......
208 208
		
209 209
		ArrayList keys = contentFrame.getKeys();
210 210
		for (int i = 0; i < keys.size(); i++) {
211
			SingletonViewInfo svi = (SingletonViewInfo) keys.get(i);
211
			SingletonWindowInfo svi = (SingletonWindowInfo) keys.get(i);
212 212
			
213 213
			if (svi.modelo == model){
214 214
				ret.add(contentFrame.get(svi));
......
223 223
	 * @return
224 224
	 */
225 225
	public JInternalFrame getFrame(SingletonWindow sv) {
226
		SingletonViewInfo svi = new SingletonViewInfo(sv.getClass(), sv.getWindowModel());
226
		SingletonWindowInfo svi = new SingletonWindowInfo(sv.getClass(), sv.getWindowModel());
227 227
		return getFrame(svi);
228 228
	}
229 229

  
......
232 232
	 * @param i
233 233
	 */
234 234
	public void setX(SingletonWindow sv, int x) {
235
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getWindowModel()));
235
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
236 236

  
237 237
        if (o == null) return;
238 238
        o.setLocation(x, o.getY());
......
243 243
	 * @param i
244 244
	 */
245 245
	public void setY(SingletonWindow sv, int y) {
246
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getWindowModel()));
246
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
247 247

  
248 248
        if (o == null) return;
249 249
        
......
255 255
	 * @param i
256 256
	 */
257 257
	public void setHeight(SingletonWindow sv, int height) {
258
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getWindowModel()));
258
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
259 259

  
260 260
        if (o == null) return;
261 261
            
......
267 267
	 * @param i
268 268
	 */
269 269
	public void setWidth(SingletonWindow sv, int width) {
270
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getWindowModel()));
270
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
271 271

  
272 272
        if (o == null) return;
273 273
        o.setSize(width, o.getHeight());
......
278 278
	 * @param string
279 279
	 */
280 280
	public void setTitle(SingletonWindow sv, String title) {
281
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getWindowModel()));
281
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
282 282

  
283 283
        if (o == null) return;
284 284
        o.setTitle(title);
......
288 288
	    private ArrayList keys = new ArrayList();
289 289
	    private ArrayList values = new ArrayList();
290 290
	    
291
	    public void put(SingletonViewInfo key, Object value) {
291
	    public void put(SingletonWindowInfo key, Object value) {
292 292
	        int index = -1;
293 293
	        for (int i = 0; i < keys.size(); i++) {
294 294
	            if (keys.get(i).equals(key)){
......
306 306
	        }
307 307
	    }
308 308
	    
309
	    public boolean containsKey(SingletonViewInfo key){
309
	    public boolean containsKey(SingletonWindowInfo key){
310 310
	        for (int i = 0; i < keys.size(); i++) {
311 311
	            if (keys.get(i).equals(key)){
312 312
	                return true;
......
316 316
	        return false;
317 317
	    }
318 318
	    
319
	    public Object get(SingletonViewInfo key){
319
	    public Object get(SingletonWindowInfo key){
320 320
	        for (int i = 0; i < keys.size(); i++) {
321 321
	            if (keys.get(i).equals(key)){
322 322
	                return values.get(i);
......
326 326
	        return null;
327 327
	    }
328 328
	    
329
	    public void remove(SingletonViewInfo key){
329
	    public void remove(SingletonWindowInfo key){
330 330
	        for (int i = 0; i < keys.size(); i++) {
331 331
	            if (keys.get(i).equals(key)){
332 332
	                keys.remove(i);

Also available in: Unified diff