Skip to content

Commit edce007

Browse files
authored
IEP-1650 Convert NVS Title Area dialog to the editor (#1339)
* feat: convertin NVS dialog to the editor * fix: replace enum with EnumMap * feat: optimizing performance * feat: improving tooltip performance * feat: move to the new API, improving tooltip * fix: fixed potential NPE is there is no selected project * fix: addressing coderabbit point about NPE * fix: remove duplicate editor in the plugin.xml * feat: improved status messaging * feat: setting the default partition size to improve the UX * fix: set dirty false after save action * fix: addressing coderabbit comment about possible NPE * fix: addressing minor fix about filter path * feat: saving the status of fields based on the project * feat: improving UX by utilizing ColumnLabelProvider * fix: return non editable for first row * feat: refactoring to reduce size of the EditorPage and make it easier to read * feat: refactoring - moved storing preference logic to the separate class * fix: fixed typo in the methods names
1 parent 4ec9db2 commit edce007

File tree

10 files changed

+1340
-107
lines changed

10 files changed

+1340
-107
lines changed

bundles/com.espressif.idf.ui/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,8 @@
739739
class="com.espressif.idf.ui.nvs.dialog.NvsEditor"
740740
default="false"
741741
icon="icons/ESP-IDF_NVS_Table_Editor.png"
742-
id="com.espressif.idf.ui.nvs_table_editor"
743-
name="NVS Table Editor">
742+
id="com.espressif.idf.ui.nvs.nvsEditor"
743+
name="%command.name.nvsTableEditor">
744744
<contentTypeBinding
745745
contentTypeId="com.espressif.idf.ui.nvs_editor_content_type">
746746
</contentTypeBinding>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*******************************************************************************
2+
* Copyright 2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
3+
* Use is subject to license terms.
4+
*******************************************************************************/
5+
package com.espressif.idf.ui.nvs.dialog;
6+
7+
import java.util.stream.Stream;
8+
9+
/**
10+
* Represents the columns in the NVS TableViewer. This enum provides a type-safe way to manage column properties,
11+
* replacing "magic numbers" and string arrays.
12+
*/
13+
public enum NvsColumn
14+
{
15+
16+
KEY("Key", 100), TYPE("Type", 100), ENCODING("Encoding", 100), VALUE("Value", 150); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
17+
18+
private final String displayName;
19+
private final int defaultWidth;
20+
21+
NvsColumn(String displayName, int defaultWidth)
22+
{
23+
this.displayName = displayName;
24+
this.defaultWidth = defaultWidth;
25+
}
26+
27+
/**
28+
* @return The human-readable name for the table header.
29+
*/
30+
public String getDisplayName()
31+
{
32+
return displayName;
33+
}
34+
35+
/**
36+
* @return The default pixel width for the column.
37+
*/
38+
public int getDefaultWidth()
39+
{
40+
return defaultWidth;
41+
}
42+
43+
/**
44+
* @return The integer index (position) of this column.
45+
*/
46+
public int getIndex()
47+
{
48+
return this.ordinal();
49+
}
50+
51+
/**
52+
* A static helper to get an array of all display names for JFace APIs like {@code setColumnProperties}.
53+
*
54+
* @return ["Key", "Type", "Encoding", "Value"]
55+
*/
56+
public static String[] getColumnProperties()
57+
{
58+
return Stream.of(values()).map(NvsColumn::getDisplayName).toArray(String[]::new);
59+
}
60+
61+
/**
62+
* A static helper to get the enum constant from its index.
63+
*
64+
* @param index The column index.
65+
* @return The matching NvsColumn (e.g., KEY for index 0).
66+
*/
67+
public static NvsColumn fromIndex(int index)
68+
{
69+
if (index >= 0 && index < values().length)
70+
{
71+
return values()[index];
72+
}
73+
// This should ideally not be reachable if validation is correct
74+
throw new IndexOutOfBoundsException("Invalid column index: " + index); //$NON-NLS-1$
75+
}
76+
}

0 commit comments

Comments
 (0)