1 11 package org.eclipse.pde.internal.core.target; 12 13 import java.io.PrintWriter ; 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 ; 18 import org.w3c.dom.Node ; 19 20 public class LocationInfo extends TargetObject implements ILocationInfo{ 21 22 private static final long serialVersionUID = 1L; 23 24 private String fPath = ""; private boolean fUseDefault = true; 26 27 public LocationInfo(ITargetModel model) { 28 super(model); 29 } 30 31 public void parse(Node node) { 32 Element element = (Element )node; 33 fPath = element.getAttribute("path"); fUseDefault = "true".equalsIgnoreCase(element.getAttribute("useDefault")); } 36 37 public void write(String indent, PrintWriter writer) { 38 writer.println(); 39 writer.print(indent + "<location"); if (fUseDefault) 41 writer.print(" useDefault=\"true\""); else if (fPath != null && fPath.trim().length() > 0) 43 writer.print(" path=\"" + getWritableString(fPath.trim()) + "\""); writer.println("/>"); } 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, ""); else 56 firePropertyChanged(P_LOC, "", fPath); } 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 : ""; firePropertyChanged(P_LOC, oldValue, fPath); 68 } 69 70 } 71 | Popular Tags |