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

View differences:

SingletonWindowSupport.java
70 70
	private WindowInfoSupport vis;
71 71
	private FrameWindowSupport frameWindowSupport;
72 72
	private HashMap contentFrame = new HashMap();
73
	
73

  
74 74
	/**
75 75
	 * DOCUMENT ME!
76 76
	 *
......
106 106
			}
107 107

  
108 108
			wi.setWindowInfo((WindowInfo)contentWindowInfo.get(swi));
109
			
109

  
110 110
			return true;
111 111
		} else {
112 112
			//La ventana singleton no estaba mostrada
......
120 120
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
121 121
		contentFrame.put(swi, frame);
122 122
	}
123
	
123

  
124 124
	public boolean contains(SingletonWindow sw){
125 125
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
126 126
		return contentFrame.containsKey(swi);
127 127
	}
128
	
128

  
129 129
	/**
130 130
	 * DOCUMENT ME!
131 131
	 *
......
134 134
	public void closeWindow(SingletonWindow sw) {
135 135
		SingletonWindowInfo swi = new SingletonWindowInfo(sw.getClass(), sw.getWindowModel());
136 136
		WindowInfo viewInfo = (WindowInfo) contentWindowInfo.get(swi);
137
		JInternalFrame c = (JInternalFrame) contentFrame.get(swi); 
138
		viewInfo.setWidth(c.getWidth());
139
		viewInfo.setHeight(c.getHeight());
140
		viewInfo.setX(c.getX());
141
		viewInfo.setY(c.getY());
142
		viewInfo.setClosed(true);
143
		viewInfo.setNormalBounds(c.getNormalBounds());
144
		viewInfo.setMaximized(c.isMaximum());
145
        
137
		if (viewInfo!=null) {
138
			JInternalFrame c = (JInternalFrame) contentFrame.get(swi);
139
			viewInfo.setWidth(c.getWidth());
140
			viewInfo.setHeight(c.getHeight());
141
			viewInfo.setX(c.getX());
142
			viewInfo.setY(c.getY());
143
			viewInfo.setClosed(true);
144
			viewInfo.setNormalBounds(c.getNormalBounds());
145
			viewInfo.setMaximized(c.isMaximum());
146
		}
146 147
		contentFrame.remove(swi);
147 148
	}
148
	
149

  
149 150
	/**
150 151
	 * Representa una vista singleton manteniendo el modelo y la clase de la
151 152
	 * vista que lo muestra
......
153 154
	 * @author Fernando Gonz?lez Cort?s
154 155
	 */
155 156
	public class SingletonWindowInfo {
156
		
157

  
157 158
		public int id;
158
		
159

  
159 160
		/** Clase de la vista */
160 161
		public Class clase;
161 162

  
162 163
		/** Modelo que representa la vista */
163 164
		public Object modelo;
164
		
165

  
165 166
		/**
166 167
		 * Creates a new SingletonView object.
167 168
		 *
......
197 198
		WindowInfo vi = (WindowInfo) contentWindowInfo.get(svi);
198 199
		return (JInternalFrame) contentFrame.get(svi);
199 200
	}
200
	
201

  
201 202
	public JInternalFrame getFrame(Class viewClass, Object model){
202 203
		SingletonWindowInfo svi = new SingletonWindowInfo(viewClass, model);
203 204
		return getFrame(svi);
......
209 210
	 */
210 211
	public JInternalFrame[] getFrames(Object model) {
211 212
		ArrayList ret = new ArrayList();
212
		
213

  
213 214
		ArrayList keys = contentFrame.getKeys();
214 215
		for (int i = 0; i < keys.size(); i++) {
215 216
			SingletonWindowInfo svi = (SingletonWindowInfo) keys.get(i);
216
			
217

  
217 218
			if (svi.modelo == model){
218 219
				ret.add(contentFrame.get(svi));
219 220
			}
220 221
		}
221
		
222

  
222 223
		return (JInternalFrame[]) ret.toArray(new JInternalFrame[0]);
223 224
	}
224 225

  
......
250 251
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
251 252

  
252 253
        if (o == null) return;
253
        
254

  
254 255
        o.setLocation(o.getX(), y);
255 256
	}
256 257

  
......
262 263
		JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonWindowInfo(sv.getClass(), sv.getWindowModel()));
263 264

  
264 265
        if (o == null) return;
265
            
266

  
266 267
        o.setSize(o.getWidth(), height);
267 268
	}
268 269

  
......
292 293
			//e.printStackTrace();
293 294
		}
294 295
	}
295
	
296

  
296 297
	/**
297 298
	 * @param sw
298 299
	 * @param maximized
......
303 304
        if (frame == null) return;
304 305
        frame.setNormalBounds(normalBounds);
305 306
	}
306
	
307

  
307 308
	/**
308 309
	 * @param sv
309 310
	 * @param string
......
314 315
        if (o == null) return;
315 316
        o.setTitle(title);
316 317
	}
317
	
318

  
318 319
	private class HashMap {
319 320
	    private ArrayList keys = new ArrayList();
320 321
	    private ArrayList values = new ArrayList();
321
	    
322

  
322 323
	    public void put(SingletonWindowInfo key, Object value) {
323 324
	        int index = -1;
324 325
	        for (int i = 0; i < keys.size(); i++) {
......
327 328
	                break;
328 329
	            }
329 330
            }
330
	        
331

  
331 332
	        if (index != -1){
332 333
	            keys.add(index, key);
333 334
	            values.add(index, value);
......
336 337
	            values.add(value);
337 338
	        }
338 339
	    }
339
	    
340

  
340 341
	    public boolean containsKey(SingletonWindowInfo key){
341 342
	        for (int i = 0; i < keys.size(); i++) {
342 343
	            if (keys.get(i).equals(key)){
343 344
	                return true;
344 345
	            }
345 346
	        }
346
	        
347

  
347 348
	        return false;
348 349
	    }
349
	    
350

  
350 351
	    public Object get(SingletonWindowInfo key){
351 352
	        for (int i = 0; i < keys.size(); i++) {
352 353
	            if (keys.get(i).equals(key)){
353 354
	                return values.get(i);
354 355
	            }
355 356
	        }
356
	        
357

  
357 358
	        return null;
358 359
	    }
359
	    
360

  
360 361
	    public void remove(SingletonWindowInfo key){
361 362
	        for (int i = 0; i < keys.size(); i++) {
362 363
	            if (keys.get(i).equals(key)){
......
365 366
	            }
366 367
	        }
367 368
	    }
368
	    
369

  
369 370
	    public ArrayList getKeys(){
370 371
	        return keys;
371 372
	    }

Also available in: Unified diff