diff options
author | apanchenk | 2009-04-15 09:48:23 +0000 |
---|---|---|
committer | apanchenk | 2009-04-15 09:48:23 +0000 |
commit | 10657829fab15958284c23d9a8fa555551fee82b (patch) | |
tree | c397934e61aaa0d9c9a4b5648866ca63df5c9dac | |
parent | f30a916145babdb478a24e6b70a88a5d1be06d4a (diff) | |
download | org.eclipse.dltk.tcl-10657829fab15958284c23d9a8fa555551fee82b.tar.gz org.eclipse.dltk.tcl-10657829fab15958284c23d9a8fa555551fee82b.tar.xz org.eclipse.dltk.tcl-10657829fab15958284c23d9a8fa555551fee82b.zip |
templates for new file
10 files changed, 103 insertions, 33 deletions
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.properties b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.properties index 4a00370f..1c410422 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.properties +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.properties @@ -64,6 +64,8 @@ ActionDefinition.OpenMethod.description= Open a method in a Tcl editor # Templates TclTemplateContext.name = tcl +TclFileContextType.name=Tcl File + # Preference pages TclPreferencePage.name = Tcl TclCorePreferencePage.name = Core @@ -98,7 +100,7 @@ OpenTypeInHierarchyAction.label=Open Type in Hierarch&y... OpenTypeInHierarchyAction.tooltip=Opens a Type in a Type Hierarchy TclTaskTagsPreferencePage.name = Task Tags -TclEnvironmentPropertyPage.name = Environment +TclEnvironmentPropertyPage.name = Execution # Compare TclCompareFontDefiniton.label=Tcl compare text font diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml index e4a97a18..5294f949 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml @@ -172,14 +172,18 @@ name="%TclTemplateContext.name"> </contextType> <contextType - class="org.eclipse.jface.text.templates.TemplateContextType" + class="org.eclipse.dltk.ui.text.templates.SourceModuleTemplateContextType" id="org.eclipse.dltk.tcl.text.template.type.tcl" - name="Tcl File"> + name="%TclFileContextType.name"> </contextType> <include file="templates/templates.xml" translations="templates/templates.properties"> </include> + <include + file="templates/file-templates.xml" + translations="templates/file-templates.properties"> + </include> </extension> <extension point="org.eclipse.ui.preferencePages"> diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclCodeTemplateArea.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclCodeTemplateArea.java new file mode 100644 index 00000000..ed060768 --- /dev/null +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclCodeTemplateArea.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2009 xored software, Inc. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.tcl.internal.ui; + +import org.eclipse.dltk.ui.text.templates.ICodeTemplateAccess; +import org.eclipse.dltk.ui.text.templates.ICodeTemplateArea; + +public class TclCodeTemplateArea implements ICodeTemplateArea { + + private static final String PREF_ID = "org.eclipse.dltk.tcl.preferences.code.templates"; //$NON-NLS-1$ + private static final String PROP_ID = "org.eclipse.dltk.tcl.propertyPage.CodeTemplatePage"; //$NON-NLS-1$ + + /* + * @see ICodeTemplateArea#getCodeTemplateAccess() + */ + public ICodeTemplateAccess getTemplateAccess() { + return TclUI.getDefault().getCodeTemplateAccess(); + } + + /* + * @see ICodeTemplateArea#getCodeTemplatePreferencePageId() + */ + public String getTemplatePreferencePageId() { + return PREF_ID; + } + + /* + * @see ICodeTemplateArea#getCodeTemplatePropertyPageId() + */ + public String getTemplatePropertyPageId() { + return PROP_ID; + } + +} diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclUI.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclUI.java index 18f664ca..64cc0916 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclUI.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/TclUI.java @@ -20,6 +20,7 @@ import org.eclipse.dltk.tcl.internal.ui.text.TclTextTools; import org.eclipse.dltk.ui.DLTKUILanguageManager; import org.eclipse.dltk.ui.IDLTKUILanguageToolkit; import org.eclipse.dltk.ui.text.templates.ICodeTemplateAccess; +import org.eclipse.dltk.ui.text.templates.ITemplateAccess; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -58,8 +59,8 @@ public class TclUI extends AbstractUIPlugin { public void stop(BundleContext context) throws Exception { try { if (codeTemplateAccess != null) { - if (codeTemplateAccess instanceof ICodeTemplateAccess.ICodeTemplateAccessInternal) { - ((ICodeTemplateAccess.ICodeTemplateAccessInternal) codeTemplateAccess) + if (codeTemplateAccess instanceof ITemplateAccess.ITemplateAccessInternal) { + ((ITemplateAccess.ITemplateAccessInternal) codeTemplateAccess) .dispose(); } codeTemplateAccess = null; diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/preferences/TclCodeTemplatesPreferencePage.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/preferences/TclCodeTemplatesPreferencePage.java index f0c957fc..88c56e46 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/preferences/TclCodeTemplatesPreferencePage.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/preferences/TclCodeTemplatesPreferencePage.java @@ -11,33 +11,16 @@ *******************************************************************************/ package org.eclipse.dltk.tcl.internal.ui.preferences; +import org.eclipse.dltk.tcl.internal.ui.TclCodeTemplateArea; import org.eclipse.dltk.tcl.internal.ui.TclUI; import org.eclipse.dltk.tcl.internal.ui.TclUILanguageToolkit; import org.eclipse.dltk.ui.preferences.CodeTemplatesPreferencePage; public class TclCodeTemplatesPreferencePage extends CodeTemplatesPreferencePage { - public static final String PREF_ID = "org.eclipse.dltk.tcl.preferencePage.CodeTemplatePage"; //$NON-NLS-1$ - public static final String PROP_ID = "org.eclipse.dltk.tcl.propertyPage.CodeTemplatePage"; //$NON-NLS-1$ - public TclCodeTemplatesPreferencePage() { - super(TclUILanguageToolkit.getInstance(), TclUI.getDefault() - .getCodeTemplateAccess()); + super(TclUILanguageToolkit.getInstance(), new TclCodeTemplateArea()); setPreferenceStore(TclUI.getDefault().getPreferenceStore()); } - /* - * @see PropertyAndPreferencePage#getPreferencePageId() - */ - protected String getPreferencePageId() { - return PREF_ID; - } - - /* - * @see PropertyAndPreferencePage#getPropertyPageId() - */ - protected String getPropertyPageId() { - return PROP_ID; - } - } diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/text/TclCodeTemplateAccess.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/text/TclCodeTemplateAccess.java index 08c0ccb3..c256acfa 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/text/TclCodeTemplateAccess.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/text/TclCodeTemplateAccess.java @@ -45,7 +45,7 @@ public class TclCodeTemplateAccess extends CodeTemplateAccess { public ICodeTemplateCategory[] getCategories() { if (categories == null) { - Iterator i = getCodeTemplateContextRegistry().contextTypes(); + Iterator i = getContextTypeRegistry().contextTypes(); List contextTypes = new ArrayList(); while (i.hasNext()) { contextTypes.add(i.next()); diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/wizards/TclFileCreationPage.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/wizards/TclFileCreationPage.java index f2b7d11d..1b6d50b9 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/wizards/TclFileCreationPage.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/wizards/TclFileCreationPage.java @@ -10,9 +10,10 @@ package org.eclipse.dltk.tcl.internal.ui.wizards; import org.eclipse.dltk.tcl.core.TclNature; +import org.eclipse.dltk.tcl.internal.ui.TclCodeTemplateArea; +import org.eclipse.dltk.ui.text.templates.ICodeTemplateArea; import org.eclipse.dltk.ui.wizards.NewSourceModulePage; - public class TclFileCreationPage extends NewSourceModulePage { protected String getRequiredNature() { @@ -23,7 +24,37 @@ public class TclFileCreationPage extends NewSourceModulePage { return "This wizard creates a new Tcl file."; } - protected String getPageTitle() { + protected String getPageTitle() { return "Create new Tcl file"; } + + private final ICodeTemplateArea codeTemplateArea = new TclCodeTemplateArea(); + + /* + * @see NewSourceModulePage#getCodeTemplateArea() + */ + protected ICodeTemplateArea getTemplateArea() { + return codeTemplateArea; + } + + /* + * @see NewSourceModulePage#getCodeTemplateContextTypes() + */ + protected String[] getCodeTemplateContextTypeIds() { + return new String[] { "org.eclipse.dltk.tcl.text.template.type.tcl" }; //$NON-NLS-1$ + } + + /* + * @see NewSourceModulePage#getDefaultCodeTemplateId() + */ + protected String getDefaultCodeTemplateId() { + return "org.eclipse.dltk.tcl.text.templates.tcl"; //$NON-NLS-1$ + } + + /** + * @return the name of the template used in the previous dialog invocation. + */ + protected String getLastUsedTemplateName() { + return null; + } } diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.properties b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.properties new file mode 100644 index 00000000..0ef698c9 --- /dev/null +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.properties @@ -0,0 +1,2 @@ +tclfile.template.name=Tcl File +wishfile.template.name=Wish File diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.xml b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.xml new file mode 100644 index 00000000..0f254058 --- /dev/null +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/file-templates.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates> + +<template name="%tclfile.template.name" id="org.eclipse.dltk.tcl.text.templates.tcl" description="Tcl File" context="org.eclipse.dltk.tcl.text.template.type.tcl" enabled="true">#!/bin/tclsh +</template> + +<template name="%wishfile.template.name" id="org.eclipse.dltk.tcl.text.templates.wish" description="Wish File" context="org.eclipse.dltk.tcl.text.template.type.tcl" enabled="true">#!/bin/wish +</template> + +</templates> diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/templates.xml b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/templates.xml index 77569638..92cd08d3 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/templates.xml +++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/templates/templates.xml @@ -1,10 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <templates> -<template name="Tcl File" id="org.eclipse.dltk.tcl.text.templates.tcl" description="Tcl File" context="org.eclipse.dltk.tcl.text.template.type.tcl" enabled="true">#!/bin/tclsh -</template> - -<template name="Wish File" id="org.eclipse.dltk.tcl.text.templates.wish" description="Wish File" context="org.eclipse.dltk.tcl.text.template.type.tcl" enabled="true">#!/bin/wish -</template> - </templates> |