diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/ToolSetConfigurationManager.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/ToolSetConfigurationManager.java index c9cc93e4a..e24d81ee1 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/ToolSetConfigurationManager.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/ToolSetConfigurationManager.java @@ -50,6 +50,21 @@ public void delete(IDFToolSet idfToolSet) { reload = true; getIdfToolSets(false); + // cleanup the env and toolchains + IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables(); + idfEnvironmentVariables.removeAllEnvVariables(); + try + { + ESPToolChainManager espToolChainManager = new ESPToolChainManager(); + espToolChainManager.removeCmakeToolChains(); + espToolChainManager.removeStdToolChains(); + } + catch (Exception e) + { + Logger.log(e); + } + + // update the json now to remove the idf from it. List idfToolSetsToExport = new ArrayList(); for (IDFToolSet idfTool : idfToolSets) { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java index f2364bf4f..6295948f7 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java @@ -333,7 +333,7 @@ public void done(IJobChangeEvent event) Display.getDefault().asyncExec(() -> { if (espidfMainTablePage != null) { - espidfMainTablePage.refreshTable(); + espidfMainTablePage.refreshEditorUI(); } }); diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java index 2afda61f2..25f631a0f 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java @@ -116,11 +116,12 @@ public class Messages extends NLS public static String EspIdfManagerStateCol; public static String EspIdfManagerActivateCol; public static String EspIdfManagerAddToolsBtn; + public static String EspIdfManagerRemoveAllBtn; public static String EspIdfManagerDeleteBtn; - public static String EspIdfManagerMessageBoxActiveToolchainDelete; - public static String EspIdfManagerMessageBoxActiveToolchainDeleteTitle; public static String EspIdfManagerMessageBoxDeleteConfirmMessage; public static String EspIdfManagerMessageBoxDeleteConfirmMessageTitle; + public static String EspIdfManagerMessageBoxDeleteAllConfirmMessage; + public static String EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle; public static String IDFDownloadHandler_ESPIDFConfiguration; public static String IDFDownloadHandler_DownloadPage_Title; diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java index 91afb5749..438e5e510 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java @@ -49,7 +49,7 @@ public void done(IJobChangeEvent event) Display.getDefault().asyncExec(() -> { if (espidfMainTablePage != null) { - espidfMainTablePage.refreshTable(); + espidfMainTablePage.refreshEditorUI(); } }); OpenDialogListenerSupport.getSupport().firePropertyChange(PopupDialog.ENABLE_LAUNCHBAR_EVENTS.name(), null, diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java index 2386ceb55..76bc486ac 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java @@ -5,6 +5,7 @@ package com.espressif.idf.ui.tools.manager.pages; import java.text.MessageFormat; +import java.util.List; import org.eclipse.jface.layout.TableColumnLayout; import org.eclipse.jface.viewers.ArrayContentProvider; @@ -35,6 +36,7 @@ import com.espressif.idf.core.tools.ToolSetConfigurationManager; import com.espressif.idf.core.tools.vo.IDFToolSet; import com.espressif.idf.core.util.IDFUtil; +import com.espressif.idf.ui.LaunchBarListener; import com.espressif.idf.ui.UIPlugin; import com.espressif.idf.ui.install.IDFNewToolsWizard; import com.espressif.idf.ui.tools.Messages; @@ -58,7 +60,9 @@ public class ESPIDFMainTablePage private TableViewerColumn removeColumn; private TableColumnLayout tableColumnLayout; private Composite tableComposite; - + private List idfToolSets; + private Button removeAllButton; + private static final String REMOVE_ICON = "icons/tools/delete.png"; //$NON-NLS-1$ private static final String RELOAD_ICON = "icons/tools/reload.png"; //$NON-NLS-1$ private static final String IDF_TOOL_SET_BTN_KEY = "IDFToolSet"; //$NON-NLS-1$ @@ -66,6 +70,7 @@ public class ESPIDFMainTablePage public Composite createPage(Composite composite) { toolSetConfigurationManager = new ToolSetConfigurationManager(); + idfToolSets = toolSetConfigurationManager.getIdfToolSets(true); container = new Composite(composite, SWT.NONE); final int numColumns = 2; GridLayout gridLayout = new GridLayout(numColumns, false); @@ -74,7 +79,7 @@ public Composite createPage(Composite composite) return container; } - public void refreshTable() + public void refreshEditorUI() { for (TableItem item : tableViewer.getTable().getItems()) { @@ -104,12 +109,22 @@ public void refreshTable() } } toolSetConfigurationManager.setReload(true); + idfToolSets = toolSetConfigurationManager.getIdfToolSets(true); setupColumns(); - tableViewer.setInput(toolSetConfigurationManager.getIdfToolSets(true)); + tableViewer.setInput(idfToolSets); tableViewer.getControl().requestLayout(); tableViewer.refresh(); container.redraw(); toolSetConfigurationManager.setReload(false); + + if (idfToolSets == null || idfToolSets.isEmpty()) + { + removeAllButton.setEnabled(false); + } + else + { + removeAllButton.setEnabled(true); + } } private Composite createIdfTable(Composite parent) @@ -144,15 +159,19 @@ private Composite createIdfTable(Composite parent) GridData buttonCompositeGridData = new GridData(SWT.RIGHT, SWT.CENTER, false, false); buttonCompositeGridData.verticalAlignment = SWT.TOP; // Aligns the button composite at the top buttonComposite.setLayoutData(buttonCompositeGridData); - buttonComposite.setLayout(new FillLayout()); + buttonComposite.setLayout(new GridLayout(1, true)); // Creating the "Add" button Button addButton = new Button(buttonComposite, SWT.PUSH); addButton.setText(Messages.EspIdfManagerAddToolsBtn); - addButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IDFNewToolsWizard wizard = new IDFNewToolsWizard(ESPIDFMainTablePage.this); + GridData addButtonGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + addButton.setLayoutData(addButtonGridData); + addButton.addSelectionListener(new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + IDFNewToolsWizard wizard = new IDFNewToolsWizard(ESPIDFMainTablePage.this); wizard.setWindowTitle(Messages.IDFDownloadHandler_ESPIDFConfiguration); WizardDialog wizDialog = new WizardDialog(container.getShell(), wizard); wizDialog.create(); @@ -162,9 +181,43 @@ public void widgetSelected(SelectionEvent e) { wizDialog.getShell().setSize(Math.max(850, wizDialog.getShell().getSize().x), 550); wizDialog.open(); - } - }); + } + }); + + removeAllButton = new Button(buttonComposite, SWT.PUSH); + removeAllButton.setText(Messages.EspIdfManagerRemoveAllBtn); + removeAllButton.addSelectionListener(new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), + SWT.ICON_WARNING | SWT.YES | SWT.NO); + messageBox.setMessage(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessage); + messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle); + int response = messageBox.open(); + if (response == SWT.YES) + { + for(IDFToolSet idfToolSet : idfToolSets) + { + toolSetConfigurationManager.delete(idfToolSet); + } + refreshEditorUI(); + } + } + }); + GridData removeAllButtonGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + removeAllButton.setLayoutData(removeAllButtonGridData); + if (idfToolSets == null || idfToolSets.isEmpty()) + { + removeAllButton.setEnabled(false); + } + else + { + removeAllButton.setEnabled(true); + } + return idfToolsGroup; } @@ -246,25 +299,14 @@ public void widgetSelected(SelectionEvent e) private void performDeleteOperation(IDFToolSet idfToolSet) { - if (idfToolSet.isActive()) + MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), + SWT.ICON_WARNING | SWT.YES | SWT.NO); + messageBox.setMessage(MessageFormat.format(Messages.EspIdfManagerMessageBoxDeleteConfirmMessage, idfToolSet.getIdfVersion())); + messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteConfirmMessageTitle); + int response = messageBox.open(); + if (response == SWT.YES) { - MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), - SWT.ICON_INFORMATION | SWT.OK); - messageBox.setMessage(Messages.EspIdfManagerMessageBoxActiveToolchainDelete); - messageBox.setText(Messages.EspIdfManagerMessageBoxActiveToolchainDeleteTitle); - messageBox.open(); - } - else - { - MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(), - SWT.ICON_WARNING | SWT.YES | SWT.NO); - messageBox.setMessage(MessageFormat.format(Messages.EspIdfManagerMessageBoxDeleteConfirmMessage, idfToolSet.getIdfVersion())); - messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteConfirmMessageTitle); - int response = messageBox.open(); - if (response == SWT.YES) - { - toolSetConfigurationManager.delete(idfToolSet); - } + toolSetConfigurationManager.delete(idfToolSet); } } @@ -409,20 +451,18 @@ private void createButtonsForLastCol(ViewerCell cell) toolsActivationJob.schedule(); }); } - else - { - Button removeButton = new Button(buttonComposite, SWT.PUSH | SWT.FLAT); - removeButton.pack(); - removeButton.setData(IDF_TOOL_SET_BTN_KEY, idfToolSet); - removeButton.setImage(UIPlugin.getImage(REMOVE_ICON)); - removeButton.setToolTipText(Messages.EspIdfManagerDeleteBtnToolTip); - removeButton.addListener(SWT.Selection, e -> { - Button btn = (Button) e.widget; - IDFToolSet selectedToolSet = (IDFToolSet) btn.getData(IDF_TOOL_SET_BTN_KEY); - performDeleteOperation(selectedToolSet); - refreshTable(); - }); - } + + Button removeButton = new Button(buttonComposite, SWT.PUSH | SWT.FLAT); + removeButton.pack(); + removeButton.setData(IDF_TOOL_SET_BTN_KEY, idfToolSet); + removeButton.setImage(UIPlugin.getImage(REMOVE_ICON)); + removeButton.setToolTipText(Messages.EspIdfManagerDeleteBtnToolTip); + removeButton.addListener(SWT.Selection, e -> { + Button btn = (Button) e.widget; + IDFToolSet selectedToolSet = (IDFToolSet) btn.getData(IDF_TOOL_SET_BTN_KEY); + performDeleteOperation(selectedToolSet); + refreshEditorUI(); + }); editor.grabHorizontal = true; editor.setEditor(buttonComposite, item, cell.getColumnIndex()); 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 477de071c..2330273a7 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 @@ -118,11 +118,12 @@ EspIdfManagerLocationCol=Location EspIdfManagerStateCol=State EspIdfManagerActivateCol=Active EspIdfManagerAddToolsBtn=Add ESP-IDF +EspIdfManagerRemoveAllBtn=Remove All EspIdfManagerDeleteBtn=Delete -EspIdfManagerMessageBoxActiveToolchainDelete=You are trying to delete active toolchain. Please switch active toolchain to delete. -EspIdfManagerMessageBoxActiveToolchainDeleteTitle=Cannot delete active toolchain -EspIdfManagerMessageBoxDeleteConfirmMessage=Do you want to delete the toolchain with ESP-IDF version: {0} -EspIdfManagerMessageBoxDeleteConfirmMessageTitle=Confirm Delete +EspIdfManagerMessageBoxDeleteConfirmMessage=Do you want to remove the toolchain with ESP-IDF version: {0} +EspIdfManagerMessageBoxDeleteConfirmMessageTitle=Confirm Remove +EspIdfManagerMessageBoxDeleteAllConfirmMessage=Do you want to remove all ESP-IDF versions from IDE +EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle=Remove All ESP-IDF Versions EspIdfManagerReloadBtnToolTip=Reload from disk EspIdfManagerDeleteBtnToolTip=Delete ESP-IDF version from IDE