KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > template > java > Templates


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.corext.template.java;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IPath;
17
18 import org.eclipse.jdt.internal.ui.JavaPlugin;
19
20 /**
21  * <code>Templates</code> gives access to the available templates.
22  *
23  * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.templates.persistence.TemplateStore}
24  */

25 public class Templates extends org.eclipse.jdt.internal.corext.template.java.TemplateSet {
26
27     private static final String JavaDoc TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
28

29     /** Singleton. */
30     private static Templates fgTemplates;
31
32     /**
33      * Returns an instance of templates.
34      *
35      * @return an instance of templates
36      * @deprecated As of 3.0, replaced by
37      * {@link org.eclipse.jdt.internal.ui.JavaPlugin#getTemplateStore()}
38      */

39     public static Templates getInstance() {
40         if (fgTemplates == null)
41             fgTemplates= new Templates();
42         
43         return fgTemplates;
44     }
45     
46     public Templates() {
47         super("template", JavaPlugin.getDefault().getTemplateContextRegistry()); //$NON-NLS-1$
48
create();
49     }
50     
51
52     private void create() {
53
54         try {
55             File JavaDoc templateFile= getTemplateFile();
56             if (templateFile.exists()) {
57                 addFromFile(templateFile, false);
58             }
59
60         } catch (CoreException e) {
61             JavaPlugin.log(e);
62             clear();
63         }
64
65     }
66     
67     /**
68      * Resets the template set.
69      *
70      * @throws CoreException in case the reset operation fails
71      */

72     public void reset() throws CoreException {
73     }
74
75     /**
76      * Resets the template set with the default templates.
77      *
78      * @throws CoreException in case the restore operation fails
79      */

80     public void restoreDefaults() throws CoreException {
81     }
82
83     /**
84      * Saves the template set.
85      *
86      * @throws CoreException in case the save operation fails
87      */

88     public void save() throws CoreException {
89     }
90
91     private static File JavaDoc getTemplateFile() {
92         IPath path= JavaPlugin.getDefault().getStateLocation();
93         path= path.append(TEMPLATE_FILE);
94         
95         return path.toFile();
96     }
97 }
98
99
Popular Tags