01: /*******************************************************************************
02: * Copyright (c) 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 org.eclipse.jdt.internal.ui.JavaPlugin;
13: import org.eclipse.jface.preference.IPreferenceStore;
14: import org.eclipse.pde.internal.ui.editor.build.BuildSourcePage;
15: import org.eclipse.pde.internal.ui.editor.build.BuildSourceViewerConfiguration;
16: import org.eclipse.pde.internal.ui.editor.plugin.BundleSourcePage;
17: import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
18: import org.eclipse.pde.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration;
19: import org.eclipse.pde.internal.ui.editor.text.IColorManager;
20: import org.eclipse.pde.internal.ui.editor.text.ManifestConfiguration;
21: import org.eclipse.pde.internal.ui.editor.text.PluginXMLConfiguration;
22: import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration;
23:
24: public class SourceViewerConfigurationFactory {
25:
26: public static ChangeAwareSourceViewerConfiguration createSourceViewerConfiguration(
27: PDESourcePage page, IColorManager manager) {
28: if (page instanceof XMLSourcePage) {
29: if (page.getEditor() instanceof ManifestEditor)
30: return new PluginXMLConfiguration(manager, page);
31: return new XMLConfiguration(manager, page);
32: }
33: if (page instanceof BundleSourcePage)
34: return new ManifestConfiguration(manager, page);
35: if (page instanceof BuildSourcePage) {
36: IPreferenceStore store = JavaPlugin.getDefault()
37: .getCombinedPreferenceStore();
38: ((BuildSourcePage) page).setPreferenceStore(store);
39: return new BuildSourceViewerConfiguration(manager, store,
40: page);
41: }
42: return null;
43: }
44:
45: }
|