From 6173beb279f3918c6236434b42700e6a5f196f1e Mon Sep 17 00:00:00 2001 From: Simon Sohrt Date: Fri, 11 Aug 2023 10:37:21 +0200 Subject: [PATCH 1/3] Fixes #1294: WebRoot folder can now be set when debugging a URL --- .../debug/AbstractHTMLDebugDelegate.java | 8 + .../debug/AbstractRunHTMLDebugTab.java | 156 ++++++++++++++---- .../wildwebdeveloper/debug/Messages.java | 4 + .../firefox/FirefoxRunDABDebugDelegate.java | 2 - .../debug/messages.properties | 4 + 5 files changed, 142 insertions(+), 32 deletions(-) diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java index 99884376a3..5df3d9637d 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.jface.dialogs.ErrorDialog; @@ -29,6 +30,7 @@ public class AbstractHTMLDebugDelegate extends DSPLaunchDelegate { public static final String ARGUMENTS = "runtimeArgs"; //$NON-NLS-1$ + public static final String WEBROOT = "webRoot"; public void launchWithParameters(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor, Map param, File debugAdapter) throws CoreException { @@ -39,6 +41,12 @@ public void launchWithParameters(ILaunchConfiguration configuration, String mode monitor); builder.setLaunchDebugAdapter(NodeJSManager.getNodeJsLocation().getAbsolutePath(), debugCmdArgs); builder.setMonitorDebugAdapter(configuration.getAttribute(DSPPlugin.ATTR_DSP_MONITOR_DEBUG_ADAPTER, false)); + + //If webRoot is set -> Inform DSPLaunchDelegate + if (!configuration.getAttribute(WEBROOT, "").isBlank()) { + param.put(WEBROOT, VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configuration.getAttribute(WEBROOT,""))); + } + builder.setDspParameters(param); super.launch(builder); diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java index bbecb8767c..9048207ede 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.wildwebdeveloper.debug; +import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; import static org.eclipse.wildwebdeveloper.debug.SelectionUtils.getSelectedFile; import static org.eclipse.wildwebdeveloper.debug.SelectionUtils.getSelectedProject; import static org.eclipse.wildwebdeveloper.debug.SelectionUtils.pathOrEmpty; @@ -21,13 +22,19 @@ import java.net.URL; import java.text.MessageFormat; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.jface.fieldassist.FieldDecoration; import org.eclipse.jface.fieldassist.FieldDecorationRegistry; @@ -41,20 +48,29 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.views.navigator.ResourceComparator; import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.chrome.ChromeRunDAPDebugDelegate; import org.eclipse.wildwebdeveloper.debug.chrome.ChromeRunDebugLaunchShortcut; public abstract class AbstractRunHTMLDebugTab extends AbstractLaunchConfigurationTab { - + private Text programPathText; private Text argumentsText; private Text workingDirectoryText; protected Composite resComposite; private Text urlText; + private ControlDecoration urlDecoration; + private Text webRootText; + private ControlDecoration webRootDecoration; + private Button webRootProjectSelectButton; + private Button webRootFilesystemSelectButton; protected AbstractDebugAdapterLaunchShortcut shortcut = new ChromeRunDebugLaunchShortcut(); private Button filePath; - private ControlDecoration decoration; + private ControlDecoration fileDecoration; private Button fileRadio; private Button urlRadio; @@ -64,29 +80,30 @@ public AbstractRunHTMLDebugTab() { @Override public void createControl(Composite parent) { resComposite = new Composite(parent, SWT.NONE); - resComposite.setLayout(new GridLayout(3, false)); + resComposite.setLayout(new GridLayout(4, false)); fileRadio = createRadioButton(resComposite, Messages.FirefoxDebugTab_File); fileRadio.setToolTipText(Messages.AbstractRunHTMLDebugTab_fileRadioToolTip); fileRadio.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false)); fileRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { urlText.setEnabled(false); + webRootText.setEnabled(false); + webRootProjectSelectButton.setEnabled(false); + webRootFilesystemSelectButton.setEnabled(false); programPathText.setEnabled(true); filePath.setEnabled(true); - validateProgramPath(); - setDirty(true); + validateProgramPathAndURL(); updateLaunchConfigurationDialog(); })); this.programPathText = new Text(resComposite, SWT.BORDER); - this.programPathText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - decoration = new ControlDecoration(programPathText, SWT.TOP | SWT.LEFT); + this.programPathText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1)); + fileDecoration = new ControlDecoration(programPathText, SWT.TOP | SWT.LEFT); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); - decoration.setImage(fieldDecoration.getImage()); + fileDecoration.setImage(fieldDecoration.getImage()); this.programPathText.addModifyListener(event -> { - setDirty(true); - validateProgramPath(); + validateProgramPathAndURL(); updateLaunchConfigurationDialog(); }); filePath = new Button(resComposite, SWT.PUSH); @@ -98,8 +115,6 @@ public void createControl(Composite parent) { String path = filePathDialog.open(); if (path != null) { programPathText.setText(path); - setDirty(true); - updateLaunchConfigurationDialog(); } })); @@ -110,24 +125,83 @@ public void createControl(Composite parent) { programPathText.setEnabled(false); filePath.setEnabled(false); urlText.setEnabled(true); - decoration.hide(); - setDirty(true); + webRootText.setEnabled(true); + webRootProjectSelectButton.setEnabled(true); + webRootFilesystemSelectButton.setEnabled(true); + validateProgramPathAndURL(); updateLaunchConfigurationDialog(); })); urlText = new Text(resComposite, SWT.BORDER); GridData urlTextGD = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - urlTextGD.horizontalSpan = 2; + urlTextGD.horizontalSpan = 3; urlText.setLayoutData(urlTextGD); + urlDecoration = new ControlDecoration(urlText, SWT.TOP | SWT.LEFT); + urlDecoration.setImage(fieldDecoration.getImage()); urlText.addModifyListener(e -> { - setDirty(true); - validateProgramPath(); + validateProgramPathAndURL(); updateLaunchConfigurationDialog(); }); + new Label(resComposite, SWT.NONE).setText(Messages.AbstractRunHTMLDebugTab_webRoot_folder); + webRootText = new Text(resComposite, SWT.BORDER); + webRootText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + webRootDecoration = new ControlDecoration(webRootText, SWT.TOP | SWT.LEFT); + webRootDecoration.setImage(fieldDecoration.getImage()); + webRootText.addModifyListener(e -> { + validateProgramPathAndURL(); + updateLaunchConfigurationDialog(); + }); + webRootProjectSelectButton = new Button(resComposite, SWT.PUSH); + webRootProjectSelectButton.setText(Messages.AbstractRunHTMLDebugTab_browse_workspace); + webRootProjectSelectButton.addSelectionListener(widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.AbstractRunHTMLDebugTab_select_webroot); + dialog.setMessage(Messages.AbstractRunHTMLDebugTab_select_webroot); + dialog.setValidator(selection -> { + //Ok-button is only activated after the user has selected something + if (selection.length == 0) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + "", null); + } + for (Object f : selection) { + if (!(f instanceof IProject || f instanceof IFolder)) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + "Must select a project or a folder", null); //$NON-NLS-1$ + } + } + return new Status(IStatus.OK, Activator.PLUGIN_ID, 0, + "", null); + }); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + if (resource != null) { + String arg = resource.getFullPath().toString(); + String fileLoc = VariablesPlugin.getDefault().getStringVariableManager() + .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ + webRootText.setText(fileLoc); + } + } + })); + webRootFilesystemSelectButton = new Button(resComposite, SWT.PUSH); + webRootFilesystemSelectButton.setText(Messages.AbstractRunHTMLDebugTab_browse); + webRootFilesystemSelectButton.addSelectionListener(SelectionListener.widgetSelectedAdapter((e) -> { + DirectoryDialog directoryDialog = new DirectoryDialog(resComposite.getShell()); + directoryDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()); + directoryDialog.setText(Messages.AbstractRunHTMLDebugTab_select_webroot); + String path = directoryDialog.open(); + if (path != null) { + webRootText.setText(path); + } + })); + + new Label(resComposite, SWT.NONE).setText(Messages.RunProgramTab_argument); this.argumentsText = new Text(resComposite, SWT.BORDER); GridData argsGD = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - argsGD.horizontalSpan = 2; + argsGD.horizontalSpan = 3; this.argumentsText.setLayoutData(argsGD); this.argumentsText.addModifyListener(e -> { setDirty(true); @@ -135,7 +209,7 @@ public void createControl(Composite parent) { }); new Label(resComposite, SWT.NONE).setText(Messages.RunProgramTab_workingDirectory); this.workingDirectoryText = new Text(resComposite, SWT.BORDER); - this.workingDirectoryText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + this.workingDirectoryText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1)); this.workingDirectoryText.addModifyListener(e -> { setDirty(true); updateLaunchConfigurationDialog(); @@ -156,8 +230,13 @@ public void createControl(Composite parent) { setControl(resComposite); } - private void validateProgramPath() { + private void validateProgramPathAndURL() { setDirty(true); + + setErrorMessage(null); + fileDecoration.hide(); + urlDecoration.hide(); + webRootDecoration.hide(); String errorMessage = null; if (fileRadio.getSelection()) { @@ -175,6 +254,13 @@ private void validateProgramPath() { } catch (CoreException ex) { errorMessage = ex.getMessage(); } + + if (errorMessage != null) { + setErrorMessage(errorMessage); + fileDecoration.setDescriptionText(errorMessage); + fileDecoration.show(); + } + } else if (urlRadio.getSelection()) { if (urlText.getText().length() > 0) { try { @@ -183,19 +269,21 @@ private void validateProgramPath() { errorMessage = MessageFormat.format( Messages.RunProgramTab_error_malformedUR, ex.getMessage()); + urlDecoration.setDescriptionText(errorMessage); + urlDecoration.show(); + } + if(webRootText.getText().isBlank()) { + errorMessage = Messages.AbstractRunHTMLDebugTab_cannot_debug_without_webroot; + webRootDecoration.setDescriptionText(errorMessage); + webRootDecoration.show(); + } + + if (errorMessage != null) { + setErrorMessage(errorMessage); } } } - if (errorMessage != null) { - setErrorMessage(errorMessage); - decoration.setDescriptionText(errorMessage); - decoration.show(); - } else { - setErrorMessage(null); - decoration.hide(); - } - updateLaunchConfigurationDialog(); } @@ -214,15 +302,22 @@ public void initializeFrom(ILaunchConfiguration configuration) { this.workingDirectoryText.setText( configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, pathOrEmpty(getSelectedProject()))); this.urlText.setText(configuration.getAttribute(ChromeRunDAPDebugDelegate.URL, "")); //$NON-NLS-1$ + this.webRootText.setText(configuration.getAttribute(AbstractHTMLDebugDelegate.WEBROOT, "")); if (urlText.getText().isEmpty()) { fileRadio.setSelection(true); urlText.setEnabled(false); + webRootText.setEnabled(false); + webRootProjectSelectButton.setEnabled(false); + webRootFilesystemSelectButton.setEnabled(false); } else { programPathText.setEnabled(false); filePath.setEnabled(false); urlText.setEnabled(true); + webRootText.setEnabled(true); + webRootProjectSelectButton.setEnabled(true); + webRootFilesystemSelectButton.setEnabled(true); urlRadio.setSelection(true); - decoration.hide(); + fileDecoration.hide(); } } catch (CoreException e) { Activator.getDefault().getLog().log(e.getStatus()); @@ -238,6 +333,7 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { } else if (urlText.isEnabled()) { configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, urlText.getText()); configuration.setAttribute(LaunchConstants.PROGRAM, ""); + configuration.setAttribute(AbstractHTMLDebugDelegate.WEBROOT, this.webRootText.getText()); } configuration.setAttribute(AbstractHTMLDebugDelegate.ARGUMENTS, this.argumentsText.getText()); diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java index 055f5ace45..9fd51dac57 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java @@ -18,6 +18,10 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.wildwebdeveloper.debug.messages"; //$NON-NLS-1$ public static String AbstractRunHTMLDebugTab_browse; public static String AbstractRunHTMLDebugTab_fileRadioToolTip; + public static String AbstractRunHTMLDebugTab_webRoot_folder; + public static String AbstractRunHTMLDebugTab_browse_workspace; + public static String AbstractRunHTMLDebugTab_select_webroot; + public static String AbstractRunHTMLDebugTab_cannot_debug_without_webroot; public static String AttachTab_address; public static String AttachTab_port; public static String AttachTab_title; diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java index a2ad5a6258..b18e9f06f4 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java @@ -78,8 +78,6 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun String url = configuration.getAttribute(ChromeRunDAPDebugDelegate.URL, ""); if (!url.isEmpty()) { param.put(ChromeRunDAPDebugDelegate.URL, url); - File projectDirectory = new File(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, ""))); - param.put("webRoot", projectDirectory.getAbsolutePath()); } else { param.put(FILE, VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configuration.getAttribute(LaunchConstants.PROGRAM, "No program path set").trim())); //$NON-NLS-1$ } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties index 644289dc93..793c993889 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties @@ -12,6 +12,10 @@ ################################################################ AbstractRunHTMLDebugTab_browse=\ud83d\udcc2 Browse... AbstractRunHTMLDebugTab_fileRadioToolTip=The local .html file to debug. +AbstractRunHTMLDebugTab_webRoot_folder=WebRoot Folder +AbstractRunHTMLDebugTab_browse_workspace=\ud83d\udcc2 Browse workspace... +AbstractRunHTMLDebugTab_select_webroot=Select the root folder of your web application +AbstractRunHTMLDebugTab_cannot_debug_without_webroot=Without specifying the webRoot folder, no breakpoints will be triggered. AttachTab_address=Address: AttachTab_port=Port: AttachTab_title=\ud83d\udd17 Attach From 97f4dbcda076a683acf163550a6e114a26428014 Mon Sep 17 00:00:00 2001 From: Simon Sohrt Date: Mon, 14 Aug 2023 13:25:41 +0200 Subject: [PATCH 2/3] #1294: Fixed three bugs in "Chrome Debug": 1. It is now impossible to select both radio buttons at the same time 2. The debug dialog no longer deletes user input when reverting 3. The debug dialog no longer deletes user input when re-opening See: https://github.com/eclipse-wildwebdeveloper/wildwebdeveloper/pull/1306#issuecomment-1677141087 --- .../debug/AbstractHTMLDebugDelegate.java | 1 + .../debug/AbstractRunHTMLDebugTab.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java index 5df3d9637d..7d47bccad9 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java @@ -31,6 +31,7 @@ public class AbstractHTMLDebugDelegate extends DSPLaunchDelegate { public static final String ARGUMENTS = "runtimeArgs"; //$NON-NLS-1$ public static final String WEBROOT = "webRoot"; + public static final String FILE_RADIO_BUTTON_SELECTED = "fileRadioButtonSelected"; public void launchWithParameters(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor, Map param, File debugAdapter) throws CoreException { diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java index 9048207ede..8db5ed412b 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java @@ -303,22 +303,29 @@ public void initializeFrom(ILaunchConfiguration configuration) { configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, pathOrEmpty(getSelectedProject()))); this.urlText.setText(configuration.getAttribute(ChromeRunDAPDebugDelegate.URL, "")); //$NON-NLS-1$ this.webRootText.setText(configuration.getAttribute(AbstractHTMLDebugDelegate.WEBROOT, "")); - if (urlText.getText().isEmpty()) { + boolean fileRadioButtonSelected = configuration.getAttribute(AbstractHTMLDebugDelegate.FILE_RADIO_BUTTON_SELECTED, true); + if (fileRadioButtonSelected) { fileRadio.setSelection(true); + urlRadio.setSelection(false); + programPathText.setEnabled(true); + filePath.setEnabled(true); urlText.setEnabled(false); webRootText.setEnabled(false); webRootProjectSelectButton.setEnabled(false); webRootFilesystemSelectButton.setEnabled(false); } else { + fileRadio.setSelection(false); + urlRadio.setSelection(true); programPathText.setEnabled(false); filePath.setEnabled(false); urlText.setEnabled(true); webRootText.setEnabled(true); webRootProjectSelectButton.setEnabled(true); webRootFilesystemSelectButton.setEnabled(true); - urlRadio.setSelection(true); - fileDecoration.hide(); } + + validateProgramPathAndURL(); + } catch (CoreException e) { Activator.getDefault().getLog().log(e.getStatus()); } @@ -327,14 +334,10 @@ public void initializeFrom(ILaunchConfiguration configuration) { @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String programPath = this.programPathText.getText(); - if (programPathText.isEnabled()) { - configuration.setAttribute(LaunchConstants.PROGRAM, programPath); - configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, ""); - } else if (urlText.isEnabled()) { - configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, urlText.getText()); - configuration.setAttribute(LaunchConstants.PROGRAM, ""); - configuration.setAttribute(AbstractHTMLDebugDelegate.WEBROOT, this.webRootText.getText()); - } + configuration.setAttribute(LaunchConstants.PROGRAM, programPath); + configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, urlText.getText()); + configuration.setAttribute(AbstractHTMLDebugDelegate.WEBROOT, this.webRootText.getText()); + configuration.setAttribute(AbstractHTMLDebugDelegate.FILE_RADIO_BUTTON_SELECTED, fileRadio.getSelection()); configuration.setAttribute(AbstractHTMLDebugDelegate.ARGUMENTS, this.argumentsText.getText()); String workingDirectory = this.workingDirectoryText.getText(); From 1384fd02d1621fc1dde4d6fc7eb6559cca1518d0 Mon Sep 17 00:00:00 2001 From: Simon Sohrt Date: Mon, 14 Aug 2023 13:57:06 +0200 Subject: [PATCH 3/3] #1294: WebRoot folder is now validated --- .../debug/AbstractRunHTMLDebugTab.java | 21 ++++++++++++++++++- .../wildwebdeveloper/debug/Messages.java | 2 ++ .../debug/messages.properties | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java index 8db5ed412b..d7277d65c4 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java @@ -272,12 +272,31 @@ private void validateProgramPathAndURL() { urlDecoration.setDescriptionText(errorMessage); urlDecoration.show(); } + boolean showWebRootDecoration = false; if(webRootText.getText().isBlank()) { errorMessage = Messages.AbstractRunHTMLDebugTab_cannot_debug_without_webroot; + showWebRootDecoration = true; + } else { + try { + File file = new File(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(webRootText.getText())); + if (!file.exists()) { + errorMessage = Messages.AbstractRunHTMLDebugTab_cannot_access_webroot_folder; + showWebRootDecoration = true; + } else if (!file.isDirectory()) { + errorMessage = Messages.AbstractRunHTMLDebugTab_webroot_folder_is_not_a_directory; + showWebRootDecoration = true; + } + } catch (CoreException e) { + errorMessage = e.getMessage(); + showWebRootDecoration = true; + } + } + + if (showWebRootDecoration) { webRootDecoration.setDescriptionText(errorMessage); webRootDecoration.show(); } - + if (errorMessage != null) { setErrorMessage(errorMessage); } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java index 9fd51dac57..781598d4b8 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/Messages.java @@ -22,6 +22,8 @@ public class Messages extends NLS { public static String AbstractRunHTMLDebugTab_browse_workspace; public static String AbstractRunHTMLDebugTab_select_webroot; public static String AbstractRunHTMLDebugTab_cannot_debug_without_webroot; + public static String AbstractRunHTMLDebugTab_cannot_access_webroot_folder; + public static String AbstractRunHTMLDebugTab_webroot_folder_is_not_a_directory; public static String AttachTab_address; public static String AttachTab_port; public static String AttachTab_title; diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties index 793c993889..6650d01c6c 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/messages.properties @@ -16,6 +16,8 @@ AbstractRunHTMLDebugTab_webRoot_folder=WebRoot Folder AbstractRunHTMLDebugTab_browse_workspace=\ud83d\udcc2 Browse workspace... AbstractRunHTMLDebugTab_select_webroot=Select the root folder of your web application AbstractRunHTMLDebugTab_cannot_debug_without_webroot=Without specifying the webRoot folder, no breakpoints will be triggered. +AbstractRunHTMLDebugTab_cannot_access_webroot_folder=Cannot open webRoot folder. +AbstractRunHTMLDebugTab_webroot_folder_is_not_a_directory=WebRoot folder must be a directory. AttachTab_address=Address: AttachTab_port=Port: AttachTab_title=\ud83d\udd17 Attach