diff options
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.web.ui/src')
99 files changed, 0 insertions, 10232 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java deleted file mode 100644 index 3c7655f2f6..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java deleted file mode 100644 index 298210c003..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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; - -import java.lang.reflect.InvocationTargetException; -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.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.dialogs.PreferencesUtil; -import org.eclipse.ui.progress.IProgressService; -import org.eclipse.wst.jsdt.core.IIncludePathEntry; -import org.eclipse.wst.jsdt.core.IJavaScriptProject; -import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin; - -/** - * Not API - */ -public class SetupProjectsWizzard implements IObjectActionDelegate, IActionDelegate { - IWorkbenchPart fPart; - Object[] fTarget; - - private void doInstall(IProject project, final boolean openProperties, IProgressMonitor monitor) { - boolean configured = false; - JsWebNature nature = new JsWebNature(project, monitor); - try { - boolean hadBasicNature = JsWebNature.hasNature(project); - - nature.configure(); - - if (!hadBasicNature) { - /* - * No nature before, so no existing build path. Define the - * project itself as an include folder. - */ - IJavaScriptProject jp = JavaScriptCore.create(project); - IIncludePathEntry[] oldEntries = null; - try { - oldEntries = jp.getRawIncludepath(); - } - catch (JavaScriptModelException ex1) { - Logger.log(Logger.ERROR_DEBUG, null, ex1); - } - - IPath projectPath = project.getFullPath(); - IIncludePathEntry projectPathEntry = JavaScriptCore.newSourceEntry(projectPath); - - if (! Arrays.asList(oldEntries).contains(projectPathEntry)) { - IIncludePathEntry[] newEntries = new IIncludePathEntry[oldEntries.length + 1]; - System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length); - - newEntries[oldEntries.length] = projectPathEntry; - jp.setRawIncludepath(newEntries, monitor); - } - } - configured = true; - } - catch (CoreException ex) { - Logger.logException(ex); - } - - if (configured && openProperties) { - showPropertiesOn(project, monitor); - } - } - - private void doUninstall(IProject project, IProgressMonitor monitor) { - JsWebNature nature = new JsWebNature(project, monitor); - try { - nature.deconfigure(); - } catch (CoreException ex) { - Logger.logException(ex); - } - } - - private void install(final IProject project, final boolean openProperties) { - IProgressService service = null; - if (fPart != null) { - service = (IProgressService) fPart.getSite().getService(IProgressService.class); - } - if (service == null) { - doInstall(project, openProperties, null); - } - else { - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - doInstall(project, openProperties, monitor); - } - }; - try { - service.run(false, false, runnable); - } - catch (InvocationTargetException e) { - Logger.logException(e); - } - catch (InterruptedException e) { - Logger.logException(e); - } - } - } - - public void run(IAction action) { - if (fTarget == null) - return; - - for (int i = 0; i < fTarget.length; i++) { - if (fTarget[i] instanceof IResource) { - final IProject project = ((IResource) fTarget[i]).getProject(); - - if (!JsWebNature.hasNature(project)) { - /* Doesn't have nature, do a full install. */ - install(project, i == fTarget.length - 1); - } - else { - /* - * Has nature, check for browser library on include path - * and setup if not found. - */ - IJavaScriptProject jp = JavaScriptCore.create(project); - IIncludePathEntry[] rawClasspath = null; - try { - rawClasspath = jp.getRawIncludepath(); - } - catch (JavaScriptModelException ex1) { - Logger.log(Logger.ERROR_DEBUG, null, ex1); - } - - boolean browserFound = false; - for (int k = 0; rawClasspath != null && !browserFound && k < rawClasspath.length; k++) { - if (rawClasspath[k].getPath().equals(JsWebNature.VIRTUAL_BROWSER_CLASSPATH)) { - browserFound = true; - } - } - if (!browserFound) { - install(project, false); - } - } - } - } - - } - - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof IStructuredSelection) { - fTarget = ((IStructuredSelection) selection).toArray(); - } - else { - fTarget = null; - } - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fPart = targetPart; - } - - private void showPropertiesOn(final IProject project, final IProgressMonitor monitor) { - IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui.propertyPages").getExtensions(); //$NON-NLS-1$ - final List pageIds = new ArrayList(8); - for (int i = 0; i < extensions.length; i++) { - if (extensions[i].getNamespaceIdentifier().startsWith("org.eclipse.wst.jsdt.")) { //$NON-NLS-1$ - IConfigurationElement[] configurationElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configurationElements.length; j++) { - if ("page".equals(configurationElements[j].getName())) { - pageIds.add(configurationElements[j].getAttribute("id")); //$NON-NLS-1$ - } - } - } - } - Shell shell = (Shell) fPart.getAdapter(Shell.class); - if (shell == null) { - IWorkbenchWindow activeWorkbenchWindow = JsUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if (activeWorkbenchWindow != null) - shell = activeWorkbenchWindow.getShell(); - } - final Shell finalShell = shell; - if (finalShell != null) { - finalShell.getDisplay().asyncExec(new Runnable() { - public void run() { - PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(finalShell, project, "org.eclipse.wst.jsdt.ui.propertyPages.BuildPathsPropertyPage", (String[]) pageIds.toArray(new String[pageIds.size()]), null); //$NON-NLS-1$ - if (dialog.open() == Window.CANCEL) { - doUninstall(project, monitor); - } - } - }); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java deleted file mode 100644 index b339576983..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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; - -import org.eclipse.jface.text.formatter.IContentFormatter; -import org.eclipse.jface.text.formatter.MultiPassContentFormatter; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML; -import org.eclipse.wst.jsdt.web.ui.internal.format.FormattingStrategyJSDT; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * Configuration for a source viewer which shows Html and supports JSDT. - * <p> - * Clients can subclass and override just those methods which must be specific - * to their needs. - * </p> - * - * @see org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration - * @since 1.0 - */ -public class StructuredTextViewerConfigurationJSDT extends StructuredTextViewerConfigurationHTML { - /** - * Create new instance of StructuredTextViewerConfigurationHTML - */ - public StructuredTextViewerConfigurationJSDT() { - // Must have empty constructor to createExecutableExtension - super(); - } - - public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { - final IContentFormatter formatter = super.getContentFormatter(sourceViewer); - if(formatter instanceof MultiPassContentFormatter) { - /* - * Check for any externally supported auto edit strategies from EP. - * [Bradley Childs - childsb@us.ibm.com] - */ - String[] contentTypes = getConfiguredContentTypes(sourceViewer); - for (int i = 0; i < contentTypes.length; i++) { - if (IHTMLPartitions.SCRIPT.equals(contentTypes[i]) || IHTMLPartitions.SCRIPT_EVENTHANDLER.equals(contentTypes[i])) { - ((MultiPassContentFormatter) formatter).setSlaveStrategy(new FormattingStrategyJSDT(), contentTypes[i]); - } - } - } - return formatter; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java deleted file mode 100644 index 03aeccebb3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.wst.jsdt.core.IJavaScriptProject; -import org.eclipse.wst.jsdt.internal.ui.IJsGlobalScopeContainerInitializerExtension; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class WebProjectJsGlobalScopeUIInitializer implements IJsGlobalScopeContainerInitializerExtension{ - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.internal.ui.IJsGlobalScopeContainerInitialzerExtension#getImage(org.eclipse.core.runtime.IPath, java.lang.String, org.eclipse.wst.jsdt.core.IJavaScriptProject) - */ - public ImageDescriptor getImage(IPath containerPath, String element, IJavaScriptProject project) { - return ImageDescriptor.createFromFile(this.getClass(),"web1.JPG"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java deleted file mode 100644 index 560444cc64..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IMember; -import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter; -import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class AddJavaDocStubAction implements IObjectActionDelegate { - private ISelection selection; - private IWorkbenchPart targetPart; - - public String getDialogTitle() { - return Messages.getString("AddJavaDocStubAction.0"); //$NON-NLS-1$ - } - - public Shell getShell() { - return getSite().getShell(); - } - - public IWorkbenchPartSite getSite() { - return targetPart.getSite(); - } - - public void run(IAction action) { - IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection); - if (elements == null || elements.length < 1) { - return; - } - IJavaScriptElement parent = elements[0].getParent(); - /* find the cu */ - while (parent != null && !(parent instanceof IJavaScriptUnit)) { - - } - if (parent != null) { - ArrayList members = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - if (elements[i] instanceof IMember) { - members.add(elements[i]); - } - } - JsJfaceNode node[] = SimpleJSDTActionProxy.getJsJfaceNodesFromSelection(selection); - /* only should be one node */ - run((IJavaScriptUnit) parent, (IMember[]) members.toArray(new IMember[members.size()]), node[0]); - } - } - - public void run(IJavaScriptUnit cu, IMember[] members, JsJfaceNode node) { - try { - AddJavaDocStubOperation op = new AddJavaDocStubOperation(members, node); - PlatformUI.getWorkbench().getProgressService().runInUI(PlatformUI.getWorkbench().getProgressService(), new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule()); - } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, getShell(), getDialogTitle(), Messages.getString("AddJavaDocStubAction.1")); //$NON-NLS-1$ - } catch (InterruptedException e) { - // operation canceled - } - } - - public void selectionChanged(IAction action, ISelection selection) { - this.selection = selection; - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - this.targetPart = targetPart; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java deleted file mode 100644 index edde605e85..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.text.edits.MalformedTreeException; -import org.eclipse.text.edits.MultiTextEdit; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.IMember; -import org.eclipse.wst.jsdt.web.core.javascript.DocumentChangeListenerToTextEdit; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; - -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class AddJavaDocStubOperation extends org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddJavaDocStubOperation { - private IDocument copy; - /** - * @param members - */ - private JsJfaceNode node; - private DocumentChangeListenerToTextEdit textEditListener; - - public AddJavaDocStubOperation(IMember[] members, JsJfaceNode node) { - super(members); - this.node = node; - } - - protected void applyChanges() { - IModelManager modelManager = StructuredModelManager.getModelManager(); - IStructuredModel model = null; - IStructuredDocument doc = node.getStructuredDocument(); - try { - MultiTextEdit edits = textEditListener.getTextEdits(); - model = modelManager.getExistingModelForEdit(doc); - model.aboutToChangeModel(); - model.beginRecording(this, Messages.getString("AddJavaDocStubOperation.0"), Messages.getString("AddJavaDocStubOperation.1")); //$NON-NLS-1$ //$NON-NLS-2$ - edits.apply(doc); - } catch (MalformedTreeException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (BadLocationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } finally { - if (model != null) { - model.endRecording(this); - model.changedModel(); - model.releaseFromEdit(); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddJavaDocStubOperation#getDocument(org.eclipse.wst.jsdt.core.IJavaScriptUnit, - * org.eclipse.core.runtime.IProgressMonitor) - */ - - protected IDocument getDocument(IJavaScriptUnit cu, IProgressMonitor monitor) throws CoreException { - return getJavaDocumentFromNode(); - } - - protected IDocument getJavaDocumentFromNode() { - if (copy == null) { - IJsTranslation tran = node.getTranslation(); - copy = new Document(tran.getJsText()); - textEditListener = new DocumentChangeListenerToTextEdit(); - copy.addDocumentListener(textEditListener); - } - return copy; - } - - - public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { - super.run(monitor); - applyChanges(); - /* need to apply the text edits back to the original doc */ - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java deleted file mode 100644 index 28a4c705a4..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class FindReferencesAction extends JsElementActionProxy { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgs(org.eclipse.jface.action.IAction) - */ - - public Object[] getRunArgs(IAction action) { - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements != null && elements.length > 0) { - return new Object[] { elements[0] }; - } - return new Object[0]; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgTypes() - */ - - public Class[] getRunArgTypes() { - return new Class[] { IJavaScriptElement.class }; - } - - - public void selectionChanged(IAction action, ISelection selection) { - setSelection(selection); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java deleted file mode 100644 index 0c8f424f86..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class FindReferencesInWorkingSetAction extends FindReferencesAction { - - public void run(IAction action) { - try { - Object handler = getActionHandler(action); - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements == null || elements.length == 0) { - return; - } - SimpleJSDTActionProxy.executeMethod(handler, "run", new Class[] { IJavaScriptElement.class }, new Object[] { elements[0] }); //$NON-NLS-1$ - } catch (IllegalArgumentException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (SecurityException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (IllegalAccessException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (NoSuchMethodException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InstantiationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InvocationTargetException ex) { - // If user doesn't select a working set an exception is thrown so we - // wont print stack trace here - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java deleted file mode 100644 index 00771faad8..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class JsElementActionProxy extends SimpleJSDTActionProxy { - /* Util method to get all the java elements in a selection */ - public static IJavaScriptElement[] getJsElementsFromSelection(ISelection selection) { - if (selection == null) { - return new IJavaScriptElement[0]; - } - ArrayList elements = new ArrayList(); - if (selection instanceof IStructuredSelection) { - Iterator itt = ((IStructuredSelection) selection).iterator(); - while (itt.hasNext()) { - Object element = itt.next(); - if (element instanceof IJavaScriptElement) { - elements.add(element); - } - if (element instanceof IJavaWebNode) { - elements.add(((IJavaWebNode) element).getJavaElement()); - } - } - return (IJavaScriptElement[]) elements.toArray(new IJavaScriptElement[elements.size()]); - } - return new IJavaScriptElement[0]; - } - - - public Object[] getRunArgs(IAction action) { - /* - * Needs to return an array of IJavaElements. Since its one arg of type - * IJavaScriptElement[] need to put into an object array - */ - return new Object[] { JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()) }; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.SimpleJSDTActionProxy#getRunArgTypes() - */ - - public Class[] getRunArgTypes() { - return new Class[] { (new IJavaScriptElement[0]).getClass() }; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java deleted file mode 100644 index 0bfa17b330..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.actions; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.actions.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java deleted file mode 100644 index 06083a323f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class OpenCallHierarchyAction extends JsElementActionProxy { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.SimpleJSDTActionProxy#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - - public void selectionChanged(IAction action, ISelection selection) { - IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection); - /* Open call hierarchy needs to be disabled for TYPEs */ - for (int i = 0; i < elements.length; i++) { - if (elements[i].getElementType() == IJavaScriptElement.TYPE) { - action.setEnabled(false); - return; - } - } - super.selectionChanged(action, selection); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java deleted file mode 100644 index 405a4c6d48..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class OpenTypeHierarchy extends JsElementActionProxy { - - public void selectionChanged(IAction action, ISelection selection) { - IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection); - /* Open call hierarchy needs to be disabled for TYPEs */ - for (int i = 0; i < elements.length; i++) { - if (elements[i].getElementType() != IJavaScriptElement.TYPE) { - action.setEnabled(false); - return; - } - } - super.selectionChanged(action, selection); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java deleted file mode 100644 index 678c02f444..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class ShowHistoryAction extends JsElementActionProxy { - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - private IResource getHostResource(IJavaScriptElement virtualElement) { - IProject project = virtualElement.getJavaScriptProject().getProject(); - IPath path = new Path(virtualElement.getHostPath().getPath()); - IResource host = project.getWorkspace().getRoot().findMember(path); - return host; - } - - - public void run(IAction action) { - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements == null || elements.length == 0) { - return; - } - IResource resource = null; - if (elements[0].isVirtual()) { - resource = getHostResource(elements[0]); - } else { - resource = elements[0].getResource(); - } - if (resource == null) { - return; - } - try { - IWorkbenchPage page = targetWorkbenchPart.getSite().getPage(); - IViewPart view = page.showView(IPageLayout.ID_RES_NAV); - if (view instanceof ISetSelectionTarget) { - ISelection selection = new StructuredSelection(resource); - ((ISetSelectionTarget) view).selectReveal(selection); - } - } catch (PartInitException e) { - ExceptionHandler.handle(e, targetWorkbenchPart.getSite().getShell(), Messages.getString("ShowHistoryAction.0"), Messages.getString("ShowHistoryAction.1") + e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - - public void selectionChanged(IAction action, ISelection selection) { - setSelection(selection); - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - for (int i = 0; i < elements.length; i++) { - if (elements[i].isVirtual()) { - IResource resource = getHostResource(elements[i]); - if (resource == null || !resource.exists()) { - action.setEnabled(false); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java deleted file mode 100644 index 628b942632..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class ShowInNavigatorAction extends JsElementActionProxy { - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - private IResource getHostResource(IJavaScriptElement virtualElement) { - IProject project = virtualElement.getJavaScriptProject().getProject(); - IPath path = new Path(virtualElement.getHostPath().getPath()); - IResource host = project.getWorkspace().getRoot().findMember(path); - return host; - } - - - public void run(IAction action) { - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements == null || elements.length == 0) { - return; - } - IResource resource = null; - if (elements[0].isVirtual()) { - resource = getHostResource(elements[0]); - } else { - resource = elements[0].getResource(); - } - if (resource == null) { - return; - } - try { - IWorkbenchPage page = targetWorkbenchPart.getSite().getPage(); - IViewPart view = page.showView(IPageLayout.ID_RES_NAV); - if (view instanceof ISetSelectionTarget) { - ISelection selection = new StructuredSelection(resource); - ((ISetSelectionTarget) view).selectReveal(selection); - } - } catch (PartInitException e) { - ExceptionHandler.handle(e, targetWorkbenchPart.getSite().getShell(), Messages.getString("ShowInNavigatorAction.0"), Messages.getString("ShowInNavigatorAction.1") + e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - - public void selectionChanged(IAction action, ISelection selection) { - setSelection(selection); - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - for (int i = 0; i < elements.length; i++) { - if (elements[i].isVirtual()) { - IResource resource = getHostResource(elements[i]); - if (resource == null || !resource.exists()) { - action.setEnabled(false); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java deleted file mode 100644 index 799ea1f01d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class ShowInScriptExplorerAction extends JsElementActionProxy { - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - private IResource getHostResource(IJavaScriptElement virtualElement) { - IProject project = virtualElement.getJavaScriptProject().getProject(); - IPath path = new Path(virtualElement.getHostPath().getPath()); - IResource host = project.getWorkspace().getRoot().findMember(path); - return host; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgs(org.eclipse.jface.action.IAction) - */ - - public Object[] getRunArgs(IAction action) { - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements != null && elements.length > 0) { - return new Object[] { elements[0] }; - } - return new Object[0]; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgTypes() - */ - - public Class[] getRunArgTypes() { - return new Class[] { IJavaScriptElement.class }; - } - - - public void run(IAction action) { - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - if (elements == null || elements.length == 0) { - return; - } - IResource resource = null; - if (elements[0].isVirtual()) { - resource = getHostResource(elements[0]); - } else { - resource = elements[0].getResource(); - } - if (resource == null) { - return; - } - try { - PackageExplorerPart view = PackageExplorerPart.openInActivePerspective(); - view.tryToReveal(resource); -// IWorkbenchPage page= targetWorkbenchPart.getSite().getPage(); -// IViewPart view= page.showView(IPageLayout.ID_RES_NAV); - if (view instanceof ISetSelectionTarget) { - ISelection selection = new StructuredSelection(resource); - ((ISetSelectionTarget) view).selectReveal(selection); - } - } catch (Exception e) { - // ExceptionHandler.handle(e, - // targetWorkbenchPart.getSite().getShell(), "Error Opening in - // Script View", "Error while displaying element in Script View:\n" - // + e); - } - } - - - public void selectionChanged(IAction action, ISelection selection) { - setSelection(selection); - IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()); - for (int i = 0; i < elements.length; i++) { - if (elements[i].isVirtual()) { - IResource resource = getHostResource(elements[i]); - if (resource == null || !resource.exists()) { - action.setEnabled(false); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java deleted file mode 100644 index 3d24b703fa..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.actions; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class SimpleJSDTActionProxy implements IObjectActionDelegate { - public static Object executeMethod(Object handler, String methodName, Class[] paramaterTypes, Object[] paramaterValues) throws SecurityException, - NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { - Class target = handler.getClass(); - Method m = target.getMethod(methodName, paramaterTypes); - return m.invoke(handler, paramaterValues); - } - - public static JsJfaceNode[] getJsJfaceNodesFromSelection(ISelection selection) { - if (selection == null) { - return new JsJfaceNode[0]; - } - ArrayList elements = new ArrayList(); - if (selection instanceof IStructuredSelection) { - Iterator itt = ((IStructuredSelection) selection).iterator(); - while (itt.hasNext()) { - Object element = itt.next(); - if (element instanceof JsJfaceNode) { - elements.add(element); - } - } - return (JsJfaceNode[]) elements.toArray(new JsJfaceNode[elements.size()]); - } - return new JsJfaceNode[0]; - } - protected Object actionHandlerTarget; - private ISelection currentSelection; - protected IAction handlerTargetAction; - protected IWorkbenchPart targetWorkbenchPart; - - public SimpleJSDTActionProxy() {} - - /* - * Most handlers look for WorkBenchSite, so we convert the WorkBenchPart to - * WorkBenchSite for init - */ - protected Object getActionHandler(IAction action) throws IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InstantiationException, - InvocationTargetException { - /* Target class is cached */ - if (handlerTargetAction == action && actionHandlerTarget != null) { - return actionHandlerTarget; - } - Class target = null; - String className = getActionHandlerClassName(action); - try { - target = Class.forName(className); - } catch (ClassNotFoundException ex) { - System.out.println("Error.. Class target of action handler not found: " + action); - System.out.println(Messages.getString("SimpleJSDTActionProxy.0") + ex); //$NON-NLS-1$ - } - // use the loaded class - Class[] types = new Class[] { IWorkbenchSite.class }; - Constructor cons = target.getConstructor(types); - Object[] args = new Object[] { targetWorkbenchPart.getSite() }; - - actionHandlerTarget = cons.newInstance(args); - handlerTargetAction = action; - return actionHandlerTarget; - } - - /* - * Default way of determining the action handlers class name.. may be - * subclassed/overridden - */ - protected String getActionHandlerClassName(IAction action) { - return action.getId(); - } - - public ISelection getCurrentSelection() { - return currentSelection; - } - - public Object[] getRunArgs(IAction action) { - return new Object[] { getCurrentSelection() }; - } - - public Class[] getRunArgTypes() { - return new Class[] { IStructuredSelection.class }; - } - - public Object[] getSelectionChangeArgs(IAction action, ISelection selection) { - return new Object[] { getCurrentSelection() }; - } - - public Class[] getSelectionChangeArgTypes() { - return new Class[] { IStructuredSelection.class }; - } - - /* - * Generic reflection util method to execute a named method with unknown - * paramaters on an object - */ - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - try { - Object handler = getActionHandler(action); - SimpleJSDTActionProxy.executeMethod(handler, "run", getRunArgTypes(), getRunArgs(action)); //$NON-NLS-1$ - } catch (IllegalArgumentException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (SecurityException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (IllegalAccessException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (NoSuchMethodException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InstantiationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InvocationTargetException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - currentSelection = selection; - if(targetWorkbenchPart==null) return; - - try { - Object handler = getActionHandler(action); - SimpleJSDTActionProxy.executeMethod(handler, "selectionChanged", getSelectionChangeArgTypes(), getSelectionChangeArgs(action, selection)); //$NON-NLS-1$ - } catch (IllegalArgumentException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (SecurityException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (IllegalAccessException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (NoSuchMethodException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InstantiationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } catch (InvocationTargetException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - this.targetWorkbenchPart = targetPart; - } - - protected void setSelection(ISelection selection) { - this.currentSelection = selection; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java deleted file mode 100644 index 75815ea255..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class SourceActionsAction implements IObjectActionDelegate { - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - action.setEnabled(false); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, - * org.eclipse.ui.IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java deleted file mode 100644 index 8677ee4a68..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.actions; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class StandardEditorActionsAction implements IObjectActionDelegate { - private static final boolean APPEND_NEW_LINES_TO_COPY = true; - protected static final String COPY = "org.eclipse.wst.jsdt.web.ui.copy"; //$NON-NLS-1$ - protected static final String CUT = "org.eclipse.wst.jsdt.web.ui.cut"; //$NON-NLS-1$ - protected static final String DELETE = "org.eclipse.wst.jsdt.web.ui.delete"; //$NON-NLS-1$ - private static final char NEW_LINE = '\n'; - protected static final String PASTE_AFTER = "org.eclipse.wst.jsdt.web.ui.paste.after"; //$NON-NLS-1$ - protected static final String PASTE_BEFORE = "org.eclipse.wst.jsdt.web.ui.paste.before"; //$NON-NLS-1$ - protected ISelection selection; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - private void copy(IAction action) { - JsJfaceNode[] nodes = parseSelection(); - if (nodes == null || nodes.length == 0) { - return; - } - Clipboard clipboard = null; - StringBuffer text = new StringBuffer(); - if (StandardEditorActionsAction.APPEND_NEW_LINES_TO_COPY) { - text.append(StandardEditorActionsAction.NEW_LINE); - } - try { - for (int i = 0; i < nodes.length; i++) { - JsJfaceNode currentNode = nodes[i]; - int start = currentNode.getStartOffset(); - int length = currentNode.getLength(); - IStructuredDocument doc = currentNode.getStructuredDocument(); - try { - String elementText = doc.get(start, length); - text.append(elementText); - } catch (BadLocationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - if (StandardEditorActionsAction.APPEND_NEW_LINES_TO_COPY) { - text.append(StandardEditorActionsAction.NEW_LINE); - } - clipboard = new Clipboard(Display.getCurrent()); - clipboard.setContents(new Object[] { text.toString() }, new Transfer[] { TextTransfer.getInstance() }); - } - } finally { - if (clipboard != null) { - clipboard.dispose(); - } - } - } - - private void delete(IAction action) { - JsJfaceNode[] nodes = parseSelection(); - if (nodes == null || nodes.length == 0) { - return; - } - IStructuredDocument lastDoc = null; - IModelManager modelManager = StructuredModelManager.getModelManager(); - IStructuredModel model = null; - try { - int start; - int length; - for (int i = 0; i < nodes.length; i++) { - JsJfaceNode currentNode = nodes[i]; - start = currentNode.getStartOffset(); - length = currentNode.getLength(); - IStructuredDocument doc = currentNode.getStructuredDocument(); - if (doc != lastDoc) { - lastDoc = doc; - if (model != null) { - model.endRecording(action); - model.changedModel(); - model.releaseFromEdit(); - } - if (modelManager != null) { - model = modelManager.getExistingModelForEdit(doc); - model.aboutToChangeModel(); - model.beginRecording(action, "Delete JavaScript Element", "Delete JavaScript Element"); - } - } - doc.replaceText(action, start, length, ""); //$NON-NLS-1$ - } - model.endRecording(action); - } catch (Exception e) { - System.out.println(Messages.getString("StandardEditorActionsAction.8") + e); //$NON-NLS-1$ - } finally { - if (model != null) { - model.changedModel(); - model.releaseFromEdit(); - } - } - } - - private JsJfaceNode[] parseSelection() { - if (selection == null) { - return new JsJfaceNode[0]; - } - ArrayList elements = new ArrayList(); - if (selection instanceof IStructuredSelection) { - Iterator itt = ((IStructuredSelection) selection).iterator(); - while (itt.hasNext()) { - Object element = itt.next(); - if (element instanceof IJavaScriptElement) { - elements.add(element); - } - if (element instanceof IJavaWebNode) { - elements.add(element); - } - } - return (JsJfaceNode[]) elements.toArray(new JsJfaceNode[elements.size()]); - } - return new JsJfaceNode[0]; - } - - private void paste(IAction action, boolean atEnd) { - JsJfaceNode[] nodes = parseSelection(); - if (nodes == null || nodes.length == 0) { - return; - } - int startOfPaste = -1; - IStructuredDocument doc = null; - /* Figure out where to paste the content */ - if (atEnd) { - for (int i = 0; i < nodes.length; i++) { - if ((nodes[i].getStartOffset() + nodes[i].getLength()) > startOfPaste) { - startOfPaste = (nodes[i].getStartOffset() + nodes[i].getLength()); - doc = nodes[i].getStructuredDocument(); - } - } - } else { - for (int i = 0; i < nodes.length; i++) { - if ((nodes[i].getStartOffset() < startOfPaste || startOfPaste < 0)) { - startOfPaste = nodes[i].getStartOffset(); - doc = nodes[i].getStructuredDocument(); - } - } - } - Clipboard clipboard = null; - IModelManager modelManager = StructuredModelManager.getModelManager(); - IStructuredModel model = null; - try { - clipboard = new Clipboard(Display.getCurrent()); - String pasteString = (String) clipboard.getContents(TextTransfer.getInstance()); - model = modelManager.getExistingModelForEdit(doc); - model.aboutToChangeModel(); - model.beginRecording(action, Messages.getString("StandardEditorActionsAction.9") + (atEnd ? Messages.getString("StandardEditorActionsAction.10") : Messages.getString("StandardEditorActionsAction.11")) + Messages.getString("StandardEditorActionsAction.12"), Messages.getString("StandardEditorActionsAction.13") + (atEnd ? Messages.getString("StandardEditorActionsAction.14") : Messages.getString("StandardEditorActionsAction.15")) + Messages.getString("StandardEditorActionsAction.16")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ - doc.replaceText(action, startOfPaste, 0, pasteString); - } finally { - if (clipboard != null) { - clipboard.dispose(); - } - if (model != null) { - model.endRecording(action); - model.changedModel(); - model.releaseFromEdit(); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - if (action.getId().equals(StandardEditorActionsAction.CUT)) { - copy(action); - delete(action); - } else if (action.getId().equals(StandardEditorActionsAction.COPY)) { - copy(action); - } else if (action.getId().equals(StandardEditorActionsAction.PASTE_BEFORE)) { - paste(action, false); - } else if (action.getId().equals(StandardEditorActionsAction.PASTE_AFTER)) { - paste(action, true); - } else if (action.getId().equals(StandardEditorActionsAction.DELETE)) { - delete(action); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - this.selection = selection; - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) {} -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties deleted file mode 100644 index c89b7618ee..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties +++ /dev/null @@ -1,28 +0,0 @@ -############################################################################### -# Copyright (c) 2007 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 -############################################################################### -StandardEditorActionsAction.8=Error in Standard Editor Action : -StandardEditorActionsAction.9=Insert Text -StandardEditorActionsAction.10=before -StandardEditorActionsAction.11=after -StandardEditorActionsAction.12=\ a JavaScript Element. -StandardEditorActionsAction.13=Insert Text -StandardEditorActionsAction.14=before -StandardEditorActionsAction.15=after -StandardEditorActionsAction.16=\ a JavaScript Element. -SimpleJSDTActionProxy.0=Exception : -ShowHistoryAction.0=Error Opening in Script View -ShowHistoryAction.1=Error while displaying element in Script View:\n -ShowInNavigatorAction.0=Error Opening in Script View -ShowInNavigatorAction.1=Error while displaying element in Script View:\n -AddJavaDocStubAction.0=JavaScript Doc -AddJavaDocStubAction.1=Error while adding comment -AddJavaDocStubOperation.0=Generate JsDoc -AddJavaDocStubOperation.1=Generate JsDoc diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java deleted file mode 100644 index 7d1af51520..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public interface IActionConstantsJs { - public final static String ACTION_NAME_MOVE_ELEMENT = "MoveElement"; //$NON-NLS-1$ - public final static String ACTION_NAME_RENAME_ELEMENT = "RenameElement"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java deleted file mode 100644 index 91616817f8..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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; - -import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public interface IActionDefinitionIdsJs { - public final static String MOVE_ELEMENT = IJavaEditorActionDefinitionIds.MOVE_ELEMENT; - public final static String RENAME_ELEMENT = IJavaEditorActionDefinitionIds.RENAME_ELEMENT; -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties deleted file mode 100644 index 2cb5d2733c..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties +++ /dev/null @@ -1,87 +0,0 @@ -############################################################################### -# Copyright (c) 2004, 2007 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 -############################################################################### -## The following line is a sample JSP document. Please translate only the following parts: -## Use below tags ONLY for JSP 1.1 -## Welcome! -## Use below tags ONLY for JSP 1.2 -## Welcome! -Sample_JSP_doc=<%@ page \n\tlanguage=\"java\" \n\tcontentType=\"text/html; charset=ISO-8859-1\"\n%>\n<jsp:include flush=\"true\" page=\"titleBar.jsp\"/>\n\n<%-- Use below tags ONLY for JSP 1.1 --%>\n<%\n\tSystem.out.println(\"Welcome!\");\n%>\n<%-- Use below tags ONLY for JSP 1.2 --%>\n<jsp:scriptlet>\n\tSystem.out.println(\"Welcome!\");\n</jsp:scriptlet> -JSP_Delimiters_UI_=JSP Delimiters -Refactor_label=Refactor -RenameElement_label=Rename -MoveElement_label=Move -MoveElementWizard=Move the selected elements -# -OK=OK -JSP_changes=JSP changes -ActionContributorJSP_0=Refa&ctor -JSPRenameElementAction_0=Editor selection does not resolve to a renamable Java element -JSPMoveElementAction_0=Editor selection does not resolve to movable Java elements -BasicRefactorSearchRequestor_0=JSP Rename -BasicRefactorSearchRequestor_1=in file: {0} line: {1} -BasicRefactorSearchRequestor_2=Move Type ''{0}'' to package ''{1}'' -BasicRefactorSearchRequestor_3=Rename Method ''{0}'' to ''{1}'' -BasicRefactorSearchRequestor_4=Rename Type ''{0}'' to ''{1}'' -BasicRefactorSearchRequestor_5=Rename Package ''{0}'' to ''{1}'' -BasicRefactorSearchRequestor_6=JSP Rename Change -# -_UI_WIZARD_NEW_TITLE = New JavaServer Page -_UI_WIZARD_NEW_HEADING = JavaServer Page -_UI_WIZARD_NEW_DESCRIPTION = Create a new JavaServer Page. -_ERROR_FILENAME_MUST_END_JSP = The file name must end in one of the following extensions {0}. -_WARNING_FILE_MUST_BE_INSIDE_JAVA_PROJECT = JavaServer Pages created in projects that do not support Java might not work as expected. -_WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT = Files created outside of the Web Content folder will not be included in your deployed Web application. -ResourceGroup_nameExists = The same name already exists. -NewJSPTemplatesWizardPage_0=Select JSP Template -NewJSPTemplatesWizardPage_1=Select a template as initial content in the JSP page. -NewJSPTemplatesWizardPage_2=Name -NewJSPTemplatesWizardPage_3=Description -NewJSPTemplatesWizardPage_4=Use JSP Template -NewJSPTemplatesWizardPage_5=Preview -NewJSPTemplatesWizardPage_6=Templates are 'New JSP' templates found in the <a>JSP Templates</a> preference page. -# Copied from sse.ui -CleanupDocument_label=Cleanup Document... -CleanupDocument_tooltip=Cleanup Document -CleanupDocument_description=Cleanup Document -ToggleComment_label=Toggle Comment -ToggleComment_tooltip=Toggle Comment -ToggleComment_description=Toggle Comment -AddBlockComment_label=Add Block Comment -AddBlockComment_tooltip=Add Block Comment -AddBlockComment_description=Add Block Comment -RemoveBlockComment_label=Remove Block Comment -RemoveBlockComment_tooltip=Remove Block Comment -RemoveBlockComment_description=Remove Block Comment -FindOccurrences_label=Occurrences in File -OccurrencesSearchQuery_0={0} - {1} Occurrences in {2} -OccurrencesSearchQuery_2=file -Content_Assist_not_availab_UI_=Content Assist not available at the current location -Java_Content_Assist_is_not_UI_=Java Content Assist is not available for the current cursor location -# -Override_method_in=Override method in ' -Creating_files_encoding=Creating files encoding preference -# -JSPSourcePreferencePage_0=JSP Source preferences are based on the content within the JSP. -JSPSourcePreferencePage_1=See <a>''{0}''</a> for JSP with HTML content. -JSPSourcePreferencePage_2=See <a>''{0}''</a> for JSP with XML content. -JSPColorPage_jsp_content=JSP Content -JSPFilesPreferencePage_0=Validating files -JSPFilesPreferencePage_1=Validate JSP fragments -# JSP Fragments -JSPFContentSettingsPropertyPage_0=none -JSPFContentSettingsPropertyPage_1=The properties used instead of the page directive that cannot be specified in JSP fragment files. The project setting is used if you specify "none." -JSPFContentSettingsPropertyPage_2=Language: -JSPFContentSettingsPropertyPage_3=Content Type: -JSPFContentSettingsPropertyPage_4=Enable specific setting: -ProjectJSPFContentSettingsPropertyPage_0=The properties for J2EE Web projects act as "project" default to be looked up when no properties are specified for a particular JSP fragment file. -# CSS JSP -Title_InvalidValue=Invalid Value -Message_InvalidValue=Invalid property value. diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java deleted file mode 100644 index fbd9cf896f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java +++ /dev/null @@ -1,110 +0,0 @@ -/********************************************************************** - * Copyright (c) 2005, 2007 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 - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.jsdt.web.ui.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.osgi.util.NLS; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - - */ -public class JsUIMessages extends NLS { - public static String _ERROR_FILENAME_MUST_END_JSP; - public static String _UI_WIZARD_NEW_DESCRIPTION; - public static String _UI_WIZARD_NEW_HEADING; - public static String _UI_WIZARD_NEW_TITLE; - public static String _WARNING_FILE_MUST_BE_INSIDE_JAVA_PROJECT; - public static String _WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT; - public static String ActionContributorJSP_0; - public static String AddBlockComment_description; // resource bundle - public static String AddBlockComment_label; // resource bundle - public static String AddBlockComment_tooltip; // resource bundle - public static String BasicRefactorSearchRequestor_0; - public static String BasicRefactorSearchRequestor_1; - public static String BasicRefactorSearchRequestor_2; - public static String BasicRefactorSearchRequestor_3; - public static String BasicRefactorSearchRequestor_4; - public static String BasicRefactorSearchRequestor_5; - public static String BasicRefactorSearchRequestor_6; - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.internal.JSPUIPluginResources";//$NON-NLS-1$ - public static String CleanupDocument_description; // resource bundle - public static String CleanupDocument_label; // resource bundle - public static String CleanupDocument_tooltip; // resource bundle - public static String Content_Assist_not_availab_UI_; - public static String Creating_files_encoding; - public static String FindOccurrences_label; // resource bundle - private static ResourceBundle fResourceBundle; - public static String Java_Content_Assist_is_not_UI_; - public static String JSP_changes; - public static String JSP_Delimiters_UI_; - public static String JSPColorPage_jsp_content; - public static String JSPFContentSettingsPropertyPage_0; - public static String JSPFContentSettingsPropertyPage_1; - public static String JSPFContentSettingsPropertyPage_2; - public static String JSPFContentSettingsPropertyPage_3; - public static String JSPFContentSettingsPropertyPage_4; - public static String JSPFilesPreferencePage_0; - public static String JSPFilesPreferencePage_1; - public static String JSPMoveElementAction_0; - public static String JSPRenameElementAction_0; - public static String JSPSourcePreferencePage_0; - public static String JSPSourcePreferencePage_1; - public static String JSPSourcePreferencePage_2; - public static String Message_InvalidValue; - public static String MoveElement_label; // resource bundle - public static String MoveElementWizard; - public static String NewJSPTemplatesWizardPage_0; - public static String NewJSPTemplatesWizardPage_1; - public static String NewJSPTemplatesWizardPage_2; - public static String NewJSPTemplatesWizardPage_3; - public static String NewJSPTemplatesWizardPage_4; - public static String NewJSPTemplatesWizardPage_5; - public static String NewJSPTemplatesWizardPage_6; - public static String OccurrencesSearchQuery_0; - public static String OccurrencesSearchQuery_2; - public static String OK; - public static String Override_method_in; - public static String ProjectJSPFContentSettingsPropertyPage_0; - public static String Refactor_label; - public static String RemoveBlockComment_description; // resource bundle - public static String RemoveBlockComment_label; // resource bundle - public static String RemoveBlockComment_tooltip; // resource bundle - public static String RenameElement_label; // resource bundle - public static String ResourceGroup_nameExists; - public static String Sample_JSP_doc; - public static String Title_InvalidValue; - public static String ToggleComment_description; // resource bundle - public static String ToggleComment_label; // resource bundle - public static String ToggleComment_tooltip; // resource bundle - static { - // load message values from bundle file - NLS.initializeMessages(JsUIMessages.BUNDLE_NAME, JsUIMessages.class); - } - - public static ResourceBundle getResourceBundle() { - try { - if (JsUIMessages.fResourceBundle == null) { - JsUIMessages.fResourceBundle = ResourceBundle.getBundle(JsUIMessages.BUNDLE_NAME); - } - } catch (MissingResourceException x) { - JsUIMessages.fResourceBundle = null; - } - return JsUIMessages.fResourceBundle; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java deleted file mode 100644 index 70b836d4b3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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; - -import java.io.IOException; - -import org.eclipse.jface.text.templates.ContextTypeRegistry; -import org.eclipse.jface.text.templates.persistence.TemplateStore; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin; -import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry; -import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl; -import org.osgi.framework.BundleContext; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsUIPlugin extends AbstractUIPlugin { - public final static String ID = "org.eclipse.wst.jsdt.web.ui"; //$NON-NLS-1$ - protected static JsUIPlugin instance = null; - - public static JsUIPlugin getDefault() { - return JsUIPlugin.instance; - } - - public synchronized static JsUIPlugin getInstance() { - return JsUIPlugin.instance; - } - /** - * The template context type registry for the jsp editor. - */ - private ContextTypeRegistry fContextTypeRegistry; - /** - * The template store for the jsp editor. - */ - private TemplateStore fTemplateStore; - - public JsUIPlugin() { - super(); - JsUIPlugin.instance = this; - } - - public AdapterFactoryRegistry getAdapterFactoryRegistry() { - return AdapterFactoryRegistryImpl.getInstance(); - } - - /** - * Returns the template context type registry for the jsp plugin. - * - * @return the template context type registry for the jsp plugin - */ - public ContextTypeRegistry getTemplateContextRegistry() { - if (fContextTypeRegistry == null) { -// ContributionContextTypeRegistry registry = new -// ContributionContextTypeRegistry(); -// registry.addContextType(TemplateContextTypeIdsJSP.ALL); -// registry.addContextType(TemplateContextTypeIdsJSP.NEW); -// registry.addContextType(TemplateContextTypeIdsJSP.TAG); -// registry.addContextType(TemplateContextTypeIdsJSP.ATTRIBUTE); -// registry.addContextType(TemplateContextTypeIdsJSP.ATTRIBUTE_VALUE); - fContextTypeRegistry = JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry(); - } - return fContextTypeRegistry; - } - - /** - * Returns the template store for the jsp editor templates. - * - * @return the template store for the jsp editor templates - */ - public TemplateStore getTemplateStore() { - if (fTemplateStore == null) { -// fTemplateStore = new ContributionTemplateStore( -// getTemplateContextRegistry(), getPreferenceStore(), -// JSPUIPreferenceNames.TEMPLATES_KEY); - JavaScriptPlugin jp = JavaScriptPlugin.getDefault(); - fTemplateStore = jp.getTemplateStore(); - try { - fTemplateStore.load(); - } catch (IOException e) { - Logger.logException(e); - } - } - return fTemplateStore; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - instance = this; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - instance = null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java deleted file mode 100644 index f79c751d2f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -import com.ibm.icu.util.StringTokenizer; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class Logger { - public static final int ERROR = IStatus.ERROR; // 4 - public static final int ERROR_DEBUG = 200 + Logger.ERROR; - public static final int INFO = IStatus.INFO; // 1 - public static final int INFO_DEBUG = 200 + Logger.INFO; - public static final int OK = IStatus.OK; // 0 - public static final int OK_DEBUG = 200 + Logger.OK; - private static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.ui"; //$NON-NLS-1$ - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - public static final int WARNING = IStatus.WARNING; // 2 - public static final int WARNING_DEBUG = 200 + Logger.WARNING; - - /** - * Adds message to log. - * - * @param level - * severity level of the message (OK, INFO, WARNING, ERROR, - * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message - * text to add to the log - * @param exception - * exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == Logger.OK_DEBUG || level == Logger.INFO_DEBUG || level == Logger.WARNING_DEBUG || level == Logger.ERROR_DEBUG) { - if (!Logger.isDebugging()) { - return; - } - } - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG: - case INFO: - severity = IStatus.INFO; - break; - case WARNING_DEBUG: - case WARNING: - severity = IStatus.WARNING; - break; - case ERROR_DEBUG: - case ERROR: - severity = IStatus.ERROR; - } - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(severity, Logger.PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID); - if (bundle != null) { - Platform.getLog(bundle).log(statusObj); - } - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * - * @param message - * text to print - * @param category - * category of the message, to be compared with - * /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (Logger.isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, Logger.PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID); - if (bundle != null) { - Platform.getLog(bundle).log(statusObj); - } - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - /** - * Determines if currently tracing a category - * - * @param category - * @return true if tracing category, false otherwise - */ - public static boolean isTracing(String category) { - if (!Logger.isDebugging()) { - return false; - } - String traceFilter = Platform.getDebugOption(Logger.PLUGIN_ID + Logger.TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - return true; - } - } - } - return false; - } - - public static void log(int level, String message) { - Logger._log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - Logger._log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - Logger._log(Logger.ERROR, message, exception); - } - - public static void logException(Throwable exception) { - Logger._log(Logger.ERROR, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - Logger._trace(category, message, null); - } - - public static void traceException(String category, String message, Throwable exception) { - Logger._trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - Logger._trace(category, exception.getMessage(), exception); - } -} 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 deleted file mode 100644 index b6622031b9..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.text.DocumentCommand; -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.jsdt.core.IJavaScriptProject; -import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy; -import org.eclipse.wst.jsdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy; -import org.eclipse.wst.jsdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class AutoEditStrategyForJs implements IAutoEditStrategy { - private IAutoEditStrategy[] fStrategies; - - public AutoEditStrategyForJs() { - super(); - } - - public void customizeDocumentCommand(IDocument document, DocumentCommand command) { - IAutoEditStrategy[] strats = getAutoEditStrategies(document); - for (int i = 0; i < strats.length; i++) { - strats[i].customizeDocumentCommand(document, command); - } - } - - public IAutoEditStrategy[] getAutoEditStrategies(IDocument document) { - if (fStrategies != null) { - return fStrategies; - } - String partitioning = IHTMLPartitions.SCRIPT; - fStrategies = new IAutoEditStrategy[] { new JavaDocAutoIndentStrategy(partitioning), new SmartSemicolonAutoEditStrategy(partitioning), - new JavaAutoIndentStrategy(partitioning, getJavaProject(document), null) }; - /* new AutoEditStrategyForTabs() */ - return fStrategies; - } - - private IJavaScriptProject getJavaProject(IDocument document) { - IDOMModel model = null; - IJavaScriptProject javaProject = null; - try { - model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document); - String baseLocation = model.getBaseLocation(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IPath filePath = new Path(baseLocation); - IProject project = null; - if (filePath.segmentCount() > 0) { - project = root.getProject(filePath.segment(0)); - } - if (project != null) { - javaProject = JavaScriptCore.create(project); - } - } finally { - 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/AutoEditStrategyForTabs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForTabs.java deleted file mode 100644 index 50ab442d0b..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForTabs.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.autoedit; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.ConfigurableLineTracker; -import org.eclipse.jface.text.DocumentCommand; -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ILineTracker; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.TextUtilities; -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.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class AutoEditStrategyForTabs implements IAutoEditStrategy { - private final String TAB_CHARACTER = "\t"; //$NON-NLS-1$ - - public void customizeDocumentCommand(IDocument document, DocumentCommand command) { - // if not in smart insert mode just ignore - if (!isSmartInsertMode()) { - return; - } - // spaces for tab character - if (command.length == 0 && command.text != null && command.text.length() > 0 && command.text.indexOf(TAB_CHARACTER) != -1) { - smartInsertForTab(command, document); - } - } - - /** - * Returns indentation width if using spaces for indentation, -1 otherwise - * - * @return - */ - private int getIndentationWidth() { - int width = -1; - Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); - if (HTMLCorePreferenceNames.SPACE.equals(preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) { - width = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE); - } - return width; - } - - /** - * Calculate number of spaces for next tab stop - */ - private String getIndentString(int indentationWidth, int lineOffset, ILineTracker lineTracker, int index) { - int indentSize = indentationWidth; - int offsetInLine = -1; - if (lineTracker != null) { - try { - IRegion lineInfo = lineTracker.getLineInformationOfOffset(index); - if (lineInfo.getOffset() == 0 && lineOffset > -1) { - offsetInLine = lineOffset + index; - } else { - offsetInLine = index - lineInfo.getOffset(); - } - } catch (BadLocationException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } else { - if (lineOffset > -1) { - offsetInLine = lineOffset + index; - } - } - if (offsetInLine > -1 && indentationWidth > 0) { - int remainder = offsetInLine % indentationWidth; - indentSize = indentationWidth - remainder; - } - StringBuffer indent = new StringBuffer(); - for (int i = 0; i < indentSize; i++) { - indent.append(' '); - } - return indent.toString(); - } - - /** - * Set up a line tracker for text within command if text is multi-line - */ - private ILineTracker getLineTracker(IDocument document, String originalText) { - ConfigurableLineTracker lineTracker = null; - int[] delims = TextUtilities.indexOf(document.getLegalLineDelimiters(), originalText, 0); - if (delims[0] != -1 || delims[1] != -1) { - lineTracker = new ConfigurableLineTracker(document.getLegalLineDelimiters()); - lineTracker.set(originalText); - } - return lineTracker; - } - - /** - * Return true if active editor is in smart insert mode, false otherwise - * - * @return - */ - private boolean isSmartInsertMode() { - boolean isSmartInsertMode = false; - ITextEditor textEditor = null; - 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) { - textEditor = (ITextEditor) editor; - } else { - textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); - } - } - } - } - // check if smart insert mode - if (textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT) { - isSmartInsertMode = true; - } - return isSmartInsertMode; - } - - /** - * Insert spaces for tabs - * - * @param command - */ - private void smartInsertForTab(DocumentCommand command, IDocument document) { - // tab key was pressed. now check preferences to see if need to insert - // spaces instead of tab - int indentationWidth = getIndentationWidth(); - if (indentationWidth > -1) { - String originalText = command.text; - StringBuffer newText = new StringBuffer(originalText); - // determine where in line this command begins - int lineOffset = -1; - try { - IRegion lineInfo = document.getLineInformationOfOffset(command.offset); - lineOffset = command.offset - lineInfo.getOffset(); - } catch (BadLocationException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - ILineTracker lineTracker = getLineTracker(document, originalText); - int startIndex = 0; - int index = newText.indexOf(TAB_CHARACTER); - while (index != -1) { - String indent = getIndentString(indentationWidth, lineOffset, lineTracker, index); - // replace \t character with spaces - newText.replace(index, index + 1, indent); - if (lineTracker != null) { - try { - lineTracker.replace(index, 1, indent); - } catch (BadLocationException e) { - // if something goes wrong with replacing text, just - // reset to current string - lineTracker.set(newText.toString()); - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - startIndex = index + indent.length(); - index = newText.indexOf(TAB_CHARACTER, startIndex); - } - command.text = newText.toString(); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java deleted file mode 100644 index 7f598f7f73..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.contentassist; - -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal; -import org.eclipse.wst.jsdt.internal.ui.text.java.LazyJavaCompletionProposal; -import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTCompletionProposal extends JavaCompletionProposal implements IJavaCompletionProposal { - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483 - * - * This is a wrapped proposal so we don't need to make "slow" calls to the - * java proposal up front, only when needed for example, getAdditionalInfo() - * reads external javadoc, and it makes no sense - */ - ICompletionProposal fJavaCompletionProposal = null; - - public JSDTCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, - String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance, - boolean updateReplacementLengthOnValidate) { - super(replacementString, replacementOffset, replacementLength, image, displayString, relevance); - super.setCursorPosition(cursorPosition); - super.setContextInformation(contextInformation); -// super(replacementString, replacementOffset, replacementLength, -// cursorPosition, image, displayString, contextInformation, -// additionalProposalInfo, relevance, -// updateReplacementLengthOnValidate); - } - - /** - * Sets cursor position after applying. - */ - - public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) { - if (this.fJavaCompletionProposal instanceof LazyJavaCompletionProposal) - { - ((LazyJavaCompletionProposal)this.fJavaCompletionProposal).apply(viewer.getDocument(), trigger, offset); - } else { - super.apply(viewer, trigger, stateMask, offset); - } - } - - - public String getAdditionalProposalInfo() { - String additionalInfo = super.getAdditionalProposalInfo(); - ICompletionProposal javaProposal = getJavaCompletionProposal(); - if (javaProposal != null) { - additionalInfo = javaProposal.getAdditionalProposalInfo(); - } - return additionalInfo; - } - - final public ICompletionProposal getJavaCompletionProposal() { - return fJavaCompletionProposal; - } - - final public void setJavaCompletionProposal(ICompletionProposal javaCompletionProposal) { - fJavaCompletionProposal = javaCompletionProposal; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java deleted file mode 100644 index 6725196626..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.contentassist; - -import java.util.Arrays; -import java.util.Vector; - -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTContentAssistant extends AbstractContentAssistProcessor { - private JSDTContentAssistantProcessor fContentAssistProcessor; - private JSDTTemplateAssistProcessor fTemplateAssistProcessor; - private JsTranslationAdapter fTranslationAdapter; - private JSDTHtmlCompletionProcessor fHhtmlcomp; - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) { - Vector proposals = new Vector(); - ICompletionProposal[] completionProposals; - ICompletionProposal endScript = getHtmlContentAssistProcessor().getEndScriptProposal(viewer, documentPosition); - if(endScript!=null) { - return new ICompletionProposal[] {endScript}; - //proposals.add(endScript); - } - JSDTProposalCollector theCollector = getProposalCollector(viewer, documentPosition); - /* add end script tag if needed */ - - /* --------- Content Assistant --------- */ - if(theCollector==null) return new ICompletionProposal[0]; - - getContentAssistProcessor().setProposalCollector(theCollector); - completionProposals = getContentAssistProcessor().computeCompletionProposals(viewer, documentPosition); - proposals.addAll(Arrays.asList(completionProposals)); - /* HTML Proposals */ - completionProposals = getHtmlContentAssistProcessor().computeCompletionProposals(viewer, documentPosition); - proposals.addAll(Arrays.asList(completionProposals)); - /* --------- template completions --------- */ - getTemplateCompletionProcessor().setProposalCollector(theCollector); - completionProposals = getTemplateCompletionProcessor().computeCompletionProposals(viewer, documentPosition); - proposals.addAll(Arrays.asList(completionProposals)); - return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[0]); - } - - private JSDTHtmlCompletionProcessor getHtmlContentAssistProcessor() { - if (fHhtmlcomp == null) { - fHhtmlcomp = new JSDTHtmlCompletionProcessor(); - } - return fHhtmlcomp; - } - - private JSDTContentAssistantProcessor getContentAssistProcessor() { - if (fContentAssistProcessor == null) { - fContentAssistProcessor = new JSDTContentAssistantProcessor(); - } - return fContentAssistProcessor; - } - private IJsTranslation getJSPTranslation(ITextViewer viewer, int offset) { - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument()); - IDOMDocument xmlDoc = xmlModel.getDocument(); - if (fTranslationAdapter == null) { - fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - } - if (fTranslationAdapter != null) { - return fTranslationAdapter.getJsTranslation(true); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return null; - } - - protected JSDTProposalCollector getProposalCollector(ITextViewer viewer, int offset) { - IJsTranslation tran = getJSPTranslation(viewer, offset); - if(tran==null) return null; - return new JSDTProposalCollector(tran); - } - - private JSDTTemplateAssistProcessor getTemplateCompletionProcessor() { - if (fTemplateAssistProcessor == null) { - fTemplateAssistProcessor = new JSDTTemplateAssistProcessor(); - } - return fTemplateAssistProcessor; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java deleted file mode 100644 index ac367f2af8..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.contentassist; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor; -import org.osgi.framework.Bundle; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTContentAssistantProcessor extends AbstractContentAssistProcessor { - private static final String JSDT_CORE_PLUGIN_ID = "org.eclipse.wst.jsdt.core"; //$NON-NLS-1$ -// static { -// String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation"); //$NON-NLS-1$ -// //DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ -// } - protected String fErrorMessage = null; - protected int fJspSourcePosition, fJavaPosition; - private JSDTProposalCollector fProposalCollector; - private JsTranslationAdapter fTranslationAdapter = null; - protected StructuredTextViewer fViewer = null; - - public JSDTContentAssistantProcessor() { - super(); - } - - /** - * Returns a list of completion proposals based on the specified location - * within the document that corresponds to the current cursor position - * within the text viewer. - * - * @param viewer - * the viewer whose document is used to compute the proposals - * @param documentPosition - * an offset within the document for which completions should be - * computed - * @return an array of completion proposals or <code>null</code> if no - * proposals are possible - */ - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int pos) { - initialize(pos); - JSDTProposalCollector collector = null; - IDOMModel xmlModel = null; - try { - if (viewer instanceof StructuredTextViewer) { - fViewer = (StructuredTextViewer) viewer; - } - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument()); - IDOMDocument xmlDoc = xmlModel.getDocument(); - if (fTranslationAdapter == null) { - fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - } - if (fTranslationAdapter != null) { - IJsTranslation translation = fTranslationAdapter.getJsTranslation(true); - fJavaPosition = getDocumentPosition(); - try { - IJavaScriptUnit cu = translation.getCompilationUnit(); - // can't get java proposals w/out a compilation unit - // or without a valid position - if (cu == null || -1 == fJavaPosition) { - return new ICompletionProposal[0]; - } - collector = getProposalCollector(); - synchronized (cu) { - cu.codeComplete(fJavaPosition, collector, null); - } - } catch (CoreException coreEx) { - // a possible Java Model Exception due to not being a Web - // (Java) Project - coreEx.printStackTrace(); - } - } - } catch (Exception exc) { - exc.printStackTrace(); - // throw out exceptions on code assist. - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - ICompletionProposal[] results = new ICompletionProposal[0]; - if (collector != null) { - results = collector.getJSPCompletionProposals(); - if (results == null || results.length < 1) { - fErrorMessage = JsUIMessages.Java_Content_Assist_is_not_UI_; - } - } - return results; - } - - /** - * Returns information about possible contexts based on the specified - * location within the document that corresponds to the current cursor - * position within the text viewer. - * - * @param viewer - * the viewer whose document is used to compute the possible - * contexts - * @param documentPosition - * an offset within the document for which context information - * should be computed - * @return an array of context information objects or <code>null</code> if - * no context could be found - */ - - public org.eclipse.jface.text.contentassist.IContextInformation[] computeContextInformation(org.eclipse.jface.text.ITextViewer viewer, int documentOffset) { - return null; - } - - /** - * Returns a string of characters which when pressed should automatically - * display content-assist proposals. - * - * @return string of characters - */ - public java.lang.String getAutoProposalInvocationCharacters() { - return null; - } - - /** - * Returns a string of characters which when pressed should automatically - * display a content-assist tip. - * - * @return string of characters - */ - public java.lang.String getAutoTipInvocationCharacters() { - return null; - } - - /** - * Returns the characters which when entered by the user should - * automatically trigger the presentation of possible completions. - * - * @return the auto activation characters for completion proposal or - * <code>null</code> if no auto activation is desired - */ - - public char[] getCompletionProposalAutoActivationCharacters() { - return null; - } - - /** - * Returns the characters which when entered by the user should - * automatically trigger the presentation of context information. - * - * @return the auto activation characters for presenting context information - * or <code>null</code> if no auto activation is desired - */ - - public char[] getContextInformationAutoActivationCharacters() { - return null; - } - - /** - * Returns a validator used to determine when displayed context information - * should be dismissed. May only return <code>null</code> if the processor - * is incapable of computing context information. - * - * @return a context information validator, or <code>null</code> if the - * processor is incapable of computing context information - */ - - public org.eclipse.jface.text.contentassist.IContextInformationValidator getContextInformationValidator() { - return null; - } - - protected int getDocumentPosition() { - return fJspSourcePosition; - } - - - public String getErrorMessage() { - // TODO: get appropriate error message - // if (fCollector.getErrorMessage() != null && - // fCollector.getErrorMessage().length() > 0) - // return fCollector.getErrorMessage(); - return fErrorMessage; - } - - protected JSDTProposalCollector getProposalCollector() { - return fProposalCollector; - // return new JSPProposalCollector(translation); - } - - /** - * Initialize the code assist processor. - */ - protected void initialize(int pos) { - initializeJavaPlugins(); - fJspSourcePosition = pos; - fErrorMessage = null; - } - - /** - * Initialize the Java Plugins that the JSP processor requires. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=143765 We should not call - * "start", because that will cause that state to be remembered, and - * re-started automatically during the next boot up sequence. - * - * ISSUE: we may be able to get rid of this all together, in future, since - * 99% we probably have already used some JDT class by the time we need JDT - * to be active ... but ... this is the safest fix for this point in 1.5 - * stream. Next release, let's just remove this, re-discover what ever bug - * this was fixing (if any) and if there is one, then we'll either put back - * in, as is, or come up with a more appropriate fix. - * - */ - protected void initializeJavaPlugins() { - try { - Bundle bundle = Platform.getBundle(JSDTContentAssistantProcessor.JSDT_CORE_PLUGIN_ID); - bundle.loadClass("dummyClassNameThatShouldNeverExist"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // this is the expected result, we just want to - // nudge the bundle to be sure its activated. - } - } - - - public void release() { - fTranslationAdapter = null; - } - - public void setProposalCollector(JSDTProposalCollector translation) { - this.fProposalCollector = translation; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java deleted file mode 100644 index dcd07a86c0..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.contentassist; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTContetAssistInvocationContext extends JavaContentAssistInvocationContext { - public static JSDTContetAssistInvocationContext getInstance(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) { - JSDTContetAssistInvocationContext.getJSPTranslation(viewer); - return new JSDTContetAssistInvocationContext(viewer, offset, theCollector); - } - - private static IJsTranslation getJSPTranslation(ITextViewer viewer) { - IJsTranslation fTranslation = null; - - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument()); - IDOMDocument xmlDoc = xmlModel.getDocument(); - JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (fTranslationAdapter != null) { - fTranslation = fTranslationAdapter.getJsTranslation(true); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return fTranslation; - } - ITextViewer viewer; - - private JSDTContetAssistInvocationContext(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) { - super(viewer, offset, null); - this.viewer = viewer; - // this.offset=getJSPTranslation().getJavaOffset(offset); - // CompletionProposalCollector theCollector = getProposalCollector(); - super.setCollector(theCollector); - } - -// public IDocument getDocument() { -// return -// ((JSPTranslationExtension)getJSPTranslation(viewer)).getJavaDocument(); -// -// } -// protected CompletionProposalCollector getProposalCollector() { -// -// return ((CompletionProposalCollector) ( new JSPProposalCollector( -// getJSPTranslation()) )); -// } - - public IDocument getDocument() { - return viewer.getDocument(); - } -// public IJavaScriptUnit getCompilationUnit() { -// return getJSPTranslation(viewer).getCompilationUnit(); -// } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java deleted file mode 100644 index 21727a6cff..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.contentassist; -import java.util.ArrayList; - -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTHtmlCompletionProcessor { - - public JSDTHtmlCompletionProcessor() {} - - - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - /* add </script if necisary */ - ArrayList allProposals = new ArrayList(); - getJSPTranslation(viewer); - - return (ICompletionProposal[])allProposals.toArray(new ICompletionProposal[allProposals.size()]); - } - - public ICompletionProposal getEndScriptProposal(ITextViewer viewer, int offset) { - /* add </script if necisary */ - - IJsTranslation tran = getJSPTranslation(viewer); - if(tran==null) return null; - - int missingAtOffset = tran.getMissingTagStart(); - - if(offset>=missingAtOffset&& missingAtOffset>-1) { - - String allText = viewer.getDocument().get(); - String text = "</script>"; //$NON-NLS-1$ - - int startInTag = -1; - - for(int i=0;i<text.length() && allText.length()>offset-1;i++) { - if(allText.charAt(offset-1)==text.charAt(i)) { - startInTag = i; - break; - } - } - - if(startInTag==-1 ) { - String displayText = Messages.getString("JSDTHtmlCompletionProcessor.1"); //$NON-NLS-1$ - return new CustomCompletionProposal("\n" + text + "\n" ,offset,0,offset,null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.4"),100); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - String text1 = allText.substring(offset - startInTag - 1, offset).toLowerCase(); - String text2 = text.substring(0, startInTag+1).toLowerCase(); - if(startInTag>-1 && text2.compareTo(text1)==0 ) { - String displayText = Messages.getString("JSDTHtmlCompletionProcessor.5"); //$NON-NLS-1$ - return new CustomCompletionProposal(text ,offset-startInTag-1,0,text.length(),null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.6"),100); //$NON-NLS-1$ - } - - } - - return null; - } - private IJsTranslation getJSPTranslation(ITextViewer viewer) { - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument()); - IDOMDocument xmlDoc = xmlModel.getDocument(); - - JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - - if (fTranslationAdapter != null) { - return fTranslationAdapter.getJsTranslation(true); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return null; - } - -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java deleted file mode 100644 index c59550d820..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java +++ /dev/null @@ -1,222 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.contentassist; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.jsdt.core.CompletionProposal; -import org.eclipse.wst.jsdt.core.Signature; -import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector; -import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator; -import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; - - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTProposalCollector extends CompletionProposalCollector { - static char[] getTypeTriggers() { - return CompletionProposalCollector.TYPE_TRIGGERS; - } - private Comparator fComparator; - private IJsTranslation fTranslation; - -// public List getGeneratedFunctionNames(){ -// if(fGeneratedFunctionNames==null){ -// fGeneratedFunctionNames = fTranslation.getGeneratedFunctionNames(); -// } -// return fGeneratedFunctionNames; -// } - public JSDTProposalCollector(IJsTranslation translation) { - super(translation!=null?translation.getCompilationUnit():null); - if (translation == null) { - throw new IllegalArgumentException("JSPTranslation cannot be null"); //$NON-NLS-1$ - } - fTranslation = translation; - } - - /** - * Cacluates the where the cursor should be after applying this proposal. - * eg. method(|) if the method proposal chosen had params. - * - * @param proposal - * @param completion - * @return - */ - private int calculatePositionAfter(CompletionProposal proposal, String completion) { - int positionAfter = completion.length(); - int kind = proposal.getKind(); - // may need better logic here... - // put cursor inside parenthesis if there's params - // only checking for any kind of declaration - if (kind == CompletionProposal.ANONYMOUS_CLASS_DECLARATION || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.POTENTIAL_METHOD_DECLARATION || kind == CompletionProposal.METHOD_REF) { - int paramCount = Signature.getParameterCount(proposal.getSignature()); - if (completion.length() > 0 && paramCount > 0) { - positionAfter--; - } - } - return positionAfter; - } - - /** - * Overridden to: - translate Java -> JSP offsets - fix - * cursor-position-after - fix mangled servlet name in display string - - * remove unwanted proposals (servlet constructor) - */ - - protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) { - JSDTCompletionProposal jspProposal = null; - // ignore constructor proposals (they're not relevant for our JSP - // proposal list) - if (!proposal.isConstructor()) { -// if (proposal.getKind() == CompletionProposal.TYPE_REF) { -// String signature = String.valueOf(proposal -// .getDeclarationSignature()); -// String completion = String.valueOf(proposal.getCompletion()); -// if (completion.indexOf(signature) != -1) { -// jspProposal = createAutoImportProposal(proposal); -// } -// } - // default behavior -// if (jspProposal == null) { -// for(int i = 0;i<getGeneratedFunctionNames().size();i++){ -// if((new -// String(proposal.getName())).equalsIgnoreCase((String)getGeneratedFunctionNames().get(i))) -// return jspProposal; -// } - jspProposal = createJspProposal(proposal); - // } - } - return jspProposal; - } - -// private JSPCompletionProposal createAutoImportProposal( -// CompletionProposal proposal) { -// -// JSPCompletionProposal jspProposal = null; -// -// String signature = new String(proposal.getDeclarationSignature()); -// String completion = new String(proposal.getCompletion()); -// -// // it's fully qualified so we should -// // add an import statement -// // create an autoimport proposal -// String newCompletion = completion.replaceAll(signature + ".", ""); -// //$NON-NLS-1$ //$NON-NLS-2$ -// -// // java offset -// int offset = proposal.getReplaceStart(); -// // replacement length -// int length = proposal.getReplaceEnd() - offset; -// // translate offset from Java > JSP -// offset = fTranslation.getJspOffset(offset); -// // cursor position after must be calculated -// int positionAfter = calculatePositionAfter(proposal, newCompletion, -// offset); -// -// // from java proposal -// IJavaCompletionProposal javaProposal = super -// .createJavaCompletionProposal(proposal); -// proposal.getDeclarationSignature(); -// Image image = javaProposal.getImage(); -// String displayString = javaProposal.getDisplayString(); -// displayString = getTranslation().fixupMangledName(displayString); -// IContextInformation contextInformation = javaProposal -// .getContextInformation(); -// // don't do this, it's slow -// // String additionalInfo = javaProposal.getAdditionalProposalInfo(); -// int relevance = javaProposal.getRelevance(); -// -// boolean updateLengthOnValidate = true; -// -// jspProposal = new AutoImportProposal(completion, newCompletion, offset, -// length, positionAfter, image, displayString, -// contextInformation, null, relevance, updateLengthOnValidate); -// -// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483 -// // set wrapped java proposal so additional info can be calculated on -// // demand -// jspProposal.setJavaCompletionProposal(javaProposal); -// -// return jspProposal; -// } - private JSDTCompletionProposal createJspProposal(CompletionProposal proposal) { - JSDTCompletionProposal jspProposal; - String completion = String.valueOf(proposal.getCompletion()); - // java offset - int offset = proposal.getReplaceStart(); - // replacement length - int length = proposal.getReplaceEnd() - offset; - // translate offset from Java > JSP - // cursor position after must be calculated - int positionAfter = calculatePositionAfter(proposal, completion); - // from java proposal - IJavaCompletionProposal javaProposal = super.createJavaCompletionProposal(proposal); - proposal.getDeclarationSignature(); - Image image = javaProposal.getImage(); - String displayString = javaProposal.getDisplayString(); - displayString = getTranslation().fixupMangledName(displayString); -// for(int i = 0;i<getGeneratedFunctionNames().size();i++){ -// displayString.replace((String)getGeneratedFunctionNames().get(i), ""); -// } - IContextInformation contextInformation = javaProposal.getContextInformation(); - // String additionalInfo = javaProposal.getAdditionalProposalInfo(); - int relevance = javaProposal.getRelevance(); - boolean updateLengthOnValidate = true; - jspProposal = new JSDTCompletionProposal(completion, offset, length, positionAfter, image, displayString, contextInformation, null, relevance, updateLengthOnValidate); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483 - // set wrapped java proposal so additional info can be calculated on - // demand - jspProposal.setJavaCompletionProposal(javaProposal); - return jspProposal; - } - - private Comparator getComparator() { - if (fComparator == null) { - fComparator = new CompletionProposalComparator(); - } - return fComparator; - } - - /** - * Ensures that we only return JSPCompletionProposals. - * - * @return an array of JSPCompletionProposals - */ - public JSDTCompletionProposal[] getJSPCompletionProposals() { - List results = new ArrayList(); - IJavaCompletionProposal[] javaProposals = getJavaCompletionProposals(); - // need to filter out non JSPCompletionProposals - // because their offsets haven't been translated - for (int i = 0; i < javaProposals.length; i++) { - if (javaProposals[i] instanceof JSDTCompletionProposal) { - results.add(javaProposals[i]); - } - } - Collections.sort(results, getComparator()); - return (JSDTCompletionProposal[]) results.toArray(new JSDTCompletionProposal[results.size()]); - } - - public IJsTranslation getTranslation() { - return fTranslation; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java deleted file mode 100644 index 1f9817875e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.contentassist; - -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.wst.jsdt.internal.ui.text.java.TemplateCompletionProposalComputer; -import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTTemplateAssistProcessor { - TemplateCompletionProposalComputer fJavaTemplateCompletion; - JSDTProposalCollector fProposalCollector; - JsTranslationAdapter fTranslationAdapter; - IProgressMonitor monitor; - - public JSDTTemplateAssistProcessor() { - monitor = new NullProgressMonitor(); - } - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - JavaContentAssistInvocationContext context = getInvocationContext(viewer, offset); - List props = getTemplateCompletionProposalComputer().computeCompletionProposals(context, monitor); - return (ICompletionProposal[]) props.toArray(new ICompletionProposal[] {}); - } - - private JavaContentAssistInvocationContext getInvocationContext(ITextViewer viewer, int offset) { - return JSDTContetAssistInvocationContext.getInstance(viewer, offset, getProposalCollector()); - } - - protected JSDTProposalCollector getProposalCollector() { - return fProposalCollector; - // return new JSPProposalCollector(translation); - } - - private TemplateCompletionProposalComputer getTemplateCompletionProposalComputer() { - if (fJavaTemplateCompletion == null) { - fJavaTemplateCompletion = new TemplateCompletionProposalComputer(); - } - return fJavaTemplateCompletion; - } - - public void setProposalCollector(JSDTProposalCollector translation) { - this.fProposalCollector = translation; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java deleted file mode 100644 index d59e21666a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.contentassist; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.internal.contentassist.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties deleted file mode 100644 index fbdf80852c..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2007 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 -############################################################################### -JSDTHtmlCompletionProcessor.1=<> end with </script> -JSDTHtmlCompletionProcessor.4=Close the script tag. -JSDTHtmlCompletionProcessor.5=<> end with </script> -JSDTHtmlCompletionProcessor.6=Close the script tag. diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java deleted file mode 100644 index e893d448c3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.derived; - -import java.io.IOException; -import java.io.Reader; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public abstract class SingleCharReader extends Reader { - /** - * Gets the content as a String - */ - public String getString() throws IOException { - StringBuffer buf = new StringBuffer(); - int ch; - while ((ch = read()) != -1) { - buf.append((char) ch); - } - return buf.toString(); - } - - /** - * @see Reader#read() - */ - - public abstract int read() throws IOException; - - /** - * @see Reader#read(char[],int,int) - */ - - public int read(char cbuf[], int off, int len) throws IOException { - int end = off + len; - for (int i = off; i < end; i++) { - int ch = read(); - if (ch == -1) { - if (i == off) { - return -1; - } - return i - off; - } - cbuf[i] = (char) ch; - } - return len; - } - - /** - * @see Reader#ready() - */ - - public boolean ready() throws IOException { - return true; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java deleted file mode 100644 index 7a9f5d9755..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.editor; - -import java.util.ResourceBundle; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.RetargetTextEditorAction; -import org.eclipse.wst.html.ui.internal.edit.ui.ActionContributorHTML; -import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup; -import org.eclipse.wst.jsdt.web.ui.internal.IActionConstantsJs; -import org.eclipse.wst.jsdt.web.ui.internal.IActionDefinitionIdsJs; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class ActionContributorJSP extends ActionContributorHTML { - private static final String[] EDITOR_IDS = { "org.eclipse.wst.html.core.htmlsource.source", "org.eclipse.wst.sse.ui.StructuredTextEditor" }; //$NON-NLS-1$ //$NON-NLS-2$ - private RetargetTextEditorAction moveElementAction = null; - private IMenuManager refactorMenu = null; - private RetargetTextEditorAction renameElementAction = null; - - public ActionContributorJSP() { - super(); - ResourceBundle bundle = JsUIMessages.getResourceBundle(); - this.renameElementAction = new RetargetTextEditorAction(bundle, IActionConstantsJs.ACTION_NAME_RENAME_ELEMENT + StructuredTextEditorActionConstants.UNDERSCORE); - this.renameElementAction.setActionDefinitionId(IActionDefinitionIdsJs.RENAME_ELEMENT); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this.renameElementAction, IHelpContextIds.JSP_REFACTORRENAME_HELPID); - this.moveElementAction = new RetargetTextEditorAction(bundle, IActionConstantsJs.ACTION_NAME_MOVE_ELEMENT + StructuredTextEditorActionConstants.UNDERSCORE); - this.moveElementAction.setActionDefinitionId(IActionDefinitionIdsJs.MOVE_ELEMENT); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this.moveElementAction, IHelpContextIds.JSP_REFACTORMOVE_HELPID); - // the refactor menu, add the menu itself to add all refactor actions - this.refactorMenu = new MenuManager(JsUIMessages.ActionContributorJSP_0, RefactorActionGroup.MENU_ID); - refactorMenu.add(this.renameElementAction); - refactorMenu.add(this.moveElementAction); - } - - - protected void addToMenu(IMenuManager menu) { - super.addToMenu(menu); - menu.insertAfter(IWorkbenchActionConstants.M_EDIT, this.refactorMenu); - } - - - protected String[] getExtensionIDs() { - return ActionContributorJSP.EDITOR_IDS; - } - - - public void setActiveEditor(IEditorPart activeEditor) { - super.setActiveEditor(activeEditor); - this.renameElementAction.setAction(getAction(getTextEditor(getActiveEditorPart()), IActionConstantsJs.ACTION_NAME_RENAME_ELEMENT)); - this.moveElementAction.setAction(getAction(getTextEditor(getActiveEditorPart()), IActionConstantsJs.ACTION_NAME_MOVE_ELEMENT)); - } - - - public void setViewerSpecificContributionsEnabled(boolean enabled) { - super.setViewerSpecificContributionsEnabled(enabled); - this.renameElementAction.setEnabled(enabled); - this.moveElementAction.setEnabled(enabled); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java deleted file mode 100644 index c4418fb7d7..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.editor; - -import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public interface IHelpContextIds { - // JSP Fragment Property Page - public static final String JSP_FRAGMENT_HELPID = IHelpContextIds.PREFIX + "jspf1000"; //$NON-NLS-1$ - // // figured out on the fly - // // JSP Source page editor - // public static final String JSP_SOURCEVIEW_HELPID = - // ContentTypeIdForJSP.ContentTypeID_JSP +"_source_HelpId"; //$NON-NLS-1$ - // JSP New File Wizard - Template Page - public static final String JSP_NEWWIZARD_TEMPLATE_HELPID = IHelpContextIds.PREFIX + "jspw0010"; //$NON-NLS-1$ - // JSP Files Preference page - public static final String JSP_PREFWEBX_FILES_HELPID = IHelpContextIds.PREFIX + "webx0050"; //$NON-NLS-1$ - // JSP Styles Preference page - public static final String JSP_PREFWEBX_STYLES_HELPID = IHelpContextIds.PREFIX + "webx0051"; //$NON-NLS-1$ - // JSP Templates Preference page - public static final String JSP_PREFWEBX_TEMPLATES_HELPID = IHelpContextIds.PREFIX + "webx0052"; //$NON-NLS-1$ - // Refactor Move - public static final String JSP_REFACTORMOVE_HELPID = IHelpContextIds.PREFIX + "jspr0020"; //$NON-NLS-1$ - // JSP Source Editor Context Menu - // Refactor Rename - public static final String JSP_REFACTORRENAME_HELPID = IHelpContextIds.PREFIX + "jspr0010"; //$NON-NLS-1$ - // org.eclipse.wst.jsdt.web.ui. - public static final String PREFIX = JsUIPlugin.ID + "."; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java deleted file mode 100644 index 3a9b26af46..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentPartitioningListener; -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.text.edits.TextEdit; -import org.eclipse.wst.jsdt.core.IJavaScriptProject; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.core.formatter.CodeFormatter; -import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil; -import org.eclipse.wst.jsdt.internal.formatter.DefaultCodeFormatter; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class FormattingStrategyJSDT extends ContextBasedFormattingStrategy { - private static final int regionStartIndentLevel = 1; - /** 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(); - private int startIndentLevel; - - /** - * Creates a new java formatting strategy. - */ - public FormattingStrategyJSDT() { - super(); - } - - class ModelIrritant implements IDocumentPartitioningListener { - public ModelIrritant(IDocument attachedDoc) {} - - public void documentPartitioningChanged(IDocument document) { - document.removeDocumentPartitioningListener(this); - if (document instanceof BasicStructuredDocument) { - try { - ((BasicStructuredDocument) document).replace(0, document.getLength(), document.get()); - } catch (BadLocationException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - } - } - } - - /* - * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format() - */ - - public void format() { - super.format(); - final IStructuredDocument document = (IStructuredDocument) fDocuments.removeFirst(); - final TypedPosition partition = (TypedPosition) fPartitions.removeFirst(); - if (document != null) { - try { - // JSPTranslationUtil translationUtil = new - // JSPTranslationUtil(document); - IJsTranslation translation = getTranslation(document); - IJavaScriptUnit cu = translation.getCompilationUnit(); - if (cu != null) { - String cuSource = cu.getSource(); - int javaStart = partition.getOffset(); - int javaLength = partition.getLength(); - TextEdit edit = CodeFormatterUtil.format2(CodeFormatter.K_JAVASCRIPT_UNIT, cuSource, javaStart, javaLength, startIndentLevel, TextUtilities.getDefaultLineDelimiter(document), getPreferences()); - IDocument doc = new Document(translation.getJsText()); - /* error formating the code so abort */ - if(edit==null) return; - edit.apply(doc); - String replaceText = TextUtilities.getDefaultLineDelimiter(document) + getIndentationString(getPreferences(), startIndentLevel) + (doc.get(edit.getOffset(), edit.getLength())).trim() + TextUtilities.getDefaultLineDelimiter(document); - /* - * this is necisary since SSE disconnects document - * partitioners.. Because of that, the replaced regions are - * considered 'partitionless' when the linestyle provider - * trys to color them. - * - */ - document.replaceText(document, partition.getOffset(), partition.getLength(), replaceText); - // document.addDocumentPartitioningListener(new ModelIrritant(document)); - } - } catch (BadLocationException e) { - } catch (JavaScriptModelException e) { - } - } - } - - /* - * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext) - */ - - public void formatterStarts(final IFormattingContext context) { - fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION)); - fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM)); - startIndentLevel = FormattingStrategyJSDT.regionStartIndentLevel + 0; - Map projectOptions = (Map) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES); - if (projectOptions == null) { - IDocument doc = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM); - context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, getProjectOptions(doc)); - } - super.formatterStarts(context); - } - - /* - * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops() - */ - - public void formatterStops() { - super.formatterStops(); - fPartitions.clear(); - fDocuments.clear(); - startIndentLevel = 0; - } - - public String getIndentationString(Map options, int indentationLevel) { - DefaultCodeFormatter formatter = new DefaultCodeFormatter(options); - return formatter.createIndentationString(indentationLevel); - } - - private Map getProjectOptions(IDocument baseDocument) { - IJavaScriptProject javaProject = null; - IDOMModel xmlModel = null; - Map options = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(baseDocument); - String baseLocation = xmlModel.getBaseLocation(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IPath filePath = new Path(baseLocation); - IProject project = null; - if (filePath.segmentCount() > 0) { - project = root.getProject(filePath.segment(0)); - } - if (project != null) { - javaProject = JavaScriptCore.create(project); - } - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - if (javaProject != null) { - options = javaProject.getOptions(true); - } - return options; - } - - public IJsTranslation getTranslation(IStructuredDocument document) { - IJsTranslation tran = null; - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document); - IDOMDocument xmlDoc = xmlModel.getDocument(); - JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (translationAdapter != null) { - tran = translationAdapter.getJsTranslation(true); - } - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return tran; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java deleted file mode 100644 index 018c42416e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.hyperlink; - -import java.io.File; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPathEditorInput; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.editors.text.ILocationProvider; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class ExternalFileEditorInput implements IEditorInput, ILocationProvider { - // copies of this class exist in: - // org.eclipse.wst.xml.ui.internal.hyperlink - // org.eclipse.wst.html.ui.internal.hyperlink - // org.eclipse.wst.jsdt.web.ui.internal.hyperlink - /** - * The workbench adapter which simply provides the label. - * - * @see Eclipse 3.1 - */ - private class WorkbenchAdapter implements IWorkbenchAdapter { - /* - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - return null; - } - - /* - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - - /* - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return ((ExternalFileEditorInput) o).getName(); - } - - /* - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } - } - private File fFile; - private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter(); - - public ExternalFileEditorInput(File file) { - super(); - fFile = file; - fWorkbenchAdapter = new WorkbenchAdapter(); - } - - /* - * @see java.lang.Object#equals(java.lang.Object) - */ - - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ExternalFileEditorInput) { - ExternalFileEditorInput input = (ExternalFileEditorInput) o; - return fFile.equals(input.fFile); - } - if (o instanceof IPathEditorInput) { - IPathEditorInput input = (IPathEditorInput) o; - return getPath().equals(input.getPath()); - } - return false; - } - - /* - * @see org.eclipse.ui.IEditorInput#exists() - */ - public boolean exists() { - return fFile.exists(); - } - - /* - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (ILocationProvider.class.equals(adapter)) { - return this; - } - if (IWorkbenchAdapter.class.equals(adapter)) { - return fWorkbenchAdapter; - } - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - /* - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* - * @see org.eclipse.ui.IEditorInput#getName() - */ - public String getName() { - return fFile.getName(); - } - - /* - * @see org.eclipse.ui.IPathEditorInput#getPath() - * @since 3.1 - */ - public IPath getPath() { - return Path.fromOSString(fFile.getAbsolutePath()); - } - - /* - * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object) - */ - public IPath getPath(Object element) { - if (element instanceof ExternalFileEditorInput) { - ExternalFileEditorInput input = (ExternalFileEditorInput) element; - return Path.fromOSString(input.fFile.getAbsolutePath()); - } - return null; - } - - /* - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - public IPersistableElement getPersistable() { - return null; - } - - /* - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return fFile.getAbsolutePath(); - } - - /* - * @see java.lang.Object#hashCode() - */ - - public int hashCode() { - return fFile.hashCode(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java deleted file mode 100644 index d8905ef9f1..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.hyperlink; - -import java.io.File; - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -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.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class ExternalFileHyperlink implements IHyperlink { - // copies of this class exist in: - // org.eclipse.wst.xml.ui.internal.hyperlink - // org.eclipse.wst.html.ui.internal.hyperlink - // org.eclipse.wst.jsdt.web.ui.internal.hyperlink - private File fHyperlinkFile; - private IRegion fHyperlinkRegion; - - public ExternalFileHyperlink(IRegion region, File file) { - fHyperlinkFile = file; - fHyperlinkRegion = region; - } - - public IRegion getHyperlinkRegion() { - return fHyperlinkRegion; - } - - public String getHyperlinkText() { - String path = fHyperlinkFile.getPath(); - if (path.length() > 60) { - path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length()); - } - return NLS.bind(HTMLUIMessages.Open, path); - } - - public String getTypeLabel() { - return null; - } - - public void open() { - if (fHyperlinkFile != null) { - IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile); - IEditorDescriptor descriptor; - try { - descriptor = IDE.getEditorDescriptor(input.getName(), true); - if (descriptor != null) { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IDE.openEditor(page, input, descriptor.getId(), true); - } - } catch (PartInitException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java deleted file mode 100644 index b0c8096efe..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.hyperlink; - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages; -import org.eclipse.wst.jsdt.ui.JavaScriptUI; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JSDTHyperlink implements IHyperlink { - private IJavaScriptElement fElement; - private IRegion fRegion; - - public JSDTHyperlink(IRegion region, IJavaScriptElement element) { - fRegion = region; - fElement = element; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion() - */ - public IRegion getHyperlinkRegion() { - return fRegion; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() - */ - public String getHyperlinkText() { - return ActionMessages.OpenAction_declaration_label; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() - */ - public String getTypeLabel() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#open() - */ - public void open() { - try { - IEditorPart editor = JavaScriptUI.openInEditor(fElement); - if (editor != null) { - JavaScriptUI.revealInEditor(editor, fElement); - } - } catch (Exception e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java deleted file mode 100644 index 2193098830..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java +++ /dev/null @@ -1,263 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.hyperlink; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.wst.jsdt.core.IClassFile; -import org.eclipse.wst.jsdt.core.IField; -import org.eclipse.wst.jsdt.core.IFunction; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.ILocalVariable; -import org.eclipse.wst.jsdt.core.ISourceRange; -import org.eclipse.wst.jsdt.core.ISourceReference; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.internal.core.JavaElement; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -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.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTHyperlinkDetector extends AbstractHyperlinkDetector { - private IHyperlink createHyperlink(IJavaScriptElement element, IRegion region, IDocument document) { - IHyperlink link = null; - if (region != null) { - // open local variable in the JSP file... - if (element instanceof ISourceReference) { - IFile file = null; - IPath outsidePath = null; - int jspOffset = 0; - IStructuredModel sModel = null; - // try to locate the file in the workspace - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (sModel != null) { - //URIResolver resolver = sModel.getResolver(); - //if (resolver != null) { - // String uriString = resolver.getFileBaseLocation(); - String uriString = sModel.getBaseLocation(); - file = getFile(uriString); - // } - } - } finally { - if (sModel != null) { - sModel.releaseFromRead(); - } - } - // get Java range, translate coordinate to JSP - try { - ISourceRange range = null; - IJsTranslation jspTranslation = getJsTranslation(document); - if (jspTranslation != null) { - // link to local variable definitions - if (element instanceof ILocalVariable) { - range = ((ILocalVariable) element).getNameRange(); - IJavaScriptElement unit=((ILocalVariable) element).getParent(); - IJavaScriptUnit myUnit = jspTranslation.getCompilationUnit(); - - while(!(unit instanceof IJavaScriptUnit || unit instanceof IClassFile || unit==null)) { - unit = ((JavaElement) unit).getParent(); - } - if(unit instanceof IJavaScriptUnit) { - IJavaScriptUnit cu = (IJavaScriptUnit)unit; - if(cu!=myUnit) { - file = getFile(cu.getPath().toString()); - if(file==null) { - outsidePath = cu.getPath(); - } - } - }else if(unit instanceof IClassFile) { - IClassFile cu = (IClassFile)unit; - if(cu!=myUnit) { - file = getFile(cu.getPath().toString()); - if(file==null) { - outsidePath = cu.getPath(); - } - } - } - - } - // linking to fields of the same compilation unit - else if (element.getElementType() == IJavaScriptElement.FIELD) { - Object cu = ((IField) element).getJavaScriptUnit(); - if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) { - range = ((ISourceReference) element).getSourceRange(); - } - } - // linking to methods of the same compilation unit - else if (element.getElementType() == IJavaScriptElement.METHOD) { - Object cu = ((IFunction) element).getJavaScriptUnit(); - if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) { - range = ((ISourceReference) element).getSourceRange(); - } - } - } - if (range != null && file != null) { - jspOffset = range.getOffset(); - if (jspOffset >= 0) { - link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength())); - } - }else if (range!=null && outsidePath!=null) { - jspOffset = range.getOffset(); - if (jspOffset >= 0) { - link = new ExternalFileHyperlink(region,outsidePath.toFile()); - } - } - } catch (JavaScriptModelException jme) { - Logger.log(Logger.WARNING_DEBUG, jme.getMessage(), jme); - } - } - if (link == null) { - link = new JSDTHyperlink(region, element); - } - } - return link; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, - * org.eclipse.jface.text.IRegion, boolean) - */ - public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { - List hyperlinks = new ArrayList(0); - if (region != null && textViewer != null) { - IDocument document = textViewer.getDocument(); - IJsTranslation jsTranslation = getJsTranslation(document); - if (jsTranslation != null) { - IJavaScriptElement[] elements = jsTranslation.getElementsFromJsRange(region.getOffset(), region.getOffset() + region.getLength()); - if (elements != null && elements.length > 0) { - // create a hyperlink for each JavaScript element - for (int i = 0; i < elements.length; ++i) { - IJavaScriptElement element = elements[i]; - // find hyperlink range for Java element - IRegion hyperlinkRegion = selectWord(document, region.getOffset()); - IHyperlink link = createHyperlink(element, hyperlinkRegion, document); - if (link != null) { - hyperlinks.add(link); - } - } - } - } - } - if (hyperlinks.size() == 0) { - return null; - } - return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]); - } - - /** - * Returns an IFile from the given uri if possible, null if cannot find file - * from uri. - * - * @param fileString - * file system path - * @return returns IFile if fileString exists in the workspace - */ - private IFile getFile(String fileString) { - IFile file = null; - if (fileString != null) { - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(fileString); - if(resource!=null && resource instanceof IFile) { - file = (IFile)resource; - } - } - return file; - } - - /** - * Get JSP translation object - * - * @return JSPTranslation if one exists, null otherwise - */ - private IJsTranslation getJsTranslation(IDocument document) { - IJsTranslation translation = null; - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (xmlModel != null) { - IDOMDocument xmlDoc = xmlModel.getDocument(); - JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (adapter != null) { - translation = adapter.getJsTranslation(true); - } - } - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return translation; - } - - /** - * Java always selects word when defining region - * - * @param document - * @param anchor - * @return IRegion - */ - private IRegion selectWord(IDocument document, int anchor) { - try { - int offset = anchor; - char c; - while (offset >= 0) { - c = document.getChar(offset); - if (!Character.isJavaIdentifierPart(c)) { - break; - } - --offset; - } - int start = offset; - offset = anchor; - int length = document.getLength(); - while (offset < length) { - c = document.getChar(offset); - if (!Character.isJavaIdentifierPart(c)) { - break; - } - ++offset; - } - int end = offset; - if (start == end) { - return new Region(start, 0); - } - return new Region(start + 1, end - start - 1); - } catch (BadLocationException x) { - return null; - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java deleted file mode 100644 index ea48fbb941..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.hyperlink; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; - -class WorkspaceFileHyperlink implements IHyperlink { - // copies of this class exist in: - // org.eclipse.wst.xml.ui.internal.hyperlink - // org.eclipse.wst.html.ui.internal.hyperlink - // org.eclipse.wst.jsdt.web.ui.internal.hyperlink - private IFile fFile; - private IRegion fHighlightRange; - private IRegion fRegion; - - public WorkspaceFileHyperlink(IRegion region, IFile file) { - fRegion = region; - fFile = file; - } - - public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range) { - fRegion = region; - fFile = file; - fHighlightRange = range; - } - - public IRegion getHyperlinkRegion() { - return fRegion; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() - */ - public String getHyperlinkText() { - String path = fFile.getFullPath().toString(); - if (path.length() > 60) { - path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length()); - } - return NLS.bind(HTMLUIMessages.Open, path); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() - */ - public String getTypeLabel() { - // TODO Auto-generated method stub - return null; - } - - public void open() { - if (fFile != null && fFile.exists()) { - try { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IEditorPart editor = IDE.openEditor(page, fFile, true); - // highlight range in editor if possible - if (fHighlightRange != null && editor instanceof ITextEditor) { - ((ITextEditor) editor).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength()); - } - } catch (PartInitException pie) { - Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie); - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java deleted file mode 100644 index bf603d05b9..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java +++ /dev/null @@ -1,502 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.hyperlink; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; -import org.eclipse.jface.text.hyperlink.URLHyperlink; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper; -import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Attr; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -import com.ibm.icu.util.StringTokenizer; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class XMLHyperlinkDetector implements IHyperlinkDetector { - // copies of this class exist in: - // org.eclipse.wst.xml.ui.internal.hyperlink - // org.eclipse.wst.html.ui.internal.hyperlink - // org.eclipse.wst.jsdt.web.ui.internal.hyperlink - private final String HTTP_PROTOCOL = "http://";//$NON-NLS-1$ - private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation"; //$NON-NLS-1$ - private final String SCHEMA_LOCATION = "schemaLocation"; //$NON-NLS-1$ - private final String XMLNS = "xmlns"; //$NON-NLS-1$ - private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$ - - /** - * Create the appropriate hyperlink - * - * @param uriString - * @param hyperlinkRegion - * @return IHyperlink - */ - private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) { - IHyperlink link = null; - if (isHttp(uriString)) { - link = new URLHyperlink(hyperlinkRegion, uriString); - } else { - // try to locate the file in the workspace - File systemFile = getFileFromUriString(uriString); - if (systemFile != null) { - String systemPath = systemFile.getPath(); - IFile file = getFile(systemPath); - if (file != null) { - // this is a WorkspaceFileHyperlink since file exists in - // workspace - link = new WorkspaceFileHyperlink(hyperlinkRegion, file); - } else { - // this is an ExternalFileHyperlink since file does not - // exist in workspace - link = new ExternalFileHyperlink(hyperlinkRegion, systemFile); - } - } - } - return link; - } - - public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { - // for now, only capable of creating 1 hyperlink - List hyperlinks = new ArrayList(0); - if (region != null && textViewer != null) { - IDocument document = textViewer.getDocument(); - Node currentNode = getCurrentNode(document, region.getOffset()); - if (currentNode != null) { - String uriString = null; - if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) { - // doctype nodes - uriString = getURIString(currentNode, document); - } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) { - // element nodes - Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset()); - if (currentAttr != null) { - // try to find link for current attribute - // resolve attribute value - uriString = getURIString(currentAttr, document); - // verify validity of uri string - if (uriString == null || !isValidURI(uriString)) { - // reset current attribute - currentAttr = null; - } - } - if (currentAttr == null) { - // try to find a linkable attribute within element - currentAttr = getLinkableAttr((Element) currentNode); - if (currentAttr != null) { - uriString = getURIString(currentAttr, document); - } - } - currentNode = currentAttr; - } - // try to create hyperlink from information gathered - if (uriString != null && currentNode != null && isValidURI(uriString)) { - IRegion hyperlinkRegion = getHyperlinkRegion(currentNode); - IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode); - if (hyperlink != null) { - hyperlinks.add(hyperlink); - } - } - } - } - if (hyperlinks.size() == 0) { - return null; - } - return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]); - } - - /** - * Get the base location from the current model (local file system) - */ - private String getBaseLocation(IDocument document) { - String baseLoc = null; - // get the base location from the current model - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (sModel != null) { - IPath location = new Path(sModel.getBaseLocation()); - if (location.toFile().exists()) { - baseLoc = location.toString(); - } else { - if (location.segmentCount() > 1) { - baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(location).getLocation().toString(); - } else { - baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(location).toString(); - } - } - } - } finally { - if (sModel != null) { - sModel.releaseFromRead(); - } - } - return baseLoc; - } - - /** - * Get the CMElementDeclaration for an element - * - * @param element - * @return CMElementDeclaration - */ - private CMElementDeclaration getCMElementDeclaration(Element element) { - CMElementDeclaration ed = null; - ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - if (mq != null) { - ed = mq.getCMElementDeclaration(element); - } - return ed; - } - - /** - * Returns the attribute node within node at offset - * - * @param node - * @param offset - * @return Attr - */ - private Attr getCurrentAttrNode(Node node, int offset) { - if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && (node.hasAttributes())) { - NamedNodeMap attrs = node.getAttributes(); - // go through each attribute in node and if attribute contains - // offset, return that attribute - for (int i = 0; i < attrs.getLength(); ++i) { - // assumption that if parent node is of type IndexedRegion, - // then its attributes will also be of type IndexedRegion - IndexedRegion attRegion = (IndexedRegion) attrs.item(i); - if (attRegion.contains(offset)) { - return (Attr) attrs.item(i); - } - } - } - return null; - } - - /** - * Returns the node the cursor is currently on in the document. null if no - * node is selected - * - * @param offset - * @return Node either element, doctype, text, or null - */ - private Node getCurrentNode(IDocument document, int offset) { - // get the current node at the offset (returns either: element, - // doctype, text) - IndexedRegion inode = null; - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); - inode = sModel.getIndexedRegion(offset); - if (inode == null) { - inode = sModel.getIndexedRegion(offset - 1); - } - } finally { - if (sModel != null) { - sModel.releaseFromRead(); - } - } - if (inode instanceof Node) { - return (Node) inode; - } - return null; - } - - /** - * Returns an IFile from the given uri if possible, null if cannot find file - * from uri. - * - * @param fileString - * file system path - * @return returns IFile if fileString exists in the workspace - */ - private IFile getFile(String fileString) { - IFile file = null; - if (fileString != null) { - IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString)); - for (int i = 0; i < files.length && file == null; i++) { - if (files[i].exists()) { - file = files[i]; - } - } - } - return file; - } - - /** - * Create a file from the given uri string - * - * @param uriString - - * assumes uriString is not http:// - * @return File created from uriString if possible, null otherwise - */ - private File getFileFromUriString(String uriString) { - File file = null; - try { - // first just try to create a file directly from uriString as - // default in case create file from uri does not work - file = new File(uriString); - // try to create file from uri - URI uri = new URI(uriString); - file = new File(uri); - } catch (Exception e) { - // if exception is thrown while trying to create File just ignore - // and file will be null - } - return file; - } - - private IRegion getHyperlinkRegion(Node node) { - IRegion hyperRegion = null; - if (node != null) { - short nodeType = node.getNodeType(); - if (nodeType == Node.DOCUMENT_TYPE_NODE) { - // handle doc type node - IDOMNode docNode = (IDOMNode) node; - hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset()); - } else if (nodeType == Node.ATTRIBUTE_NODE) { - // handle attribute nodes - IDOMAttr att = (IDOMAttr) node; - // do not include quotes in attribute value region - int regOffset = att.getValueRegionStartOffset(); - ITextRegion valueRegion = att.getValueRegion(); - if (valueRegion != null) { - int regLength = valueRegion.getTextLength(); - String attValue = att.getValueRegionText(); - if (StringUtils.isQuoted(attValue)) { - ++regOffset; - regLength = regLength - 2; - } - hyperRegion = new Region(regOffset, regLength); - } - } - } - return hyperRegion; - } - - /** - * Attempts to find an attribute within element that is openable. - * - * @param element - - * cannot be null - * @return Attr attribute that can be used for open on, null if no attribute - * could be found - */ - private Attr getLinkableAttr(Element element) { - CMElementDeclaration ed = getCMElementDeclaration(element); - // get the list of attributes for this node - NamedNodeMap attrs = element.getAttributes(); - for (int i = 0; i < attrs.getLength(); ++i) { - // check if this attribute is "openOn-able" - Attr att = (Attr) attrs.item(i); - if (isLinkableAttr(att, ed)) { - return att; - } - } - return null; - } - - /** - * Find the location hint for the given namespaceURI if it exists - * - * @param elementNode - - * cannot be null - * @param namespaceURI - - * cannot be null - * @return location hint (systemId) if it was found, null otherwise - */ - private String getLocationHint(Element elementNode, String namespaceURI) { - Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION); - if (schemaLocNode != null) { - StringTokenizer st = new StringTokenizer(schemaLocNode.getValue()); - while (st.hasMoreTokens()) { - String publicId = st.hasMoreTokens() ? st.nextToken() : null; - String systemId = st.hasMoreTokens() ? st.nextToken() : null; - // found location hint - if (namespaceURI.equalsIgnoreCase(publicId)) { - return systemId; - } - } - } - return null; - } - - /** - * Returns the URI string - * - * @param node - - * assumes not null - */ - private String getURIString(Node node, IDocument document) { - String resolvedURI = null; - // need the base location, publicId, and systemId for URIResolver - String baseLoc = null; - String publicId = null; - String systemId = null; - short nodeType = node.getNodeType(); - // handle doc type node - if (nodeType == Node.DOCUMENT_TYPE_NODE) { - baseLoc = getBaseLocation(document); - publicId = ((DocumentType) node).getPublicId(); - systemId = ((DocumentType) node).getSystemId(); - } else if (nodeType == Node.ATTRIBUTE_NODE) { - // handle attribute node - Attr attrNode = (Attr) node; - String attrName = attrNode.getName(); - String attrValue = attrNode.getValue(); - attrValue = StringUtils.strip(attrValue); - if (attrValue != null && attrValue.length() > 0) { - baseLoc = getBaseLocation(document); - // handle schemaLocation attribute - String prefix = DOMNamespaceHelper.getPrefix(attrName); - String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName); - if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) { - publicId = attrValue; - systemId = getLocationHint(attrNode.getOwnerElement(), publicId); - if (systemId == null) { - systemId = attrValue; - } - } else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) { - // for now just use the first pair - // need to look into being more precise - StringTokenizer st = new StringTokenizer(attrValue); - publicId = st.hasMoreTokens() ? st.nextToken() : null; - systemId = st.hasMoreTokens() ? st.nextToken() : null; - // else check if xmlns publicId = value - } else { - systemId = attrValue; - } - } - } - resolvedURI = resolveURI(baseLoc, publicId, systemId); - return resolvedURI; - } - - /** - * Returns true if this uriString is an http string - * - * @param uriString - * @return true if uriString is http string, false otherwise - */ - private boolean isHttp(String uriString) { - boolean isHttp = false; - if (uriString != null) { - String tempString = uriString.toLowerCase(); - if (tempString.startsWith(HTTP_PROTOCOL)) { - isHttp = true; - } - } - return isHttp; - } - - /** - * Checks to see if the given attribute is openable. Attribute is openable - * if it is a namespace declaration attribute or if the attribute value is - * of type URI. - * - * @param attr - * cannot be null - * @param cmElement - * CMElementDeclaration associated with the attribute (can be - * null) - * @return true if this attribute is "openOn-able" false otherwise - */ - private boolean isLinkableAttr(Attr attr, CMElementDeclaration cmElement) { - String attrName = attr.getName(); - String prefix = DOMNamespaceHelper.getPrefix(attrName); - String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName); - // determine if attribute is namespace declaration - if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) { - return true; - } - // determine if attribute contains schema location - if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) { - return true; - } - // determine if attribute value is of type URI - if (cmElement != null) { - CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) cmElement.getAttributes().getNamedItem(attrName); - if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) { - return true; - } - } - return false; - } - - /** - * Checks whether the given uriString is really pointing to a file - * - * @param uriString - * @return boolean - */ - private boolean isValidURI(String uriString) { - boolean isValid = false; - if (isHttp(uriString)) { - isValid = true; - } else { - File file = getFileFromUriString(uriString); - if (file != null) { - isValid = file.isFile(); - } - } - return isValid; - } - - /** - * Resolves the given URI information - * - * @param baseLocation - * @param publicId - * @param systemId - * @return String resolved uri. - */ - private String resolveURI(String baseLocation, String publicId, String systemId) { - // dont resolve if there's nothing to resolve - if ((baseLocation == null) && (publicId == null) && (systemId == null)) { - return null; - } - return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java deleted file mode 100644 index e165f7ddd7..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.DocumentChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.osgi.util.NLS; -import org.eclipse.text.edits.MalformedTreeException; -import org.eclipse.text.edits.MultiTextEdit; -import org.eclipse.text.edits.ReplaceEdit; -import org.eclipse.text.edits.TextEdit; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.core.search.SearchMatch; -import org.eclipse.wst.jsdt.core.search.SearchRequestor; -import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -import org.eclipse.wst.sse.core.internal.document.DocumentReader; -import org.eclipse.wst.sse.core.internal.encoding.CodedStreamCreator; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class BasicRefactorSearchRequestor extends SearchRequestor { - /** - * Change class that wraps a text edit on the jsp document - */ - private class RenameChange extends DocumentChange { - private String fDescription = JsUIMessages.BasicRefactorSearchRequestor_0; - private TextEdit fEdit = null; - private IDocument fJSPDoc = null; - private IFile fJSPFile = null; - - public RenameChange(IFile jspFile, IDocument jspDoc, TextEdit edit, String description) { - super(JsUIMessages.BasicRefactorSearchRequestor_6, jspDoc); - this.fEdit = edit; - this.fJSPFile = jspFile; - this.fJSPDoc = jspDoc; - this.fDescription = description; - } - - - public Object getModifiedElement() { - return getElement(); - } - - - public String getName() { - return this.fDescription; - } - - - public IDocument getPreviewDocument(IProgressMonitor pm) throws CoreException { - IDocument copyDoc = new Document(fJSPDoc.get()); - try { - fEdit.apply(copyDoc); - } catch (MalformedTreeException e) { - // ignore - } catch (BadLocationException e) { - // ignore - } - return copyDoc; - } - - /** - * Checks if a document is open in an editor - * - * @param jspDoc - * @return - */ - private boolean isOpenInEditor(IDocument jspDoc) { - IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - IWorkbenchWindow w = null; - for (int i = 0; i < windows.length; i++) { - w = windows[i]; - IWorkbenchPage page = w.getActivePage(); - if (page != null) { - IEditorReference[] references = page.getEditorReferences(); - IEditorPart editor = null; - Object o = null; - IDocument doc = null; - for (int j = 0; j < references.length; j++) { - editor = references[j].getEditor(true); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3764 - // use adapter to get ITextEditor (for things like - // page designer) - o = editor.getAdapter(ITextEditor.class); - if (o != null && o instanceof ITextEditor) { - doc = ((ITextEditor) o).getDocumentProvider().getDocument(editor.getEditorInput()); - if (doc != null && doc.equals(jspDoc)) { - return true; - } - } - } - } - } - return false; - } - - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - return new RefactoringStatus(); - } - - - public Change perform(IProgressMonitor pm) throws CoreException { - RenameChange undoChange = null; - try { - if (!isOpenInEditor(this.fJSPDoc)) { - // apply edit to JSP doc AND save model - undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription); - saveFile(this.fJSPFile, this.fJSPDoc); - } else { - // just apply edit to JSP document - undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription); - } - } catch (MalformedTreeException e) { - Logger.logException(e); - } catch (BadLocationException e) { - Logger.logException(e); - } - return undoChange; - } - - /** - * Performed in an operation since it modifies resources in the - * workspace - * - * @param jspDoc - * @throws CoreException - */ - private void saveFile(IFile jspFile, IDocument jspDoc) { - SaveJspFileOp op = new SaveJspFileOp(jspFile, jspDoc); - try { - op.run(JsSearchSupport.getInstance().getProgressMonitor()); - } catch (InvocationTargetException e) { - Logger.logException(e); - } catch (InterruptedException e) { - Logger.logException(e); - } - } - } - // end inner class SaveJspFileOp - /** - * Workspace operation to perform save on model for updated documents. - * Should only be done on models not open in an editor. - */ - private class SaveJspFileOp extends WorkspaceModifyOperation { - private IDocument fJSPDoc = null; - private IFile fJSPFile = null; - - public SaveJspFileOp(IFile jspFile, IDocument jspDoc) { - this.fJSPDoc = jspDoc; - this.fJSPFile = jspFile; - } - - - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3765 - // save file w/ no intermediate model creation - CodedStreamCreator codedStreamCreator = new CodedStreamCreator(); - Reader reader = new DocumentReader(this.fJSPDoc); - codedStreamCreator.set(this.fJSPFile, reader); - ByteArrayOutputStream codedByteStream = null; - InputStream codedStream = null; - try { - codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(); - codedStream = new ByteArrayInputStream(codedByteStream.toByteArray()); - if (this.fJSPFile.exists()) { - this.fJSPFile.setContents(codedStream, true, true, null); - } else { - this.fJSPFile.create(codedStream, false, null); - } - } catch (CoreException e) { - Logger.logException(e); - } catch (IOException e) { - Logger.logException(e); - } finally { - try { - if (codedByteStream != null) { - codedByteStream.close(); - } - if (codedStream != null) { - codedStream.close(); - } - } catch (IOException e) { - // unlikely - } - } - } - } - // end inner class RenameChange - /** The type being renamed (the old type) */ - IJavaScriptElement fElement = null; - /** The new name of the type being renamed */ - private String fNewName = ""; //$NON-NLS-1$ - /** maps a JSPSearchDocument path -> MultiTextEdit for the java file */ - private HashMap fSearchDocPath2JavaEditMap = null; - - public BasicRefactorSearchRequestor(IJavaScriptElement element, String newName) { - this.fNewName = newName; - this.fElement = element; - this.fSearchDocPath2JavaEditMap = new HashMap(); - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch) - */ - - public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException { - String matchDocumentPath = javaMatch.getResource().getFullPath().toString(); - SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath); - if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) { - String renameText = getRenameText((JSDTSearchDocumentDelegate) searchDoc, javaMatch); - // add it for the correct document - addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText)); - } - } - - /** - * Adds to the multi edit for a give java document. - * - * @param javaDocument - * @param javaEdit - */ - private void addJavaEdit(String searchDocPath, ReplaceEdit javaEdit) { - Object o = this.fSearchDocPath2JavaEditMap.get(searchDocPath); - if (o != null) { - MultiTextEdit multi = (MultiTextEdit) o; - multi.addChild(javaEdit); - } else { - // use a multi edit so doc position offsets get updated - // automatically - // when adding multiple child edits - MultiTextEdit multi = new MultiTextEdit(); - multi.addChild(javaEdit); - this.fSearchDocPath2JavaEditMap.put(searchDocPath, multi); - } - } - - private Change createChange(JSDTSearchDocumentDelegate searchDoc, TextEdit edit) { - IDocument doc = searchDoc.getJspTranslation().getHtmlDocument(); - String file = searchDoc.getFile().getName(); - String description = getDescription(); - try { - // document lines are 0 based - String lineNumber = Integer.toString(doc.getLineOfOffset(edit.getOffset()) + 1); - description += " " + NLS.bind(JsUIMessages.BasicRefactorSearchRequestor_1, new String[] { file, lineNumber }); //$NON-NLS-1$ - } catch (BadLocationException e) { - Logger.logException(e); - } - return new RenameChange(searchDoc.getFile(), doc, edit, description); - } - - /** - * - * @return all JSP changes for the search matches for the given Type - */ - public Change[] getChanges() { - JsSearchSupport support = JsSearchSupport.getInstance(); - List changes = new ArrayList(); - Iterator keys = fSearchDocPath2JavaEditMap.keySet().iterator(); - String searchDocPath = null; - SearchDocument delegate = null; - while (keys.hasNext()) { - // create on the fly - searchDocPath = (String) keys.next(); - MultiTextEdit javaEdit = (MultiTextEdit) fSearchDocPath2JavaEditMap.get(searchDocPath); - delegate = support.getSearchDocument(searchDocPath); - if (delegate != null && delegate instanceof JSDTSearchDocumentDelegate) { - JSDTSearchDocumentDelegate javaDelegate = (JSDTSearchDocumentDelegate) delegate; - changes.add(createChange(javaDelegate, javaEdit)); - } - } - return (Change[]) changes.toArray(new Change[changes.size()]); - } - - /** - * Subclasses should override to better describe the change. - * - * @return - */ - protected String getDescription() { - return ""; //$NON-NLS-1$ - } - - public IJavaScriptElement getElement() { - return this.fElement; - } - - /** - * @return the new name for the Type - */ - public String getNewName() { - return this.fNewName; - } - - /** - * @param searchDoc - * @return - */ - protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - return getNewName(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java deleted file mode 100644 index d671fcf160..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.java.refactoring; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -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.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JSPJavaSelectionProvider { - static IJavaScriptElement[] getSelection(ITextEditor textEditor) { - IJavaScriptElement[] elements = null; - IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); - ISelection selection = textEditor.getSelectionProvider().getSelection(); - if (selection instanceof ITextSelection) { - ITextSelection textSelection = (ITextSelection) selection; - // get the JSP translation object for this editor's document - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model instanceof IDOMModel) { - IDOMModel xmlModel = (IDOMModel) model; - IDOMDocument xmlDoc = xmlModel.getDocument(); - JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (adapter != null) { - IJsTranslation translation = adapter.getJsTranslation(true); - elements = translation.getElementsFromJsRange(textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength()); - } - } - } finally { - if (model != null) { - model.releaseFromRead(); - } - } - } - if (elements == null) { - elements = new IJavaScriptElement[0]; - } - return elements; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java deleted file mode 100644 index 447afce30b..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.wst.jsdt.core.IFunction; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPMethodRenameChange extends Change { - public static Change[] createChangesFor(IFunction method, String newName) { - JsSearchSupport support = JsSearchSupport.getInstance(); - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - BasicRefactorSearchRequestor requestor = new JSPMethodRenameRequestor(method, newName); - support.searchRunnable(method, new JsSearchScope(), requestor); - return requestor.getChanges(); - } - - - public Object getModifiedElement() { - // pa_TODO Auto-generated method stub - return null; - } - - - public String getName() { - return JsUIMessages.JSP_changes; - } - - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - - public Change perform(IProgressMonitor pm) throws CoreException { - // pa_TODO return the "undo" change here - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java deleted file mode 100644 index 27f7ddbfb2..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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 - *******************************************************************************/ -/* - * Created on May 6, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; -import org.eclipse.wst.jsdt.core.IFunction; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPMethodRenameParticipant extends RenameParticipant { - private IFunction fMethod = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPMethodRenameChange.createChangesFor(this.fMethod, getArguments().getNewName()); - CompositeChange multiChange = null; - if (changes.length > 0) { - multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes); - } - return multiChange; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - - public String getName() { - String name = ""; //$NON-NLS-1$ - if (this.fMethod != null) { - try { - name = this.fMethod.getSource(); - } catch (JavaScriptModelException e) { - Logger.logException(e); - } - } - return name; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - - protected boolean initialize(Object element) { - if (element instanceof IFunction) { - this.fMethod = (IFunction) element; - return true; - }else if (element instanceof IJavaWebNode) { - if(((IJavaWebNode)element).getJavaElement() instanceof IFunction) { - this.fMethod = (IFunction) ((IJavaWebNode)element).getJavaElement(); - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java deleted file mode 100644 index 11e6833c3e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.search.SearchMatch; -import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPMethodRenameRequestor extends BasicRefactorSearchRequestor { - public JSPMethodRenameRequestor(IJavaScriptElement element, String newName) { - super(element, newName); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - - protected String getDescription() { - String methodName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_3, new String[] { methodName, newName }); - return description; - } - - - protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - String javaText = searchDoc.getJspTranslation().getJsText(); - String methodText = javaText.substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - String methodSuffix = methodText.substring(methodText.indexOf("(")); //$NON-NLS-1$ - return getNewName() + methodSuffix; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java deleted file mode 100644 index 0679a104e2..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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.java.refactoring; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * An action delegate that launches JDT move element wizard - * - * Still relies heavily on internal API will change post 3.0 with public move - * support https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 - */ -public class JSPMoveElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - // private IEditorPart fEditor; - public void dispose() { - // nulling out just in case - // fEditor = null; - } - - public void init(IAction action) { - if (action != null) { - action.setText(JsUIMessages.MoveElement_label); - action.setToolTipText(JsUIMessages.MoveElement_label); - } - } - - public void init(IViewPart view) { - // do nothing - } - - public void run(IAction action) { - // no-op until we know how we're supposed to use this - // eclipse 3.2M5 - // public move support: - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 - // IJavaScriptElement[] elements = getSelectedElements(); - // if (elements.length > 0) { - // - // // need to check if it's movable - // try { - // JavaMoveProcessor processor = - // JavaMoveProcessor.create(getResources(elements), elements); - // - // Shell parent = - // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - // MoveRefactoring refactoring = new MoveRefactoring(processor); - // - // RefactoringWizard wizard = createWizard(refactoring); - // - // /* - // * We want to get the shell from the refactoring dialog but - // * it's not known at this point, so we pass the wizard and - // * then, once the dialog is open, we will have access to its - // * shell. - // */ - // - // processor.setCreateTargetQueries(new CreateTargetQueries(wizard)); - // processor.setReorgQueries(new ReorgQueries(wizard)); - // // String openRefactoringWizMsg = - // // - // RefactoringMessages.getString("OpenRefactoringWizardAction.refactoring"); - // // //$NON-NLS-1$ - // String openRefactoringWizMsg = JSPUIMessages.MoveElementWizard; // - // "Move - // // the - // // selected - // // elements"; - // // //$NON-NLS-1$ - // new RefactoringStarter().activate(refactoring, wizard, parent, - // openRefactoringWizMsg, true); - // - // PlatformStatusLineUtil.clearStatusLine(); - // - // } - // catch (JavaScriptModelException e) { - // Logger.logException(e); - // } - // } - // else { - // PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPMoveElementAction_0); - // //$NON-NLS-1$ - // } - } - - public void runWithEvent(IAction action, Event event) { - run(action); - } - - public void selectionChanged(IAction action, ISelection selection) { - PlatformStatusLineUtil.clearStatusLine(); - } - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - // fEditor = targetEditor; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java deleted file mode 100644 index 8a8a378351..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.wst.jsdt.core.IPackageFragment; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPPackageRenameChange extends Change { - public static Change[] createChangesFor(IPackageFragment pkg, String newName) { - JsSearchSupport support = JsSearchSupport.getInstance(); - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - BasicRefactorSearchRequestor requestor = new JSPPackageRenameRequestor(pkg, newName); - support.searchRunnable(pkg, new JsSearchScope(), requestor); - return requestor.getChanges(); - } - - - public Object getModifiedElement() { - // return this.pkg; - return null; - } - - - public String getName() { - return JsUIMessages.JSP_changes; - } - - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java deleted file mode 100644 index 161f73a736..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; -import org.eclipse.wst.jsdt.core.IPackageFragment; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * Remember to change the plugin.xml file if the name of this class changes. - * - * @author pavery - */ -public class JSPPackageRenameParticipant extends RenameParticipant { - private IPackageFragment fPkg = null; - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPPackageRenameChange.createChangesFor(this.fPkg, getArguments().getNewName()); - CompositeChange multiChange = null; - if (changes.length > 0) { - multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes); - } - return multiChange; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - - public String getName() { - String name = ""; //$NON-NLS-1$ - if (this.fPkg != null) { - name = this.fPkg.getElementName(); - } - return name; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - - protected boolean initialize(Object element) { - if (element instanceof IPackageFragment) { - this.fPkg = (IPackageFragment) element; - return true; - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java deleted file mode 100644 index 6fa4592043..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPPackageRenameRequestor extends BasicRefactorSearchRequestor { - /** - * Element is the old package. newName is the new package name. - * - * @param element - * @param newName - */ - public JSPPackageRenameRequestor(IJavaScriptElement element, String newName) { - super(element, newName); - } - - /* - * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - - protected String getDescription() { - String packageName = getElement().getElementName(); - String newName = getNewName(); - String description = NLS.bind(JsUIMessages.BasicRefactorSearchRequestor_5, (new String[] { packageName, newName })); - return description; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java deleted file mode 100644 index 7fd2fb5441..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IFunction; -import org.eclipse.wst.jsdt.core.IPackageFragment; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.ui.refactoring.RenameSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSPRenameElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - private IEditorPart fEditor; - - public void dispose() { - // nulling out just in case - fEditor = null; - } - - private IJavaScriptElement getSelectedElement() { - IJavaScriptElement element = null; - if (fEditor instanceof ITextEditor) { - IJavaScriptElement[] elements = JSPJavaSelectionProvider.getSelection((ITextEditor) fEditor); - if (elements.length == 1) { - element = elements[0]; - } - } - return element; - } - - public void init(IAction action) { - if (action != null) { - action.setText(JsUIMessages.RenameElement_label); - action.setToolTipText(JsUIMessages.RenameElement_label); - } - } - - public void init(IViewPart view) { - // do nothing - } - - public void run(IAction action) { - IJavaScriptElement element = getSelectedElement(); - if (element != null) { - RenameSupport renameSupport = null; - try { - switch (element.getElementType()) { - case IJavaScriptElement.TYPE: - renameSupport = RenameSupport.create((IType) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - case IJavaScriptElement.METHOD: - renameSupport = RenameSupport.create((IFunction) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - case IJavaScriptElement.PACKAGE_FRAGMENT: - renameSupport = RenameSupport.create((IPackageFragment) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - } - if (renameSupport != null) { - renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - PlatformStatusLineUtil.clearStatusLine(); - } - } catch (CoreException e) { - Logger.logException(e); - } - } else { - PlatformStatusLineUtil.displayErrorMessage(JsUIMessages.JSPRenameElementAction_0); - PlatformStatusLineUtil.addOneTimeClearListener(); - } - } - - public void runWithEvent(IAction action, Event event) { - run(action); - } - - public void selectionChanged(IAction action, ISelection selection) { - PlatformStatusLineUtil.clearStatusLine(); - } - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - fEditor = targetEditor; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java deleted file mode 100644 index 6eaa39b9ec..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSPTypeMoveChange extends Change { - public static Change[] createChangesFor(IType type, String newName) { - JsSearchSupport support = JsSearchSupport.getInstance(); - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - JSPTypeMoveRequestor requestor = new JSPTypeMoveRequestor(type, newName); - support.searchRunnable(type, new JsSearchScope(), requestor); - return requestor.getChanges(); - } - - - public Object getModifiedElement() { - return null; - } - - - public String getName() { - return JsUIMessages.JSP_changes; - } - - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java deleted file mode 100644 index 8088e460a5..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.MoveParticipant; -import org.eclipse.wst.jsdt.core.IPackageFragment; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSPTypeMoveParticipant extends MoveParticipant { - IType fType = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - - public Change createChange(IProgressMonitor pm) throws CoreException { - if (pm != null && pm.isCanceled()) { - return null; - } - CompositeChange multiChange = null; - Object dest = getArguments().getDestination(); - if (dest instanceof IPackageFragment) { - Change[] changes = JSPTypeMoveChange.createChangesFor(fType, ((IPackageFragment) dest).getElementName()); - if (changes.length > 0) { - multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes); - } - } - return multiChange; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - - public String getName() { - String name = ""; //$NON-NLS-1$ - if (this.fType != null) { - name = this.fType.getElementName(); - } - return name; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - - protected boolean initialize(Object element) { - if (element instanceof IType) { - this.fType = (IType) element; - return true; - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java deleted file mode 100644 index e76080983e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.search.SearchMatch; -//import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPTypeMoveRequestor extends BasicRefactorSearchRequestor { - /** - * @param element - * @param newName - */ - public JSPTypeMoveRequestor(IJavaScriptElement element, String newPackage) { - super(element, newPackage); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - - protected String getDescription() { - String typeName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_2, new String[] { typeName, newName }); - return description; - } - - - protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - String renameText = getElement().getElementName(); - // JsTranslation trans = searchDoc.getJspTranslation(); - //String matchText = trans.getJsText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - // if it's an import or jsp:useBean, we need to add the package name as - // well -// if (trans.isImport(javaMatch.getOffset()) -// -// || isFullyQualified(matchText)) { -// if (!getNewName().equals("")) { -// // getNewName() is the pkg name -// renameText = getNewName() + "." + renameText; //$NON-NLS-1$ -// } -// } - return renameText; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java deleted file mode 100644 index 10ad88af5e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JSPTypeRenameChange extends Change { - public static Change[] createChangesFor(IType type, String newName) { - JsSearchSupport support = JsSearchSupport.getInstance(); - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - JSPTypeRenameRequestor requestor = new JSPTypeRenameRequestor(type, newName); - support.searchRunnable(type, new JsSearchScope(), requestor); - return requestor.getChanges(); - } - - - public Object getModifiedElement() { - // TODO Auto-generated method stub - return null; - } - - - public String getName() { - return JsUIMessages.JSP_changes; - } - - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java deleted file mode 100644 index 56a46dd590..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * Remember to change the plugin.xml file if the name of this class changes. - * - * @author pavery - */ -public class JSPTypeRenameParticipant extends RenameParticipant { - private IType fType = null; - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPTypeRenameChange.createChangesFor(fType, getArguments().getNewName()); - CompositeChange multiChange = null; - if (changes.length > 0) { - multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes); - } - return multiChange; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - - public String getName() { - String name = ""; //$NON-NLS-1$ - if (this.fType != null) { - try { - name = this.fType.getSource(); - } catch (JavaScriptModelException e) { - Logger.logException(e); - } - } - return name; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - - protected boolean initialize(Object element) { - if (element instanceof IType) { - this.fType = (IType) element; - return true; - }else if (element instanceof IJavaWebNode) { - if(((IJavaWebNode)element).getJavaElement() instanceof IType) { - this.fType = (IType) ((IJavaWebNode)element).getJavaElement(); - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java deleted file mode 100644 index fbce86e9a5..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2009 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.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.core.search.SearchMatch; -//import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * Creates document change(s) for a type rename. Changes are created for every - * type "match" in the workspace - * - * @author pavery - */ -public class JSPTypeRenameRequestor extends BasicRefactorSearchRequestor { - public JSPTypeRenameRequestor(IType type, String newName) { - super(type, newName); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - - protected String getDescription() { - String typeName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_4, new String[] { typeName, newName }); - return description; - } - - - protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - String renameText = getNewName(); - // String pkg = getType().getPackageFragment().getElementName(); - // JsTranslation trans = searchDoc.getJspTranslation(); - // String matchText = trans.getJsText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - // if it's an import or jsp:useBean or fully qualified type, we need to - // add the package name as well -// if (trans.isImport(javaMatch.getOffset()) -// || /* trans.isUseBean(javaMatch.getOffset()) || -// */isFullyQualified(matchText)) { -// if (!pkg.equals("")) { -// renameText = pkg + "." + renameText; //$NON-NLS-1$ -// } -// } - return renameText; - } - -// private IType getType() { -// return (IType) getElement(); -// } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java deleted file mode 100644 index 31d10ba172..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.core.search.SearchMatch; -import org.eclipse.wst.jsdt.core.search.SearchParticipant; -import org.eclipse.wst.jsdt.core.search.SearchRequestor; - -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class BasicJsSearchRequestor extends SearchRequestor { - // for debugging - private static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - /** - * Maps java search coordinates to corresponding JSP coordinates. Adds the - * matches to the Search Results view. - * - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch) - */ - - public void acceptSearchMatch(SearchMatch match) throws CoreException { - if (JsSearchSupport.getInstance().isCanceled()) { - return; - } - String matchDocumentPath = match.getResource().getFullPath().toString(); - SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath); - if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) { - JSDTSearchDocumentDelegate javaSearchDoc = (JSDTSearchDocumentDelegate) searchDoc; - int jspStart = match.getOffset(); - int jspEnd = match.getOffset() + match.getLength(); - IJsTranslation trans = javaSearchDoc.getJspTranslation(); - String jspText = trans.getHtmlText(); - String javaText = javaSearchDoc.getJavaText(); - if (BasicJsSearchRequestor.DEBUG) { - displayDebugInfo(match, jspStart, jspEnd, jspText, javaText); - } - if (jspStart > -1 && jspEnd > -1) { - addSearchMatch(new Document(trans.getHtmlText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText); - } - } - } - - /** - * @param searchDoc - * @param jspStart - * @param jspEnd - * @param jspTranslation - * @param jspText - * @throws CoreException - */ - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - // implement in subclass - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#beginReporting() - */ - - public void beginReporting() { - if (BasicJsSearchRequestor.DEBUG) { - System.out.println("JSP Search requestor: beginReporting()"); //$NON-NLS-1$ - } - } - - /** - * For debug. - * - * @param origMatch - * @param jspStart - * @param jspEnd - * @param jspText - * @param javaText - */ - private void displayDebugInfo(SearchMatch origMatch, int jspStart, int jspEnd, String jspText, String javaText) { - if (origMatch == null || jspStart == -1 || jspEnd == -1 || jspEnd < jspStart || jspText == null || javaText == null) { - return; - } - System.out.println("+-----------------------------------------+"); //$NON-NLS-1$ - System.out.println("accept possible match [jspDoc: " + origMatch.getResource().getFullPath().toOSString() + " " + origMatch.getOffset() + ":" + origMatch.getOffset() + origMatch.getLength() + "]?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - System.out.println("match info:"); //$NON-NLS-1$ - System.out.println("the java text is:" + javaText.substring(origMatch.getOffset(), origMatch.getOffset() + origMatch.getLength())); //$NON-NLS-1$ - System.out.println("java search match translates to jsp coords [start: " + jspStart + " end:" + jspEnd + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - System.out.println(" the jsp text is:" + jspText.substring(jspStart, jspEnd)); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#endReporting() - */ - - public void endReporting() { - if (BasicJsSearchRequestor.DEBUG) { - System.out.println("JSP Search requestor: endReporting()"); //$NON-NLS-1$ - } - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#enterParticipant(org.eclipse.wst.jsdt.core.search.SearchParticipant) - */ - - public void enterParticipant(SearchParticipant participant) { - if (BasicJsSearchRequestor.DEBUG) { - System.out.println("JSP Search requestor: enterParticipant()"); //$NON-NLS-1$ - } - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#exitParticipant(org.eclipse.wst.jsdt.core.search.SearchParticipant) - */ - - public void exitParticipant(SearchParticipant participant) { - if (BasicJsSearchRequestor.DEBUG) { - System.out.println("JSP Search requestor: exitParticipant()"); //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java deleted file mode 100644 index bbfc6339b0..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.java.search; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.html.ui.internal.search.HTMLFindOccurrencesProcessor; -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate { - private List fProcessors; - - - protected List getProcessors() { - if (fProcessors == null) { - fProcessors = new ArrayList(); - HTMLFindOccurrencesProcessor htmlProcessor = new HTMLFindOccurrencesProcessor(); - fProcessors.add(htmlProcessor); - // temporary, workaround to disable function, since using the - // function - // can easily cause deadlock to occur. - // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=103662 -// JSPFindOccurrencesProcessor jspProcessor = new -// JSPFindOccurrencesProcessor(); -// fProcessors.add(jspProcessor); - } - return fProcessors; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java deleted file mode 100644 index f9b963f21c..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.search.ui.ISearchQuery; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.jsdt.web.core.text.IJsPartitions; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsFindOccurrencesProcessor extends FindOccurrencesProcessor { - private IJavaScriptElement getJavaElement(IDocument document, ITextSelection textSelection) { - IJavaScriptElement[] elements = getJavaElementsForCurrentSelection(document, textSelection); - return elements.length > 0 ? elements[0] : null; - } - - /** - * uses JSPTranslation to get currently selected Java elements. - * - * @return currently selected IJavaElements - */ - private IJavaScriptElement[] getJavaElementsForCurrentSelection(IDocument document, ITextSelection selection) { - IJavaScriptElement[] elements = new IJavaScriptElement[0]; - // get JSP translation object for this viewer's document - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model != null && model instanceof IDOMModel) { - IDOMDocument xmlDoc = ((IDOMModel) model).getDocument(); - JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (adapter != null) { - IJsTranslation translation = adapter.getJsTranslation(true); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102211 - elements = translation.getElementsFromJsRange(selection.getOffset(), selection.getOffset() + selection.getLength()); - } - } - } finally { - if (model != null) { - model.releaseFromRead(); - } - } - return elements; - } - - - protected String[] getPartitionTypes() { - return new String[] { IJsPartitions.HtmlJsPartition }; - } - - - protected String[] getRegionTypes() { - return new String[] { DOMRegionContext.BLOCK_TEXT }; - } - - - protected ISearchQuery getSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType, ITextSelection textSelection) { - return new JsSearchQuery(file, getJavaElement(document, textSelection)); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java deleted file mode 100644 index 504987ec64..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.search; - -import org.eclipse.search.ui.ISearchQuery; -import org.eclipse.search.ui.text.Match; -import org.eclipse.wst.sse.ui.internal.search.OccurrencesSearchResult; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsOccurrencesSearchResult extends OccurrencesSearchResult { - public JsOccurrencesSearchResult(ISearchQuery query) { - super(query); - } - - - public Match[] getMatches() { - return super.getMatches(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java deleted file mode 100644 index d3807e0220..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.util.NLS; -import org.eclipse.search.ui.ISearchResult; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages; -import org.eclipse.wst.sse.ui.internal.search.BasicSearchQuery; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsSearchQuery extends BasicSearchQuery { - /** the IJavaScriptElement we are searching for in the file * */ - private IJavaScriptElement fElement = null; - - public JsSearchQuery(IFile file, IJavaScriptElement element) { - super(file); - this.fElement = element; - } - - - public boolean canRerun() { - return false; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground() - */ - - public boolean canRunInBackground() { - return true; - } - - - protected IStatus doQuery() { - IStatus status = Status.OK_STATUS; - try { - JsSearchSupport support = JsSearchSupport.getInstance(); - // index the file - SearchDocument delegate = support.addJspFile(getFile()); - String scopePath = delegate.getPath(); - JsSearchScope singleFileScope = new JsSearchScope(new String[] { getFile().getFullPath().toString(), scopePath }); - // perform a searchs - // by passing in this jsp search query, requstor can add matches - // support.searchRunnable(getJavaElement(), singleFileScope, new - // JSPSingleFileSearchRequestor(getInstance())); - support.searchRunnable(getJavaElement(), singleFileScope, new JsSingleFileSearchRequestor(getInstance())); - } catch (Exception e) { - status = new Status(IStatus.ERROR, "org.eclipse.wst.sse.ui", IStatus.OK, "", null); //$NON-NLS-1$ //$NON-NLS-2$ - } - return status; - } - - private String getFilename() { - String filename = JsUIMessages.OccurrencesSearchQuery_2; - if (getFile() != null) { - filename = getFile().getName(); - } - return filename; - } - - // for access by inner class - public JsSearchQuery getInstance() { - return this; - } - - public IJavaScriptElement getJavaElement() { - return this.fElement; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#getLabel() - */ - - public String getLabel() { - String[] args = { getSearchText(), getOccurrencesCountText(), getFilename() }; - return NLS.bind(JsUIMessages.OccurrencesSearchQuery_0, args); - } - - private String getOccurrencesCountText() { - String count = ""; //$NON-NLS-1$ - // pa_TODO make dynamic - return count; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#getSearchResult() - */ - - public ISearchResult getSearchResult() { - return new JsOccurrencesSearchResult(this); - } - - - protected String getSearchText() { - return fElement.getElementName(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java deleted file mode 100644 index 33feb500d8..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.search; - -import java.util.HashMap; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.ui.text.Match; -import org.eclipse.wst.jsdt.ui.search.ISearchRequestor; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsSearchRequestor extends BasicJsSearchRequestor { - private ISearchRequestor fJavaRequestor = null; - - public JsSearchRequestor() { - super(); - } - - public JsSearchRequestor(ISearchRequestor javaRequestor) { - // need to report matches to javaRequestor - this.fJavaRequestor = javaRequestor; - } - - - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - if (!jspFile.exists()) { - return; - } - int lineNumber = -1; - try { - lineNumber = jspDocument.getLineOfOffset(jspStart); - } catch (BadLocationException e) { - Logger.logException("offset: " + Integer.toString(jspStart), e); //$NON-NLS-1$ - } - createSearchMarker(jspFile, jspStart, jspEnd, lineNumber); - if (this.fJavaRequestor != null) { - Match match = new Match(jspFile, jspStart, jspEnd - jspStart); - this.fJavaRequestor.reportMatch(match); - } - } - - /** - * @param jspFile - * @param jspStart - * @param jspEnd - */ - private void createSearchMarker(IFile jspFile, int jspStart, int jspEnd, int lineNumber) { - try { - IMarker marker = jspFile.createMarker(NewSearchUI.SEARCH_MARKER); - HashMap attributes = new HashMap(4); - attributes.put(IMarker.CHAR_START, new Integer(jspStart)); - attributes.put(IMarker.CHAR_END, new Integer(jspEnd)); - attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber)); - marker.setAttributes(attributes); - } catch (CoreException e) { - Logger.logException(e); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java deleted file mode 100644 index 955652546e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.text.IDocument; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsSingleFileSearchRequestor extends BasicJsSearchRequestor { - private JsSearchQuery fQuery = null; - - public JsSingleFileSearchRequestor(JsSearchQuery query) { - this.fQuery = query; - } - - - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - // add match to JSP query... - this.fQuery.addMatch(jspDocument, jspStart, jspEnd); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java deleted file mode 100644 index aaa8880d9f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java.search.ui; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.search.ui.text.Match; -import org.eclipse.ui.PartInitException; -import org.eclipse.wst.jsdt.ui.search.IMatchPresentation; -import org.eclipse.wst.sse.ui.internal.search.BasicSearchLabelProvider; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsMatchPresentation implements IMatchPresentation { - /** - * @see org.eclipse.wst.jsdt.ui.search.IMatchPresentation#createLabelProvider() - */ - public ILabelProvider createLabelProvider() { - return new BasicSearchLabelProvider(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.ui.search.IMatchPresentation#showMatch(org.eclipse.search.ui.text.Match, - * int, int, boolean) - */ - public void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException { - // pa_TODO implement - // Object obj = match.getElement(); - // show match in JSP editor - if (activate) { - // use show in target? - } else { - // just select - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java deleted file mode 100644 index faf529194d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java.search.ui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.search.SearchPattern; -import org.eclipse.wst.jsdt.core.search.SearchRequestor; -import org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification; -import org.eclipse.wst.jsdt.ui.search.IMatchPresentation; -import org.eclipse.wst.jsdt.ui.search.IQueryParticipant; -import org.eclipse.wst.jsdt.ui.search.ISearchRequestor; -import org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification; -import org.eclipse.wst.jsdt.ui.search.QuerySpecification; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope; -import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport; -import org.eclipse.wst.jsdt.web.ui.internal.java.search.JsSearchRequestor; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author pavery - */ -public class JsQueryParticipant implements IQueryParticipant { - // for debugging - private static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#estimateTicks(org.eclipse.wst.jsdt.ui.search.QuerySpecification) - */ - public int estimateTicks(QuerySpecification data) { - // pa_TODO use project file counter from JSPSearchSupport... - return 0; - } - - /** - * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#getUIParticipant() - */ - public IMatchPresentation getUIParticipant() { - return new JsMatchPresentation(); - } - - /** - * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#search(org.eclipse.wst.jsdt.ui.search.ISearchRequestor, - * org.eclipse.wst.jsdt.ui.search.QuerySpecification, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public void search(ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException { - // indexIfNeeded(); - // do search based on the particular Java query - if (querySpecification instanceof ElementQuerySpecification) { - // element search (eg. from global find references in Java file) - ElementQuerySpecification elementQuery = (ElementQuerySpecification) querySpecification; - IJavaScriptElement element = elementQuery.getElement(); - if (JsQueryParticipant.DEBUG) { - System.out.println("JSP Query Participant searching on ELEMENT: " + element); //$NON-NLS-1$ - } - SearchRequestor jspRequestor = new JsSearchRequestor(requestor); - // pa_TODO need to adapt JavaSearchScope to a JSPSearchScope - JsSearchSupport.getInstance().search(element, new JsSearchScope(), jspRequestor); - } else if (querySpecification instanceof PatternQuerySpecification) { - // pattern search (eg. from Java search page) - PatternQuerySpecification patternQuery = (PatternQuerySpecification) querySpecification; - String pattern = patternQuery.getPattern(); - if (JsQueryParticipant.DEBUG) { - System.out.println("JSP Query Participant searching on PATTERN: " + pattern); //$NON-NLS-1$ - } - SearchRequestor jspRequestor = new JsSearchRequestor(requestor); - JsSearchSupport.getInstance().search(pattern, new JsSearchScope(), patternQuery.getSearchFor(), patternQuery.getLimitTo(), SearchPattern.R_PATTERN_MATCH, false, jspRequestor); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java deleted file mode 100644 index f4b6a69287..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.registry; - -import org.eclipse.wst.html.core.internal.modelhandler.ModelHandlerForHTML; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapterFactory; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterFactoryForJSDT; -import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler; -import org.eclipse.wst.sse.core.internal.model.FactoryRegistry; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter; -import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider; -import org.eclipse.wst.sse.ui.internal.util.Assert; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class AdapterFactoryProviderForJSDT implements AdapterFactoryProvider { - /* - * @see AdapterFactoryProvider#addAdapterFactories(IStructuredModel) - */ - public void addAdapterFactories(IStructuredModel structuredModel) { - // these are the main factories, on model's factory registry - addContentBasedFactories(structuredModel); - // ------- - // Must update/add to propagating adapters here too - addPropagatingAdapters(structuredModel); - } - - protected void addContentBasedFactories(IStructuredModel structuredModel) { - FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry(); - Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry"); //$NON-NLS-1$ - INodeAdapterFactory factory = null; - factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class); - if (!(factory instanceof JFaceNodeAdapterFactoryForJSDT)) { - factoryRegistry.removeFactoriesFor(IJFaceNodeAdapter.class); - factory = new JFaceNodeAdapterFactoryForJSDT(IJFaceNodeAdapter.class, true); - factoryRegistry.addFactory(factory); - } - - JsTranslationAdapterFactory.setupAdapterFactory(structuredModel); - } - - protected void addPropagatingAdapters(IStructuredModel structuredModel) {} - - /* - * @see AdapterFactoryProvider#isFor(ContentTypeDescription) - */ - public boolean isFor(IDocumentTypeHandler contentTypeDescription) { - // return (contentTypeDescription instanceof ModelHandlerForJSP); - return (contentTypeDescription instanceof ModelHandlerForHTML); - } - - public void reinitializeFactories(IStructuredModel structuredModel) { - addAdapterFactories(structuredModel); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java deleted file mode 100644 index 4a237d6f1e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public interface IStyleConstantsJs { - public static final String JSP_CONTENT = "jsp_content"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java deleted file mode 100644 index 625fec639e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.java; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public interface IStyleConstantsJSDT { - String JAVA_DEFAULT = "default"; //$NON-NLS-1$ - String JAVA_KEYWORD = "keyword"; //$NON-NLS-1$ - String JAVA_SINGLE_LINE_COMMENT = "single_line_comment"; //$NON-NLS-1$ - String JAVA_STRING = "string"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java deleted file mode 100644 index f74f1b0aac..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.text.rules.EndOfLineRule; -import org.eclipse.jface.text.rules.IRule; -import org.eclipse.jface.text.rules.IToken; -import org.eclipse.jface.text.rules.MultiLineRule; -import org.eclipse.jface.text.rules.SingleLineRule; -import org.eclipse.jface.text.rules.Token; -import org.eclipse.jface.text.rules.WordRule; -import org.eclipse.wst.jsdt.web.core.javascript.JsDataTypes; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JSDTCodeScanner extends org.eclipse.jface.text.rules.RuleBasedScanner { - private static String[] fgConstants = JsDataTypes.CONSTANTS; - private static String[] fgKeywords = JsDataTypes.KEYWORDS; - private static String[] fgTypes = JsDataTypes.TYPES; - private IToken fDefaultToken; - private IToken fKeywordToken; - private IToken fSingleLineCommentToken; - private IToken fStringToken; - private IToken fTypeToken; - - /** - * Creates a Java code scanner - */ - public JSDTCodeScanner() { - super(); - } - - public void initializeRules() { - List rules = new ArrayList(); - // Add rule for multiple line comments. - rules.add(new MultiLineRule("/*", "*/", fSingleLineCommentToken));//$NON-NLS-1$ //$NON-NLS-2$ - // Add rule for single line comments. - rules.add(new EndOfLineRule("//", fSingleLineCommentToken));//$NON-NLS-1$ - // Add rule for strings and character constants. - rules.add(new SingleLineRule("\"", "\"", fStringToken, '\\'));//$NON-NLS-2$//$NON-NLS-1$ - rules.add(new SingleLineRule("'", "'", fStringToken, '\\'));//$NON-NLS-2$//$NON-NLS-1$ - // Add generic whitespace rule. - // rules.add(new WhitespaceRule(new JavaWhitespaceDetector())); - // Add word rule for keywords, types, and constants. - WordRule wordRule = new WordRule(new JavaWordDetector(), fDefaultToken); - for (int i = 0; i < JSDTCodeScanner.fgKeywords.length; i++) { - wordRule.addWord(JSDTCodeScanner.fgKeywords[i], fKeywordToken); - } - for (int i = 0; i < JSDTCodeScanner.fgTypes.length; i++) { - wordRule.addWord(JSDTCodeScanner.fgTypes[i], fTypeToken); - } - for (int i = 0; i < JSDTCodeScanner.fgConstants.length; i++) { - wordRule.addWord(JSDTCodeScanner.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 == IStyleConstantsJSDT.JAVA_KEYWORD) { - fKeywordToken = new Token(data); - fTypeToken = new Token(data); - } else if (tokenKey == IStyleConstantsJSDT.JAVA_STRING) { - fStringToken = new Token(data); - } else if (tokenKey == IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT) { - fSingleLineCommentToken = new Token(data); - } else if (tokenKey == IStyleConstantsJSDT.JAVA_DEFAULT) { - fDefaultToken = new Token(data); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java deleted file mode 100644 index a16268abfd..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.java; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JavaWordDetector 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/java/LineStyleProviderForJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/LineStyleProviderForJSDT.java deleted file mode 100644 index fe6ad6d1fa..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/LineStyleProviderForJSDT.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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.java; - -import java.util.Collection; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -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.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML; -import org.eclipse.wst.jsdt.ui.PreferenceConstants; -import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin; -import org.eclipse.wst.jsdt.web.ui.internal.style.IStyleConstantsJs; -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.ui.internal.style.IStyleConstantsXML; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class LineStyleProviderForJSDT extends AbstractLineStyleProvider implements LineStyleProvider { - /** The scanner it uses */ - private JSDTCodeScanner fScanner; - - private IPropertyChangeListener fPreferenceListener = new 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); - } - }; - - public LineStyleProviderForJSDT() { - super(); - fScanner = new JSDTCodeScanner(); - } - - /** - * 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 == IStyleConstantsJSDT.JAVA_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 == IStyleConstantsJSDT.JAVA_STRING) { - // string - RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_STRING_COLOR); - boolean bold = store.getBoolean(PreferenceConstants.EDITOR_STRING_BOLD); - boolean italics = store.getBoolean(PreferenceConstants.EDITOR_STRING_ITALIC); - boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_STRING_STRIKETHROUGH); - boolean underline = store.getBoolean(PreferenceConstants.EDITOR_STRING_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 == IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT) { - // single line comment - RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR); - boolean bold = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD); - boolean italics = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC); - boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH); - boolean underline = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_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 == IStyleConstantsJSDT.JAVA_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); - } - } - } - - /** - * 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 - TextAttribute ta = (TextAttribute) getTextAttributes().get(IStyleConstantsJs.JSP_CONTENT); - Color bgColor = ta.getBackground(); - if (bgColor == null) { - bgColor = attr.getBackground(); - } - StyleRange result = new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle()); - if ((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) { - result.strikeout = true; - } - if ((attr.getStyle() & TextAttribute.UNDERLINE) != 0) { - result.underline = true; - } - presentation.add(result); - } - - protected IPreferenceStore getColorPreferences() { - return JsUIPlugin.getDefault().getPreferenceStore(); - } - - private IPreferenceStore getJavaColorPreferences() { - return PreferenceConstants.getPreferenceStore(); - } - - /** - * 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(IStyleConstantsJSDT.JAVA_DEFAULT); - } - return ta; - } - - 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 (IStyleConstantsJs.JSP_CONTENT.equals(prefKey)) { - styleKey = IStyleConstantsJs.JSP_CONTENT; - } else if (PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC.equals(prefKey))) { - javaStyleKey = IStyleConstantsJSDT.JAVA_KEYWORD; - } else if (PreferenceConstants.EDITOR_STRING_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_STRING_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_STRING_ITALIC.equals(prefKey))) { - javaStyleKey = IStyleConstantsJSDT.JAVA_STRING; - } else if (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC.equals(prefKey))) { - javaStyleKey = IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT; - } else if (PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC.equals(prefKey))) { - javaStyleKey = IStyleConstantsJSDT.JAVA_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 - super.getHighlighter().refreshDisplay(); - } - } - - protected void loadColors() { - addTextAttribute(IStyleConstantsHTML.SCRIPT_AREA_BORDER); - addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME); - addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE); - addTextAttribute(IStyleConstantsJs.JSP_CONTENT); - addJavaTextAttribute(IStyleConstantsJSDT.JAVA_KEYWORD); - addJavaTextAttribute(IStyleConstantsJSDT.JAVA_STRING); - addJavaTextAttribute(IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT); - addJavaTextAttribute(IStyleConstantsJSDT.JAVA_DEFAULT); - fScanner.initializeRules(); - } - - public boolean prepareRegions(ITypedRegion typedRegion, int ssssrequestedStart, int ssssrequestedLength, Collection holdResults) { - boolean result = true; - /* Initialize the text attributes. Also load the colors and initialize the rules of the scanner */ - getTextAttributes(); - 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 lastStart = typedRegion.getOffset(); - int length = 0; - IToken lastToken = Token.UNDEFINED; - fScanner.setRange(getDocument(), lastStart, typedRegion.getLength()); - while (true) { - IToken token = fScanner.nextToken(); - if (token.isEOF()) { - if (!lastToken.isUndefined() && length != 0) { - addRange(holdResults, lastStart, 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, length, getTokenTextAttribute(lastToken)); - lastToken = token; - lastStart = fScanner.getTokenOffset(); - length = fScanner.getTokenLength(); - continue; - } - length += fScanner.getTokenLength(); - } - } catch (Exception e) { - // shouldn't happen, but we don't want it to stop other - // highlighting, if it does. - result = false; - } - return result; - } - - protected TextAttribute getAttributeFor(ITextRegion region) { - return null; - } - - protected void registerPreferenceManager() { - getColorPreferences().addPropertyChangeListener(fPreferenceListener); - getJavaColorPreferences().addPropertyChangeListener(fPreferenceListener); - } - - public void release() { - super.release(); - fScanner = null; - } - - protected void unRegisterPreferenceManager() { - getColorPreferences().removePropertyChangeListener(fPreferenceListener); - getJavaColorPreferences().removePropertyChangeListener(fPreferenceListener); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java deleted file mode 100644 index bd00e78d09..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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 java.io.IOException; -import java.io.Reader; -import java.net.URL; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTError; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.jsdt.web.ui.internal.Logger; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class HTMLPrinter { - static RGB BG_COLOR_RGB = null; - static { - final Display display = Display.getDefault(); - if (display != null && !display.isDisposed()) { - try { - display.asyncExec(new Runnable() { - /* - * @see java.lang.Runnable#run() - */ - public void run() { - HTMLPrinter.BG_COLOR_RGB = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); - } - }); - } catch (SWTError err) { - // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=45294 - if (err.code != SWT.ERROR_DEVICE_DISPOSED) { - throw err; - } - } - } - } - - public static void addBullet(StringBuffer buffer, String bullet) { - if (bullet != null) { - buffer.append("<li>"); //$NON-NLS-1$ - buffer.append(bullet); - buffer.append("</li>"); //$NON-NLS-1$ - } - } - - public static void addPageEpilog(StringBuffer buffer) { - buffer.append("</font></body></html>"); //$NON-NLS-1$ - } - - public static void addPageProlog(StringBuffer buffer) { - HTMLPrinter.insertPageProlog(buffer, buffer.length()); - } - - public static void addParagraph(StringBuffer buffer, Reader paragraphReader) { - if (paragraphReader != null) { - HTMLPrinter.addParagraph(buffer, HTMLPrinter.read(paragraphReader)); - } - } - - public static void addParagraph(StringBuffer buffer, String paragraph) { - if (paragraph != null) { - buffer.append("<p>"); //$NON-NLS-1$ - buffer.append(paragraph); - } - } - - public static void addSmallHeader(StringBuffer buffer, String header) { - if (header != null) { - buffer.append("<h5>"); //$NON-NLS-1$ - buffer.append(header); - buffer.append("</h5>"); //$NON-NLS-1$ - } - } - - private static void appendColor(StringBuffer buffer, RGB rgb) { - buffer.append('#'); - buffer.append(Integer.toHexString(rgb.red)); - buffer.append(Integer.toHexString(rgb.green)); - buffer.append(Integer.toHexString(rgb.blue)); - } - - private static void appendStyleSheetLink(StringBuffer buffer, URL styleSheetURL) { - if (styleSheetURL == null) { - return; - } - buffer.append("<head>"); //$NON-NLS-1$ - buffer.append("<LINK REL=\"stylesheet\" HREF= \""); //$NON-NLS-1$ - buffer.append(styleSheetURL); - buffer.append("\" CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">"); //$NON-NLS-1$ - buffer.append("</head>"); //$NON-NLS-1$ - } - - public static String convertToHTMLContent(String content) { - content = HTMLPrinter.replace(content, '&', "&"); //$NON-NLS-1$ - content = HTMLPrinter.replace(content, '"', """); //$NON-NLS-1$ - content = HTMLPrinter.replace(content, '<', "<"); //$NON-NLS-1$ - return HTMLPrinter.replace(content, '>', ">"); //$NON-NLS-1$ - } - - public static void endBulletList(StringBuffer buffer) { - buffer.append("</ul>"); //$NON-NLS-1$ - } - - private static RGB getBgColor() { - if (HTMLPrinter.BG_COLOR_RGB != null) { - return HTMLPrinter.BG_COLOR_RGB; - } - // RGB value of info bg color on WindowsXP - return new RGB(255, 255, 225); - } - - public static void insertPageProlog(StringBuffer buffer, int position) { - HTMLPrinter.insertPageProlog(buffer, position, HTMLPrinter.getBgColor()); - } - - public static void insertPageProlog(StringBuffer buffer, int position, RGB bgRGB) { - if (bgRGB == null) { - HTMLPrinter.insertPageProlog(buffer, position); - } else { - StringBuffer pageProlog = new StringBuffer(60); - pageProlog.append("<html><body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$ - HTMLPrinter.appendColor(pageProlog, bgRGB); - pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$ - buffer.insert(position, pageProlog.toString()); - } - } - - public static void insertPageProlog(StringBuffer buffer, int position, RGB bgRGB, URL styleSheetURL) { - if (bgRGB == null) { - HTMLPrinter.insertPageProlog(buffer, position, styleSheetURL); - } else { - StringBuffer pageProlog = new StringBuffer(300); - pageProlog.append("<html>"); //$NON-NLS-1$ - HTMLPrinter.appendStyleSheetLink(pageProlog, styleSheetURL); - pageProlog.append("<body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$ - HTMLPrinter.appendColor(pageProlog, bgRGB); - pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$ - buffer.insert(position, pageProlog.toString()); - } - } - - public static void insertPageProlog(StringBuffer buffer, int position, URL styleSheetURL) { - HTMLPrinter.insertPageProlog(buffer, position, HTMLPrinter.getBgColor(), styleSheetURL); - } - - static String read(Reader rd) { - StringBuffer buffer = new StringBuffer(); - char[] readBuffer = new char[2048]; - try { - int n = rd.read(readBuffer); - while (n > 0) { - buffer.append(readBuffer, 0, n); - n = rd.read(readBuffer); - } - return buffer.toString(); - } catch (IOException x) { - // never expected - Logger.log(Logger.WARNING_DEBUG, x.getMessage(), x); - } - return null; - } - - private static String replace(String text, char c, String s) { - int previous = 0; - int current = text.indexOf(c, previous); - if (current == -1) { - return text; - } - StringBuffer buffer = new StringBuffer(); - while (current > -1) { - buffer.append(text.substring(previous, current)); - buffer.append(s); - previous = current + 1; - current = text.indexOf(c, previous); - } - buffer.append(text.substring(previous)); - return buffer.toString(); - } - - public static void startBulletList(StringBuffer buffer) { - buffer.append("<ul>"); //$NON-NLS-1$ - } - - private HTMLPrinter() { - // nothing - } -} 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 deleted file mode 100644 index d5e16697ea..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2009 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 java.io.Reader; - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IMember; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.ui.JSdocContentAccess; -import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.ui.internal.taginfo.AbstractHoverProcessor; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JSDTHoverProcessor extends AbstractHoverProcessor { - /* - * Bulk of the work was copied from - * org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavadocHover - */ - private final long LABEL_FLAGS = JavaScriptElementLabels.ALL_FULLY_QUALIFIED | JavaScriptElementLabels.M_PRE_RETURNTYPE | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_PARAMETER_NAMES | JavaScriptElementLabels.M_EXCEPTIONS | JavaScriptElementLabels.F_PRE_TYPE_SIGNATURE | JavaScriptElementLabels.M_PRE_TYPE_PARAMETERS | JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.USE_RESOLVED; - private final long LOCAL_VARIABLE_FLAGS = LABEL_FLAGS & ~JavaScriptElementLabels.F_FULLY_QUALIFIED | JavaScriptElementLabels.F_POST_QUALIFIED; - - private String getHoverInfo(IJavaScriptElement[] result) { - StringBuffer buffer = new StringBuffer(); - int nResults = result.length; - if (nResults == 0) { - return null; - } - if (nResults > 1) { - for (int i = 0; i < result.length; i++) { - HTMLPrinter.startBulletList(buffer); - IJavaScriptElement curr = result[i]; - if (curr instanceof IMember || curr.getElementType() == IJavaScriptElement.LOCAL_VARIABLE) { - HTMLPrinter.addBullet(buffer, getInfoText(curr)); - } - HTMLPrinter.endBulletList(buffer); - } - } else { - IJavaScriptElement curr = result[0]; - if (curr == null) { - return null; - } - if (curr instanceof IMember) { - IMember member = (IMember) curr; - HTMLPrinter.addSmallHeader(buffer, getInfoText(member)); - Reader reader; - try { - reader = JSdocContentAccess.getHTMLContentReader(member, true, true); - } catch (JavaScriptModelException ex) { - return null; - } - if (reader != null) { - HTMLPrinter.addParagraph(buffer, reader); - } - } else if (curr.getElementType() == IJavaScriptElement.LOCAL_VARIABLE) { - HTMLPrinter.addSmallHeader(buffer, getInfoText(curr)); - } - } - if (buffer.length() > 0) { - HTMLPrinter.insertPageProlog(buffer, 0); - HTMLPrinter.addPageEpilog(buffer); - return buffer.toString(); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, - * org.eclipse.jface.text.IRegion) - */ - public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { - // get JSP translation object for this viewer's document - IDOMModel xmlModel = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument()); - if (xmlModel != null) { - IDOMDocument xmlDoc = xmlModel.getDocument(); - JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - if (adapter != null) { - IJsTranslation translation = adapter.getJsTranslation(true); - IJavaScriptElement[] result = translation.getElementsFromJsRange(hoverRegion.getOffset(), hoverRegion.getOffset() + hoverRegion.getLength()); -// Vector filteredResults = new Vector(); -// List badFunctions = translation.getGeneratedFunctionNames(); -// boolean bad = false; -// for(int i = 0;i<result.length;i++){ -// bad=false; -// if(result[i] instanceof IFunction){ -// for(int j=0;j<badFunctions.size() && ! bad;j++){ -// if(((IFunction)result[i]).getElementName().equalsIgnoreCase((String)badFunctions.get(j))){ -// bad=true; -// continue; -// } -// } -// if(!bad)filteredResults.add(result[i]); -// } -// } -// if(filteredResults.size()<1) return new String(); -// -// String filteredResult = -// translation.fixupMangledName(getHoverInfo((IJavaScriptElement[])filteredResults.toArray(new -// IJavaScriptElement[]{}))); -// for(int i = 0;i<badFunctions.size();i++){ -// filteredResult.replace((String)badFunctions.get(i), ""); -// } -// return filteredResult; - return translation.fixupMangledName(getHoverInfo(result)); - } - } - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, - * int) - */ - public IRegion getHoverRegion(ITextViewer textViewer, int offset) { - return JsWordFinder.findWord(textViewer.getDocument(), offset); - } - - private String getInfoText(IJavaScriptElement member) { - long flags = member.getElementType() == IJavaScriptElement.LOCAL_VARIABLE ? LOCAL_VARIABLE_FLAGS : LABEL_FLAGS; - String label = JavaScriptElementLabels.getElementLabel(member, flags); - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < label.length(); i++) { - char ch = label.charAt(i); - if (ch == '<') { - buf.append("<"); //$NON-NLS-1$ - } else if (ch == '>') { - buf.append(">"); //$NON-NLS-1$ - } else { - buf.append(ch); - } - } - return buf.toString(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java deleted file mode 100644 index b9311afa9f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JsWordFinder { - public static IRegion findWord(IDocument document, int offset) { - int start = -1; - int end = -1; - try { - int pos = offset; - char c; - while (pos >= 0) { - c = document.getChar(pos); - // System.out.println("JavaWordFinder.findWord() Test java char - // (--):" + c); - if (!Character.isJavaIdentifierPart(c)) { - break; - } - --pos; - } - start = pos; - pos = offset; - int length = document.getLength(); - while (pos < length) { - c = document.getChar(pos); - // System.out.println("JavaWordFinder.findWord() Test java char - // (++):" + c); - if (!Character.isJavaIdentifierPart(c)) { - break; - } - ++pos; - } - end = pos; - // System.out.println("Start:" + start + "End:"+end); - // System.out.println("JavaWordFinder.findWord() Retrieved java - // token of:" + document.get(start, end-start) ); - } catch (BadLocationException x) { - } - if (start > -1 && end > -1) { - if (start == offset && end == offset) { - return new Region(offset, 0); - } else if (start == offset) { - return new Region(start, end - start); - } else { - return new Region(start + 1, end - start - 1); - } - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java deleted file mode 100644 index 29937d0e11..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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 - *******************************************************************************/ -/* - * Created on Sep 2, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.jsdt.web.ui.internal.text; - -import java.io.IOException; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.jsdt.web.ui.internal.derived.SingleCharReader; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JsCodeReader extends SingleCharReader { - /** The EOF character */ - public static final int EOF = -1; - private int fCachedLineNumber = -1; - private int fCachedLineOffset = -1; - private IDocument fDocument; - private int fEnd = -1; - private boolean fForward = false; - private int fOffset; - private boolean fSkipComments = false; - private boolean fSkipStrings = false; - - public JsCodeReader() {} - - /* - * @see Reader#close() - */ - - public void close() throws IOException { - fDocument = null; - } - - public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException { - fDocument = document; - fOffset = offset; - fSkipComments = skipComments; - fSkipStrings = skipStrings; - fForward = false; - try { - fCachedLineNumber = fDocument.getLineOfOffset(fOffset); - } catch (BadLocationException x) { - throw new IOException(x.getMessage()); - } - } - - public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException { - fDocument = document; - fOffset = offset; - fSkipComments = skipComments; - fSkipStrings = skipStrings; - fForward = true; - fEnd = Math.min(fDocument.getLength(), fOffset + length); - } - - /** - * Returns the offset of the last read character. Should only be called - * after read has been called. - */ - public int getOffset() { - return fForward ? fOffset - 1 : fOffset; - } - - private void gotoCommentEnd() throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - if (current == '*') { - if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') { - ++fOffset; - return; - } - } - } - } - - private void gotoCommentStart() throws BadLocationException { - while (0 < fOffset) { - char current = fDocument.getChar(fOffset--); - if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/') { - return; - } - } - } - - private void gotoLineEnd() throws BadLocationException { - int line = fDocument.getLineOfOffset(fOffset); - fOffset = fDocument.getLineOffset(line + 1); - } - - private void gotoStringEnd(char delimiter) throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - if (current == '\\') { - // ignore escaped characters - ++fOffset; - } else if (current == delimiter) { - return; - } - } - } - - private void gotoStringStart(char delimiter) throws BadLocationException { - while (0 < fOffset) { - char current = fDocument.getChar(fOffset); - if (current == delimiter) { - if (!(0 <= fOffset && fDocument.getChar(fOffset - 1) == '\\')) { - return; - } - } - --fOffset; - } - } - - private void handleSingleLineComment() throws BadLocationException { - int line = fDocument.getLineOfOffset(fOffset); - if (line < fCachedLineNumber) { - fCachedLineNumber = line; - fCachedLineOffset = fDocument.getLineOffset(line); - int offset = fOffset; - while (fCachedLineOffset < offset) { - char current = fDocument.getChar(offset--); - if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') { - fOffset = offset; - return; - } - } - } - } - - /* - * @see SingleCharReader#read() - */ - - public int read() throws IOException { - try { - return fForward ? readForwards() : readBackwards(); - } catch (BadLocationException x) { - throw new IOException(x.getMessage()); - } - } - - private int readBackwards() throws BadLocationException { - while (0 < fOffset) { - --fOffset; - handleSingleLineComment(); - char current = fDocument.getChar(fOffset); - switch (current) { - case '/': - if (fSkipComments && fOffset > 1) { - char next = fDocument.getChar(fOffset - 1); - if (next == '*') { - // a comment ends, advance to the comment start - fOffset -= 2; - gotoCommentStart(); - continue; - } - } - return current; - case '"': - case '\'': - if (fSkipStrings) { - --fOffset; - gotoStringStart(current); - continue; - } - return current; - } - return current; - } - return JsCodeReader.EOF; - } - - private int readForwards() throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - switch (current) { - case '/': - if (fSkipComments && fOffset < fEnd) { - char next = fDocument.getChar(fOffset); - if (next == '*') { - // a comment starts, advance to the comment end - ++fOffset; - gotoCommentEnd(); - continue; - } else if (next == '/') { - // '//'-comment starts, advance to the line end - gotoLineEnd(); - continue; - } - } - return current; - case '"': - case '\'': - if (fSkipStrings) { - gotoStringEnd(current); - continue; - } - return current; - } - return current; - } - return JsCodeReader.EOF; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java deleted file mode 100644 index 86c10d8a8a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.text; - -import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsDocumentRegionEdgeMatcher extends DocumentRegionEdgeMatcher { - protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']' }; - - /** - * @param validContexts - * @param nextMatcher - */ - public JsDocumentRegionEdgeMatcher() { - super(new String[] { DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_COMMENT_TEXT, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_PI_OPEN, - DOMRegionContext.XML_PI_CONTENT }, new JsPairMatcher(JsDocumentRegionEdgeMatcher.BRACKETS)); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java deleted file mode 100644 index a1965a0833..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.text; - -import java.io.IOException; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.source.ICharacterPairMatcher; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -class JsPairMatcher implements ICharacterPairMatcher { - protected int fAnchor; - protected IDocument fDocument; - protected int fEndPos; - protected int fOffset; - protected char[] fPairs; - protected JsCodeReader fReader = new JsCodeReader(); - protected int fStartPos; - - public JsPairMatcher(char[] pairs) { - fPairs = pairs; - } - - /* - * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear() - */ - public void clear() { - if (fReader != null) { - try { - fReader.close(); - } catch (IOException x) { - // ignore - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.ICharacterPairMatcher#dispose() - */ - public void dispose() { - clear(); - fDocument = null; - fReader = null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.ICharacterPairMatcher#getAnchor() - */ - public int getAnchor() { - return fAnchor; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.ICharacterPairMatcher#match(org.eclipse.jface.text.IDocument, - * int) - */ - public IRegion match(IDocument document, int offset) { - fOffset = offset; - if (fOffset < 0) { - return null; - } - fDocument = document; - if (fDocument != null && matchPairsAt() && fStartPos != fEndPos) { - return new Region(fStartPos, fEndPos - fStartPos + 1); - } - return null; - } - - protected boolean matchPairsAt() { - int i; - int pairIndex1 = fPairs.length; - int pairIndex2 = fPairs.length; - fStartPos = -1; - fEndPos = -1; - // get the chars preceding and following the start position - try { - char prevChar = fDocument.getChar(Math.max(fOffset - 1, 0)); - // modified behavior for - // http://dev.eclipse.org/bugs/show_bug.cgi?id=16879 - // char nextChar= fDocument.getChar(fOffset); - // search for opening peer character next to the activation point - for (i = 0; i < fPairs.length; i = i + 2) { - // if (nextChar == fPairs[i]) { - // fStartPos= fOffset; - // pairIndex1= i; - // } else - if (prevChar == fPairs[i]) { - fStartPos = fOffset - 1; - pairIndex1 = i; - } - } - // search for closing peer character next to the activation point - for (i = 1; i < fPairs.length; i = i + 2) { - if (prevChar == fPairs[i]) { - fEndPos = fOffset - 1; - pairIndex2 = i; - } - // else if (nextChar == fPairs[i]) { - // fEndPos= fOffset; - // pairIndex2= i; - // } - } - if (fEndPos > -1) { - fAnchor = ICharacterPairMatcher.RIGHT; - fStartPos = searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument); - if (fStartPos > -1) { - return true; - } else { - fEndPos = -1; - } - } else if (fStartPos > -1) { - fAnchor = ICharacterPairMatcher.LEFT; - fEndPos = searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument); - if (fEndPos > -1) { - return true; - } else { - fStartPos = -1; - } - } - } catch (BadLocationException x) { - } catch (IOException x) { - } - return false; - } - - protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { - fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true); - int stack = 1; - int c = fReader.read(); - while (c != JsCodeReader.EOF) { - if (c == openingPeer && c != closingPeer) { - stack++; - } else if (c == closingPeer) { - stack--; - } - if (stack == 0) { - return fReader.getOffset(); - } - c = fReader.read(); - } - return -1; - } - - protected int searchForOpeningPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { - fReader.configureBackwardReader(document, offset, true, true); - int stack = 1; - int c = fReader.read(); - while (c != JsCodeReader.EOF) { - if (c == closingPeer && c != openingPeer) { - stack++; - } else if (c == openingPeer) { - stack--; - } - if (stack == 0) { - return fReader.getOffset(); - } - c = fReader.read(); - } - return -1; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties deleted file mode 100644 index c6061c4829..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2007, 2008 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 -############################################################################### -WebProjectJsGlobalScopeContainerInitializer.0=Web Project support for JSDT diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg Binary files differdeleted file mode 100644 index b5a6af566e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg +++ /dev/null diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java deleted file mode 100644 index b69918f873..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.views.contentoutline; - -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.w3c.dom.Node; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public interface IJavaWebNode { - public IJavaScriptElement getJavaElement(); - - public Node getParentNode(); - - public boolean hasChildren(); - - -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java deleted file mode 100644 index 9afa9561e6..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.views.contentoutline; - -import org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline.JsContentOutlineConfig; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JFaceNodeAdapterFactoryForJSDT extends JFaceNodeAdapterFactory { - public JFaceNodeAdapterFactoryForJSDT() { - this(IJFaceNodeAdapter.class, true); - } - - public JFaceNodeAdapterFactoryForJSDT(Object adapterKey, boolean registerAdapters) { - super(adapterKey, registerAdapters); - } - - - public INodeAdapterFactory copy() { - return new JFaceNodeAdapterFactoryForJSDT(getAdapterKey(), isShouldRegisterAdapter()); - } - - - protected INodeAdapter createAdapter(INodeNotifier node) { - if (singletonAdapter == null) { - // create the JFaceNodeAdapter - // singletonAdapter = new JFaceNodeAdapterForJSDT(this); - if (JsContentOutlineConfig.USE_ADVANCED) { - singletonAdapter = new org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline.JFaceNodeAdapterForJs(this); - } else { - singletonAdapter = new org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterForJs(this); - } - initAdapter(singletonAdapter, node); - } - return singletonAdapter; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java deleted file mode 100644 index 456ef6f5ac..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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 - * bug:244839 - eugene@genuitec.com - *******************************************************************************/ -package org.eclipse.wst.jsdt.web.ui.views.contentoutline; - -import java.util.Vector; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.text.Position; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterForHTML; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.IMember; -import org.eclipse.wst.jsdt.core.ISourceRange; -import org.eclipse.wst.jsdt.core.ISourceReference; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.internal.core.JavaElement; -import org.eclipse.wst.jsdt.internal.core.Member; -import org.eclipse.wst.jsdt.internal.core.SourceRefElement; -import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider; -import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter; -import org.eclipse.wst.xml.core.internal.document.NodeImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory; -import org.w3c.dom.Node; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML { - - public JFaceNodeAdapterForJs(JFaceNodeAdapterFactory adapterFactory) { - super(adapterFactory); - } - - private IJavaScriptUnit lazyCu; - private IProgressMonitor monitor; - private JavaScriptElementLabelProvider javaElementLabelProvider; - - public Object[] getChildren(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().getChildren(object); - } - if (object instanceof IJavaWebNode) { - JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getJavaElement(); - if (enclosedElement != null) { - try { - IJavaScriptElement[] children = enclosedElement.getChildren(); - if (children == null) { - return new IJavaScriptElement[0]; - } - Object[] nodes = new Object[children.length]; - Node parent = ((IJavaWebNode) object).getParentNode(); - - for (int i = 0; i < children.length; i++) { - // int htmllength = ((SourceRefElement) (children[i])).getSourceRange().getLength(); - // int htmloffset = ((SourceRefElement) (children[i])).getSourceRange().getOffset(); - IJavaScriptElement javaElement = children[i]; - ISourceRange range = null; - if (javaElement instanceof Member) { - range = ((IMember) javaElement).getNameRange(); - } else { - range = ((ISourceReference) javaElement).getSourceRange(); - } - int htmllength = range.getLength(); - int htmloffset = range.getOffset(); - - - Position position = new Position(htmloffset, htmllength); - nodes[i] = getJsNode(parent, javaElement, position); - } - return nodes; - } catch (JavaScriptModelException ex) { - } - } - } - Node node = (Node) object; - if (isJSElementParent(node)) { - Object[] results = getJSElementsFromNode(node.getFirstChild(), true); - - - return filter( results ); - } - return super.getChildren(object); - } - - /* - * @GINO: Anonymous -- matches anonymous types on the top level - */ - protected boolean matches(Object elementObj) { - - if( elementObj instanceof IJavaWebNode ){ - IJavaScriptElement element = ((IJavaWebNode)elementObj).getJavaElement(); - if (element.getElementType() == IJavaScriptElement.TYPE && element.getParent().getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT ) { - - IType type = (IType)element; - try { - return type.isAnonymous(); - } catch (JavaScriptModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - return false; - } - - /* - * @GINO: Anonymous Filter from top level - * - */ - protected Object[] filter(Object[] children) { - boolean initializers= false; - for (int i= 0; i < children.length; i++) { - if (matches(children[i])) { - initializers= true; - break; - } - } - - if (!initializers) - return children; - - Vector v= new Vector(); - for (int i= 0; i < children.length; i++) { - if (matches(children[i])) - continue; - v.addElement(children[i]); - } - - Object[] result= new Object[v.size()]; - v.copyInto(result); - return result; - } - - public Object[] getElements(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().getElements(object); - } - return super.getElements(object); - } - - private JavaScriptElementLabelProvider getJavaElementLabelProvider() { - if(javaElementLabelProvider==null) { - javaElementLabelProvider = new JavaScriptElementLabelProvider(); - } - return javaElementLabelProvider; - } - - private StandardJavaScriptElementContentProvider getJavaElementProvider() { - return new StandardJavaScriptElementContentProvider(true); - } - - private Object[] filterChildrenForRange(IJavaScriptElement[] allChildren, Node node) { - // int javaPositionStart = ((NodeImpl) node).getStartOffset(); - // int javaPositionEnd = ((NodeImpl) node).getEndOffset(); - - // Object[] result =new Object[0]; - - int javaPositionEnd = ((NodeImpl) node).getEndOffset(); - int javaPositionStart = ((NodeImpl) node).getStartOffset(); - - Vector validChildren = new Vector(); - for (int i = 0; i < allChildren.length; i++) { - if (allChildren[i] instanceof IJavaScriptElement) { - ISourceRange range = null; - if (allChildren[i] instanceof Member) { - try { - range = ((Member) allChildren[i]).getNameRange(); - } catch (JavaScriptModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else if (allChildren[i] instanceof SourceRefElement) { - try { - range = ((SourceRefElement)allChildren[i] ).getSourceRange(); - } catch (JavaScriptModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - if (allChildren[i].getElementType() == IJavaScriptElement.TYPE || (javaPositionStart <= range.getOffset() && range.getLength() + range.getOffset() <= (javaPositionEnd))) { - - - int htmllength = range == null ? 0 : range.getLength(); - int htmloffset = range == null ? 0 : range.getOffset(); - if (htmllength < 0 || htmloffset < 0) { - continue; - } - Position position = new Position(htmloffset, htmllength); - validChildren.add(getJsNode(node.getParentNode(), allChildren[i], position)); - - - } - } - } - Object[] result = new Object[0]; - - - if (validChildren.size() > 0) { - result = validChildren.toArray(); - } - if (result == null || result.length == 0) { - return new IJavaScriptElement[0]; - } - return result; - } - - private synchronized Object[] getJSElementsFromNode(Node node, boolean ensureConsistant) { - -// int startOffset = 0; -// int endOffset = 0; -// int type = node.getNodeType(); - Object[] result = null; - //JsTranslation translation = null; - if (node.getNodeType() == Node.TEXT_NODE && (node instanceof NodeImpl)) { -// startOffset = ((NodeImpl) node).getStartOffset(); -// endOffset = ((NodeImpl) node).getEndOffset(); - IJavaScriptUnit unit = getLazyCu(node); - // Genuitec Begin Fix 6149: Exception opening external HTML file - if (unit == null) { - return new Object[0]; - } - // Genuitec End Fix 6149: Exception opening external HTML file - try { - if(ensureConsistant) unit.makeConsistent(getProgressMonitor()); - } catch (JavaScriptModelException ex1) { - // TODO Auto-generated catch block - ex1.printStackTrace(); - } - try { - result = filterChildrenForRange(unit.getChildren(),node); - } catch (JavaScriptModelException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - result = new Object[0]; - lazyCu=null; - } - - //translation = getTranslation(node); - //result = translation.getAllElementsInJsRange(startOffset, endOffset); - } - return result; - } - - private IProgressMonitor getProgressMonitor() { - if(monitor==null) { - monitor = new NullProgressMonitor(); - } - - return monitor; - - } - - private Object getJsNode(Node parent, IJavaScriptElement root, Position position) { - JsJfaceNode instance = null; - if (root.getElementType() == IJavaScriptElement.TYPE) { - instance = new JsJfaceNode(parent, root, position, ((SourceRefElement) root).getElementName()); - } else if (root.getElementType() == IJavaScriptElement.FIELD) { - /* Field refrence, possibly to a type may need to implement later */ - instance = new JsJfaceNode(parent, root, position); - } else { - instance = new JsJfaceNode(parent, root, position); - } - String name = getJavaElementLabelProvider().getText(root); - instance.setName(name); - // ((JsJfaceNode)instance).setAdapterRegistry(registry); - INodeAdapter adapter = (instance).getAdapterFor(IJFaceNodeAdapter.class); - if (!(adapter instanceof JFaceNodeAdapterForJs)) { - (instance).removeAdapter(adapter); - (instance).addAdapter(this); - } - return instance; - } - - - public Image getLabelImage(Object node) { - if (node instanceof JsJfaceNode) { - return ((JsJfaceNode) node).getImage(); - } - if (node instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getImage(node); - } - return super.getLabelImage(node); - } - - - public String getLabelText(Object node) { -// if (node instanceof JsJfaceNode) { -// return ((JsJfaceNode) node).getName(); -// } - if (node instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getText(node); - } - return super.getLabelText(node); - } - - - public Object getParent(Object element) { - if (element instanceof IJavaScriptElement) { - return getJavaElementProvider().getParent(element); - } - return super.getParent(element); - } - - private IJavaScriptUnit getLazyCu(Node node) { - if(lazyCu==null) { - IJsTranslation tran = getTranslation(node); - if(tran== null) return null; - lazyCu = tran.getCompilationUnit(); - if(lazyCu==null) return null; - - try { - lazyCu.makeConsistent( new NullProgressMonitor() ); - } catch (JavaScriptModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return lazyCu; - } - - private IJsTranslation getTranslation(Node node) { - IStructuredModel model = null; - IModelManager modelManager = StructuredModelManager.getModelManager(); - IDOMDocument xmlDoc = null; - try { - if (modelManager != null) { - IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument(); - model = modelManager.getExistingModelForRead(doc); - // model = modelManager.getModelForRead(doc); - } - IDOMModel domModel = (IDOMModel) model; - if(domModel == null) return null; - xmlDoc = domModel.getDocument(); - } catch (Exception e) { - Logger.logException(e); - } finally { - if (model != null) { - // model.changedModel(); - model.releaseFromRead(); - } - } - if (xmlDoc == null) { - return null; - } - JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - return translationAdapter.getJsTranslation(true); - } - - - public boolean hasChildren(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().hasChildren(object); - } - Node node = (Node) object; - if (node instanceof IJavaWebNode) { - return ((IJavaWebNode) object).hasChildren(); - - } - if (isJSElementParent(node)) { - Object[] nodes = getJSElementsFromNode(node.getFirstChild(),false); - boolean hasElements = (nodes != null && nodes.length > 0); - return hasElements; - } - return super.hasChildren(object); - } - - private boolean isJSElementParent(Node node) { - return (node.hasChildNodes() && node.getNodeName().equalsIgnoreCase("script")); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java deleted file mode 100644 index 0f5b3410d1..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.views.contentoutline; - -import java.util.Collection; - -import org.eclipse.jface.text.Position; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.internal.core.JavaElement; -import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.model.FactoryRegistry; -import org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.xml.core.internal.document.ElementImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.Node; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsJfaceNode extends ElementImpl implements IndexedRegion, INodeNotifier, Node, IJavaWebNode { - private class JsAdaptableNode extends AbstractNotifier { - - public FactoryRegistry getFactoryRegistry() { - return adapterRegistry; - } - } - private JsAdaptableNode adaptableDomNode = new JsAdaptableNode(); - private FactoryRegistry adapterRegistry; - private Position fDocPosition; -// private Node parent; - private String typeName; - //private IJavaScriptElement dirtyElement; - private boolean hasChildren; - //private String name; - private Image me; - - public JsJfaceNode(Node parent, IJavaScriptElement originalElement, Position structureDocLocation) { - this(parent, originalElement, structureDocLocation, null); - } - - public JsJfaceNode(Node parent, IJavaScriptElement originalElement, Position structureDocLocation, String typeName) { - //super(); - super(((ElementImpl)parent)); - // super(parentObject, parentObject.getElementName()); - fDocPosition = structureDocLocation; - //this.parent = parent; - this.typeName = typeName; - try { - hasChildren=((JavaElement)originalElement).hasChildren(); - } catch (JavaScriptModelException ex) { - hasChildren=false; - } - removeAttributes(); - me = (new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT|JavaScriptElementLabelProvider.SHOW_SMALL_ICONS)).getImage(originalElement); - } - - public Image getImage() { - return me; - } - - public boolean hasChildren() { -// try { -// return ((JavaElement)this.dirtyElement).hasChildren(); -// } catch (JavaScriptModelException ex) { -// // TODO Auto-generated catch block -// ex.printStackTrace(); -// } - return hasChildren; - } - - - public void setName(String name) { - super.setTagName(name); - } - - public void addAdapter(INodeAdapter adapter) { - adaptableDomNode.addAdapter(adapter); - } - - - public boolean contains(int testPosition) { - return false; - } - - - public boolean equals(Object o) { - return (o != null && o instanceof JsJfaceNode && ((JsJfaceNode) o).fDocPosition == this.fDocPosition); - } - -// public static Object getInstance(Object parent, Position structureDocLocation -// ){ -// //return new JsJfaceNode((JavaElement)parent.getParent(), -// parent.getElementName(),structureDocLocation); -// Vector interfaces = new Vector(); -// interfaces.addAll(Arrays.asList(parent.getClass().getInterfaces())); -// JsJfaceNode me = new JsJfaceNode(parent,structureDocLocation); -// interfaces.addAll(Arrays.asList(me.getClass().getInterfaces())); -// Object proxy = null; -// try { -// proxy= Proxy.newProxyInstance( -// parent.getClass().getClassLoader(), -// (Class[])interfaces.toArray(new Class[]{}),me); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// System.out.println(e); -// } -// return proxy; -// } -// - - public INodeAdapter getAdapterFor(Object type) { - return adaptableDomNode.getAdapterFor(type); - } - - - public Collection getAdapters() { - return adaptableDomNode.getAdapters(); - } - - - public int getEndOffset() { - return fDocPosition.getOffset() + fDocPosition.getLength(); - } - - - public INodeAdapter getExistingAdapter(Object type) { - // TODO Auto-generated method stub - return adaptableDomNode.getExistingAdapter(type); - } - - public synchronized IJavaScriptElement getJavaElement() { - /* - * since this may become 'stale' we need to rediscover our element every - * time we're asked - */ - IJsTranslation tran = getTranslation(); - int startOffset = getStartOffset(); - int endOffset = getLength(); - if (typeName != null) { - IJavaScriptElement myType = tran.getCompilationUnit().getType(typeName); - return myType; - } - IJavaScriptElement elements[] = tran.getAllElementsInJsRange(startOffset, startOffset + endOffset); - if (elements != null) { - return elements[0]; - } else { - System.out.println(Messages.getString("JsJfaceNode.1")); //$NON-NLS-1$ - return null; - } - } - - - public int getLength() { - return fDocPosition.getLength(); - } - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getOwnerDocument() - */ - - - - - - - - public int getStartOffset() { - return fDocPosition.getOffset(); - } - -// private Method[] getMethods(){ -// // returns the methods this class supports (as declared in interfaces) -// Class[] interfaces = getClass().getInterfaces(); -// Vector vMethods = new Vector(); -// for(int i = 0;i<interfaces.length;i++){ -// Method methods[] = interfaces[i].getDeclaredMethods(); -// vMethods.addAll(Arrays.asList(methods)); -// } -// -// return (Method[])vMethods.toArray(); -// } -// public Object invoke(Object proxy, Method method, Object[] args) throws -// Throwable { -// Object result; -// Method[] myMethods = getMethods(); -// -// try { -// for(int i = 0;i<myMethods.length;i++){ -// if(myMethods[i]==method){ -// return method.invoke(this, args); -// } -// } -// result = method.invoke(parentType, args); -// } catch (InvocationTargetException e) { -// throw e.getTargetException(); -// } catch (Exception e) { -// throw new RuntimeException("unexpected invocation exception: " + -// e.getMessage()); -// } -// -// return result; -// } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getStructuredDocument() - */ - - - - public IJsTranslation getTranslation() { - IStructuredModel model = null; - IModelManager modelManager = StructuredModelManager.getModelManager(); - IDOMDocument xmlDoc = null; - try { - if (modelManager != null) { - IStructuredDocument doc = getStructuredDocument(); - model = modelManager.getExistingModelForRead(doc); - // model = modelManager.getModelForRead(doc); - } - IDOMModel domModel = (IDOMModel) model; - xmlDoc = domModel.getDocument(); - } catch (Exception e) { - Logger.logException(e); - } finally { - if (model != null) { - // model.changedModel(); - model.releaseFromRead(); - } - } - if (xmlDoc == null) { - return null; - } - JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - return translationAdapter.getJsTranslation(true); - } - - - public void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { - adaptableDomNode.notify(eventType, changedFeature, oldValue, newValue, pos); - } - - - public void removeAdapter(INodeAdapter adapter) { - adaptableDomNode.removeAdapter(adapter); - } - - public void setAdapterRegistry(FactoryRegistry registry) { - this.adapterRegistry = registry; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java deleted file mode 100644 index 8a4481361e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.views.contentoutline; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -* - * @author childsb - * - */ -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.views.contentoutline.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties deleted file mode 100644 index b36e5bef71..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2007, 2008 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 -############################################################################### -JsJfaceNode.1=error in JsJfaceNode... I couldn't retrieve my java element from the original page diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java deleted file mode 100644 index 6e47c34294..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.views.provisional.contentoutline; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterForHTML; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider; -import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.xml.core.internal.document.NodeImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory; -import org.w3c.dom.Node; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML { - public JFaceNodeAdapterForJs(JFaceNodeAdapterFactory adapterFactory) { - super(adapterFactory); - } - - - public Object[] getChildren(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().getChildren(object); - } - Node node = (Node) object; - if (isJSElementParent(node)) { -// Object[] results = getJSElementsFromNode(node.getFirstChild()); -// IMember[] allResults = new IMember[results.length]; -// for(int i = 0;i<results.length;i++) { -// if(results[i]==null) continue; -// IMember member = ((IMember)results[i]); -// allResults[i] = member; - // } - return getJSElementsFromNode(node.getFirstChild()); - } - return super.getChildren(object); - } - - - public Object[] getElements(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().getElements(object); - } - return super.getElements(object); - } - - private JavaScriptElementLabelProvider getJavaElementLabelProvider() { - return new JavaScriptElementLabelProvider(); - } - - private StandardJavaScriptElementContentProvider getJavaElementProvider() { - return new StandardJavaScriptElementContentProvider(true); - } - - private synchronized Object[] getJSElementsFromNode(Node node) { - if (node == null) { - return new Object[0]; - } - int startOffset = 0; - int endOffset = 0; - IJavaScriptElement[] result = null; - IJsTranslation translation = null; - if (node.getNodeType() == Node.TEXT_NODE && (node instanceof NodeImpl)) { - startOffset = ((NodeImpl) node).getStartOffset(); - endOffset = ((NodeImpl) node).getEndOffset(); - translation = getTranslation(node); - result = translation.getAllElementsInJsRange(startOffset, endOffset); - } - return result; -// -// if (result == null) return null; -// Object[] newResults = new Object[result.length]; -// for (int i = 0; i < result.length; i++) { -// int htmllength = 0; -// int htmloffset = 0; -// Position position = null; -// try { -// htmllength = ((SourceRefElement) (result[i])).getSourceRange().getLength(); -// htmloffset = translation.getJspOffset(((SourceRefElement) -// (result[i])).getSourceRange().getOffset()); -// position = new Position(htmloffset, htmllength); -// } catch (JavaScriptModelException e) { -// e.printStackTrace(); -// } -// newResults[i] = getJsNode(node.getParentNode(), (IJavaScriptElement) result[i], -// position); -// } -// return newResults; - } - - - public Image getLabelImage(Object node) { - if (node instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getImage(node); - } - return super.getLabelImage(node); - } - - - public String getLabelText(Object node) { - if (node instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getText(node); - } - return super.getLabelText(node); - } - - - public Object getParent(Object element) { - if (element instanceof IJavaScriptElement) { - return getJavaElementProvider().getParent(element); - } - return super.getParent(element); - } - - private IJsTranslation getTranslation(Node node) { - IStructuredModel model = null; - IModelManager modelManager = StructuredModelManager.getModelManager(); - IDOMDocument xmlDoc = null; - try { - if (modelManager != null) { - IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument(); - model = modelManager.getExistingModelForRead(doc); - // model = modelManager.getModelForRead(doc); - } - IDOMModel domModel = (IDOMModel) model; - xmlDoc = domModel.getDocument(); - } catch (Exception e) { - Logger.logException(e); - } finally { - if (model != null) { - // model.changedModel(); - model.releaseFromRead(); - } - } - if (xmlDoc == null) { - return null; - } - JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - return translationAdapter.getJsTranslation(true); - } - - - public boolean hasChildren(Object object) { - if (object instanceof IJavaScriptElement) { - return getJavaElementProvider().hasChildren(object); - } - Node node = (Node) object; - if (isJSElementParent(node)) { - Object[] results = getJSElementsFromNode(node.getFirstChild()); - return (results != null && results.length > 0); - } - return super.hasChildren(object); - } - - private boolean isJSElementParent(Node node) { - return (node.getNodeName().equalsIgnoreCase("script")); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java deleted file mode 100644 index 88896318b0..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.views.provisional.contentoutline; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.wst.html.ui.views.contentoutline.HTMLContentOutlineConfiguration; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsContentOutlineConfig extends HTMLContentOutlineConfiguration { - public static final boolean USE_ADVANCED = false; - ILabelProvider fLabelProvider = null; - - public JsContentOutlineConfig() {} - - private ILabelProvider getJavaLabelProvider() { - if (fLabelProvider == null) { - fLabelProvider = new JsLabelProvider(); - } - return fLabelProvider; - } - - - public ILabelProvider getLabelProvider(TreeViewer viewer) { - if (!JsContentOutlineConfig.USE_ADVANCED) { - return super.getLabelProvider(viewer); - } - return getJavaLabelProvider(); - } - - - public IMenuListener getMenuListener(TreeViewer treeViewer) { - // if(!USE_ADVANCED) - // return super.getMenuListener(treeViewer); - return new JsMenuListener(treeViewer); - } - - - public ILabelProvider getStatusLineLabelProvider(TreeViewer treeViewer) { - if (!JsContentOutlineConfig.USE_ADVANCED) { - return super.getStatusLineLabelProvider(treeViewer); - } - return getJavaLabelProvider(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java deleted file mode 100644 index 9c30f15ea3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsLabelProvider extends XMLLabelProvider { - JavaScriptElementLabelProvider fLabelProvider = null; - - - public Image getImage(Object o) { - if (o instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getImage(o); - } - return super.getImage(o); - } - - private JavaScriptElementLabelProvider getJavaElementLabelProvider() { - if (fLabelProvider == null) { - fLabelProvider = new JavaScriptElementLabelProvider(); - } - return fLabelProvider; - } - - - public String getText(Object o) { - if (o instanceof IJavaScriptElement) { - return getJavaElementLabelProvider().getText(o); - } - return super.getText(o); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java deleted file mode 100644 index 1a0fd0bfe9..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.views.provisional.contentoutline; - -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor; -import org.eclipse.wst.jsdt.ui.IContextMenuConstants; -import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.internal.IReleasable; -import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsMenuListener extends XMLNodeActionManager implements IMenuListener, IReleasable { - public static final String EDIT_GROUP_ID = "group.edit"; //$NON-NLS-1$ - CompilationUnitEditorActionContributor contrib; - private XMLNodeActionManager fActionManager; - private TreeViewer fTreeViewer; - ISelectionProvider selectionProvider; - - public JsMenuListener(TreeViewer viewer) { - super((IStructuredModel) viewer.getInput(), viewer); - contrib = new CompilationUnitEditorActionContributor(); - fTreeViewer = viewer; -// -// fActionGroups= new CompositeActionGroup(new ActionGroup[] { -// new OpenViewActionGroup(getWorkbenchSite(), getSelectionProvider()), -// new CCPActionGroup(getWorkbenchSite()), -// new GenerateActionGroup(getWorkbenchSite()), -// new RefactorActionGroup(getWorkbenchSite()), -// new JavaSearchActionGroup(getWorkbenchSite())}); - } - - public IAction[] getAllJsActions() { - return null; - } - -// private IWorkbenchSite getWorkbenchSite() { -// return InternalHandlerUtil.getActiveSite(fTreeViewer); -// } - - public void menuAboutToShow(IMenuManager manager) { - ISelection selection = fTreeViewer.getSelection(); - if (selection instanceof TreeSelection) { - TreeSelection tselect = (TreeSelection) selection; - Object[] elements = tselect.toArray(); - int javaCount = 0; - for (int i = 0; i < elements.length; i++) { - if (elements[i] instanceof IJavaWebNode) { - javaCount++; - } - } - //IContributionItem[] items = manager.getItems(); -// manager.add(new Separator(IContextMenuConstants.GROUP_NEW)); -// menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); -// menu.add(new Separator(IContextMenuConstants.GROUP_OPEN)); -// manager.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW)); -// menu.add(new Separator(ICommonMenuConstants.GROUP_EDIT)); -// menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); -// menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE)); -// menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); -// menu.add(new Separator(IContextMenuConstants.GROUP_BUILD)); -// menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); -// menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); -// menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); - if (javaCount == elements.length && javaCount != 0) { - // see plugin.xml for object contributions that populate these - // menus - /* - * Menu for: - * - * Open Type Hierarchy Open Call Hierarchy Show In--> Script - * Explorer Navigator - */ - manager.add(new Separator(IContextMenuConstants.GROUP_SHOW)); - manager.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW)); - /* - * Menu for: Cut Copy Paste Delete - */ - manager.add(new Separator(JsMenuListener.EDIT_GROUP_ID)); - manager.add(new GroupMarker(JsMenuListener.EDIT_GROUP_ID)); - /* - * Menu for: - * - * Source--> Generate Element Comment - * - * - * Refactor--> Rename Move Change Function Signature Inline - * Introduce Indirection Infer Generic Type Arguments - */ - manager.add(new Separator(IContextMenuConstants.GROUP_SOURCE)); - manager.add(new GroupMarker(IContextMenuConstants.GROUP_SOURCE)); - /* - * Menu for: - * - * Refrences--> Workspace Project Hierarchy Working Set - * - * Declerations--> Workspace Project Hierarchy Working Set - * - */ - manager.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); - manager.add(new GroupMarker(IContextMenuConstants.GROUP_SEARCH)); - /* all Java Elements */ -// -// -// -// JavaScriptPlugin.createStandardGroups(manager); -// String[] actionSets = JSDTActionSetUtil.getAllActionSets(); -// -// IAction[] actions = JSDTActionSetUtil.getActionsFromSet(actionSets); -// for(int i = 0;i<actions.length;i++) { -// manager.add(actions[i]); -// } -// fActionGroups.setContext(new ActionContext(selection)); -// fActionGroups.fillContextMenu(manager); -// - } else if (javaCount == 0) { - fillContextMenu(manager, selection); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.internal.IReleasable#release() - */ - public void release() { - fTreeViewer = null; - if (fActionManager != null) { - fActionManager.setModel(null); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java deleted file mode 100644 index 1c0db53d01..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.views.provisional.contentoutline; - -import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider; -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class JsWebElementProvider extends StandardJavaScriptElementContentProvider {} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java deleted file mode 100644 index cf5c62c187..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.views.provisional.contentoutline; - -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** -* - -* Provisional API: This class/interface is part of an interim API that is still under development and expected to -* change significantly before reaching stability. It is being made available at this early stage to solicit feedback -* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken -* (repeatedly) as the API evolves. -*/ -public class XMLLabelProvider extends JFaceNodeLabelProvider { - boolean fShowAttributes = false; - - - public String getText(Object o) { - StringBuffer text = new StringBuffer(super.getText(o)); - if (o instanceof Node) { - Node node = (Node) o; - if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444 - if (node.hasAttributes()) { - Element element = (Element) node; - NamedNodeMap attributes = element.getAttributes(); - Node idTypedAttribute = null; - Node requiredAttribute = null; - boolean hasId = false; - boolean hasName = false; - Node shownAttribute = null; - // try to get content model element - // declaration - CMElementDeclaration elementDecl = null; - ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - if (mq != null) { - elementDecl = mq.getCMElementDeclaration(element); - } - // find an attribute of type (or just named) - // ID - if (elementDecl != null) { - int i = 0; - while ((i < attributes.getLength()) && (idTypedAttribute == null)) { - Node attr = attributes.item(i); - String attrName = attr.getNodeName(); - CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) elementDecl.getAttributes().getNamedItem(attrName); - if (attrDecl != null) { - if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) { - idTypedAttribute = attr; - } else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) { - // as a backup, keep tabs on - // any required - // attributes - requiredAttribute = attr; - } else { - hasId = hasId || attrName.equals("id"); //$NON-NLS-1$ - hasName = hasName || attrName.equals("name"); //$NON-NLS-1$ - } - } - ++i; - } - } - /* - * If no suitable attribute was found, try using a - * required attribute, if none, then prefer "id" or - * "name", otherwise just use first attribute - */ - if (idTypedAttribute != null) { - shownAttribute = idTypedAttribute; - } else if (requiredAttribute != null) { - shownAttribute = requiredAttribute; - } else if (hasId) { - shownAttribute = attributes.getNamedItem("id"); //$NON-NLS-1$ - } else if (hasName) { - shownAttribute = attributes.getNamedItem("name"); //$NON-NLS-1$ - } - if (shownAttribute == null) { - shownAttribute = attributes.item(0); - } - // display the attribute and value (without quotes) - String attributeName = shownAttribute.getNodeName(); - if ((attributeName != null) && (attributeName.length() > 0)) { - text.append(" " + attributeName); //$NON-NLS-1$ - String attributeValue = shownAttribute.getNodeValue(); - if ((attributeValue != null) && (attributeValue.length() > 0)) { - text.append("=" + StringUtils.strip(attributeValue)); //$NON-NLS-1$ - } - } - } - } - } - return text.toString(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF Binary files differdeleted file mode 100644 index a9a220dada..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF +++ /dev/null diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG Binary files differdeleted file mode 100644 index 68bf9c549f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG +++ /dev/null |