01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.target;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.pde.internal.core.itarget.ILocationInfo;
15: import org.eclipse.pde.internal.core.itarget.ITargetModel;
16: import org.w3c.dom.Element;
17: import org.w3c.dom.Node;
18:
19: public class LocationInfo extends TargetObject implements ILocationInfo {
20:
21: private static final long serialVersionUID = 1L;
22:
23: private String fPath = ""; //$NON-NLS-1$
24: private boolean fUseDefault = true;
25:
26: public LocationInfo(ITargetModel model) {
27: super (model);
28: }
29:
30: public void parse(Node node) {
31: Element element = (Element) node;
32: fPath = element.getAttribute("path"); //$NON-NLS-1$
33: fUseDefault = "true".equalsIgnoreCase(element.getAttribute("useDefault")); //$NON-NLS-1$ //$NON-NLS-2$
34: }
35:
36: public void write(String indent, PrintWriter writer) {
37: writer.println();
38: writer.print(indent + "<location"); //$NON-NLS-1$
39: if (fUseDefault)
40: writer.print(" useDefault=\"true\""); //$NON-NLS-1$
41: else if (fPath != null && fPath.trim().length() > 0)
42: writer
43: .print(" path=\"" + getWritableString(fPath.trim()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
44: writer.println("/>"); //$NON-NLS-1$
45: }
46:
47: public boolean useDefault() {
48: return fUseDefault;
49: }
50:
51: public void setDefault(boolean value) {
52: fUseDefault = value;
53: if (value)
54: firePropertyChanged(P_LOC, fPath, ""); //$NON-NLS-1$
55: else
56: firePropertyChanged(P_LOC, "", fPath); //$NON-NLS-1$
57: }
58:
59: public String getPath() {
60: return fPath;
61: }
62:
63: public void setPath(String path) {
64: fUseDefault = false;
65: String oldValue = fPath;
66: fPath = (path != null) ? path : ""; //$NON-NLS-1$
67: firePropertyChanged(P_LOC, oldValue, fPath);
68: }
69:
70: }
|