KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > target > LocationInfo


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.target;
12
13 import java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.pde.internal.core.itarget.ILocationInfo;
16 import org.eclipse.pde.internal.core.itarget.ITargetModel;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.Node JavaDoc;
19
20 public class LocationInfo extends TargetObject implements ILocationInfo{
21
22     private static final long serialVersionUID = 1L;
23     
24     private String JavaDoc fPath = ""; //$NON-NLS-1$
25
private boolean fUseDefault = true;
26
27     public LocationInfo(ITargetModel model) {
28         super(model);
29     }
30
31     public void parse(Node JavaDoc node) {
32         Element JavaDoc element = (Element JavaDoc)node;
33         fPath = element.getAttribute("path"); //$NON-NLS-1$
34
fUseDefault = "true".equalsIgnoreCase(element.getAttribute("useDefault")); //$NON-NLS-1$ //$NON-NLS-2$
35
}
36
37     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
38         writer.println();
39         writer.print(indent + "<location"); //$NON-NLS-1$
40
if (fUseDefault)
41             writer.print(" useDefault=\"true\""); //$NON-NLS-1$
42
else if (fPath != null && fPath.trim().length() > 0)
43             writer.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 JavaDoc getPath() {
60         return fPath;
61     }
62
63     public void setPath(String JavaDoc path) {
64         fUseDefault = false;
65         String JavaDoc oldValue = fPath;
66         fPath = (path != null) ? path : ""; //$NON-NLS-1$
67
firePropertyChanged(P_LOC, oldValue, fPath);
68     }
69
70 }
71
Popular Tags