refactoring/cleanup
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF
index d498d1a..da2022a 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF
@@ -25,20 +25,15 @@
org.eclipse.wst.jsdt.web.ui.internal.registry;x-internal:=true,
org.eclipse.wst.jsdt.web.ui.internal.style;x-internal:=true,
org.eclipse.wst.jsdt.web.ui.internal.style.java;x-internal:=true,
- org.eclipse.wst.jsdt.web.ui.internal.style.jspel;x-internal:=true,
org.eclipse.wst.jsdt.web.ui.internal.taginfo;x-internal:=true,
- org.eclipse.wst.jsdt.web.ui.internal.templates;x-internal:=true,
org.eclipse.wst.jsdt.web.ui.internal.text;x-internal:=true,
- org.eclipse.wst.jsdt.web.ui.internal.wizard;x-internal:=true,
org.eclipse.wst.jsdt.web.ui.views.contentoutline
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.wst.sse.ui;bundle-version="[1.0.101,1.1.0)",
org.eclipse.wst.html.ui;bundle-version="[1.0.100,1.1.0)",
- org.eclipse.wst.css.ui;bundle-version="[1.0.100,1.1.0)",
org.eclipse.wst.xml.ui;bundle-version="[1.0.100,1.1.0)",
org.eclipse.wst.jsdt.web.core;bundle-version="[1.1.0,1.3.0)",
org.eclipse.wst.html.core;bundle-version="[1.1.0,1.2.0)",
@@ -46,16 +41,11 @@
org.eclipse.wst.xml.core;bundle-version="[1.1.0,1.2.0)",
org.eclipse.wst.sse.core;bundle-version="[1.1.0,1.2.0)",
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ltk.ui.refactoring;bundle-version="[3.2.0,4.0.0)",
org.eclipse.wst.common.uriresolver;bundle-version="[1.1.0,1.2.0)",
org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.1.0,1.2.0)",
- org.eclipse.wst.common.modulecore;bundle-version="[1.1.0,1.2.0)",
com.ibm.icu;bundle-version="[3.4.4,4.0.0)",
org.eclipse.wst.jsdt.debug,
org.eclipse.wst.jsdt.core,
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/properties/JSPedCSSPropertySource.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/properties/JSPedCSSPropertySource.java
deleted file mode 100644
index 616c506..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/properties/JSPedCSSPropertySource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.css.ui.internal.properties;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.css.ui.internal.properties.CSSPropertySource;
-
-public class JSPedCSSPropertySource extends CSSPropertySource {
-
- public JSPedCSSPropertySource(ICSSNode target) {
- super(target);
- }
-
- @Override
- public void setPropertyValue(Object name, Object value) {
- // workaround to avoid DOMException: if value contains jsp element,
- // nothing happen.
- String v = value.toString();
- if (v.indexOf("${") != -1 || v.indexOf("<%=") != -1) {
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- String title = JSPUIMessages.Title_InvalidValue;
- String message = JSPUIMessages.Message_InvalidValue;
- MessageDialog.openWarning(window.getShell(), title, message);
- return;
- }
- super.setPropertyValue(name, value);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/registry/AdapterFactoryProviderJSPedCSS.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/registry/AdapterFactoryProviderJSPedCSS.java
deleted file mode 100644
index 9ec8bfd..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/registry/AdapterFactoryProviderJSPedCSS.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.css.ui.internal.registry;
-
-import org.eclipse.wst.jsdt.web.css.core.internal.modelhandler.ModelHandlerForJSPedCSS;
-import org.eclipse.wst.css.ui.internal.registry.AdapterFactoryProviderCSS;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-
-public class AdapterFactoryProviderJSPedCSS extends AdapterFactoryProviderCSS {
-
- @Override
- public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
- return (contentTypeDescription instanceof ModelHandlerForJSPedCSS);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java
deleted file mode 100644
index 681fb68..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.css.ui.internal.views.properties;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.jsdt.web.css.ui.internal.properties.JSPedCSSPropertySource;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class JSPedCSSPropertySheetConfiguration extends
- PropertySheetConfiguration {
- private class CSSPropertySheetRefreshAdapter implements INodeAdapter {
- public boolean isAdapterForType(Object type) {
- return false;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType,
- Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (fPropertySheetPage != null) {
- getPropertiesRefreshJob().addPropertySheetPage(
- fPropertySheetPage);
- }
- }
- }
-
- private class CSSPropertySourceProvider implements IPropertySourceProvider {
- private IPropertySource fPropertySource = null;
- private ICSSNode fSource = null;
-
- public IPropertySource getPropertySource(Object object) {
- if (fSource != null && object.equals(fSource)) {
- return fPropertySource;
- }
-
- if (object instanceof ICSSNode) {
- fSource = (ICSSNode) object;
- fPropertySource = new JSPedCSSPropertySource(fSource);
- } else {
- fSource = null;
- fPropertySource = null;
- }
- return fPropertySource;
- }
- }
-
- private class PropertiesRefreshJob extends UIJob {
- public static final int UPDATE_DELAY = 200;
-
- private Set propertySheetPages = null;
-
- public PropertiesRefreshJob() {
- super(XMLUIMessages.JFaceNodeAdapter_1);
- setSystem(true);
- setPriority(Job.SHORT);
- propertySheetPages = new HashSet(1);
- }
-
- void addPropertySheetPage(IPropertySheetPage page) {
- propertySheetPages.add(page);
- schedule(UPDATE_DELAY);
- }
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Object[] pages = propertySheetPages.toArray();
- propertySheetPages.clear();
-
- for (int i = 0; i < pages.length; i++) {
- PropertySheetPage page = (PropertySheetPage) pages[i];
- if (page.getControl() != null
- && !page.getControl().isDisposed()) {
- page.refresh();
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- private PropertiesRefreshJob fPropertiesRefreshJob = null;
-
- IPropertySheetPage fPropertySheetPage;
-
- private IPropertySourceProvider fPropertySourceProvider = null;
-
- private INodeAdapter fRefreshAdapter = new CSSPropertySheetRefreshAdapter();
-
- private INodeNotifier[] fSelectedNotifiers;
-
- /**
- * Create new instance of CSSPropertySheetConfiguration
- */
- public JSPedCSSPropertySheetConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- @Override
- public ISelection getInputSelection(IWorkbenchPart selectingPart,
- ISelection selection) {
- // remove UI refresh adapters
- if (fSelectedNotifiers != null) {
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- fSelectedNotifiers = null;
- }
-
- ISelection preferredSelection = super.getInputSelection(selectingPart,
- selection);
- if (preferredSelection instanceof IStructuredSelection) {
- Object[] selectedObjects = new Object[((IStructuredSelection) selection)
- .size()];
- System.arraycopy(((IStructuredSelection) selection).toArray(), 0,
- selectedObjects, 0, selectedObjects.length);
- for (int i = 0; i < selectedObjects.length; i++) {
- if (selectedObjects[i] instanceof ICSSNode) {
- ICSSNode node = (ICSSNode) selectedObjects[i];
- while (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE
- || node.getNodeType() == ICSSNode.STYLEDECLITEM_NODE) {
- node = node.getParentNode();
- selectedObjects[i] = node;
- }
- }
- }
-
- /*
- * Add UI refresh adapters and remember notifiers for later removal
- */
- if (selectedObjects.length > 0) {
- List selectedNotifiers = new ArrayList(1);
- for (int i = 0; i < selectedObjects.length; i++) {
- if (selectedObjects[i] instanceof INodeNotifier) {
- selectedNotifiers.add(selectedObjects[i]);
- ((INodeNotifier) selectedObjects[i])
- .addAdapter(fRefreshAdapter);
- }
- }
- fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers
- .toArray(new INodeNotifier[selectedNotifiers.size()]);
- }
- preferredSelection = new StructuredSelection(selectedObjects);
- }
- return preferredSelection;
- }
-
- PropertiesRefreshJob getPropertiesRefreshJob() {
- if (fPropertiesRefreshJob == null) {
- fPropertiesRefreshJob = new PropertiesRefreshJob();
- }
- return fPropertiesRefreshJob;
- }
-
- @Override
- public IPropertySourceProvider getPropertySourceProvider(
- IPropertySheetPage page) {
- if (fPropertySourceProvider == null) {
- fPropertySourceProvider = new CSSPropertySourceProvider();
- fPropertySheetPage = page;
- }
- return fPropertySourceProvider;
- }
-
- @Override
- public void unconfigure() {
- super.unconfigure();
- if (fSelectedNotifiers != null) {
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- fSelectedNotifiers = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSP.java
index ed5ec2b..0596554 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSP.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSP.java
@@ -12,52 +12,35 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.ITextDoubleClickStrategy;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.formatter.ContentFormatter;
-import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.jface.text.information.IInformationPresenter;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.wst.jsdt.ui.JavaUI;
import org.eclipse.wst.jsdt.ui.PreferenceConstants;
import org.eclipse.wst.jsdt.ui.text.IJavaPartitions;
import org.eclipse.wst.jsdt.ui.text.JavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.web.core.internal.text.StructuredTextPartitionerForJSP;
import org.eclipse.wst.jsdt.web.core.text.IJSPPartitions;
import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForTabs;
-import org.eclipse.wst.jsdt.web.ui.internal.autoedit.StructuredAutoEditStrategyJSP;
import org.eclipse.wst.jsdt.web.ui.internal.contentassist.JSDTContentAssistant;
-
import org.eclipse.wst.jsdt.web.ui.internal.format.FormattingStrategyJSPJava;
import org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSPJavaHyperlinkDetector;
-import org.eclipse.wst.jsdt.web.ui.internal.hyperlink.XMLHyperlinkDetector;
import org.eclipse.wst.jsdt.web.ui.internal.style.java.LineStyleProviderForJSDT;
import org.eclipse.wst.jsdt.web.ui.internal.taginfo.JSDTHoverProcessor;
import org.eclipse.wst.jsdt.web.ui.internal.taginfo.JSDTInformationProvider;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
-import org.eclipse.wst.css.core.text.ICSSPartitions;
-import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
-import org.eclipse.wst.html.core.text.IHTMLPartitions;
-import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
-import org.eclipse.wst.sse.core.text.IStructuredPartitions;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
/**
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPlugin.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPlugin.java
index 3e44c37..3f6bcaa 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPlugin.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPlugin.java
@@ -14,14 +14,8 @@
import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.wst.jsdt.internal.corext.template.java.CodeTemplateContextType;
-import org.eclipse.wst.jsdt.internal.ui.JavaPlugin;
-import org.eclipse.wst.jsdt.ui.text.JavaSourceViewerConfiguration;
-import org.eclipse.wst.jsdt.web.ui.internal.preferences.JSPUIPreferenceNames;
-import org.eclipse.wst.jsdt.web.ui.internal.templates.TemplateContextTypeIdsJSP;
-import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
-import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.jsdt.internal.ui.JavaPlugin;
import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry;
import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl;
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java
index 71aa484..59ab6ec 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java
@@ -83,7 +83,7 @@
javaProject = JavaCore.create(project);
}finally{
- if(model!=null) model.releaseFromEdit();
+ if(model!=null) model.releaseFromRead();
}
return javaProject;
}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java
deleted file mode 100644
index b34f8e9..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.autoedit;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.jsdt.web.ui.internal.Logger;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-public class StructuredAutoEditStrategyJSP implements IAutoEditStrategy {
- public void customizeDocumentCommand(IDocument document,
- DocumentCommand command) {
- Object textEditor = getActiveTextEditor();
- if (!(textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor)
- .getInsertMode() == ITextEditorExtension3.SMART_INSERT)) {
- return;
- }
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager()
- .getExistingModelForRead(document);
-
- if (model != null) {
- if (command.text != null) {
- if (command.text.equals("%")) { //$NON-NLS-1$
- // scriptlet - add end %>
- IDOMNode node = (IDOMNode) model
- .getIndexedRegion(command.offset);
- if (prefixedWith(document, command.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
- command.text += " %>"; //$NON-NLS-1$
- command.shiftsCaret = false;
- command.caretOffset = command.offset + 1;
- command.doit = false;
- }
- }
- if (command.text.equals("{")) { //$NON-NLS-1$
- IDOMNode node = (IDOMNode) model
- .getIndexedRegion(command.offset);
- if ((prefixedWith(document, command.offset, "$") || prefixedWith(document, command.offset, "#")) && //$NON-NLS-1$ //$NON-NLS-2$
- !node.getSource().endsWith("}")) { //$NON-NLS-1$
- command.text += " }"; //$NON-NLS-1$
- command.shiftsCaret = false;
- command.caretOffset = command.offset + 1;
- command.doit = false;
- }
- }
- }
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
- }
-
- /**
- * Return the active text editor if possible, otherwise the active editor
- * part.
- *
- * @return
- */
- private Object getActiveTextEditor() {
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- if (editor instanceof ITextEditor) {
- return editor;
- }
- ITextEditor textEditor = (ITextEditor) editor
- .getAdapter(ITextEditor.class);
- if (textEditor != null) {
- return textEditor;
- }
- return editor;
- }
- }
- }
- return null;
- }
-
- private boolean prefixedWith(IDocument document, int offset, String string) {
-
- try {
- return document.getLength() >= string.length()
- && document.get(offset - string.length(), string.length())
- .equals(string);
- } catch (BadLocationException e) {
- Logger.logException(e);
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSPJava_ORIGINAL.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSPJava_ORIGINAL.java
deleted file mode 100644
index 6a0ea0b..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSPJava_ORIGINAL.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.format;
-
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.core.ICompilationUnit;
-import org.eclipse.wst.jsdt.core.JavaModelException;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.wst.jsdt.web.core.internal.Logger;
-import org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslationUtil;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-
-public class FormattingStrategyJSPJava_ORIGINAL extends ContextBasedFormattingStrategy {
-
- /** Documents to be formatted by this strategy */
- private final LinkedList fDocuments = new LinkedList();
- /** Partitions to be formatted by this strategy */
- private final LinkedList fPartitions = new LinkedList();
- JSPTranslation translation = null;
-
- /**
- * Creates a new java formatting strategy.
- */
- public FormattingStrategyJSPJava_ORIGINAL() {
- super();
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
- */
- @Override
- public void format() {
- super.format();
-
- final IDocument document = (IDocument) fDocuments.removeFirst();
- final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();
-
- if (document != null && partition != null) {
- try {
-
- JSPTranslationUtil translationUtil = new JSPTranslationUtil(document);
- ICompilationUnit cu = translationUtil.getCompilationUnit();
- if (cu != null) {
- String cuSource = cu.getSource();
- TextEdit textEdit = formatString(CodeFormatter.K_COMPILATION_UNIT, cuSource, 0, TextUtilities.getDefaultLineDelimiter(document), getPreferences());
-
- TextEdit jspEdit = translationUtil.getTranslation().getJspEdit(textEdit);
- if (jspEdit != null && jspEdit.hasChildren()) {
- jspEdit.apply(document);
- }
- }
-
- } catch (MalformedTreeException exception) {
- Logger.logException(exception);
- } catch (BadLocationException exception) {
- // Can only happen on concurrent document modification - log
- // and bail out
- Logger.logException(exception);
- } catch (JavaModelException exception) {
- Logger.logException(exception);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
- */
- @Override
- public void formatterStarts(final IFormattingContext context) {
- super.formatterStarts(context);
-
- fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
- fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
- */
- @Override
- public void formatterStops() {
- super.formatterStops();
-
- fPartitions.clear();
- fDocuments.clear();
- }
-
- public TextEdit formatString(int kind, String string, int indentationLevel, String lineSeparator, Map options) {
- return ToolFactory.createCodeFormatter(options).format(kind, string, 0, string.length(), indentationLevel, lineSeparator);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/preferences/JSPUIPreferenceInitializer.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/preferences/JSPUIPreferenceInitializer.java
index bc9322d..d7097e3 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/preferences/JSPUIPreferenceInitializer.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/preferences/JSPUIPreferenceInitializer.java
@@ -3,9 +3,8 @@
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.templates.Template;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.jsdt.web.ui.internal.style.IStyleConstantsJSP;
import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML;
+import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
@@ -55,8 +54,7 @@
styleValue = ColorHelper.getColorString(191, 95, 63) + NOBACKGROUNDBOLD;
store.setDefault(IStyleConstantsHTML.SCRIPT_AREA_BORDER, styleValue);
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsJSP.JSP_CONTENT, styleValue);
+
// set default new jsp file template to use in new file wizard
/*
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/LineStyleProviderForJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/LineStyleProviderForJSP.java
deleted file mode 100644
index e3d11c7..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/LineStyleProviderForJSP.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.jsdt.web.core.internal.regions.DOMJSPRegionContexts;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.provisional.style.AbstractLineStyleProvider;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-public class LineStyleProviderForJSP extends AbstractLineStyleProvider
- implements LineStyleProvider {
-
- private String fLanguage = null;
-
- // private static final String JAVA = "java"; //$NON-NLS-1$
- // private static final String[] JAVASCRIPT_LANGUAGE_KEYS = new String[] {
- // "javascript", "javascript1.0", "javascript1.1_3", "javascript1.2",
- // "javascript1.3", "javascript1.4", "javascript1.5", "javascript1.6",
- // "jscript", "sashscript" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- // //$NON-NLS-9$ //$NON-NLS-10$
-
- public LineStyleProviderForJSP() {
- super();
- }
-
- @Override
- protected TextAttribute getAttributeFor(ITextRegion region) {
- /**
- * a method to centralize all the "sytle rules" for regions
- */
- TextAttribute result = null;
- // not sure why this is coming through null, but just to catch it
- if (region == null) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.CDATA_TEXT);
- } else {
-
- if (result == null) {
- String type = region.getType();
- if ((type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN)
- || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN)
- || (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN)
- || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN)
- || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE)
- || (type == DOMJSPRegionContexts.JSP_CLOSE)) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsHTML.SCRIPT_AREA_BORDER);
- } else if (type == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME
- || type == DOMJSPRegionContexts.JSP_ROOT_TAG_NAME) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_NAME);
- } else if ((type == DOMJSPRegionContexts.JSP_COMMENT_OPEN)
- || (type == DOMJSPRegionContexts.JSP_COMMENT_CLOSE)) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.COMMENT_BORDER);
- } else if (type == DOMJSPRegionContexts.JSP_COMMENT_TEXT) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.COMMENT_TEXT);
- }
- // ============ These are in common with XML --- (for XML form
- // of tags)
- // Note: this assume's this provider is only called for
- // true JSP Nodes. If its called for others, then this will
- // cause their tag names to be highlighted too!
- // Further checks could be done to prevent that, but doesn't
- // seem worth it, since if adpaters factories are working
- // right,
- // then wouldn't be needed.
- else if (type == DOMRegionContext.XML_TAG_NAME) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_NAME);
- } else if ((type == DOMRegionContext.XML_TAG_OPEN)
- || (type == DOMRegionContext.XML_END_TAG_OPEN)
- || (type == DOMRegionContext.XML_TAG_CLOSE)
- || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_BORDER);
- } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- } else if ((type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- || (type == DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE)
- || (type == DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE)) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- }
-
- // DMW: added 9/1/2002 Undefined color may need addjustment :)
- else if (type == DOMRegionContext.UNDEFINED) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.XML_CONTENT);
- } else if (type == DOMRegionContext.WHITE_SPACE) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.XML_CONTENT);
- } else if (type == DOMRegionContext.XML_CONTENT) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.XML_CONTENT);
- } else if (type == DOMRegionContext.BLOCK_TEXT) {
- result = (TextAttribute) getTextAttributes().get(
- IStyleConstantsXML.CDATA_TEXT);
- }
- }
- }
- // default, return null to signal "not handled"
- // in which case, other factories should be tried
- return result;
- }
-
- @Override
- protected IPreferenceStore getColorPreferences() {
- return JSPUIPlugin.getDefault().getPreferenceStore();
- }
-
- @Override
- protected void loadColors() {
- addTextAttribute(IStyleConstantsXML.TAG_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_BORDER);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- addTextAttribute(IStyleConstantsXML.COMMENT_BORDER);
- addTextAttribute(IStyleConstantsXML.COMMENT_TEXT);
- addTextAttribute(IStyleConstantsXML.CDATA_BORDER);
- addTextAttribute(IStyleConstantsXML.CDATA_TEXT);
- addTextAttribute(IStyleConstantsXML.DECL_BORDER);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_NAME);
- addTextAttribute(IStyleConstantsXML.PI_CONTENT);
- addTextAttribute(IStyleConstantsXML.PI_BORDER);
- addTextAttribute(IStyleConstantsXML.XML_CONTENT);
- addTextAttribute(IStyleConstantsHTML.SCRIPT_AREA_BORDER);
- }
-
- @Override
- protected void handlePropertyChange(PropertyChangeEvent event) {
- String styleKey = null;
-
- if (event != null) {
- String prefKey = event.getProperty();
- // check if preference changed is a style preference
- if (IStyleConstantsXML.TAG_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_NAME;
- } else if (IStyleConstantsXML.TAG_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_BORDER;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_NAME;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_VALUE;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS;
- } else if (IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_BORDER;
- } else if (IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_TEXT;
- } else if (IStyleConstantsXML.CDATA_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_BORDER;
- } else if (IStyleConstantsXML.CDATA_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_TEXT;
- } else if (IStyleConstantsXML.DECL_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DECL_BORDER;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF
- .equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF
- .equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF;
- } else if (IStyleConstantsXML.DOCTYPE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_NAME;
- } else if (IStyleConstantsXML.PI_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_CONTENT;
- } else if (IStyleConstantsXML.PI_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_BORDER;
- } else if (IStyleConstantsXML.XML_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.XML_CONTENT;
- } else if (IStyleConstantsHTML.SCRIPT_AREA_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsHTML.SCRIPT_AREA_BORDER;
- }
- }
-
- if (styleKey != null) {
- // overwrite style preference with new value
- addTextAttribute(styleKey);
- super.handlePropertyChange(event);
- }
- }
-
- /**
- * Returns the language.
- *
- * @return String
- */
- public String getLanguage() {
- return fLanguage;
- }
-
- /**
- * Sets the language.
- *
- * @param language
- * The language to set
- */
- public void setLanguage(String language) {
- this.fLanguage = language;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/IStyleConstantsJSPEL.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/IStyleConstantsJSPEL.java
deleted file mode 100644
index 7ecd0c6..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/IStyleConstantsJSPEL.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-public interface IStyleConstantsJSPEL {
- String EL_KEYWORD = "keyword"; //$NON-NLS-1$
- String EL_DEFAULT = "default"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELCodeScanner.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELCodeScanner.java
deleted file mode 100644
index 956710c..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELCodeScanner.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WhitespaceRule;
-import org.eclipse.jface.text.rules.WordRule;
-
-/**
- * A Java code scanner.
- */
-public class JSPELCodeScanner extends
- org.eclipse.jface.text.rules.RuleBasedScanner {
- private IToken fKeywordToken;
- private IToken fTypeToken;
- private IToken fDefaultToken;
-
- private static String[] fgKeywords = { "and", //$NON-NLS-1$
- "did", //$NON-NLS-1$
- "div", //$NON-NLS-1$
- "empty", //$NON-NLS-1$
- "eq", //$NON-NLS-1$
- "ge", //$NON-NLS-1$
- "gt", //$NON-NLS-1$
- "or", //$NON-NLS-1$
- "le", //$NON-NLS-1$
- "lt", //$NON-NLS-1$
- "mod", //$NON-NLS-1$
- "ne", //$NON-NLS-1$
- "not" //$NON-NLS-1$
- };
- private static String[] fgConstants = { "false", "true" };//$NON-NLS-2$//$NON-NLS-1$
-
- /**
- * Creates a Java code scanner
- */
- public JSPELCodeScanner() {
- super();
- }
-
- public void initializeRules() {
- List rules = new ArrayList();
-
- // Add generic whitespace rule.
- rules.add(new WhitespaceRule(new JSPELWhitespaceDetector()));
-
- // Add word rule for keywords, types, and constants.
- WordRule wordRule = new WordRule(new JSPELWordDetector(), fDefaultToken);
- for (int i = 0; i < fgKeywords.length; i++) {
- wordRule.addWord(fgKeywords[i], fKeywordToken);
- }
- for (int i = 0; i < fgConstants.length; i++) {
- wordRule.addWord(fgConstants[i], fTypeToken);
- }
- rules.add(wordRule);
-
- IRule[] result = new IRule[rules.size()];
- rules.toArray(result);
- setRules(result);
- }
-
- public void setTokenData(String tokenKey, Object data) {
- if (tokenKey == IStyleConstantsJSPEL.EL_KEYWORD) {
- fKeywordToken = new Token(data);
- fTypeToken = new Token(data);
- } else if (tokenKey == IStyleConstantsJSPEL.EL_DEFAULT) {
- fDefaultToken = new Token(data);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELColorProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELColorProvider.java
deleted file mode 100644
index 883a280..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELColorProvider.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
-
-/**
- * Colors used in the Java editor
- */
-public class JSPELColorProvider {
-
- // people should not be setting these, even though they are currently not
- // final
- public static RGB MULTI_LINE_COMMENT = new RGB(128, 0, 0);
- public static RGB SINGLE_LINE_COMMENT = new RGB(128, 128, 0);
- public static RGB KEYWORD = new RGB(0, 0, 128);
- public static RGB TYPE = new RGB(0, 0, 128);
- public static RGB STRING = new RGB(0, 128, 0);
- public static RGB DEFAULT = new RGB(0, 0, 0);
- public static RGB JAVADOC_KEYWORD = new RGB(0, 128, 0);
- public static RGB JAVADOC_TAG = new RGB(128, 128, 128);
- public static RGB JAVADOC_LINK = new RGB(128, 128, 128);
- public static RGB JAVADOC_DEFAULT = new RGB(0, 128, 128);
-
- public static int MULTI_LINE_COMMENT_BOLD = SWT.NORMAL;
- public static int SINGLE_LINE_COMMENT_BOLD = SWT.NORMAL;
- public static int KEYWORD_BOLD = SWT.BOLD;
- public static int TYPE_BOLD = SWT.BOLD;
- public static int STRING_BOLD = SWT.NORMAL;
- public static int DEFAULT_BOLD = SWT.NORMAL;
- public static int JAVADOC_KEYWORD_BOLD = SWT.BOLD;
- public static int JAVADOC_TAG_BOLD = SWT.NORMAL;
- public static int JAVADOC_LINK_BOLD = SWT.NORMAL;
- public static int JAVADOC_DEFAULT_BOLD = SWT.NORMAL;
-
- /**
- * @deprecated all editors use same
- */
- @Deprecated
- public static RGB EDITOR_BACKGROUND = new RGB(255, 255, 255);
- /**
- * @deprecated all editors use same
- */
- @Deprecated
- public static boolean EDITOR_CURRENT_LINE = true;
- /**
- * @deprecated all editors use same
- */
- @Deprecated
- public static RGB EDITOR_CURRENT_LINE_COLOR = new RGB(128, 128, 128);
-
- private static JSPELColorProvider fInstance = null;
-
- public static JSPELColorProvider getInstance() {
- if (fInstance == null) {
- fInstance = new JSPELColorProvider();
- }
- return fInstance;
- }
-
- /**
- * Use colors from JDT plugin
- */
- public void loadJavaColors() {
-
- IPreferenceStore jdtStore = PreferenceConstants.getPreferenceStore();
- MULTI_LINE_COMMENT = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR);
- SINGLE_LINE_COMMENT = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR);
- KEYWORD = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
- TYPE = KEYWORD;
- STRING = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_STRING_COLOR);
- DEFAULT = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR);
- JAVADOC_KEYWORD = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR);
- JAVADOC_TAG = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR);
- JAVADOC_LINK = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR);
- JAVADOC_DEFAULT = PreferenceConverter.getColor(jdtStore,
- PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR);
-
- MULTI_LINE_COMMENT_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- SINGLE_LINE_COMMENT_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- KEYWORD_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- TYPE_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- STRING_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_STRING_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- DEFAULT_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- JAVADOC_TAG_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- JAVADOC_LINK_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
- JAVADOC_DEFAULT_BOLD = jdtStore
- .getBoolean(PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD) ? SWT.BOLD
- : SWT.NORMAL;
-
- // EDITOR_BACKGROUND = new RGB(255, 255, 255);
-
- // IPreferenceStore sseStore =
- // SSEUIPlugin.getDefault().getPreferenceStore();
- // EDITOR_CURRENT_LINE =
- // sseStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE);
- // EDITOR_CURRENT_LINE_COLOR = PreferenceConverter.getColor(sseStore,
- // AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWhitespaceDetector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWhitespaceDetector.java
deleted file mode 100644
index 547e697..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWhitespaceDetector.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-/**
- * A java aware white space detector.
- */
-public class JSPELWhitespaceDetector implements
- org.eclipse.jface.text.rules.IWhitespaceDetector {
-
- /**
- * @see org.eclipse.jface.text.rules.IWhitespaceDetector#isWhitespace
- */
- public boolean isWhitespace(char c) {
- return Character.isWhitespace(c);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWordDetector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWordDetector.java
deleted file mode 100644
index adb9a97..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/JSPELWordDetector.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-/**
- * A Java aware word detector.
- */
-public class JSPELWordDetector implements
- org.eclipse.jface.text.rules.IWordDetector {
-
- /**
- * @see org.eclipse.jface.text.rules.IWordDetector#isWordIdentifierPart
- */
- public boolean isWordPart(char c) {
- return Character.isJavaIdentifierPart(c);
- }
-
- /**
- * @see org.eclipse.jface.text.rules.IWordDetector#isWordIdentifierStart
- */
- public boolean isWordStart(char c) {
- return Character.isJavaIdentifierStart(c);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/LineStyleProviderForJSPEL.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/LineStyleProviderForJSPEL.java
deleted file mode 100644
index 557f539..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/jspel/LineStyleProviderForJSPEL.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.style.jspel;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import org.eclipse.wst.jsdt.ui.PreferenceConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.jsdt.web.ui.internal.style.IStyleConstantsJSP;
-import org.eclipse.wst.jsdt.web.ui.internal.style.java.IStyleConstantsJSPJava;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
-import org.eclipse.wst.sse.ui.internal.provisional.style.Highlighter;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-// Note: many of the methods in this class were based on (or copied from)
-// those
-// found in the example Java Editor
-public class LineStyleProviderForJSPEL implements LineStyleProvider {
- private class PropertyChangeListener implements IPropertyChangeListener {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- // have to do it this way so others can override the method
- handlePropertyChange(event);
- }
- }
-
- private IDocument fDocument;
- private Highlighter fHighlighter;
- private boolean fIsInitialized = false;
- private PropertyChangeListener fPreferenceListener = new PropertyChangeListener();
- /** The scanner it uses */
- private JSPELCodeScanner fScanner;
- /** Contains all text attributes pretaining to this line style provider */
- private HashMap fTextAttributes = null;
-
- public LineStyleProviderForJSPEL() {
- super();
- fScanner = new JSPELCodeScanner();
- }
-
- /**
- * Adds style information to the given text presentation.
- *
- * @param presentation
- * the text presentation to be extended
- * @param offset
- * the offset of the range to be styled
- * @param length
- * the length of the range to be styled
- * @param attr
- * the attribute describing the style of the range to be styled
- */
- private void addRange(Collection presentation, int offset, int length,
- TextAttribute attr) {
- // support for user defined backgroud for JSP scriptlet regions
- String styleString = JSPUIPlugin.getDefault().getPreferenceStore()
- .getString(IStyleConstantsJSP.JSP_CONTENT);
- String[] prefs = ColorHelper.unpackStylePreferences(styleString);
- Color bgColor = (prefs != null && prefs.length == 3
- && prefs[1].startsWith("#") && Display.getCurrent() != null) //$NON-NLS-1$
- ? new Color(Display.getCurrent(), ColorHelper.toRGB(prefs[1]))
- : attr.getBackground();
-
- presentation.add(new StyleRange(offset, length, attr.getForeground(),
- bgColor, attr.getStyle()));
- }
-
- /**
- * Looks up the colorKey in the preference store and adds the style
- * information to list of TextAttributes
- *
- * @param colorKey
- */
- private void addTextAttribute(String colorKey) {
- if (getColorPreferences() != null) {
- String prefString = getColorPreferences().getString(colorKey);
- String[] stylePrefs = ColorHelper
- .unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
- RGB background = ColorHelper.toRGB(stylePrefs[1]);
- boolean bold = Boolean.valueOf(stylePrefs[2]).booleanValue();
- boolean italic = Boolean.valueOf(stylePrefs[3]).booleanValue();
- boolean strikethrough = Boolean.valueOf(stylePrefs[4])
- .booleanValue();
- boolean underline = Boolean.valueOf(stylePrefs[5])
- .booleanValue();
- int style = SWT.NORMAL;
- if (bold) {
- style = style | SWT.BOLD;
- }
- if (italic) {
- style = style | SWT.ITALIC;
- }
- if (strikethrough) {
- style = style | TextAttribute.STRIKETHROUGH;
- }
- if (underline) {
- style = style | TextAttribute.UNDERLINE;
- }
-
- TextAttribute createTextAttribute = createTextAttribute(
- foreground, background, style);
- getTextAttributes().put(colorKey, createTextAttribute);
- }
- }
- }
-
- /**
- * Looks up the colorKey in the preference store and adds the style
- * information to list of TextAttributes
- *
- * @param colorKey
- */
- private void addJavaTextAttribute(String colorKey) {
- IPreferenceStore store = getJavaColorPreferences();
- if (store != null && colorKey != null) {
- TextAttribute ta = null;
- if (colorKey == IStyleConstantsJSPEL.EL_KEYWORD) {
- // keyword
- RGB foreground = PreferenceConverter.getColor(store,
- PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
- boolean bold = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD);
- boolean italics = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC);
- boolean strikethrough = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_STRIKETHROUGH);
- boolean underline = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
- int style = SWT.NORMAL;
- if (bold) {
- style = style | SWT.BOLD;
- }
- if (italics) {
- style = style | SWT.ITALIC;
- }
- if (strikethrough) {
- style = style | TextAttribute.STRIKETHROUGH;
- }
- if (underline) {
- style = style | TextAttribute.UNDERLINE;
- }
-
- ta = createTextAttribute(foreground, null, style);
- } else if (colorKey == IStyleConstantsJSPEL.EL_DEFAULT) {
- // default
- RGB foreground = PreferenceConverter.getColor(store,
- PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR);
- boolean bold = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD);
- boolean italics = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC);
- boolean strikethrough = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_STRIKETHROUGH);
- boolean underline = store
- .getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_UNDERLINE);
- int style = SWT.NORMAL;
- if (bold) {
- style = style | SWT.BOLD;
- }
- if (italics) {
- style = style | SWT.ITALIC;
- }
- if (strikethrough) {
- style = style | TextAttribute.STRIKETHROUGH;
- }
- if (underline) {
- style = style | TextAttribute.UNDERLINE;
- }
-
- ta = createTextAttribute(foreground, null, style);
- }
- if (ta != null) {
- getTextAttributes().put(colorKey, ta);
- fScanner.setTokenData(colorKey, ta);
- }
- }
- }
-
- private TextAttribute createTextAttribute(RGB foreground, RGB background,
- int style) {
- return new TextAttribute((foreground != null) ? EditorUtility
- .getColor(foreground) : null,
- (background != null) ? EditorUtility.getColor(background)
- : null, style);
- }
-
- /**
- * Returns the hashtable containing all the text attributes for this line
- * style provider. Lazily creates a hashtable if one has not already been
- * created.
- *
- * @return
- */
- private HashMap getTextAttributes() {
- if (fTextAttributes == null) {
- fTextAttributes = new HashMap();
- loadColors();
- }
- return fTextAttributes;
- }
-
- /**
- * Returns a text attribute encoded in the given token. If the token's data
- * is not <code>null</code> and a text attribute it is assumed that it is
- * the encoded text attribute. It returns the default text attribute if
- * there is no encoded text attribute found.
- *
- * @param token
- * the token whose text attribute is to be determined
- * @return the token's text attribute
- */
- private TextAttribute getTokenTextAttribute(IToken token) {
- TextAttribute ta = null;
-
- Object data = token.getData();
- if (data instanceof TextAttribute) {
- ta = (TextAttribute) data;
- } else {
- ta = (TextAttribute) getTextAttributes().get(
- IStyleConstantsJSPJava.JAVA_DEFAULT);
- }
- return ta;
- }
-
- public void init(IStructuredDocument document, Highlighter highlighter) {
- fDocument = document;
- fHighlighter = highlighter;
-
- if (fIsInitialized) {
- return;
- }
-
- registerPreferenceListener();
-
- fIsInitialized = true;
- }
-
- private void loadColors() {
- addTextAttribute(IStyleConstantsHTML.SCRIPT_AREA_BORDER);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
-
- addJavaTextAttribute(IStyleConstantsJSPJava.JAVA_KEYWORD);
- addJavaTextAttribute(IStyleConstantsJSPJava.JAVA_DEFAULT);
-
- fScanner.initializeRules();
- }
-
- protected void handlePropertyChange(PropertyChangeEvent event) {
- String styleKey = null;
- String javaStyleKey = null;
-
- if (event != null) {
- String prefKey = event.getProperty();
- // check if preference changed is a style preference
- if (IStyleConstantsHTML.SCRIPT_AREA_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsHTML.SCRIPT_AREA_BORDER;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_NAME;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_VALUE;
- } else if (PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR
- .equals(prefKey)
- || (PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD
- .equals(prefKey))
- || (PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC
- .equals(prefKey))) {
- javaStyleKey = IStyleConstantsJSPEL.EL_KEYWORD;
- } else if (PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR
- .equals(prefKey)
- || (PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD
- .equals(prefKey))
- || (PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC
- .equals(prefKey))) {
- javaStyleKey = IStyleConstantsJSPEL.EL_DEFAULT;
- }
- }
-
- if (styleKey != null) {
- // overwrite style preference with new value
- addTextAttribute(styleKey);
- }
- if (javaStyleKey != null) {
- // overwrite style preference with new value
- addJavaTextAttribute(javaStyleKey);
- fScanner.initializeRules();
- }
- if (styleKey != null || javaStyleKey != null) {
- // force a full update of the text viewer
- fHighlighter.refreshDisplay();
- }
- }
-
- public boolean prepareRegions(ITypedRegion typedRegion,
- int ssssrequestedStart, int ssssrequestedLength,
- Collection holdResults) {
- boolean result = true;
- try {
- // ideally, eventually, we'll have a "virtualDocument" we can
- // refer to, but for now ... we'll simple rescan the one region.
- // use simple adjustment (since "sub-content" starts at 0
- int offsetAdjustment = typedRegion.getOffset();
- String content = fDocument.get(typedRegion.getOffset(), typedRegion
- .getLength());
- IDocument document = new Document(content);
-
- int lastStart = 0;
- int length = 0;
- IToken lastToken = Token.UNDEFINED;
-
- int remainingLength = typedRegion.getLength();
- fScanner.setRange(document, lastStart, remainingLength);
-
- while (true) {
-
- IToken token = fScanner.nextToken();
-
- if (token.isEOF()) {
- if (!lastToken.isUndefined() && length != 0) {
- addRange(holdResults, lastStart + offsetAdjustment,
- length, getTokenTextAttribute(lastToken));
- }
- break;
- }
-
- if (token.isWhitespace()) {
- length += fScanner.getTokenLength();
- continue;
- }
-
- if (lastToken.isUndefined()) {
- lastToken = token;
- length += fScanner.getTokenLength();
- continue;
- }
-
- if (token != lastToken) {
- addRange(holdResults, lastStart + offsetAdjustment, length,
- getTokenTextAttribute(lastToken));
- lastToken = token;
- lastStart = fScanner.getTokenOffset();
- length = fScanner.getTokenLength();
- continue;
- }
-
- length += fScanner.getTokenLength();
- }
- } catch (BadLocationException e) {
- // shouldn't happen, but we don't want it to stop other
- // highlighting, if it does.
- result = false;
- }
- return result;
- }
-
- private void registerPreferenceListener() {
- getColorPreferences().addPropertyChangeListener(fPreferenceListener);
- getJavaColorPreferences()
- .addPropertyChangeListener(fPreferenceListener);
- }
-
- public void release() {
- unRegisterPreferenceManager();
- if (fTextAttributes != null) {
- fTextAttributes.clear();
- fTextAttributes = null;
- }
- }
-
- private void unRegisterPreferenceManager() {
- getColorPreferences().removePropertyChangeListener(fPreferenceListener);
- getJavaColorPreferences().removePropertyChangeListener(
- fPreferenceListener);
- }
-
- private IPreferenceStore getColorPreferences() {
- return JSPUIPlugin.getDefault().getPreferenceStore();
- }
-
- private IPreferenceStore getJavaColorPreferences() {
- return PreferenceConstants.getPreferenceStore();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
index 213f7bd..9caff13 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
@@ -161,7 +161,7 @@
* int)
*/
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- return JavaWordFinder.findWord(textViewer.getDocument(), offset);
+ return JsWordFinder.findWord(textViewer.getDocument(), offset);
}
private String getInfoText(IJavaElement member) {
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPInformationProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPInformationProvider.java
deleted file mode 100644
index c7db364..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPInformationProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.taginfo;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-
-/**
- * Provides context help for JSP tags (Show tooltip description)
- */
-public class JSPInformationProvider implements IInformationProvider,
- IInformationProviderExtension {
- private ITextHover fTextHover = null;
-
- public JSPInformationProvider() {
- fTextHover = SSEUIPlugin.getDefault().getTextHoverManager()
- .createBestMatchHover(new JSPTagInfoHoverProcessor());
- }
-
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- return fTextHover.getHoverRegion(textViewer, offset);
- }
-
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return (String) getInformation2(textViewer, subject);
- }
-
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- return fTextHover.getHoverInfo(textViewer, subject);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPTagInfoHoverProcessor.java
deleted file mode 100644
index e688502..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSPTagInfoHoverProcessor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.taginfo;
-
-import org.eclipse.wst.jsdt.web.core.internal.regions.DOMJSPRegionContexts;
-import org.eclipse.wst.html.ui.internal.taginfo.HTMLTagInfoHoverProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-/**
- * Provides hover help documentation for JSP tags
- */
-public class JSPTagInfoHoverProcessor extends HTMLTagInfoHoverProcessor {
-
- @Override
- protected String computeRegionHelp(IndexedRegion treeNode,
- IDOMNode parentNode, IStructuredDocumentRegion flatNode,
- ITextRegion region) {
- String result = null;
-
- if (region == null) {
- return null;
- }
-
- String regionType = region.getType();
- if (regionType == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
- result = computeJSPDirHelp((IDOMNode) treeNode, parentNode,
- flatNode, region);
- } else {
- result = super.computeRegionHelp(treeNode, parentNode, flatNode,
- region);
- }
-
- return result;
- }
-
- /**
- * Computes the hover help for the jsp directive name for now, treat jsp
- * directives like any other tag name
- */
- protected String computeJSPDirHelp(IDOMNode xmlnode, IDOMNode parentNode,
- IStructuredDocumentRegion flatNode, ITextRegion region) {
- return computeTagNameHelp(xmlnode, parentNode, flatNode, region);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JavaWordFinder.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java
similarity index 98%
rename from bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JavaWordFinder.java
rename to bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java
index 9e97fd6..20a851f 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JavaWordFinder.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java
@@ -18,7 +18,7 @@
/**
* Copied from org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder
*/
-class JavaWordFinder {
+class JsWordFinder {
public static IRegion findWord(IDocument document, int offset) {
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/EncodingTemplateVariableResolverJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/EncodingTemplateVariableResolverJSP.java
deleted file mode 100644
index 53e9681..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/EncodingTemplateVariableResolverJSP.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.wst.jsdt.web.core.internal.JSPCorePlugin;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-
-public class EncodingTemplateVariableResolverJSP extends
- SimpleTemplateVariableResolver {
- private static final String ENCODING_TYPE = getEncodingType();
-
- private static String getEncodingType() {
- return "encoding"; //$NON-NLS-1$
- }
-
- /**
- * Creates a new encoding variable
- */
- public EncodingTemplateVariableResolverJSP() {
- super(ENCODING_TYPE, JSPUIMessages.Creating_files_encoding);
- }
-
- @Override
- protected String resolve(TemplateContext context) {
- return JSPCorePlugin.getDefault().getPluginPreferences().getString(
- CommonEncodingPreferenceNames.OUTPUT_CODESET);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeIdsJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeIdsJSP.java
deleted file mode 100644
index 3f2bfbe..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeIdsJSP.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.templates;
-
-public class TemplateContextTypeIdsJSP {
-
- 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 getPrefix() {
- return "jsp"; //$NON-NLS-1$
- }
-
- private static String getTag() {
- return getPrefix() + "_tag"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeJSP.java
deleted file mode 100644
index 0d09cbf..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/templates/TemplateContextTypeJSP.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.GlobalTemplateVariables;
-import org.eclipse.jface.text.templates.TemplateContextType;
-
-/**
- * Base class for JSP template context types. Templates of this context type
- * apply to any place within JSP content type.
- */
-public class TemplateContextTypeJSP extends TemplateContextType {
- public TemplateContextTypeJSP() {
- super();
- addResolver(new GlobalTemplateVariables.Cursor());
- addResolver(new GlobalTemplateVariables.Date());
- addResolver(new GlobalTemplateVariables.Dollar());
- addResolver(new GlobalTemplateVariables.LineSelection());
- addResolver(new GlobalTemplateVariables.Time());
- addResolver(new GlobalTemplateVariables.User());
- addResolver(new GlobalTemplateVariables.WordSelection());
- addResolver(new GlobalTemplateVariables.Year());
- addResolver(new EncodingTemplateVariableResolverJSP());
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPFileWizardPage.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPFileWizardPage.java
deleted file mode 100644
index 45129ab..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPFileWizardPage.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.wizard;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.jsdt.core.JavaCore;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.wst.jsdt.web.core.internal.JSPCorePlugin;
-import org.eclipse.wst.jsdt.web.core.internal.preferences.JSPCorePreferenceNames;
-import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForJSP;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.Logger;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-class NewJSPFileWizardPage extends WizardNewFileCreationPage {
-
- private IContentType fContentType;
- private List fValidExtensions = null;
-
- public NewJSPFileWizardPage(String pageName, IStructuredSelection selection) {
- super(pageName, selection);
- }
-
- /**
- * This method is overriden to set the selected folder to web contents
- * folder if the current selection is outside the web contents folder.
- */
- @Override
- protected void initialPopulateContainerNameField() {
- super.initialPopulateContainerNameField();
-
- IPath fullPath = getContainerFullPath();
- IProject project = getProjectFromPath(fullPath);
- IPath webContentPath = getWebContentPath(project);
-
- if (webContentPath != null && !webContentPath.isPrefixOf(fullPath)) {
- setContainerFullPath(webContentPath);
- }
- }
-
- /**
- * This method is overriden to set additional validation specific to jsp
- * files.
- */
- @Override
- protected boolean validatePage() {
- setMessage(null);
- setErrorMessage(null);
-
- if (!super.validatePage()) {
- return false;
- }
-
- String fileName = getFileName();
- IPath fullPath = getContainerFullPath();
- if ((fullPath != null) && (fullPath.isEmpty() == false)
- && (fileName != null)) {
- // check that filename does not contain invalid extension
- if (!extensionValidForContentType(fileName)) {
- setErrorMessage(NLS.bind(
- JSPUIMessages._ERROR_FILENAME_MUST_END_JSP,
- getValidExtensions().toString()));
- return false;
- }
- // no file extension specified so check adding default
- // extension doesn't equal a file that already exists
- if (fileName.lastIndexOf('.') == -1) {
- String newFileName = addDefaultExtension(fileName);
- IPath resourcePath = fullPath.append(newFileName);
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IStatus result = workspace.validatePath(
- resourcePath.toString(), IResource.FOLDER);
- if (!result.isOK()) {
- // path invalid
- setErrorMessage(result.getMessage());
- return false;
- }
-
- if ((workspace.getRoot().getFolder(resourcePath).exists() || workspace
- .getRoot().getFile(resourcePath).exists())) {
- setErrorMessage(JSPUIMessages.ResourceGroup_nameExists);
- return false;
- }
- }
-
- // get the IProject for the selection path
- IProject project = getProjectFromPath(fullPath);
- if (project != null) {
- if (!isJavaProject(project)) {
- setMessage(
- JSPUIMessages._WARNING_FILE_MUST_BE_INSIDE_JAVA_PROJECT,
- WARNING);
- }
- // if inside web project, check if inside webContent folder
- if (isDynamicWebProject(project)) {
- // check that the path is inside the webContent folder
- IPath webContentPath = getWebContentPath(project);
- if (!webContentPath.isPrefixOf(fullPath)) {
- setMessage(
- JSPUIMessages._WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT,
- WARNING);
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Adds default extension to the filename
- *
- * @param filename
- * @return
- */
- String addDefaultExtension(String filename) {
- StringBuffer newFileName = new StringBuffer(filename);
-
- Preferences preference = JSPCorePlugin.getDefault()
- .getPluginPreferences();
- String ext = preference
- .getString(JSPCorePreferenceNames.DEFAULT_EXTENSION);
-
- newFileName.append("."); //$NON-NLS-1$
- newFileName.append(ext);
-
- return newFileName.toString();
- }
-
- /**
- * Get content type associated with this new file wizard
- *
- * @return IContentType
- */
- private IContentType getContentType() {
- if (fContentType == null) {
- fContentType = Platform.getContentTypeManager().getContentType(
- ContentTypeIdForJSP.ContentTypeID_JSP);
- }
- return fContentType;
- }
-
- /**
- * Get list of valid extensions for JSP Content type
- *
- * @return
- */
- private List getValidExtensions() {
- if (fValidExtensions == null) {
- IContentType type = getContentType();
- fValidExtensions = new ArrayList(Arrays.asList(type
- .getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
- }
- return fValidExtensions;
- }
-
- /**
- * Verifies if fileName is valid name for content type. Takes base content
- * type into consideration.
- *
- * @param fileName
- * @return true if extension is valid for this content type
- */
- private boolean extensionValidForContentType(String fileName) {
- boolean valid = false;
-
- IContentType type = getContentType();
- // there is currently an extension
- if (fileName.lastIndexOf('.') != -1) {
- // check what content types are associated with current extension
- IContentType[] types = Platform.getContentTypeManager()
- .findContentTypesFor(fileName);
- int i = 0;
- while (i < types.length && !valid) {
- valid = types[i].isKindOf(type);
- ++i;
- }
- } else {
- valid = true; // no extension so valid
- }
- return valid;
- }
-
- /**
- * Returns the project that contains the specified path
- *
- * @param path
- * the path which project is needed
- * @return IProject object. If path is <code>null</code> the return value
- * is also <code>null</code>.
- */
- private IProject getProjectFromPath(IPath path) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProject project = null;
-
- if (path != null) {
- if (workspace.validatePath(path.toString(), IResource.PROJECT)
- .isOK()) {
- project = workspace.getRoot().getProject(path.toString());
- } else {
- project = workspace.getRoot().getFile(path).getProject();
- }
- }
-
- return project;
- }
-
- /**
- * Checks if the specified project is a web project.
- *
- * @param project
- * project to be checked
- * @return true if the project is web project, otherwise false
- */
- private boolean isDynamicWebProject(IProject project) {
- IFacetedProject faceted = null;
- try {
- faceted = ProjectFacetsManager.create(project);
- } catch (CoreException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- if (faceted != null
- && faceted.hasProjectFacet(ProjectFacetsManager
- .getProjectFacet(IModuleConstants.JST_WEB_MODULE))) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if the specified project is a type of java project.
- *
- * @param project
- * project to be checked (cannot be null)
- * @return true if the project is a type of java project, otherwise false
- */
- private boolean isJavaProject(IProject project) {
- boolean isJava = false;
- try {
- isJava = project.hasNature(JavaCore.NATURE_ID);
- } catch (CoreException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- return isJava;
- }
-
- /**
- * Returns the web contents folder of the specified project
- *
- * @param project
- * the project which web contents path is needed
- * @return IPath of the web contents folder
- */
- private IPath getWebContentPath(IProject project) {
- IPath path = null;
-
- if (project != null && isDynamicWebProject(project)) {
- IVirtualComponent component = ComponentCore
- .createComponent(project);
- path = component.getRootFolder().getWorkspaceRelativePath();
- }
-
- return path;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPTemplatesWizardPage.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPTemplatesWizardPage.java
deleted file mode 100644
index e18a24b..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPTemplatesWizardPage.java
+++ /dev/null
@@ -1,525 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.wizard;
-
-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.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForJSP;
-import org.eclipse.wst.jsdt.web.ui.StructuredTextViewerConfigurationJSP;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.jsdt.web.ui.internal.Logger;
-import org.eclipse.wst.jsdt.web.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.jsdt.web.ui.internal.preferences.JSPUIPreferenceNames;
-import org.eclipse.wst.jsdt.web.ui.internal.templates.TemplateContextTypeIdsJSP;
-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.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;
-
-/**
- * Templates page in new file wizard. Allows users to select a new file template
- * to be applied in new file.
- *
- */
-public class NewJSPTemplatesWizardPage extends WizardPage {
-
- /**
- * Content provider for templates
- */
- private class TemplateContentProvider implements IStructuredContentProvider {
- /** The template store. */
- private TemplateStore fStore;
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- fStore = null;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object input) {
- return fStore.getTemplates(TemplateContextTypeIdsJSP.NEW);
- }
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- 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 NewJSPTemplatesWizardPage() {
- super(
- "NewJSPTemplatesWizardPage", JSPUIMessages.NewJSPTemplatesWizardPage_0, null); //$NON-NLS-1$
- setDescription(JSPUIMessages.NewJSPTemplatesWizardPage_1);
- }
-
- /**
- * 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() {
- @Override
- 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 JSP Template
- fUseTemplateButton = new Button(parent, SWT.CHECK);
- fUseTemplateButton.setText(JSPUIMessages.NewJSPTemplatesWizardPage_4);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
- fUseTemplateButton.setLayoutData(data);
- fUseTemplateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- 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);
-
- // Create linked text to just to templates preference page
- Link link = new Link(innerParent, SWT.NONE);
- link.setText(JSPUIMessages.NewJSPTemplatesWizardPage_6);
- data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
- link.setLayoutData(data);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- linkClicked();
- }
- });
-
- // 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(JSPUIMessages.NewJSPTemplatesWizardPage_2);
-
- TableColumn column2 = new TableColumn(table, SWT.NONE);
- column2.setText(JSPUIMessages.NewJSPTemplatesWizardPage_3);
-
- fTableViewer = new TableViewer(table);
- fTableViewer.setLabelProvider(new TemplateLabelProvider());
- fTableViewer.setContentProvider(new TemplateContentProvider());
-
- fTableViewer.setSorter(new ViewerSorter() {
- @Override
- 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);
- }
-
- @Override
- 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 = JSPUIPlugin.getDefault().getTemplateStore();
- fTableViewer.setInput(fTemplateStore);
-
- configureTableResizing(innerParent, table, column1, column2);
- loadLastSavedPreferences();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
- IHelpContextIds.JSP_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 StructuredTextViewerConfigurationJSP();
-
- @Override
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return baseConfiguration
- .getConfiguredContentTypes(sourceViewer);
- }
-
- @Override
- 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(
- ContentTypeIdForJSP.ContentTypeID_JSP);
- 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(JSPUIMessages.NewJSPTemplatesWizardPage_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);
- 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.eclipse.wst.sse.ui.preferences.jsp.templates"; //$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 = JSPUIPlugin.getDefault()
- .getTemplateContextRegistry().getContextType(
- TemplateContextTypeIdsJSP.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) {
- Logger.log(Logger.WARNING_DEBUG,
- "Could not create template for new jsp", 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 JSP File wizard.
- */
- private void loadLastSavedPreferences() {
- String templateName = JSPUIPlugin.getDefault().getPreferenceStore()
- .getString(JSPUIPreferenceNames.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 JSP File wizard.
- */
- void saveLastSavedPreferences() {
- String templateName = ""; //$NON-NLS-1$
-
- Template template = getSelectedTemplate();
- if (template != null) {
- templateName = template.getName();
- }
-
- JSPUIPlugin.getDefault().getPreferenceStore().setValue(
- JSPUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
- JSPUIPlugin.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,
- TemplateContextTypeIdsJSP.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$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPWizard.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPWizard.java
deleted file mode 100644
index 66c8406..0000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/wizard/NewJSPWizard.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.wizard;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.wst.jsdt.web.core.internal.JSPCorePlugin;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.Logger;
-import org.eclipse.wst.jsdt.web.ui.internal.editor.JSPEditorPluginImageHelper;
-import org.eclipse.wst.jsdt.web.ui.internal.editor.JSPEditorPluginImages;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-
-public class NewJSPWizard extends Wizard implements INewWizard {
- private NewJSPFileWizardPage fNewFilePage;
- private NewJSPTemplatesWizardPage fNewFileTemplatesPage;
- private IStructuredSelection fSelection;
-
- @Override
- public void addPages() {
- fNewFilePage = new NewJSPFileWizardPage(
- "JSPWizardNewFileCreationPage", new StructuredSelection(IDE.computeSelectedResources(fSelection))); //$NON-NLS-1$
- fNewFilePage.setTitle(JSPUIMessages._UI_WIZARD_NEW_HEADING);
- fNewFilePage.setDescription(JSPUIMessages._UI_WIZARD_NEW_DESCRIPTION);
- addPage(fNewFilePage);
-
- fNewFileTemplatesPage = new NewJSPTemplatesWizardPage();
- addPage(fNewFileTemplatesPage);
- }
-
- public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
- fSelection = aSelection;
- setWindowTitle(JSPUIMessages._UI_WIZARD_NEW_TITLE);
-
- ImageDescriptor descriptor = JSPEditorPluginImageHelper.getInstance()
- .getImageDescriptor(
- JSPEditorPluginImages.IMG_OBJ_WIZBAN_NEWJSPFILE);
- setDefaultPageImageDescriptor(descriptor);
- }
-
- 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) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- });
- }
- }
-
- @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 = fNewFilePage.addDefaultExtension(fileName);
- 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) {
- // determine the encoding for the new file
- Preferences preference = JSPCorePlugin.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) {
- Logger.log(Logger.WARNING_DEBUG,
- "Could not create contents for new JSP file", e); //$NON-NLS-1$
- }
- }
-
- // open the file in editor
- openEditor(file);
-
- // everything's fine
- performedOK = true;
- }
- return performedOK;
- }
-
-}
\ No newline at end of file