KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > PDEStorageDocumentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.editor;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.jface.text.IDocument;
19 import org.eclipse.jface.text.source.IAnnotationModel;
20 import org.eclipse.ui.editors.text.StorageDocumentProvider;
21
22 public class PDEStorageDocumentProvider extends StorageDocumentProvider {
23     
24     private IDocumentSetupParticipant fSetupParticipant;
25
26     public PDEStorageDocumentProvider(IDocumentSetupParticipant participant) {
27         fSetupParticipant = participant;
28     }
29     
30     protected void setupDocument(Object JavaDoc element, IDocument document) {
31         if (document != null && fSetupParticipant != null) {
32             fSetupParticipant.setup(document);
33         }
34     }
35
36     /*
37      * @see AbstractDocumentProvider#createAnnotationModel(Object)
38      */

39     protected IAnnotationModel createAnnotationModel(Object JavaDoc element) throws CoreException {
40         if (element instanceof IAdaptable) {
41             IAdaptable input= (IAdaptable) element;
42             File JavaDoc file = (File JavaDoc)input.getAdapter(File JavaDoc.class);
43             if (file != null) {
44                 return new SystemFileMarkerAnnotationModel();
45             }
46         }
47         return super.createAnnotationModel(element);
48     }
49
50
51 }
52
Popular Tags