01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
11:
12: import java.io.File;
13:
14: import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
15: import org.eclipse.core.runtime.CoreException;
16: import org.eclipse.core.runtime.IAdaptable;
17: import org.eclipse.jface.text.IDocument;
18: import org.eclipse.jface.text.source.IAnnotationModel;
19: import org.eclipse.ui.editors.text.StorageDocumentProvider;
20:
21: public class PDEStorageDocumentProvider extends StorageDocumentProvider {
22:
23: private IDocumentSetupParticipant fSetupParticipant;
24:
25: public PDEStorageDocumentProvider(
26: IDocumentSetupParticipant participant) {
27: fSetupParticipant = participant;
28: }
29:
30: protected void setupDocument(Object 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 element)
40: throws CoreException {
41: if (element instanceof IAdaptable) {
42: IAdaptable input = (IAdaptable) element;
43: File file = (File) input.getAdapter(File.class);
44: if (file != null) {
45: return new SystemFileMarkerAnnotationModel();
46: }
47: }
48: return super.createAnnotationModel(element);
49: }
50:
51: }
|