1 11 package org.eclipse.pde.internal.ui.model.build; 12 13 import java.io.*; 14 import java.util.*; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.pde.core.build.*; 18 import org.eclipse.pde.internal.core.util.*; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.model.*; 21 22 public class BuildEntry implements IBuildEntry, IDocumentKey { 23 24 private int fLength = -1; 25 private int fOffset = -1; 26 private IBuildModel fModel; 27 private String fName; 28 private ArrayList fTokens = new ArrayList(); 29 30 33 public void addToken(String token) throws CoreException { 34 fTokens.add(token); 35 getModel().fireModelObjectChanged(this, getName(), null, token); 36 } 37 40 public String getName() { 41 return fName; 42 } 43 46 public String [] getTokens() { 47 return (String [])fTokens.toArray(new String [fTokens.size()]); 48 } 49 52 public boolean contains(String token) { 53 return fTokens.contains(token); 54 } 55 58 public void removeToken(String token) throws CoreException { 59 fTokens.remove(token); 60 getModel().fireModelObjectChanged(this, getName(), token, null); 61 } 62 65 public void renameToken(String oldToken, String newToken) 66 throws CoreException { 67 int index = fTokens.indexOf(oldToken); 68 if (index != -1) { 69 fTokens.set(index, newToken); 70 getModel().fireModelObjectChanged(this, getName(), oldToken, newToken); 71 } 72 } 73 76 public void setName(String name) { 77 String oldName = fName; 78 if (getModel() != null){ 79 try { 80 IBuild build = getModel().getBuild(); 81 build.remove(this); 82 fName = name; 83 build.add(this); 84 } catch (CoreException e) { 85 PDEPlugin.logException(e); 86 } 87 getModel().fireModelObjectChanged(this, getName(), oldName, name); 88 } else 89 fName = name; 90 } 91 94 public int getOffset() { 95 return fOffset; 96 } 97 100 public void setOffset(int offset) { 101 fOffset = offset; 102 } 103 104 107 public int getLength() { 108 return fLength; 109 } 110 111 114 public void setLength(int length) { 115 fLength = length; 116 } 117 120 public void write(String indent, PrintWriter writer) { 121 } 122 123 public void setModel(IBuildModel model) { 124 fModel = model; 125 } 126 127 public IBuildModel getModel() { 128 return fModel; 129 } 130 131 public void processEntry(String value) { 132 StringTokenizer stok = new StringTokenizer(value, ","); while (stok.hasMoreTokens()) { 134 fTokens.add(stok.nextToken().trim()); 135 } 136 } 137 140 public String write() { 141 return PropertiesUtil.writeKeyValuePair(getName(), getTokens()); 142 } 143 } 144 | Popular Tags |