Revision 2457 trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/SingletonViewSupport.java

View differences:

SingletonViewSupport.java
64 64
public class SingletonViewSupport {
65 65
	private static int singletonViewInfoID = 0;
66 66
	/** Hashtable que asocia contenido con vistas */
67
	private TreeMap contentViewInfo = new TreeMap(new SingletonViewInfoComparator());
67
	private HashMap contentViewInfo = new HashMap();
68 68
	private ViewInfoSupport vis;
69 69
	private FrameViewSupport frameViewSupport;
70
	private TreeMap contentFrame = new TreeMap(new SingletonViewInfoComparator());
70
	private HashMap contentFrame = new HashMap();
71 71
	
72 72
	/**
73 73
	 * DOCUMENT ME!
......
170 170
			singletonViewInfoID++;
171 171
		}
172 172

  
173
		/*
173
		/**
174 174
		 * @see java.lang.Object#equals(java.lang.Object)
175
		 *
175
		 */
176 176
		public boolean equals(Object obj) {
177 177
			if (obj.getClass() != SingletonViewInfo.class) {
178 178
				throw new IllegalArgumentException();
......
185 185
			} else {
186 186
				return false;
187 187
			}
188
		}*/
189
	}
190

  
191
	/**
192
	 * DOCUMENT ME!
193
	 *
194
	 * @author $author$
195
	 * @version $Revision$
196
	 */
197
	public class SingletonViewInfoComparator implements Comparator {
198
		/**
199
		 * @see java.util.Comparator#compare(java.lang.Object,
200
		 * 		java.lang.Object)
201
		 */
202
		public int compare(Object o1, Object o2) {
203
			try{
204
			SingletonViewInfo s1 = (SingletonViewInfo) o1;
205
			SingletonViewInfo s2 = (SingletonViewInfo) o2;
206

  
207
			if ((s1.clase.getName().equals(s2.clase.getName())) &&
208
					(s1.modelo == s2.modelo)) {
209
				return 0;
210
			} else {
211
				return (s1.id < s2.id)?-1:1;
212
			}
213
			}catch(ClassCastException e){
214
				e.printStackTrace();
215
				return 0;
216
			}
217 188
		}
218 189
	}
219 190

  
......
234 205
	public JInternalFrame[] getFrames(Object model) {
235 206
		ArrayList ret = new ArrayList();
236 207
		
237
		Iterator keys = contentFrame.keySet().iterator();
238
		while (keys.hasNext()) {
239
			SingletonViewInfo svi = (SingletonViewInfo) keys.next();
208
		ArrayList keys = contentFrame.getKeys();
209
		for (int i = 0; i < keys.size(); i++) {
210
			SingletonViewInfo svi = (SingletonViewInfo) keys.get(i);
240 211
			
241 212
			if (svi.modelo == model){
242 213
				ret.add(contentFrame.get(svi));
......
311 282
        if (o == null) return;
312 283
        o.setTitle(title);
313 284
	}
285
	
286
	private class HashMap {
287
	    private ArrayList keys = new ArrayList();
288
	    private ArrayList values = new ArrayList();
289
	    
290
	    public void put(SingletonViewInfo key, Object value) {
291
	        int index = -1;
292
	        for (int i = 0; i < keys.size(); i++) {
293
	            if (keys.get(i).equals(key)){
294
	                index = i;
295
	                break;
296
	            }
297
            }
298
	        
299
	        if (index != -1){
300
	            keys.add(index, key);
301
	            values.add(index, value);
302
	        }else{
303
	            keys.add(key);
304
	            values.add(value);
305
	        }
306
	    }
307
	    
308
	    public boolean containsKey(SingletonViewInfo key){
309
	        for (int i = 0; i < keys.size(); i++) {
310
	            if (keys.get(i).equals(key)){
311
	                return true;
312
	            }
313
	        }
314
	        
315
	        return false;
316
	    }
317
	    
318
	    public Object get(SingletonViewInfo key){
319
	        for (int i = 0; i < keys.size(); i++) {
320
	            if (keys.get(i).equals(key)){
321
	                return values.get(i);
322
	            }
323
	        }
324
	        
325
	        return null;
326
	    }
327
	    
328
	    public void remove(SingletonViewInfo key){
329
	        for (int i = 0; i < keys.size(); i++) {
330
	            if (keys.get(i).equals(key)){
331
	                keys.remove(i);
332
	                values.remove(i);
333
	            }
334
	        }
335
	    }
336
	    
337
	    public ArrayList getKeys(){
338
	        return keys;
339
	    }
340
	}
314 341
}

Also available in: Unified diff