22 import org.eclipse.swt.graphics.Image; |
22 import org.eclipse.swt.graphics.Image; |
23 |
23 |
24 /** |
24 /** |
25 * Storage of objects which have to be disposed manually. |
25 * Storage of objects which have to be disposed manually. |
26 */ |
26 */ |
27 class DisposeStorage { |
27 class DisposeStorage |
|
28 { |
28 |
29 |
29 private Vector storage; |
30 private Vector storage; |
30 |
31 |
31 DisposeStorage() { |
32 DisposeStorage() |
|
33 { |
32 storage = new Vector(); |
34 storage = new Vector(); |
33 } |
35 } |
34 |
36 |
35 /** |
37 /** |
36 * Add object which must be disposed. |
38 * Add object which must be disposed. |
37 * |
39 * |
38 * @param obj object to add. |
40 * @param obj object to add. |
39 */ |
41 */ |
40 public void addObject(Object obj) { |
42 public void addObject(Object obj) |
|
43 { |
41 storage.addElement(obj); |
44 storage.addElement(obj); |
42 } |
45 } |
43 |
46 |
44 /** |
47 /** |
45 * Dispose all objects from garbage. |
48 * Dispose all objects from garbage. |
46 */ |
49 */ |
47 public void dispose() { |
50 public void dispose() |
|
51 { |
48 Object tempObject = null; |
52 Object tempObject = null; |
49 for (int i = 0; i < storage.size(); i++) { |
53 for(int i = 0; i < storage.size(); i++) |
|
54 { |
50 tempObject = storage.elementAt(i); |
55 tempObject = storage.elementAt(i); |
51 if (tempObject instanceof Image) { |
56 if(tempObject instanceof Image) |
|
57 { |
52 ((Image) tempObject).dispose(); |
58 ((Image) tempObject).dispose(); |
53 } |
59 } |
54 else if (tempObject instanceof Color) { |
60 else if(tempObject instanceof Color) |
|
61 { |
55 ((Color) tempObject).dispose(); |
62 ((Color) tempObject).dispose(); |
56 } |
63 } |
57 } |
64 } |
58 storage.removeAllElements(); |
65 storage.removeAllElements(); |
59 } |
66 } |