001: /*******************************************************************************
002: * Copyright (c) 2005, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.core.product;
011:
012: import java.io.PrintWriter;
013:
014: import org.eclipse.pde.internal.core.iproduct.IProductModel;
015: import org.eclipse.pde.internal.core.iproduct.IWindowImages;
016: import org.w3c.dom.Element;
017: import org.w3c.dom.Node;
018:
019: public class WindowImages extends ProductObject implements
020: IWindowImages {
021:
022: private static final long serialVersionUID = 1L;
023: private String f16ImagePath;
024: private String f32ImagePath;
025: private String f48ImagePath;
026: private String f64ImagePath;
027: private String f128ImagePath;
028:
029: public WindowImages(IProductModel model) {
030: super (model);
031: }
032:
033: public String getImagePath(int size) {
034: switch (size) {
035: case 0:
036: return f16ImagePath;
037: case 1:
038: return f32ImagePath;
039: case 2:
040: return f48ImagePath;
041: case 3:
042: return f64ImagePath;
043: case 4:
044: return f128ImagePath;
045: }
046: return null;
047: }
048:
049: public void setImagePath(String path, int size) {
050: String old;
051: switch (size) {
052: case 0:
053: old = f16ImagePath;
054: f16ImagePath = path;
055: if (isEditable())
056: firePropertyChanged(P_16, old, f16ImagePath);
057: break;
058: case 1:
059: old = f32ImagePath;
060: f32ImagePath = path;
061: if (isEditable())
062: firePropertyChanged(P_32, old, f32ImagePath);
063: break;
064: case 2:
065: old = f48ImagePath;
066: f48ImagePath = path;
067: if (isEditable())
068: firePropertyChanged(P_48, old, f48ImagePath);
069: break;
070: case 3:
071: old = f64ImagePath;
072: f64ImagePath = path;
073: if (isEditable())
074: firePropertyChanged(P_64, old, f64ImagePath);
075: break;
076: case 4:
077: old = f128ImagePath;
078: f128ImagePath = path;
079: if (isEditable())
080: firePropertyChanged(P_128, old, f128ImagePath);
081: break;
082: }
083:
084: }
085:
086: public void parse(Node node) {
087: if (node.getNodeType() == Node.ELEMENT_NODE) {
088: Element element = (Element) node;
089: f16ImagePath = element.getAttribute(P_16); //$NON-NLS-1$
090: // try the old 3.1 attribute name
091: if (f16ImagePath == null || f16ImagePath.length() == 0)
092: f16ImagePath = element.getAttribute("small"); //$NON-NLS-1$
093:
094: f32ImagePath = element.getAttribute(P_32); //$NON-NLS-1$
095: // try the old 3.1 attribute name
096: if (f32ImagePath == null || f32ImagePath.length() == 0)
097: f32ImagePath = element.getAttribute("large"); //$NON-NLS-1$
098:
099: 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 indent, PrintWriter writer) {
106: writer.print(indent + "<windowImages"); //$NON-NLS-1$
107: if (f16ImagePath != null && f16ImagePath.length() > 0) {
108: writer
109: .print(" " + P_16 + "=\"" + getWritableString(f16ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
110: }
111: if (f32ImagePath != null && f32ImagePath.length() > 0) {
112: writer
113: .print(" " + P_32 + "=\"" + getWritableString(f32ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
114: }
115: if (f48ImagePath != null && f48ImagePath.length() > 0) {
116: writer
117: .print(" " + P_48 + "=\"" + getWritableString(f48ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
118: }
119: if (f64ImagePath != null && f64ImagePath.length() > 0) {
120: writer
121: .print(" " + P_64 + "=\"" + getWritableString(f64ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
122: }
123: if (f128ImagePath != null && f128ImagePath.length() > 0) {
124: writer
125: .print(" " + P_128 + "=\"" + getWritableString(f128ImagePath) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
126: }
127: writer.println("/>"); //$NON-NLS-1$
128: }
129:
130: }
|