Skip to content

Commit

Permalink
IEP-1214: Fixing UI issue with ESP-IDF Manager View (#941)
Browse files Browse the repository at this point in the history
* IEP-1214: Fixed the row color and button spacing
  • Loading branch information
alirana01 authored May 10, 2024
1 parent 4b3c0be commit 119adef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public class Messages extends NLS
public static String IDFDownloadHandler_ESPIDFConfiguration;
public static String IDFDownloadHandler_DownloadPage_Title;
public static String IDFDownloadHandler_DownloadPageMsg;
public static String EspIdfManagerReloadBtnToolTip;
public static String EspIdfManagerDeleteBtnToolTip;

static
{
// initialize resource bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public void refreshTable()
editorLast.dispose();
item.setData(EDITOR_KEY_LAST, null);
}

}
toolSetConfigurationManager.setReload(true);
setupColumns();
Expand All @@ -125,12 +124,14 @@ private Composite createIdfTable(Composite parent)
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);

tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.addListener(SWT.MeasureItem, event -> {
event.height = 25;
});
comparator = new ColumnViewerComparator();
tableViewer.setComparator(comparator);
setupColumns();
Expand Down Expand Up @@ -310,6 +311,12 @@ else if (isLastCol)
{
updateDataIntoCells(cell);
}

Color color = getBackground(cell.getElement());
if (color != null)
{
cell.setBackground(color);
}
}

private void updateDataIntoCells(ViewerCell cell)
Expand All @@ -336,6 +343,7 @@ private void updateDataIntoCells(ViewerCell cell)
private void createButtonsForFirstCol(ViewerCell cell)
{
TableItem item = (TableItem) cell.getItem();

// using a unique key to store the editor to avoid creating multiple editors for the same cell
String EDITOR_KEY = "action_editor";
if (item.getData(EDITOR_KEY) != null)
Expand Down Expand Up @@ -376,21 +384,19 @@ private void createButtonsForLastCol(ViewerCell cell)
}
TableEditor editor = new TableEditor(tableViewer.getTable());
Composite buttonComposite = new Composite(tableViewer.getTable(), SWT.NONE);
GridLayout gridLayout = new GridLayout(2, true);
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
buttonComposite.setLayout(gridLayout);
FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL);
fillLayout.marginWidth = 2;
fillLayout.spacing = 5;

buttonComposite.setLayout(fillLayout);

item.setData(EDITOR_KEY, editor);
IDFToolSet idfToolSet = (IDFToolSet) cell.getElement();
Button removeButton = new Button(buttonComposite, SWT.PUSH | SWT.FLAT);
GridData gridData = new GridData();
gridData.widthHint = 20; // Explicitly setting the width
gridData.heightHint = 20; // Explicitly setting the height
removeButton.setLayoutData(gridData);
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);
Expand All @@ -401,13 +407,10 @@ private void createButtonsForLastCol(ViewerCell cell)
if (idfToolSet.isActive())
{
Button reloadButton = new Button(buttonComposite, SWT.PUSH | SWT.FLAT);
GridData gridDataReloadButton = new GridData();
gridDataReloadButton.widthHint = 20; // Explicitly setting the width
gridDataReloadButton.heightHint = 20; // Explicitly setting the height
reloadButton.setLayoutData(gridDataReloadButton);
reloadButton.pack();
reloadButton.setData(IDF_TOOL_SET_BTN_KEY, idfToolSet);
reloadButton.setImage(UIPlugin.getImage(RELOAD_ICON));
reloadButton.setToolTipText(Messages.EspIdfManagerReloadBtnToolTip);
reloadButton.addListener(SWT.Selection, e -> {
Button btn = (Button) e.widget;
IDFToolSet selectedToolSet = (IDFToolSet) btn.getData(IDF_TOOL_SET_BTN_KEY);
Expand All @@ -420,6 +423,10 @@ private void createButtonsForLastCol(ViewerCell cell)

editor.grabHorizontal = true;
editor.setEditor(buttonComposite, item, cell.getColumnIndex());
editor.horizontalAlignment = SWT.CENTER;
editor.verticalAlignment = SWT.CENTER;
editor.minimumWidth = buttonComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
editor.minimumHeight = buttonComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ EspIdfManagerMessageBoxActiveToolchainDelete=You are trying to delete active too
EspIdfManagerMessageBoxActiveToolchainDeleteTitle=Cannot delete active toolchain
EspIdfManagerMessageBoxDeleteConfirmMessage=Do you want to delete the toolchain with ESP-IDF version: {0}
EspIdfManagerMessageBoxDeleteConfirmMessageTitle=Confirm Delete


EspIdfManagerReloadBtnToolTip=Reload from disk
EspIdfManagerDeleteBtnToolTip=Delete ESP-IDF version from IDE

IDFDownloadHandler_ESPIDFConfiguration=ESP-IDF Configuration
IDFDownloadHandler_DownloadPage_Title=Download or use ESP-IDF
Expand Down

0 comments on commit 119adef

Please sign in to comment.