KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > bundle > BundleModel


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.ui.model.bundle;
12
13 import java.io.*;
14 import java.util.jar.*;
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.jface.text.*;
17 import org.eclipse.pde.internal.core.*;
18 import org.eclipse.pde.internal.core.ibundle.*;
19 import org.eclipse.pde.internal.ui.model.*;
20 import org.osgi.framework.*;
21
22 public class BundleModel extends AbstractEditingModel implements IBundleModel {
23
24     private IBundle fBundle;
25     /**
26      * @param document
27      * @param isReconciling
28      */

29     public BundleModel(IDocument document, boolean isReconciling) {
30         super(document, isReconciling);
31         fBundle = new Bundle(this);
32     }
33     /* (non-Javadoc)
34      * @see org.eclipse.pde.internal.ui.model.AbstractEditingModel#createNLResourceHelper()
35      */

36     protected NLResourceHelper createNLResourceHelper() {
37         return null;
38     }
39     /* (non-Javadoc)
40      * @see org.eclipse.pde.internal.core.ibundle.IBundleModel#isFragmentModel()
41      */

42     public boolean isFragmentModel() {
43         return getBundle().getHeader(Constants.FRAGMENT_HOST) != null;
44     }
45     
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.core.IModel#load(java.io.InputStream, boolean)
48      */

49     public void load(InputStream source, boolean outOfSync) throws CoreException {
50         try {
51             fLoaded = true;
52             ((Bundle)getBundle()).clearHeaders();
53             ((Bundle)getBundle()).load(new Manifest(source));
54         } catch (IOException e) {
55             fLoaded = false;
56         }
57     }
58     
59     /* (non-Javadoc)
60      * @see org.eclipse.pde.internal.ui.model.AbstractEditingModel#adjustOffsets(org.eclipse.jface.text.IDocument)
61      */

62     protected void adjustOffsets(IDocument document) {
63         ((Bundle)getBundle()).clearOffsets();
64         ((Bundle)getBundle()).adjustOffsets(document);
65         ((Bundle)getBundle()).trim();
66     }
67     /* (non-Javadoc)
68      * @see org.eclipse.pde.internal.core.ibundle.IBundleModel#getBundle()
69      */

70     public IBundle getBundle() {
71         return fBundle;
72     }
73     
74 }
75
Popular Tags