1 11 package org.eclipse.pde.internal.core.product; 12 13 import java.io.PrintWriter ; 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 ; 18 import org.w3c.dom.Node ; 19 20 public class WindowImages extends ProductObject implements IWindowImages { 21 22 private static final long serialVersionUID = 1L; 23 private String f16ImagePath; 24 private String f32ImagePath; 25 private String f48ImagePath; 26 private String f64ImagePath; 27 private String f128ImagePath; 28 29 public WindowImages(IProductModel model) { 30 super(model); 31 } 32 33 public String 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 path, int size) { 50 String 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 node) { 87 if (node.getNodeType() == Node.ELEMENT_NODE) { 88 Element element = (Element )node; 89 f16ImagePath = element.getAttribute(P_16); if (f16ImagePath == null || f16ImagePath.length() == 0) 92 f16ImagePath = element.getAttribute("small"); 94 f32ImagePath = element.getAttribute(P_32); if (f32ImagePath == null || f32ImagePath.length() == 0) 97 f32ImagePath = element.getAttribute("large"); 99 f48ImagePath = element.getAttribute(P_48); f64ImagePath = element.getAttribute(P_64); f128ImagePath = element.getAttribute(P_128); } 103 } 104 105 public void write(String indent, PrintWriter writer) { 106 writer.print(indent + "<windowImages"); if (f16ImagePath != null && f16ImagePath.length() > 0) { 108 writer.print(" " + P_16 + "=\"" + getWritableString(f16ImagePath) + "\""); } 110 if (f32ImagePath != null && f32ImagePath.length() > 0) { 111 writer.print(" " + P_32 + "=\"" + getWritableString(f32ImagePath) + "\""); } 113 if (f48ImagePath != null && f48ImagePath.length() > 0) { 114 writer.print(" " + P_48 + "=\"" + getWritableString(f48ImagePath) + "\""); } 116 if (f64ImagePath != null && f64ImagePath.length() > 0) { 117 writer.print(" " + P_64 + "=\"" + getWritableString(f64ImagePath) + "\""); } 119 if (f128ImagePath != null && f128ImagePath.length() > 0) { 120 writer.print(" " + P_128 + "=\"" + getWritableString(f128ImagePath) + "\""); } 122 writer.println("/>"); } 124 125 } 126 | Popular Tags |