From ada1d9f33323e21ea538ce42b6d3a7e629816b21 Mon Sep 17 00:00:00 2001 From: Victor Rubezhny Date: Wed, 29 Apr 2020 20:47:22 +0200 Subject: Bug 562634 - Web UI directly references an action class defined in JSDT Removed the mandatory dependency to JSDT from Web UI Change-Id: Ibb8682c4507f0d1e17f37f1cf0964c7386189c3c Signed-off-by: Victor Rubezhny --- .../org.eclipse.wst.web.ui/META-INF/MANIFEST.MF | 3 +- .../icons/full/etool16/newjscript_wiz.gif | Bin 0 -> 581 bytes web/bundles/org.eclipse.wst.web.ui/plugin.xml | 2 +- web/bundles/org.eclipse.wst.web.ui/pom.xml | 2 +- .../internal/actions/AbstractOpenWizardAction.java | 10 +++-- .../ui/internal/actions/OpenJSWizardAction.java | 44 ++++++++++++++++++--- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 web/bundles/org.eclipse.wst.web.ui/icons/full/etool16/newjscript_wiz.gif diff --git a/web/bundles/org.eclipse.wst.web.ui/META-INF/MANIFEST.MF b/web/bundles/org.eclipse.wst.web.ui/META-INF/MANIFEST.MF index d1cbb64b19..4656a1786d 100644 --- a/web/bundles/org.eclipse.wst.web.ui/META-INF/MANIFEST.MF +++ b/web/bundles/org.eclipse.wst.web.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.wst.web.ui; singleton:=true -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.2.101.qualifier Bundle-Activator: org.eclipse.wst.web.ui.internal.WSTWebUIPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor.0 @@ -26,6 +26,5 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)", org.eclipse.ui.console;bundle-version="[3.7.0,4.0.0)", org.eclipse.wst.css.ui;bundle-version="[1.1.0,1.2.0)", org.eclipse.wst.html.ui;bundle-version="[1.1.0,1.2.0)", - org.eclipse.wst.jsdt.ui;bundle-version="[2.0.0,3.0.0)", org.eclipse.ui.navigator;bundle-version="[3.7.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/web/bundles/org.eclipse.wst.web.ui/icons/full/etool16/newjscript_wiz.gif b/web/bundles/org.eclipse.wst.web.ui/icons/full/etool16/newjscript_wiz.gif new file mode 100644 index 0000000000..7cd1abc201 Binary files /dev/null and b/web/bundles/org.eclipse.wst.web.ui/icons/full/etool16/newjscript_wiz.gif differ diff --git a/web/bundles/org.eclipse.wst.web.ui/plugin.xml b/web/bundles/org.eclipse.wst.web.ui/plugin.xml index 634c03023f..4ccdef7107 100644 --- a/web/bundles/org.eclipse.wst.web.ui/plugin.xml +++ b/web/bundles/org.eclipse.wst.web.ui/plugin.xml @@ -117,7 +117,7 @@ tooltip="%action.tooltip.CSS" /> org.eclipse.webtools.javaee org.eclipse.wst.web.ui - 1.2.100-SNAPSHOT + 1.2.101-SNAPSHOT eclipse-plugin diff --git a/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/AbstractOpenWizardAction.java b/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/AbstractOpenWizardAction.java index a9434e4220..861f6d4b59 100644 --- a/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/AbstractOpenWizardAction.java +++ b/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/AbstractOpenWizardAction.java @@ -53,8 +53,13 @@ public abstract class AbstractOpenWizardAction implements IWorkbenchWindowAction protected void openWizardDialog( IWorkbenchWizard wizard ) { + WizardDialog dialog = createWizardDialog(wizard); + dialog.open(); + } + + protected WizardDialog createWizardDialog(IWorkbenchWizard wizard) { ISelection selection = window.getSelectionService().getSelection(); - + if ( selection instanceof IStructuredSelection ) { wizard.init( window.getWorkbench(), (IStructuredSelection) selection ); @@ -68,7 +73,6 @@ public abstract class AbstractOpenWizardAction implements IWorkbenchWindowAction WizardDialog dialog = new WizardDialog( parent, wizard ); dialog.create(); - dialog.open(); + return dialog; } - } diff --git a/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/OpenJSWizardAction.java b/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/OpenJSWizardAction.java index 82ded80869..27028c15d0 100644 --- a/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/OpenJSWizardAction.java +++ b/web/bundles/org.eclipse.wst.web.ui/static_web_ui/org/eclipse/wst/web/ui/internal/actions/OpenJSWizardAction.java @@ -12,15 +12,49 @@ *******************************************************************************/ package org.eclipse.wst.web.ui.internal.actions; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; +import org.eclipse.ui.wizards.IWizardDescriptor; public class OpenJSWizardAction extends AbstractOpenWizardAction { - + static private final String NEW_JS_WIZARD = "org.eclipse.wst.jsdt.ui.NewJSWizard"; //$NON-NLS-1$ + static private final String NEW_FILE_WIZARD = "org.eclipse.ui.wizards.new.file"; //$NON-NLS-1$ + @Override - public void run( IAction action ) - { - openWizardDialog( new org.eclipse.wst.jsdt.internal.ui.wizards.NewJSWizard() ); + public void run(IAction action) { + IWizardDescriptor newJSWizardDescriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(NEW_JS_WIZARD); + try { + IWorkbenchWizard wizard = newJSWizardDescriptor != null ? newJSWizardDescriptor.createWizard() : null; + if (wizard != null) { + openWizardDialog(wizard); + } else { + runAlternateWizard(action); + } + } catch (CoreException e1) { + // Ignore + } + } + + public void runAlternateWizard(IAction action) { + IWizardDescriptor newFileWizardDescriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(NEW_FILE_WIZARD); + try { + IWorkbenchWizard wizard = newFileWizardDescriptor != null ? newFileWizardDescriptor.createWizard() : null; + if (wizard != null) { + WizardDialog dialog = createWizardDialog(wizard); + IWizardPage fp = wizard.getPage("newFilePage1"); //$NON-NLS-1$ + if (fp instanceof WizardNewFileCreationPage) { + ((WizardNewFileCreationPage)fp).setFileExtension("js"); //$NON-NLS-1$ + } + dialog.open(); + } + } catch (CoreException e1) { + // Ignore + } } - } -- cgit v1.2.3