Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585/src/org/python/pydev/plugin
Modified Files:
PydevPlugin.java
Log Message:
Template proposals added.
Index: PydevPlugin.java
===================================================================
RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PydevPlugin.java 2 Jul 2004 02:50:38 -0000 1.9
--- PydevPlugin.java 6 Aug 2004 17:20:03 -0000 1.10
***************
*** 1,4 ****
--- 1,5 ----
package org.python.pydev.plugin;
+ import java.io.IOException;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
***************
*** 12,15 ****
--- 13,18 ----
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
+ import org.eclipse.jface.text.templates.ContextTypeRegistry;
+ import org.eclipse.jface.text.templates.persistence.TemplateStore;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
***************
*** 19,25 ****
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
! import org.eclipse.ui.ide.IDE;
/**
--- 22,31 ----
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+ import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
+ import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
+ import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
! import org.python.pydev.editor.templates.PyContextType;
/**
***************
*** 35,38 ****
--- 41,51 ----
private ResourceBundle resourceBundle; //Resource bundle.
+ /** The template store. */
+ private TemplateStore fStore;
+ /** The context type registry. */
+ private ContributionContextTypeRegistry fRegistry=null;
+ /** Key to store custom templates. */
+ private static final String CUSTOM_TEMPLATES_PY_KEY = "org.python.pydev.editor.templates.PyTemplatePreferencesPage";
+
/**
* The constructor.
***************
*** 140,142 ****
--- 153,188 ----
}
}
+
+ /**
+ * Returns this plug-in's template store.
+ *
+ * @return the template store of this plug-in instance
+ */
+ public TemplateStore getTemplateStore() {
+ if (fStore == null) {
+ fStore= new ContributionTemplateStore(getContextTypeRegistry(), getPreferenceStore(), CUSTOM_TEMPLATES_PY_KEY);
+ try {
+ fStore.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+ return fStore;
+ }
+
+ /**
+ * Returns this plug-in's context type registry.
+ *
+ * @return the context type registry for this plug-in instance
+ */
+ public ContextTypeRegistry getContextTypeRegistry() {
+ if (fRegistry == null) {
+ // create an configure the contexts available in the template editor
+ fRegistry= new ContributionContextTypeRegistry();
+ fRegistry.addContextType(PyContextType.PY_CONTEXT_TYPE);
+ }
+ return fRegistry;
+ }
+
}
|