KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > filebuffers > FileBuffersPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.core.internal.filebuffers;
12
13 import org.osgi.framework.Bundle;
14
15 import org.eclipse.core.runtime.Assert;
16 import org.eclipse.core.runtime.Platform;
17 import org.eclipse.core.runtime.Plugin;
18
19 import org.eclipse.core.filebuffers.ITextFileBufferManager;
20
21
22
23 /**
24  * The plug-in runtime class for the file buffers plug-in (id <code>"org.eclipse.core.filebuffers"</code>).
25  *
26  * @since 3.0
27  */

28 public class FileBuffersPlugin extends Plugin {
29
30     public final static String JavaDoc PLUGIN_ID= "org.eclipse.core.filebuffers"; //$NON-NLS-1$
31

32     /** The shared plug-in instance */
33     private static FileBuffersPlugin fgPlugin;
34     /** The file buffer manager */
35     private ITextFileBufferManager fTextFileBufferManager;
36
37     /**
38      * Creates a plug-in instance.
39      */

40     public FileBuffersPlugin() {
41         Assert.isTrue(fgPlugin == null);
42         fgPlugin= this;
43     }
44
45     /**
46      * Returns the shared instance.
47      *
48      * @return the default plug-in instance
49      */

50     public static FileBuffersPlugin getDefault() {
51         return fgPlugin;
52     }
53
54     /**
55      * Returns the text file buffer manager of this plug-in.
56      *
57      * @return the text file buffer manager of this plug-in
58      */

59     public synchronized ITextFileBufferManager getFileBufferManager() {
60         if (fTextFileBufferManager == null) {
61             Bundle resourcesBundle= Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
62
if (resourcesBundle != null)
63                 fTextFileBufferManager= new ResourceTextFileBufferManager();
64             else
65                 fTextFileBufferManager= new TextFileBufferManager();
66         }
67         return fTextFileBufferManager;
68     }
69 }
70
Popular Tags