Author: mareshkau
Date: 2010-04-08 10:33:47 -0400 (Thu, 08 Apr 2010)
New Revision: 21347
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeXHTML.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/VPETemplatePreferencePage.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.xml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUiPlugin.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5946 ,
https://jira.jboss.org/jira/browse/JBIDE-6131
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2010-04-08 14:18:02 UTC
(rev 21346)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2010-04-08 14:33:47 UTC
(rev 21347)
@@ -52,7 +52,8 @@
org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100",
org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
org.eclipse.search;bundle-version="3.5.0",
- org.jboss.tools.common.el.core;bundle-version="2.0.0"
+ org.jboss.tools.common.el.core;bundle-version="2.0.0",
+ org.eclipse.wst.html.ui;bundle-version="1.0.401"
Bundle-Version: 2.0.0
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2010-04-08 14:18:02 UTC
(rev 21346)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2010-04-08 14:33:47 UTC
(rev 21347)
@@ -25,6 +25,7 @@
PreferencePage_JSFFlowTabbed=JSF Flow Diagram
PreferencePage_Validator=Validator
PreferencePage_JSFValidator=JSF Validator
+VPE_Templates=Templates
NewWizardCat_JBossTools=JBoss Tools
NewWizardCat_JSF=JSF
@@ -37,3 +38,12 @@
ImportWizardCat_Struts=Struts
ImportWizardDescription_JSFProject=Create a new Project from a JSF project in the file
system. This does not copy the project to the workspace.
ImportWizardDescription_JSFWar=Create a new Project from a JSF project in a WAR file. The
content of WAR file will be copied to the workspace.
+
+All_XHTML_context_type_Extension_Element.name=All XHTML
+XHTML_New_context_type_Extension_Element.name=New XHTML
+XHTML_Tag_context_type_Extension_Element.name=XHTML Tag
+XHTML_Attribute_context_type_Extension_Element.name=XHTML Attribute
+XHTML_Attribute_value_context_type_Extension_Element.name=XHTML Attribute value
+
+NewXHTMLPage = XHTML Page
+NewXHTMLPageDescription = Create a New XHTML Page
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-08 14:18:02 UTC (rev
21346)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-08 14:33:47 UTC (rev
21347)
@@ -8,6 +8,13 @@
id="org.jboss.tools.jsf.ui"
name="%PreferencePage_JSF">
</page>
+ <page
+ name="%VPE_Templates"
+ category="org.jboss.tools.vpe.editor"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.VPETemplatePreferencePage"
+ id="org.jboss.tools.jsf.ui.editor.pref.template">
+ <keywordReference id="org.eclipse.wst.html.ui.templates"/>
+ </page>
<page category="org.jboss.tools.jsf.ui"
class="org.jboss.tools.jsf.ui.preferences.JSFProjectPreferencesPage"
id="org.jboss.tools.jsf.ui.project"
@@ -129,6 +136,20 @@
</wizard>
<wizard
category="org.jboss.tools.jst.web/org.jboss.tools.jsf"
+ class="org.jboss.tools.jsf.ui.wizard.newfile.NewXHTMLWizard"
+
finalPerspective="org.jboss.tools.jsf.ui.wizard.project.NewProjectWizard"
+ icon="$nl$/images/xstudio/wizards/new_html_file.gif"
+ id="org.jboss.tools.jsf.ui.wizard.newfile.NewXHTMLWizard"
+ name="%NewXHTMLPage"
+ project="false">
+ <description>
+ %NewXHTMLPageDescription
+ </description>
+ <selection class="org.eclipse.core.resources.IResource">
+ </selection>
+ </wizard>
+ <wizard
+ category="org.jboss.tools.jst.web/org.jboss.tools.jsf"
class="org.jboss.tools.jsf.ui.wizard.project.NewProjectWizard"
finalPerspective="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective"
icon="$nl$/images/xstudio/wizards/new_jsf_project.gif"
@@ -450,6 +471,44 @@
class="org.jboss.tools.jsf.ui.el.refactoring.ELRefactorContributionFactory"
locationURI="popup:org.eclipse.ui.popup.any?after=save">
</menuContribution>
- </extension>
-
+ <menuContribution
+
locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor.source.EditorContext?after=paste">
+ <dynamic
+
class="org.jboss.tools.jsf.ui.editor.menu.JSF2CompositionComponentContrubutionItem"
+
id="org.jboss.tools.jsf.ui.editor.menu.JSF2CompositionComponentContrubutionItem">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <!-- Templates -->
+ <extension point="org.eclipse.ui.editors.templates">
+ <contextType
+ name="%All_XHTML_context_type_Extension_Element.name"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_all">
+ </contextType>
+ <contextType
+ name="%XHTML_New_context_type_Extension_Element.name"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_new">
+ </contextType>
+ <contextType
+ name="%XHTML_Tag_context_type_Extension_Element.name"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_tag">
+ </contextType>
+ <contextType
+ name="%XHTML_Attribute_context_type_Extension_Element.name"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_attribute">
+ </contextType>
+ <contextType
+ name="%XHTML_Attribute_value_context_type_Extension_Element.name"
+ class="org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_attribute_value">
+ </contextType>
+ <include
+ file="src/templates/xhtmldefault-templates.xml"
+ translations="src/templates/xhtmldefault-templates.properties">
+ </include>
+ </extension>
</plugin>
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2010-04-08
14:18:02 UTC (rev 21346)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -29,6 +29,17 @@
public static String REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE;
public static String EL_REFACTOR_RENAME_HANDLER_ERROR;
public static String RENAME_EL_VARIABLE_WIZARD_EL_VARIABLE_NAME;
+ public static String UI_WIZARD_XHTML_NEW_TITLE;
+ public static String UI_WIZARD_XHTML_NEW_Description;
+
+ public static String NewXHTMLTemplatesWizardPage_0;
+ public static String NewXHTMLTemplatesWizardPage_1;
+ public static String NewXHTMLTemplatesWizardPage_2;
+ public static String NewXHTMLTemplatesWizardPage_3;
+ public static String NewXHTMLTemplatesWizardPage_4;
+ public static String NewXHTMLTemplatesWizardPage_5;
+ public static String NewXHTMLTemplatesWizardPage_6;
+ public static String NewXHTMLTemplatesWizardPage_7;
static {
// initialize resource bundle
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUiPlugin.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUiPlugin.java 2010-04-08
14:18:02 UTC (rev 21346)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUiPlugin.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -10,16 +10,33 @@
******************************************************************************/
package org.jboss.tools.jsf.ui;
+import java.io.IOException;
+
+
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
+import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.jsf.ui.editor.check.ProjectNaturesChecker;
+import org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
import org.osgi.framework.BundleContext;
public class JsfUiPlugin extends BaseUIPlugin {
public static String PLUGIN_ID = "org.jboss.tools.jsf.ui"; //$NON-NLS-1$
+
+ /**
+ * The template store for the html editor.
+ */
+ private TemplateStore fTemplateStore;
+ /**
+ * The template context type registry for the html editor.
+ */
+ private ContextTypeRegistry fContextTypeRegistry;
public JsfUiPlugin() {
}
@@ -56,5 +73,37 @@
public void stop(BundleContext context) throws Exception {
super.stop(context);
}
+
+ public TemplateStore getTemplateStore() {
+ if (this.fTemplateStore == null) {
+ this.fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(),
getPreferenceStore(), "org.jboss.tools.jsf.ui.custom_templates");
+
+ try {
+ this.fTemplateStore.load();
+ } catch (IOException e) {
+ this.logError(e);
+ }
+ }
+ return this.fTemplateStore;
+ }
+ /**
+ * Returns the template context type registry for the html plugin.
+ *
+ * @return the template context type registry for the html plugin
+ */
+ public ContextTypeRegistry getTemplateContextRegistry() {
+ if (this.fContextTypeRegistry == null) {
+ ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry();
+ registry.addContextType(TemplateContextTypeIdsXHTML.ALL);
+ registry.addContextType(TemplateContextTypeIdsXHTML.NEW);
+ registry.addContextType(TemplateContextTypeIdsXHTML.TAG);
+ registry.addContextType(TemplateContextTypeIdsXHTML.ATTRIBUTE);
+ registry.addContextType(TemplateContextTypeIdsXHTML.ATTRIBUTE_VALUE);
+
+ this.fContextTypeRegistry = registry;
+ }
+
+ return this.fContextTypeRegistry;
+ }
}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.editor.pref.template;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class TemplateContextTypeIdsXHTML {
+ public static final String ALL = getAll();
+
+ public static final String ATTRIBUTE = getAttribute();
+
+ public static final String ATTRIBUTE_VALUE = getAttributeValue();
+
+ public static final String NEW = getNew();
+
+ public static final String TAG = getTag();
+
+ private static String getAll() {
+ return getPrefix() + "_all"; //$NON-NLS-1$
+ }
+
+ private static String getAttribute() {
+ return getPrefix() + "_attribute"; //$NON-NLS-1$
+ }
+
+ private static String getAttributeValue() {
+ return getPrefix() + "_attribute_value"; //$NON-NLS-1$
+ }
+
+ private static String getNew() {
+ return getPrefix() + "_new"; //$NON-NLS-1$
+ }
+
+ private static String getTag() {
+ return getPrefix() + "_tag"; //$NON-NLS-1$
+ }
+
+ private static String getPrefix() {
+ return "xhtml"; //$NON-NLS-1$
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeXHTML.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeXHTML.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeXHTML.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.editor.pref.template;
+
+import org.eclipse.wst.html.ui.internal.templates.TemplateContextTypeHTML;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class TemplateContextTypeXHTML extends TemplateContextTypeHTML {
+
+ public TemplateContextTypeXHTML() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/VPETemplatePreferencePage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/VPETemplatePreferencePage.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/VPETemplatePreferencePage.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.editor.pref.template;
+
+import org.eclipse.wst.html.ui.internal.preferences.ui.HTMLTemplatePreferencePage;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class VPETemplatePreferencePage extends HTMLTemplatePreferencePage {
+
+ public VPETemplatePreferencePage() {
+ JsfUiPlugin jsfUiPlugin = JsfUiPlugin.getDefault();
+ setPreferenceStore(jsfUiPlugin.getPreferenceStore());
+ setTemplateStore(jsfUiPlugin.getTemplateStore());
+ setContextTypeRegistry(jsfUiPlugin.getTemplateContextRegistry());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ boolean ok = super.performOk();
+ JsfUiPlugin.getDefault().savePluginPreferences();
+ return ok;
+ }
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2010-04-08
14:18:02 UTC (rev 21346)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2010-04-08
14:33:47 UTC (rev 21347)
@@ -20,4 +20,14 @@
REFACTOR_CONTRIBUTOR_MAIN_MENU=EL Refactor
REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE=Rename EL Variable
RENAME_EL_VARIABLE_WIZARD_EL_VARIABLE_NAME=Seam component name:
+UI_WIZARD_XHTML_NEW_TITLE=New XHTML Page
+UI_WIZARD_XHTML_NEW_Description=Create New XHTML Page
+NewXHTMLTemplatesWizardPage_0=Select XHTML Template
+NewXHTMLTemplatesWizardPage_1=Select a template as initial content in theX HTML page.
+NewXHTMLTemplatesWizardPage_2=Name
+NewXHTMLTemplatesWizardPage_3=Description
+NewXHTMLTemplatesWizardPage_4=&Use XHTML Template
+NewXHTMLTemplatesWizardPage_5=&Preview:
+NewXHTMLTemplatesWizardPage_6=Templates are 'New XHTML' templates found in the
<a>XHTML Templates</a> preference page.
+NewXHTMLTemplatesWizardPage_7=&Templates:
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.wizard.newfile;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.html.ui.internal.wizard.NewHTMLWizard;
+import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class NewXHTMLWizard extends NewHTMLWizard{
+
+ private static final String HTMLWizardNewFileCreationPage =
"HTMLWizardNewFileCreationPage"; //$NON-NLS-1$
+ private static final String NewHTMLTemplatesWizardPage =
"NewHTMLTemplatesWizardPage"; //$NON-NLS-1$
+
+ private WizardNewFileCreationPage fNewFilePage;
+ private NewXHTMLTemplatesWizardPage fNewFileTemplatesPage;
+
+
+
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ this.fNewFilePage = (WizardNewFileCreationPage)
getPage(NewXHTMLWizard.HTMLWizardNewFileCreationPage);
+ this.fNewFilePage.setTitle(JsfUIMessages.UI_WIZARD_XHTML_NEW_TITLE);
+ this.fNewFilePage.setDescription(JsfUIMessages.UI_WIZARD_XHTML_NEW_Description);
+
+ this.fNewFileTemplatesPage = new NewXHTMLTemplatesWizardPage();
+ addPage(this.fNewFileTemplatesPage);
+ }
+ @Override
+ public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
+ super.init(aWorkbench, aSelection);
+ setWindowTitle(JsfUIMessages.UI_WIZARD_XHTML_NEW_TITLE);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ @Override
+ public void addPage(IWizardPage page) {
+ if(!NewXHTMLWizard.NewHTMLTemplatesWizardPage.equalsIgnoreCase(page.getName())){
+ super.addPage(page);
+ }
+ }
+ @Override
+ public boolean performFinish() {
+ boolean performedOK = false;
+ // save user options for next use
+ fNewFileTemplatesPage.saveLastSavedPreferences();
+
+ // no file extension specified so add default extension
+ String fileName = fNewFilePage.getFileName();
+ if (fileName.lastIndexOf('.') == -1) {
+ String newFileName = fileName+".xthml"; //$NON-NLS-1$
+ fNewFilePage.setFileName(newFileName);
+ }
+
+ // create a new empty file
+ IFile file = fNewFilePage.createNewFile();
+
+ // if there was problem with creating file, it will be null, so make
+ // sure to check
+ if (file != null) {
+ // put template contents into file
+ String templateString = fNewFileTemplatesPage.getTemplateString();
+ if (templateString != null) {
+ templateString = applyLineDelimiter(file, templateString);
+ // determine the encoding for the new file
+ Preferences preference = JsfUiPlugin.getDefault().getPluginPreferences();
+ String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
+
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ OutputStreamWriter outputStreamWriter = null;
+ if (charSet == null || charSet.trim().equals("")) { //$NON-NLS-1$
+ // just use default encoding
+ outputStreamWriter = new OutputStreamWriter(outputStream);
+ }
+ else {
+ outputStreamWriter = new OutputStreamWriter(outputStream, charSet);
+ }
+ outputStreamWriter.write(templateString);
+ outputStreamWriter.flush();
+ outputStreamWriter.close();
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());
+ file.setContents(inputStream, true, false, null);
+ inputStream.close();
+ }
+ catch (Exception e) {
+ JsfUiPlugin.getDefault().logWarning("Could not create contents for new HTML
file", e); //$NON-NLS-1$
+ }
+ }
+
+ // open the file in editor
+ openEditor(file);
+
+ // everything's fine
+ performedOK = true;
+ }
+ return performedOK;
+ }
+ private String applyLineDelimiter(IFile file, String text) {
+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new
IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope()
});//$NON-NLS-1$
+ String convertedText = StringUtils.replace(text, "\r\n", "\n");
//$NON-NLS-1$ //$NON-NLS-2$
+ convertedText = StringUtils.replace(convertedText, "\r", "\n");
//$NON-NLS-1$//$NON-NLS-2$
+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter);
//$NON-NLS-1$
+ return convertedText;
+ }
+ private void openEditor(final IFile file) {
+ if (file != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IDE.openEditor(page, file, true);
+ }
+ catch (PartInitException e) {
+ JsfUiPlugin.getDefault().logError(e.getMessage(), e);
+ }
+ }
+ });
+ }
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.properties
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.properties 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,19 @@
+Templates.xhtml.blank = Blank XHTML Page
+Templates.xhtml.blank.desc = XHTML Blank Page Template
+Templates.xhtml.blank.content =
+
+Templates.xhtml.blank.facelet = Blank Facelet Page
+Templates.xhtml.blank.facelet.desc = XHTML Blank Facelet Page Template
+Templates.xhtml.facelet.blank.content =<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html
xmlns="http://www.w3.org/1999/xhtml"\n
xmlns:ui="http://java.sun.com/jsf/facelets"\n
xmlns:f="http://java.sun.com/jsf/core"\n
xmlns:h="http://java.sun.com/jsf/html">\n\n <ui:composition
template="">\n </ui:composition>\n</html>
+
+Templates.xhtml.facelet.common = Common Facelet Page
+Templates.xhtml.facelet.common.desc = Common Facelet Page Template
+Templates.xhtml.facelet.commont.content = <!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html
xmlns="http://www.w3.org/1999/xhtml"\n
xmlns:ui="http://java.sun.com/jsf/facelets"\n
xmlns:h="http://java.sun.com/jsf/html"\n
xmlns:f="http://java.sun.com/jsf/core">\n \n <f:loadBundle
basename="resources" var="msg"
/>\n <head>\n <title><ui:insert name="pageTitle">Page
Title</ui:insert></title>\n <style type="text/css">\n body
{\n font-family: Verdana, Arial, Helvetica, sans-serif;\n font-size:
14px;\n }\n .header {\n font-family: Verdana, Arial, Helvetica, sans-serif;\n
font-size: 18px;\n }\n .bottom {\n font-family: Verdana, Arial, Helvetica,
sans-serif;\n font-size: 9px;\n text-align: center;\n vertical-align:
middle;\n color: #8E969D;\n }\n </style>\n </head>\n\n<body
bgcolor="#ffffff">\n<table style="border:1px solid!
#CAD6E0" align="center" cellpadding="0"
cellspacing="0" border="0"
width="400">\n<tbody>\n\n <tr>\n <td class="header"
height="42" align="center" valign="middle"
width="100%" bgcolor="#E4EBEB">\n <ui:insert
name="pageHeader">Page
Header</ui:insert>\n </td>\n </tr>\n <tr>\n <td
height="1" width="100%"
bgcolor="#CAD6E0"></td>\n </tr> \n\n <tr>\n <td
width="100%" colspan="2">\n <table width="100%"
style="height:150px" align="left" cellpadding="0"
cellspacing="0"
border="0">\n <tbody>\n <tr>\n <td
align="center" width="100%"
valign="middle">\n \n <ui:insert name="body">Page
Body</ui:insert>\n \n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr> \n \n <tr>\n <td
colspan="2" valign="bottom" height="1"
width="100%"
bgcolor="#CAD6E0"></td>\n </tr>\n</tbody>\n</table>\n</body>\n \n</html>
+
+Templates.xhtml.facelet.form = Form Facelet Page
+Templates.xhtml.facelet.form.desc = Form Facelet Page Template
+Templates.xhtml.facelet.form.content = <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html
xmlns="http://www.w3.org/1999/xhtml"\n
xmlns:ui="http://java.sun.com/jsf/facelets"\n
xmlns:f="http://java.sun.com/jsf/core"\n
xmlns:h="http://java.sun.com/jsf/html">\n\n <!-- \n Replace path to
template, title, header and body\n with actual data.\n -->\n <ui:composition
template="/templates/common.xhtml">\n <ui:define
name="pageTitle">Title</ui:define>\n <ui:define
name="pageHeader">Header</ui:define>\n <ui:define
name="body">\n <form jsfc="h:form"
id="Form">\n \n </form>\n </ui:define>\n </ui:composition>\n\n</html>
+
+Templates.xhtml.jsf2.composite.component = JSF Composite Component
+Templates.xhtml.jsf2.composite.component.desc = New JSF Composite Component Template
+Templates.xhtml.jsf2.composite.component.content = <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0
Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-tran...
xmlns="http://www.w3.org/1999/xhtml"\nxmlns:h="http://java...
present in rendered
output</title>\n</head>\n<body>\n<composite:interface>\n\n</composite:interface>\n<composite:implementation>\n\n</composite:implementation>\n</body>\n</html>
Added: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.xml
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/xhtmldefault-templates.xml 2010-04-08
14:33:47 UTC (rev 21347)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates>
+<template name="%Templates.xhtml.blank"
description="%Templates.xhtml.blank.desc"
id="org.jboss.tools.jsf.ui.xhtml.blank" context="xhtml_new"
enabled="true">%Templates.xhtml.blank.content</template>
+
+<template name="%Templates.xhtml.blank.facelet"
description="%Templates.xhtml.blank.facelet.desc"
id="org.jboss.tools.jsf.ui.xhtml.facelet.blank" context="xhtml_new"
enabled="true">%Templates.xhtml.facelet.blank.content</template>
+
+<template name="%Templates.xhtml.facelet.common"
description="%Templates.xhtml.facelet.common.desc"
id="org.jboss.tools.jsf.ui.xhtml.facelet.common" context="xhtml_new"
enabled="true">%Templates.xhtml.facelet.commont.content</template>
+
+<template name="%Templates.xhtml.facelet.form"
description="%Templates.xhtml.facelet.form.desc"
id="org.jboss.tools.jsf.ui.xhtml.facelet.form" context="xhtml_new"
enabled="true">%Templates.xhtml.facelet.form.content</template>
+
+<template name="%Templates.xhtml.jsf2.composite.component"
description="%Templates.xhtml.jsf2.composite.component.desc"
id="org.jboss.tools.jsf.ui.xhtml.jsf2.composite.component"
context="xhtml_new"
enabled="true">%Templates.xhtml.jsf2.composite.component.content</template>
+
+</templates>
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2010-04-08
14:18:02 UTC (rev 21346)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -15,10 +15,7 @@
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.common.model.XModelObject;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java 2010-04-08
14:18:02 UTC (rev 21346)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java 2010-04-08
14:33:47 UTC (rev 21347)
@@ -14,9 +14,7 @@
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;