KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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 org.eclipse.jdt.internal.ui.JavaPlugin;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.pde.internal.ui.editor.build.BuildSourcePage;
16 import org.eclipse.pde.internal.ui.editor.build.BuildSourceViewerConfiguration;
17 import org.eclipse.pde.internal.ui.editor.plugin.BundleSourcePage;
18 import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
19 import org.eclipse.pde.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration;
20 import org.eclipse.pde.internal.ui.editor.text.IColorManager;
21 import org.eclipse.pde.internal.ui.editor.text.ManifestConfiguration;
22 import org.eclipse.pde.internal.ui.editor.text.PluginXMLConfiguration;
23 import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration;
24
25 public class SourceViewerConfigurationFactory {
26
27     public static ChangeAwareSourceViewerConfiguration createSourceViewerConfiguration(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().getCombinedPreferenceStore();
37             ((BuildSourcePage)page).setPreferenceStore(store);
38             return new BuildSourceViewerConfiguration(manager, store, page);
39         }
40         return null;
41     }
42     
43 }
44
Popular Tags