1 11 package org.eclipse.pde.internal.core.build; 12 13 import java.io.PrintWriter ; 14 import java.util.ArrayList ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.pde.core.IModelChangedEvent; 18 import org.eclipse.pde.core.ModelChangedEvent; 19 import org.eclipse.pde.core.build.IBuild; 20 import org.eclipse.pde.core.build.IBuildEntry; 21 22 public class Build extends BuildObject implements IBuild { 23 protected ArrayList fEntries = new ArrayList (); 24 25 public void add(IBuildEntry entry) throws CoreException { 26 ensureModelEditable(); 27 fEntries.add(entry); 28 ((BuildEntry) entry).setInTheModel(true); 29 getModel().fireModelChanged( 30 new ModelChangedEvent(getModel(), IModelChangedEvent.INSERT, 31 new Object [] { entry }, null)); 32 } 33 34 public IBuildEntry[] getBuildEntries() { 35 return (IBuildEntry[])fEntries.toArray(new IBuildEntry[fEntries.size()]); 36 } 37 38 public IBuildEntry getEntry(String name) { 39 for (int i = 0; i < fEntries.size(); i++) { 40 IBuildEntry entry = (IBuildEntry) fEntries.get(i); 41 if (entry.getName().equals(name)) 42 return entry; 43 } 44 return null; 45 } 46 47 public void processEntry(String name, String value) { 48 BuildEntry entry = (BuildEntry) getModel().getFactory().createEntry( 49 name); 50 fEntries.add(entry); 51 entry.processEntry(value); 52 } 53 54 public void remove(IBuildEntry entry) throws CoreException { 55 ensureModelEditable(); 56 fEntries.remove(entry); 57 getModel().fireModelChanged( 58 new ModelChangedEvent(getModel(), IModelChangedEvent.REMOVE, 59 new Object [] { entry }, null)); 60 } 61 62 public void reset() { 63 fEntries.clear(); 64 } 65 66 public void write(String indent, PrintWriter writer) { 67 for (int i = 0; i < fEntries.size(); i++) { 68 IBuildEntry entry = (IBuildEntry) fEntries.get(i); 69 entry.write("", writer); } 71 } 72 } 73 | Popular Tags |