Author: mareshkau
Date: 2010-04-30 13:20:33 -0400 (Fri, 30 Apr 2010)
New Revision: 21840
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jsf/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jsf/ui/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jsf/ui/editor/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeXHTML.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/VPETemplatePreferencePage.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLTemplatesWizardPage.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizardSelectTagLibrariesPage.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/templates/
Removed:
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/editor/pref/template/contentassist/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLTemplatesWizardPage.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/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizardSelectTagLibrariesPage.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates/
Modified:
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/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/WebUiPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6217,
https://jira.jboss.org/jira/browse/JBIDE-6190 wizard has been moved to
org.jboss.tools.jst.web.ui plugin.
JUnit testMethod not call inint method in wizard, so test not fixed yet. I am working
under it.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-30 17:16:33 UTC (rev
21839)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-30 17:20:33 UTC (rev
21840)
@@ -136,10 +136,10 @@
</wizard>
<wizard
category="org.jboss.tools.jst.web"
- class="org.jboss.tools.jsf.ui.wizard.newfile.NewXHTMLWizard"
+ class="org.jboss.tools.jst.web.ui.wizards.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"
+ id="org.jboss.tools.jst.web.ui.wizards.newfile.NewXHTMLWizard"
name="%NewXHTMLPage"
project="false">
<description>
@@ -479,48 +479,5 @@
</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>
- <extension point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension
targetID="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective">
- <newWizardShortcut
id="org.jboss.tools.jsf.ui.wizard.newfile.NewXHTMLWizard">
- </newWizardShortcut>
- </perspectiveExtension>
- </extension>
- <extension
- point="org.jboss.tools.jst.jsp.editorContentAssistent">
- <contentassisten
class="org.jboss.tools.jsf.ui.editor.pref.template.contentassist.XHTMLContentAssistProcessor"/>
- </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-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -29,18 +29,7 @@
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
NLS.initializeMessages(BUNDLE_NAME, JsfUIMessages.class);
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-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUiPlugin.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -10,34 +10,17 @@
******************************************************************************/
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() {
}
@@ -74,36 +57,4 @@
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
Deleted:
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 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * 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$
- }
-}
Deleted:
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 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/TemplateContextTypeXHTML.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * 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
- }
-
-}
Deleted:
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 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/VPETemplatePreferencePage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * 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;
- }
-
-}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLTemplatesWizardPage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLTemplatesWizardPage.java 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLTemplatesWizardPage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,512 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.text.templates.DocumentTemplateContext;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateBuffer;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
-import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.jboss.tools.jsf.ui.JsfUIMessages;
-import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
-
-/**
- * Copied from NewHTMLTemplatesWizardPage, because the class is internal and not provide
possibility
- * to inherit from this
- *
- *
- * @author mareshkau
- *
- */
-public class NewXHTMLTemplatesWizardPage extends WizardPage {
- /**
- * Content provider for templates
- */
- private class TemplateContentProvider implements IStructuredContentProvider {
- /** The template store. */
- private TemplateStore fStore;
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- this.fStore = null;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object input) {
- return this.fStore.getTemplates(TemplateContextTypeIdsXHTML.NEW);
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.fStore = (TemplateStore) newInput;
- }
- }
-
- /**
- * Label provider for templates.
- */
- private class TemplateLabelProvider extends LabelProvider implements ITableLabelProvider
{
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
- * int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
- * int)
- */
- public String getColumnText(Object element, int columnIndex) {
- Template template = (Template) element;
-
- switch (columnIndex) {
- case 0 :
- return template.getName();
- case 1 :
- return template.getDescription();
- default :
- return ""; //$NON-NLS-1$
- }
- }
- }
-
- /** Last selected template name */
- private String fLastSelectedTemplateName;
- /** The viewer displays the pattern of selected template. */
- private SourceViewer fPatternViewer;
- /** The table presenting the templates. */
- private TableViewer fTableViewer;
- /** Template store used by this wizard page */
- private TemplateStore fTemplateStore;
- /** Checkbox for using templates. */
- private Button fUseTemplateButton;
-
- public NewXHTMLTemplatesWizardPage() {
- super("NewXHTMLTemplatesWizardPage",
JsfUIMessages.NewXHTMLTemplatesWizardPage_0, null); //$NON-NLS-1$
- setDescription(JsfUIMessages.NewXHTMLTemplatesWizardPage_0);
- }
-
- /**
- * Correctly resizes the table so no phantom columns appear
- *
- * @param parent
- * the parent control
- * @param buttons
- * the buttons
- * @param table
- * the table
- * @param column1
- * the first column
- * @param column2
- * the second column
- * @param column3
- * the third column
- */
- private void configureTableResizing(final Composite parent, final Table table, final
TableColumn column1, final TableColumn column2) {
- parent.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Rectangle area = parent.getClientArea();
- Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int width = area.width - 2 * table.getBorderWidth();
- if (preferredSize.y > area.height) {
- // Subtract the scrollbar width from the total column
- // width
- // if a vertical scrollbar will be required
- Point vBarSize = table.getVerticalBar().getSize();
- width -= vBarSize.x;
- }
-
- Point oldSize = table.getSize();
- if (oldSize.x > width) {
- // table is getting smaller so make the columns
- // smaller first and then resize the table to
- // match the client area width
- column1.setWidth(width / 2);
- column2.setWidth(width / 2);
- table.setSize(width, area.height);
- }
- else {
- // table is getting bigger so make the table
- // bigger first and then make the columns wider
- // to match the client area width
- table.setSize(width, area.height);
- column1.setWidth(width / 2);
- column2.setWidth(width / 2);
- }
- }
- });
- }
-
- public void createControl(Composite ancestor) {
- Composite parent = new Composite(ancestor, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- parent.setLayout(layout);
-
- // create checkbox for user to use HTML Template
- fUseTemplateButton = new Button(parent, SWT.CHECK);
- fUseTemplateButton.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_4);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
- fUseTemplateButton.setLayoutData(data);
- fUseTemplateButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- enableTemplates();
- }
- });
-
- // create composite for Templates table
- Composite innerParent = new Composite(parent, SWT.NONE);
- GridLayout innerLayout = new GridLayout();
- innerLayout.numColumns = 2;
- innerLayout.marginHeight = 0;
- innerLayout.marginWidth = 0;
- innerParent.setLayout(innerLayout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
- innerParent.setLayoutData(gd);
-
- Label label = new Label(innerParent, SWT.NONE);
- label.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_7);
- data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
- label.setLayoutData(data);
-
- // create table that displays templates
- Table table = new Table(innerParent, SWT.BORDER | SWT.FULL_SELECTION);
-
- data = new GridData(GridData.FILL_BOTH);
- data.widthHint = convertWidthInCharsToPixels(2);
- data.heightHint = convertHeightInCharsToPixels(10);
- data.horizontalSpan = 2;
- table.setLayoutData(data);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- TableLayout tableLayout = new TableLayout();
- table.setLayout(tableLayout);
-
- TableColumn column1 = new TableColumn(table, SWT.NONE);
- column1.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_2);
-
- TableColumn column2 = new TableColumn(table, SWT.NONE);
- column2.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_3);
-
- fTableViewer = new TableViewer(table);
- fTableViewer.setLabelProvider(new TemplateLabelProvider());
- fTableViewer.setContentProvider(new TemplateContentProvider());
-
- fTableViewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object object1, Object object2) {
- if ((object1 instanceof Template) && (object2 instanceof Template)) {
- Template left = (Template) object1;
- Template right = (Template) object2;
- int result = left.getName().compareToIgnoreCase(right.getName());
- if (result != 0)
- return result;
- return left.getDescription().compareToIgnoreCase(right.getDescription());
- }
- return super.compare(viewer, object1, object2);
- }
-
- public boolean isSorterProperty(Object element, String property) {
- return true;
- }
- });
-
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent e) {
- updateViewerInput();
- }
- });
-
- // create viewer that displays currently selected template's contents
- fPatternViewer = doCreateViewer(parent);
-
- fTemplateStore = JsfUiPlugin.getDefault().getTemplateStore();
- fTableViewer.setInput(fTemplateStore);
-
- // Create linked text to just to templates preference page
- Link link = new Link(parent, SWT.NONE);
- link.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_6);
- data = new GridData(SWT.END, SWT.FILL, true, false, 2, 1);
- link.setLayoutData(data);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- linkClicked();
- }
- });
-
- configureTableResizing(innerParent, table, column1, column2);
- loadLastSavedPreferences();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
IHelpContextIds.HTML_NEWWIZARD_TEMPLATE_HELPID);
- Dialog.applyDialogFont(parent);
- setControl(parent);
- }
-
- /**
- * Creates, configures and returns a source viewer to present the template
- * pattern on the preference page. Clients may override to provide a
- * custom source viewer featuring e.g. syntax coloring.
- *
- * @param parent
- * the parent control
- * @return a configured source viewer
- */
- private SourceViewer createViewer(Composite parent) {
- SourceViewerConfiguration sourceViewerConfiguration = new
StructuredTextViewerConfiguration() {
- StructuredTextViewerConfiguration baseConfiguration = new
StructuredTextViewerConfigurationHTML();
-
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return baseConfiguration.getConfiguredContentTypes(sourceViewer);
- }
-
- public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String
partitionType) {
- return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
- }
- };
- SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER |
SWT.V_SCROLL | SWT.H_SCROLL);
- ((StructuredTextViewer)
viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
//$NON-NLS-1$
- IStructuredModel scratchModel =
StructuredModelManager.getModelManager().createUnManagedStructuredModelFor("org.eclipse.wst.html.core.htmlsource");
- IDocument document = scratchModel.getStructuredDocument();
- viewer.configure(sourceViewerConfiguration);
- viewer.setDocument(document);
- return viewer;
- }
-
- private SourceViewer doCreateViewer(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(JsfUIMessages.NewXHTMLTemplatesWizardPage_5);
- GridData data = new GridData();
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- SourceViewer viewer = createViewer(parent);
- viewer.setEditable(false);
-
- Control control = viewer.getControl();
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 2;
- data.heightHint = convertHeightInCharsToPixels(5);
- // [261274] - source viewer was growing to fit the max line width of the template
- data.widthHint = convertWidthInCharsToPixels(2);
- control.setLayoutData(data);
-
- return viewer;
- }
-
- /**
- * Enable/disable controls in page based on fUseTemplateButton's current
- * state.
- */
- void enableTemplates() {
- boolean enabled = fUseTemplateButton.getSelection();
-
- if (!enabled) {
- // save last selected template
- Template template = getSelectedTemplate();
- if (template != null)
- fLastSelectedTemplateName = template.getName();
- else
- fLastSelectedTemplateName = ""; //$NON-NLS-1$
-
- fTableViewer.setSelection(null);
- }
- else {
- setSelectedTemplate(fLastSelectedTemplateName);
- }
-
- fTableViewer.getControl().setEnabled(enabled);
- fPatternViewer.getControl().setEnabled(enabled);
- }
-
- /**
- * Return the template preference page id
- *
- * @return
- */
- private String getPreferencePageId() {
- return "org.jboss.tools.jsf.ui.editor.pref.template"; //$NON-NLS-1$
- }
-
- /**
- * Get the currently selected template.
- *
- * @return
- */
- private Template getSelectedTemplate() {
- Template template = null;
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
-
- if (selection.size() == 1) {
- template = (Template) selection.getFirstElement();
- }
- return template;
- }
-
- /**
- * Returns template string to insert.
- *
- * @return String to insert or null if none is to be inserted
- */
- String getTemplateString() {
- String templateString = null;
-
- Template template = getSelectedTemplate();
- if (template != null) {
- TemplateContextType contextType =
JsfUiPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsXHTML.NEW);
- IDocument document = new Document();
- TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
- try {
- TemplateBuffer buffer = context.evaluate(template);
- templateString = buffer.getString();
- }
- catch (Exception e) {
- JsfUiPlugin.getDefault().logWarning("Could not create template for new
html", e); //$NON-NLS-1$
- }
- }
-
- return templateString;
- }
-
- void linkClicked() {
- String pageId = getPreferencePageId();
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), pageId,
new String[]{pageId}, null);
- dialog.open();
- fTableViewer.refresh();
- }
-
- /**
- * Load the last template name used in New HTML File wizard.
- */
- private void loadLastSavedPreferences() {
- String templateName =
JsfUiPlugin.getDefault().getPreferenceStore().getString(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME);
- if (templateName == null || templateName.length() == 0) {
- fLastSelectedTemplateName = ""; //$NON-NLS-1$
- fUseTemplateButton.setSelection(false);
- }
- else {
- fLastSelectedTemplateName = templateName;
- fUseTemplateButton.setSelection(true);
- }
- enableTemplates();
- }
-
- /**
- * Save template name used for next call to New HTML File wizard.
- */
- void saveLastSavedPreferences() {
- String templateName = ""; //$NON-NLS-1$
-
- Template template = getSelectedTemplate();
- if (template != null) {
- templateName = template.getName();
- }
-
- JsfUiPlugin.getDefault().getPreferenceStore().setValue(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME,
templateName);
- JsfUiPlugin.getDefault().savePluginPreferences();
- }
-
- /**
- * Select a template in the table viewer given the template name. If
- * template name cannot be found or templateName is null, just select
- * first item in table. If no items in table select nothing.
- *
- * @param templateName
- */
- private void setSelectedTemplate(String templateName) {
- Object template = null;
-
- if (templateName != null && templateName.length() > 0) {
- // pick the last used template
- template = fTemplateStore.findTemplate(templateName,
TemplateContextTypeIdsXHTML.NEW);
- }
-
- // no record of last used template so just pick first element
- if (template == null) {
- // just pick first element
- template = fTableViewer.getElementAt(0);
- }
-
- if (template != null) {
- IStructuredSelection selection = new StructuredSelection(template);
- fTableViewer.setSelection(selection, true);
- }
- }
-
- /**
- * Updates the pattern viewer.
- */
- void updateViewerInput() {
- Template template = getSelectedTemplate();
- if (template != null) {
- fPatternViewer.getDocument().set(template.getPattern());
- }
- else {
- fPatternViewer.getDocument().set(""); //$NON-NLS-1$
- }
- }
-}
Deleted:
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 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * 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.IOException;
-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.swt.widgets.Composite;
-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.common.meta.action.XEntityData;
-import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
-import org.jboss.tools.common.model.XModelException;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.wizard.newfile.NewXHTMLFileWizard;
-import org.jboss.tools.common.model.ui.wizards.standard.DefaultStandardStep;
-import org.jboss.tools.jsf.ui.JsfUIMessages;
-import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jst.web.model.handlers.CreateJSPFileSupport;
-
-/**
- * @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;
- private NewXHTMLFileWizard newXHTMLFileWizard;
- private NewXHTMLWizardSelectTagLibrariesPage newXHTMLWizardSelectTagLibrariesPage;
-
-
-
- @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);
- this.newXHTMLWizardSelectTagLibrariesPage = getURISelectionPage();
- addPage(this.newXHTMLWizardSelectTagLibrariesPage);
- }
- @Override
- public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
- super.init(aWorkbench, aSelection);
- setWindowTitle(JsfUIMessages.UI_WIZARD_XHTML_NEW_TITLE);
- setNewXHTMLFileWizard(new NewXHTMLFileWizard());
- getNewXHTMLFileWizard().init(aWorkbench, aSelection);
- }
- /* (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);
- }
- }
- private NewXHTMLWizardSelectTagLibrariesPage getURISelectionPage() {
- SpecialWizardSupport support = getNewXHTMLFileWizard().getFileContext().getSupport();
- NewXHTMLWizardSelectTagLibrariesPage step = new
NewXHTMLWizardSelectTagLibrariesPage(support, 1);
- try {
- support.action(SpecialWizardSupport.NEXT);
- } catch (XModelException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- }
- step.setWizard(this);
- return step;
- }
- @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+".xhtml"; //$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();
- try {
- templateString=((CreateJSPFileSupport)getNewXHTMLFileWizard().getFileContext().getSupport()).addTaglibs(templateString);
- } catch (IOException ex) {
- JsfUiPlugin.getDefault().logWarning("Problems with adding taglibs",ex);
//$NON-NLS-1$
- }
- 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);
- }
- }
- });
- }
- }
- /**
- * @return the newXHTMLFileWizard
- */
- private NewXHTMLFileWizard getNewXHTMLFileWizard() {
- return newXHTMLFileWizard;
- }
- /**
- * @param newXHTMLFileWizard the newXHTMLFileWizard to set
- */
- private void setNewXHTMLFileWizard(NewXHTMLFileWizard newXHTMLFileWizard) {
- this.newXHTMLFileWizard = newXHTMLFileWizard;
- }
-
-
-}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizardSelectTagLibrariesPage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizardSelectTagLibrariesPage.java 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizardSelectTagLibrariesPage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.jface.wizard.IWizard;
-import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
-import org.jboss.tools.common.model.ui.wizards.standard.DefaultStandardStep;
-
-/**
- * @author mareshkau
- *
- */
-public class NewXHTMLWizardSelectTagLibrariesPage extends DefaultStandardStep {
-
- public NewXHTMLWizardSelectTagLibrariesPage(SpecialWizardSupport support,
- int id) {
- super(support, id);
- }
- @Override
- public void setWizard(IWizard wizard) {
- super.setWizard(wizard);
-// this.wizard = (DefaultStandardWizard)wizard;
- }
- @Override
- public void validate() {
- setPageComplete(true);
- }
-}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2010-04-30 17:16:33
UTC (rev 21839)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2010-04-30 17:20:33
UTC (rev 21840)
@@ -40,7 +40,9 @@
org.jboss.tools.jst.jsp;bundle-version="2.0.0",
org.eclipse.jface.text;bundle-version="3.5.0",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300",
- org.apache.velocity;bundle-version="1.5.0"
+ org.apache.velocity;bundle-version="1.5.0",
+ org.eclipse.ui.workbench.texteditor;bundle-version="3.5.1",
+ org.eclipse.wst.html.ui;bundle-version="1.0.401"
Bundle-Version: 3.1.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-04-30 17:16:33 UTC (rev
21839)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-04-30 17:20:33 UTC (rev
21840)
@@ -691,5 +691,47 @@
class="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator">
</markerResolutionGenerator>
</extension>
-
+ <!-- Templates -->
+ <extension point="org.eclipse.ui.editors.templates">
+ <contextType
+ name="%All_XHTML_context_type_Extension_Element.name"
+ class="org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_all">
+ </contextType>
+ <contextType
+ name="%XHTML_New_context_type_Extension_Element.name"
+ class="org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_new">
+ </contextType>
+ <contextType
+ name="%XHTML_Tag_context_type_Extension_Element.name"
+ class="org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_tag">
+ </contextType>
+ <contextType
+ name="%XHTML_Attribute_context_type_Extension_Element.name"
+ class="org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeXHTML"
+ id="xhtml_attribute">
+ </contextType>
+ <contextType
+ name="%XHTML_Attribute_value_context_type_Extension_Element.name"
+ class="org.jboss.tools.jst.web.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>
+
+ <extension point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
targetID="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective">
+ <newWizardShortcut
id="org.jboss.tools.jst.web.ui.wizards.newfile.NewXHTMLWizard">
+ </newWizardShortcut>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.jboss.tools.jst.jsp.editorContentAssistent">
+ <contentassisten
class="org.jboss.tools.jst.web.ui.editor.pref.template.contentassist.XHTMLContentAssistProcessor"/>
+ </extension>
</plugin>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -72,7 +72,19 @@
public static String WebCompoundEditor_WebXMLEditor;
public static String XActionProvider_CompanyName;
public static String AddTLDMarkerResolution_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
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/WebUiPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/WebUiPlugin.java 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/WebUiPlugin.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -10,15 +10,30 @@
******************************************************************************/
package org.jboss.tools.jst.web.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.jst.web.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
import org.osgi.framework.BundleContext;
public class WebUiPlugin extends BaseUIPlugin {
public static final String PLUGIN_ID = "org.jboss.tools.jst.web.ui";
//$NON-NLS-1$
static WebUiPlugin INSTANCE;
+ /**
+ * The template store for the html editor.
+ */
+ private TemplateStore fTemplateStore;
+ /**
+ * The template context type registry for the html editor.
+ */
+ private ContextTypeRegistry fContextTypeRegistry;
public WebUiPlugin() {
INSTANCE = this;
@@ -49,4 +64,36 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+ 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/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeIdsXHTML.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -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.jst.web.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/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeXHTML.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeXHTML.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/TemplateContextTypeXHTML.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -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.jst.web.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/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/VPETemplatePreferencePage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/VPETemplatePreferencePage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/VPETemplatePreferencePage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -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.jst.web.ui.editor.pref.template;
+
+import org.eclipse.wst.html.ui.internal.preferences.ui.HTMLTemplatePreferencePage;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class VPETemplatePreferencePage extends HTMLTemplatePreferencePage {
+
+ public VPETemplatePreferencePage() {
+ WebUiPlugin webUiPlugin = WebUiPlugin.getDefault();
+ setPreferenceStore(webUiPlugin.getPreferenceStore());
+ setTemplateStore(webUiPlugin.getTemplateStore());
+ setContextTypeRegistry(webUiPlugin.getTemplateContextRegistry());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ boolean ok = super.performOk();
+ WebUiPlugin.getDefault().savePluginPreferences();
+ return ok;
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist
(from rev 21828,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist)
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java 2010-04-30
14:14:04 UTC (rev 21828)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -8,7 +8,7 @@
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jsf.ui.editor.pref.template.contentassist;
+package org.jboss.tools.jst.web.ui.editor.pref.template.contentassist;
import java.util.ArrayList;
import java.util.List;
@@ -24,8 +24,8 @@
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+import org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
import org.w3c.dom.Node;
/**
@@ -186,7 +186,7 @@
protected IPreferenceStore getPreferenceStore() {
if (this.fPreferenceStore == null)
- this.fPreferenceStore = JsfUiPlugin.getDefault().getPreferenceStore();
+ this.fPreferenceStore = WebUiPlugin.getDefault().getPreferenceStore();
return this.fPreferenceStore;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java 2010-04-30
14:14:04 UTC (rev 21828)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -8,7 +8,7 @@
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jsf.ui.editor.pref.template.contentassist;
+package org.jboss.tools.jst.web.ui.editor.pref.template.contentassist;
import java.util.ArrayList;
import java.util.Collections;
@@ -31,7 +31,7 @@
import org.eclipse.jface.text.templates.persistence.TemplateStore;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.html.ui.internal.contentassist.ReplaceNameTemplateContext;
-import org.jboss.tools.jsf.ui.JsfUiPlugin;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
/**
@@ -142,7 +142,7 @@
// }
private ContextTypeRegistry getTemplateContextRegistry() {
- return JsfUiPlugin.getDefault().getTemplateContextRegistry();
+ return WebUiPlugin.getDefault().getTemplateContextRegistry();
}
protected Template[] getTemplates(String contextTypeId) {
@@ -156,7 +156,7 @@
}
private TemplateStore getTemplateStore() {
- return JsfUiPlugin.getDefault().getTemplateStore();
+ return WebUiPlugin.getDefault().getTemplateStore();
}
void setContextType(String contextTypeId) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2010-04-30
17:20:33 UTC (rev 21840)
@@ -66,3 +66,14 @@
WebCompoundEditor_WebXMLEditor=Web XML Editor
XActionProvider_CompanyName=Red Hat
AddTLDMarkerResolution_Name=Insert ''{0}'' tag library definition
+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:
+
+UI_WIZARD_XHTML_NEW_TITLE=New XHTML Page
+UI_WIZARD_XHTML_NEW_Description=Create New XHTML Page
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLTemplatesWizardPage.java
(from rev 21828,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLTemplatesWizardPage.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLTemplatesWizardPage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLTemplatesWizardPage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -0,0 +1,512 @@
+/*******************************************************************************
+ * 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.jst.web.ui.wizards.newfile;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
+import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
+import org.jboss.tools.jst.web.ui.Messages;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+import org.jboss.tools.jst.web.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
+
+/**
+ * Copied from NewHTMLTemplatesWizardPage, because the class is internal and not provide
possibility
+ * to inherit from this
+ *
+ *
+ * @author mareshkau
+ *
+ */
+public class NewXHTMLTemplatesWizardPage extends WizardPage {
+ /**
+ * Content provider for templates
+ */
+ private class TemplateContentProvider implements IStructuredContentProvider {
+ /** The template store. */
+ private TemplateStore fStore;
+
+ /*
+ * @see IContentProvider#dispose()
+ */
+ public void dispose() {
+ this.fStore = null;
+ }
+
+ /*
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object input) {
+ return this.fStore.getTemplates(TemplateContextTypeIdsXHTML.NEW);
+ }
+
+ /*
+ * @see IContentProvider#inputChanged(Viewer, Object, Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.fStore = (TemplateStore) newInput;
+ }
+ }
+
+ /**
+ * Label provider for templates.
+ */
+ private class TemplateLabelProvider extends LabelProvider implements ITableLabelProvider
{
+
+ /*
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
+ * int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
+ * int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ Template template = (Template) element;
+
+ switch (columnIndex) {
+ case 0 :
+ return template.getName();
+ case 1 :
+ return template.getDescription();
+ default :
+ return ""; //$NON-NLS-1$
+ }
+ }
+ }
+
+ /** Last selected template name */
+ private String fLastSelectedTemplateName;
+ /** The viewer displays the pattern of selected template. */
+ private SourceViewer fPatternViewer;
+ /** The table presenting the templates. */
+ private TableViewer fTableViewer;
+ /** Template store used by this wizard page */
+ private TemplateStore fTemplateStore;
+ /** Checkbox for using templates. */
+ private Button fUseTemplateButton;
+
+ public NewXHTMLTemplatesWizardPage() {
+ super("NewXHTMLTemplatesWizardPage", Messages.NewXHTMLTemplatesWizardPage_0,
null); //$NON-NLS-1$
+ setDescription(Messages.NewXHTMLTemplatesWizardPage_0);
+ }
+
+ /**
+ * Correctly resizes the table so no phantom columns appear
+ *
+ * @param parent
+ * the parent control
+ * @param buttons
+ * the buttons
+ * @param table
+ * the table
+ * @param column1
+ * the first column
+ * @param column2
+ * the second column
+ * @param column3
+ * the third column
+ */
+ private void configureTableResizing(final Composite parent, final Table table, final
TableColumn column1, final TableColumn column2) {
+ parent.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ Rectangle area = parent.getClientArea();
+ Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int width = area.width - 2 * table.getBorderWidth();
+ if (preferredSize.y > area.height) {
+ // Subtract the scrollbar width from the total column
+ // width
+ // if a vertical scrollbar will be required
+ Point vBarSize = table.getVerticalBar().getSize();
+ width -= vBarSize.x;
+ }
+
+ Point oldSize = table.getSize();
+ if (oldSize.x > width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ column1.setWidth(width / 2);
+ column2.setWidth(width / 2);
+ table.setSize(width, area.height);
+ }
+ else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ table.setSize(width, area.height);
+ column1.setWidth(width / 2);
+ column2.setWidth(width / 2);
+ }
+ }
+ });
+ }
+
+ public void createControl(Composite ancestor) {
+ Composite parent = new Composite(ancestor, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ parent.setLayout(layout);
+
+ // create checkbox for user to use HTML Template
+ fUseTemplateButton = new Button(parent, SWT.CHECK);
+ fUseTemplateButton.setText(Messages.NewXHTMLTemplatesWizardPage_4);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ fUseTemplateButton.setLayoutData(data);
+ fUseTemplateButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ enableTemplates();
+ }
+ });
+
+ // create composite for Templates table
+ Composite innerParent = new Composite(parent, SWT.NONE);
+ GridLayout innerLayout = new GridLayout();
+ innerLayout.numColumns = 2;
+ innerLayout.marginHeight = 0;
+ innerLayout.marginWidth = 0;
+ innerParent.setLayout(innerLayout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
+ innerParent.setLayoutData(gd);
+
+ Label label = new Label(innerParent, SWT.NONE);
+ label.setText(Messages.NewXHTMLTemplatesWizardPage_7);
+ data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ label.setLayoutData(data);
+
+ // create table that displays templates
+ Table table = new Table(innerParent, SWT.BORDER | SWT.FULL_SELECTION);
+
+ data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = convertWidthInCharsToPixels(2);
+ data.heightHint = convertHeightInCharsToPixels(10);
+ data.horizontalSpan = 2;
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ column1.setText(Messages.NewXHTMLTemplatesWizardPage_2);
+
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ column2.setText(Messages.NewXHTMLTemplatesWizardPage_3);
+
+ fTableViewer = new TableViewer(table);
+ fTableViewer.setLabelProvider(new TemplateLabelProvider());
+ fTableViewer.setContentProvider(new TemplateContentProvider());
+
+ fTableViewer.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer, Object object1, Object object2) {
+ if ((object1 instanceof Template) && (object2 instanceof Template)) {
+ Template left = (Template) object1;
+ Template right = (Template) object2;
+ int result = left.getName().compareToIgnoreCase(right.getName());
+ if (result != 0)
+ return result;
+ return left.getDescription().compareToIgnoreCase(right.getDescription());
+ }
+ return super.compare(viewer, object1, object2);
+ }
+
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+ });
+
+ fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ updateViewerInput();
+ }
+ });
+
+ // create viewer that displays currently selected template's contents
+ fPatternViewer = doCreateViewer(parent);
+
+ fTemplateStore = WebUiPlugin.getDefault().getTemplateStore();
+ fTableViewer.setInput(fTemplateStore);
+
+ // Create linked text to just to templates preference page
+ Link link = new Link(parent, SWT.NONE);
+ link.setText(Messages.NewXHTMLTemplatesWizardPage_6);
+ data = new GridData(SWT.END, SWT.FILL, true, false, 2, 1);
+ link.setLayoutData(data);
+ link.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ linkClicked();
+ }
+ });
+
+ configureTableResizing(innerParent, table, column1, column2);
+ loadLastSavedPreferences();
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
IHelpContextIds.HTML_NEWWIZARD_TEMPLATE_HELPID);
+ Dialog.applyDialogFont(parent);
+ setControl(parent);
+ }
+
+ /**
+ * Creates, configures and returns a source viewer to present the template
+ * pattern on the preference page. Clients may override to provide a
+ * custom source viewer featuring e.g. syntax coloring.
+ *
+ * @param parent
+ * the parent control
+ * @return a configured source viewer
+ */
+ private SourceViewer createViewer(Composite parent) {
+ SourceViewerConfiguration sourceViewerConfiguration = new
StructuredTextViewerConfiguration() {
+ StructuredTextViewerConfiguration baseConfiguration = new
StructuredTextViewerConfigurationHTML();
+
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return baseConfiguration.getConfiguredContentTypes(sourceViewer);
+ }
+
+ public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String
partitionType) {
+ return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
+ }
+ };
+ SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER |
SWT.V_SCROLL | SWT.H_SCROLL);
+ ((StructuredTextViewer)
viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
//$NON-NLS-1$
+ IStructuredModel scratchModel =
StructuredModelManager.getModelManager().createUnManagedStructuredModelFor("org.eclipse.wst.html.core.htmlsource");
+ IDocument document = scratchModel.getStructuredDocument();
+ viewer.configure(sourceViewerConfiguration);
+ viewer.setDocument(document);
+ return viewer;
+ }
+
+ private SourceViewer doCreateViewer(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(Messages.NewXHTMLTemplatesWizardPage_5);
+ GridData data = new GridData();
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ SourceViewer viewer = createViewer(parent);
+ viewer.setEditable(false);
+
+ Control control = viewer.getControl();
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 2;
+ data.heightHint = convertHeightInCharsToPixels(5);
+ // [261274] - source viewer was growing to fit the max line width of the template
+ data.widthHint = convertWidthInCharsToPixels(2);
+ control.setLayoutData(data);
+
+ return viewer;
+ }
+
+ /**
+ * Enable/disable controls in page based on fUseTemplateButton's current
+ * state.
+ */
+ void enableTemplates() {
+ boolean enabled = fUseTemplateButton.getSelection();
+
+ if (!enabled) {
+ // save last selected template
+ Template template = getSelectedTemplate();
+ if (template != null)
+ fLastSelectedTemplateName = template.getName();
+ else
+ fLastSelectedTemplateName = ""; //$NON-NLS-1$
+
+ fTableViewer.setSelection(null);
+ }
+ else {
+ setSelectedTemplate(fLastSelectedTemplateName);
+ }
+
+ fTableViewer.getControl().setEnabled(enabled);
+ fPatternViewer.getControl().setEnabled(enabled);
+ }
+
+ /**
+ * Return the template preference page id
+ *
+ * @return
+ */
+ private String getPreferencePageId() {
+ return "org.jboss.tools.jsf.ui.editor.pref.template"; //$NON-NLS-1$
+ }
+
+ /**
+ * Get the currently selected template.
+ *
+ * @return
+ */
+ private Template getSelectedTemplate() {
+ Template template = null;
+ IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+
+ if (selection.size() == 1) {
+ template = (Template) selection.getFirstElement();
+ }
+ return template;
+ }
+
+ /**
+ * Returns template string to insert.
+ *
+ * @return String to insert or null if none is to be inserted
+ */
+ String getTemplateString() {
+ String templateString = null;
+
+ Template template = getSelectedTemplate();
+ if (template != null) {
+ TemplateContextType contextType =
WebUiPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsXHTML.NEW);
+ IDocument document = new Document();
+ TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
+ try {
+ TemplateBuffer buffer = context.evaluate(template);
+ templateString = buffer.getString();
+ }
+ catch (Exception e) {
+ WebUiPlugin.getDefault().logWarning("Could not create template for new
html", e); //$NON-NLS-1$
+ }
+ }
+
+ return templateString;
+ }
+
+ void linkClicked() {
+ String pageId = getPreferencePageId();
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), pageId,
new String[]{pageId}, null);
+ dialog.open();
+ fTableViewer.refresh();
+ }
+
+ /**
+ * Load the last template name used in New HTML File wizard.
+ */
+ private void loadLastSavedPreferences() {
+ String templateName =
WebUiPlugin.getDefault().getPreferenceStore().getString(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME);
+ if (templateName == null || templateName.length() == 0) {
+ fLastSelectedTemplateName = ""; //$NON-NLS-1$
+ fUseTemplateButton.setSelection(false);
+ }
+ else {
+ fLastSelectedTemplateName = templateName;
+ fUseTemplateButton.setSelection(true);
+ }
+ enableTemplates();
+ }
+
+ /**
+ * Save template name used for next call to New HTML File wizard.
+ */
+ void saveLastSavedPreferences() {
+ String templateName = ""; //$NON-NLS-1$
+
+ Template template = getSelectedTemplate();
+ if (template != null) {
+ templateName = template.getName();
+ }
+
+ WebUiPlugin.getDefault().getPreferenceStore().setValue(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME,
templateName);
+ WebUiPlugin.getDefault().savePluginPreferences();
+ }
+
+ /**
+ * Select a template in the table viewer given the template name. If
+ * template name cannot be found or templateName is null, just select
+ * first item in table. If no items in table select nothing.
+ *
+ * @param templateName
+ */
+ private void setSelectedTemplate(String templateName) {
+ Object template = null;
+
+ if (templateName != null && templateName.length() > 0) {
+ // pick the last used template
+ template = fTemplateStore.findTemplate(templateName,
TemplateContextTypeIdsXHTML.NEW);
+ }
+
+ // no record of last used template so just pick first element
+ if (template == null) {
+ // just pick first element
+ template = fTableViewer.getElementAt(0);
+ }
+
+ if (template != null) {
+ IStructuredSelection selection = new StructuredSelection(template);
+ fTableViewer.setSelection(selection, true);
+ }
+ }
+
+ /**
+ * Updates the pattern viewer.
+ */
+ void updateViewerInput() {
+ Template template = getSelectedTemplate();
+ if (template != null) {
+ fPatternViewer.getDocument().set(template.getPattern());
+ }
+ else {
+ fPatternViewer.getDocument().set(""); //$NON-NLS-1$
+ }
+ }
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java
(from rev 21828,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizard.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * 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.jst.web.ui.wizards.newfile;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+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.common.meta.action.impl.SpecialWizardSupport;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.wizard.newfile.NewXHTMLFileWizard;
+import org.jboss.tools.jst.web.model.handlers.CreateJSPFileSupport;
+import org.jboss.tools.jst.web.ui.Messages;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+
+/**
+ * @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;
+ private NewXHTMLFileWizard newXHTMLFileWizard;
+ private NewXHTMLWizardSelectTagLibrariesPage newXHTMLWizardSelectTagLibrariesPage;
+
+
+
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ this.fNewFilePage = (WizardNewFileCreationPage)
getPage(NewXHTMLWizard.HTMLWizardNewFileCreationPage);
+ this.fNewFilePage.setTitle(Messages.UI_WIZARD_XHTML_NEW_TITLE);
+ this.fNewFilePage.setDescription(Messages.UI_WIZARD_XHTML_NEW_Description);
+
+ this.fNewFileTemplatesPage = new NewXHTMLTemplatesWizardPage();
+ addPage(this.fNewFileTemplatesPage);
+ this.newXHTMLWizardSelectTagLibrariesPage = getURISelectionPage();
+ addPage(this.newXHTMLWizardSelectTagLibrariesPage);
+ }
+ @Override
+ public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
+ super.init(aWorkbench, aSelection);
+ setWindowTitle(Messages.UI_WIZARD_XHTML_NEW_TITLE);
+ setNewXHTMLFileWizard(new NewXHTMLFileWizard());
+ getNewXHTMLFileWizard().init(aWorkbench, aSelection);
+ }
+ /* (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);
+ }
+ }
+ private NewXHTMLWizardSelectTagLibrariesPage getURISelectionPage() {
+ SpecialWizardSupport support = getNewXHTMLFileWizard().getFileContext().getSupport();
+ NewXHTMLWizardSelectTagLibrariesPage step = new
NewXHTMLWizardSelectTagLibrariesPage(support, 1);
+ try {
+ support.action(SpecialWizardSupport.NEXT);
+ } catch (XModelException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ step.setWizard(this);
+ return step;
+ }
+ @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+".xhtml"; //$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();
+ try {
+ templateString=((CreateJSPFileSupport)getNewXHTMLFileWizard().getFileContext().getSupport()).addTaglibs(templateString);
+ } catch (IOException ex) {
+ WebUiPlugin.getDefault().logWarning("Problems with adding taglibs",ex);
//$NON-NLS-1$
+ }
+ if (templateString != null) {
+ templateString = applyLineDelimiter(file, templateString);
+ // determine the encoding for the new file
+ Preferences preference = WebUiPlugin.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) {
+ WebUiPlugin.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) {
+ WebUiPlugin.getDefault().logError(e.getMessage(), e);
+ }
+ }
+ });
+ }
+ }
+ /**
+ * @return the newXHTMLFileWizard
+ */
+ private NewXHTMLFileWizard getNewXHTMLFileWizard() {
+ return this.newXHTMLFileWizard;
+ }
+ /**
+ * @param newXHTMLFileWizard the newXHTMLFileWizard to set
+ */
+ private void setNewXHTMLFileWizard(NewXHTMLFileWizard newXHTMLFileWizard) {
+ this.newXHTMLFileWizard = newXHTMLFileWizard;
+ }
+
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizardSelectTagLibrariesPage.java
(from rev 21828,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/newfile/NewXHTMLWizardSelectTagLibrariesPage.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizardSelectTagLibrariesPage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizardSelectTagLibrariesPage.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.jst.web.ui.wizards.newfile;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
+import org.jboss.tools.common.model.ui.wizards.standard.DefaultStandardStep;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class NewXHTMLWizardSelectTagLibrariesPage extends DefaultStandardStep {
+
+ public NewXHTMLWizardSelectTagLibrariesPage(SpecialWizardSupport support,
+ int id) {
+ super(support, id);
+ }
+ @Override
+ public void setWizard(IWizard wizard) {
+ super.setWizard(wizard);
+// this.wizard = (DefaultStandardWizard)wizard;
+ }
+ @Override
+ public void validate() {
+ setPageComplete(true);
+ }
+}
Copied: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/templates (from rev 21828,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/templates)
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java 2010-04-30
17:16:33 UTC (rev 21839)
+++
trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java 2010-04-30
17:20:33 UTC (rev 21840)
@@ -14,11 +14,11 @@
import org.jboss.tools.common.model.ui.wizard.newfile.NewHTMLFileWizard;
import org.jboss.tools.common.model.ui.wizard.newfile.NewJSPFileWizard;
import org.jboss.tools.common.model.ui.wizard.newfile.NewPropertiesFileWizard;
-import org.jboss.tools.common.model.ui.wizard.newfile.NewXHTMLFileWizard;
import org.jboss.tools.jst.web.ui.wizards.newfile.NewCSSFileWizard;
import org.jboss.tools.jst.web.ui.wizards.newfile.NewJSFileWizard;
import org.jboss.tools.jst.web.ui.wizards.newfile.NewTLDFileWizard;
import org.jboss.tools.jst.web.ui.wizards.newfile.NewWebFileWizard;
+import org.jboss.tools.jst.web.ui.wizards.newfile.NewXHTMLWizard;
/**
* @author eskimo
@@ -43,7 +43,7 @@
}
public void testNewXhtmlWizardInstanceIsCreated() {
- testNewWizardInstanceIsCreated(NewXHTMLFileWizard.class.getName());
+ testNewWizardInstanceIsCreated(NewXHTMLWizard.class.getName());
}
public void testNewHtmlWizardInstanceIsCreated() {