diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/URLDialog.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/URLDialog.java deleted file mode 100644 index fd9e2aa3b..000000000 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/URLDialog.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved. - * Use is subject to license terms. - *******************************************************************************/ -package com.espressif.idf.ui.dialogs; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.program.Program; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Shell; - -import com.espressif.idf.core.logging.Logger; - -/** - * URL Dialog class that can show multiple external web URLs in the text and - * make them click able and launches the default program to open them - * @author Ali Azam Rana - * - */ -public class URLDialog extends Dialog -{ - private static final String URL_REGEX = "\\b((http|https)://)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)"; //$NON-NLS-1$ - - private String text; - private String title; - - public URLDialog(Shell parentShell, String title, String text) - { - super(parentShell); - this.text = text; - this.title = title; - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite container = new Composite((Composite) super.createDialogArea(parent), SWT.NONE); - container.setLayout(new GridLayout()); - Link link = new Link(container, SWT.NONE); - link.setText(getTextForLinkControl()); - link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true)); - link.addListener(SWT.Selection, e -> Program.launch(e.text)); - return container; - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(title); - } - - private String getTextForLinkControl() - { - StringBuilder stringBuilder = new StringBuilder(); - Pattern pattern = Pattern.compile(URL_REGEX); - Matcher matcher = pattern.matcher(text); - int startIndex = 0, endIndex = text.length(); - while (matcher.find()) - { - String url = matcher.group(); - Logger.log("URL Found: " + url); - endIndex = text.indexOf(url); - stringBuilder.append(text.substring(startIndex, endIndex)); - stringBuilder.append(""); //$NON-NLS-1$ - stringBuilder.append(url); - stringBuilder.append(""); //$NON-NLS-1$ - startIndex = endIndex + url.length(); - endIndex = text.length(); - } - if (stringBuilder.toString().isEmpty()) - { - stringBuilder.append(text); - } - return stringBuilder.toString(); - } -} diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsInstallationHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsInstallationHandler.java index 448d6c0ac..8547327ca 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsInstallationHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsInstallationHandler.java @@ -49,7 +49,6 @@ import com.espressif.idf.core.util.IDFUtil; import com.espressif.idf.core.util.StringUtil; import com.espressif.idf.ui.UIPlugin; -import com.espressif.idf.ui.dialogs.URLDialog; import com.espressif.idf.ui.tools.wizard.pages.ManageToolsInstallationWizardPage; import com.espressif.idf.ui.update.InstallToolsHandler; @@ -638,21 +637,22 @@ else if (environment.containsKey("Path")) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Messages.MissingToolsValidationMessage_A); - stringBuilder.append(System.lineSeparator()); for (ToolsVO toolsVO : missingToolsVOs) { stringBuilder.append(toolsVO.getName()); - stringBuilder.append(System.lineSeparator()); + stringBuilder.append(" "); } stringBuilder.append(Messages.MissingToolsValidationMessage_B); - stringBuilder.append(System.lineSeparator()); + stringBuilder.append(""); stringBuilder.append(Messages.MissingToolsValidationLink); + stringBuilder.append(""); + + logQueue.add(stringBuilder.toString()); manageToolsInstallationWizardPage.getShell().getDisplay().asyncExec(() -> { - URLDialog urlDialog = new URLDialog(manageToolsInstallationWizardPage.getShell(), "Missing Tools", - stringBuilder.toString()); - urlDialog.open(); + manageToolsInstallationWizardPage.getLinkForDoc().setText(stringBuilder.toString()); + manageToolsInstallationWizardPage.getLinkForDoc().setVisible(true); }); } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties index 3ce48d71e..017182328 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties @@ -108,5 +108,5 @@ IDFDownloadWizard_UpdatingIDFPathMessage=Updating IDF_PATH to: {0} FilterTargetBoxToolTip=Filter the tools based on the target selection of ESP chips ShowAvailableVersionsOnlyToolTip=Shows the versions that are available already and downloaded. The versions should be in the espressif home directory to be visible with this. MissingToolsValidationMessage_A=Following required tools are missing: -MissingToolsValidationMessage_B=Please visit the Link below to see configuration for these tools +MissingToolsValidationMessage_B=Please visit the Link to see configuration for these tools MissingToolsValidationLink=https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/MissingToolsManualPathUpdateGuide.md diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/wizard/pages/ManageToolsInstallationWizardPage.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/wizard/pages/ManageToolsInstallationWizardPage.java index 194a90a30..fff211bbb 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/wizard/pages/ManageToolsInstallationWizardPage.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/wizard/pages/ManageToolsInstallationWizardPage.java @@ -28,11 +28,13 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.ProgressBar; @@ -110,6 +112,7 @@ public class ManageToolsInstallationWizardPage extends WizardPage implements ITo private Preferences scopedPreferenceStore; private Button forceDownloadBtn; private Listener[] listenersForFinish; + private Link linkForDoc; public ManageToolsInstallationWizardPage(WizardDialog parentWizardDialog, ToolsJsonParser toolsJsonParser) { @@ -270,6 +273,10 @@ public void widgetSelected(SelectionEvent e) progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); progressBar.setVisible(false); + linkForDoc = new Link(logAreaComposite, SWT.WRAP | SWT.MULTI); + linkForDoc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3)); + linkForDoc.addListener(SWT.Selection, e -> Program.launch(e.text)); + linkForDoc.setVisible(false); createButtonsBar(logAreaComposite); setButtonsEnabled(itemChecked); @@ -942,6 +949,16 @@ public void afterDeleteToolMessage() } } + public Link getLinkForDoc() + { + return linkForDoc; + } + + public void setLinkForDoc(Link linkForDoc) + { + this.linkForDoc = linkForDoc; + } + private class SelectRecommendedButtonSelectionAdapter extends SelectionAdapter { @Override