1 11 package org.eclipse.pde.internal.core.text.bundle; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.jface.text.IDocument; 18 import org.eclipse.osgi.util.ManifestElement; 19 import org.eclipse.pde.internal.core.NLResourceHelper; 20 import org.eclipse.pde.internal.core.ibundle.IBundle; 21 import org.eclipse.pde.internal.core.ibundle.IBundleModel; 22 import org.eclipse.pde.internal.core.ibundle.IBundleModelFactory; 23 import org.eclipse.pde.internal.core.text.AbstractEditingModel; 24 import org.osgi.framework.BundleException; 25 import org.osgi.framework.Constants; 26 27 public class BundleModel extends AbstractEditingModel implements IBundleModel { 28 29 private IBundle fBundle; 30 private IBundleModelFactory fFactory; 31 35 public BundleModel(IDocument document, boolean isReconciling) { 36 super(document, isReconciling); 37 fBundle = new Bundle(this); 38 } 39 42 protected NLResourceHelper createNLResourceHelper() { 43 return null; 44 } 45 48 public boolean isFragmentModel() { 49 return getBundle().getHeader(Constants.FRAGMENT_HOST) != null; 50 } 51 52 55 public void load(InputStream source, boolean outOfSync) throws CoreException { 56 try { 57 fLoaded = true; 58 ((Bundle)getBundle()).clearHeaders(); 59 ((Bundle)getBundle()).load(ManifestElement.parseBundleManifest(source, null)); 60 } catch (BundleException e) { 61 fLoaded = false; 62 } catch (IOException e) { 63 fLoaded = false; 64 } 65 } 66 67 70 public void adjustOffsets(IDocument document) { 71 ((Bundle)getBundle()).clearOffsets(); 72 ((Bundle)getBundle()).adjustOffsets(document); 73 } 74 77 public IBundle getBundle() { 78 return fBundle; 79 } 80 public IBundleModelFactory getFactory() { 81 if (fFactory == null) 82 fFactory = new BundleModelFactory(this); 83 return fFactory; 84 } 85 86 } 87 | Popular Tags |