KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > product > WindowImages


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.product;
12
13 import java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.pde.internal.core.iproduct.IProductModel;
16 import org.eclipse.pde.internal.core.iproduct.IWindowImages;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.Node JavaDoc;
19
20 public class WindowImages extends ProductObject implements IWindowImages {
21
22     private static final long serialVersionUID = 1L;
23     private String JavaDoc f16ImagePath;
24     private String JavaDoc f32ImagePath;
25     private String JavaDoc f48ImagePath;
26     private String JavaDoc f64ImagePath;
27     private String JavaDoc f128ImagePath;
28
29     public WindowImages(IProductModel model) {
30         super(model);
31     }
32
33     public String JavaDoc getImagePath(int size) {
34         switch (size) {
35         case 0:
36             return f16ImagePath;
37         case 1:
38             return f32ImagePath;
39         case 2:
40             return f48ImagePath;
41         case 3:
42             return f64ImagePath;
43         case 4:
44             return f128ImagePath;
45         }
46         return null;
47     }
48
49     public void setImagePath(String JavaDoc path, int size) {
50         String JavaDoc old;
51         switch(size) {
52         case 0:
53             old = f16ImagePath;
54             f16ImagePath = path;
55             if (isEditable())
56                 firePropertyChanged(P_16, old, f16ImagePath);
57             break;
58         case 1:
59             old = f32ImagePath;
60             f32ImagePath = path;
61             if (isEditable())
62                 firePropertyChanged(P_32, old, f32ImagePath);
63             break;
64         case 2:
65             old = f48ImagePath;
66             f48ImagePath = path;
67             if (isEditable())
68                 firePropertyChanged(P_48, old, f48ImagePath);
69             break;
70         case 3:
71             old = f64ImagePath;
72             f64ImagePath = path;
73             if (isEditable())
74                 firePropertyChanged(P_64, old, f64ImagePath);
75             break;
76         case 4:
77             old = f128ImagePath;
78             f128ImagePath = path;
79             if (isEditable())
80                 firePropertyChanged(P_128, old, f128ImagePath);
81             break;
82         }
83         
84     }
85     
86     public void parse(Node JavaDoc node) {
87         if (node.getNodeType() == Node.ELEMENT_NODE) {
88             Element JavaDoc element = (Element JavaDoc)node;
89             f16ImagePath = element.getAttribute(P_16); //$NON-NLS-1$
90
// try the old 3.1 attribute name
91
if (f16ImagePath == null || f16ImagePath.length() == 0)
92                 f16ImagePath = element.getAttribute("small"); //$NON-NLS-1$
93

94             f32ImagePath = element.getAttribute(P_32); //$NON-NLS-1$
95
// try the old 3.1 attribute name
96
if (f32ImagePath == null || f32ImagePath.length() == 0)
97                 f32ImagePath = element.getAttribute("large"); //$NON-NLS-1$
98

99             f48ImagePath = element.getAttribute(P_48); //$NON-NLS-1$
100
f64ImagePath = element.getAttribute(P_64); //$NON-NLS-1$
101
f128ImagePath = element.getAttribute(P_128); //$NON-NLS-1$
102
}
103     }
104
105     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
106         writer.print(indent + "<windowImages"); //$NON-NLS-1$
107
if (f16ImagePath != null && f16ImagePath.length() > 0) {
108             writer.print(" " + P_16 + "=\"" + getWritableString(f16ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
109
}
110         if (f32ImagePath != null && f32ImagePath.length() > 0) {
111             writer.print(" " + P_32 + "=\"" + getWritableString(f32ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
112
}
113         if (f48ImagePath != null && f48ImagePath.length() > 0) {
114             writer.print(" " + P_48 + "=\"" + getWritableString(f48ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
115
}
116         if (f64ImagePath != null && f64ImagePath.length() > 0) {
117             writer.print(" " + P_64 + "=\"" + getWritableString(f64ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
118
}
119         if (f128ImagePath != null && f128ImagePath.length() > 0) {
120             writer.print(" " + P_128 + "=\"" + getWritableString(f128ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
121
}
122         writer.println("/>"); //$NON-NLS-1$
123
}
124
125 }
126
Popular Tags