77import org .eclipse .core .resources .IFile ;
88import org .eclipse .core .resources .IProject ;
99import org .eclipse .core .runtime .IProgressMonitor ;
10+ import org .eclipse .jface .resource .FontDescriptor ;
1011import org .eclipse .swt .SWT ;
1112import org .eclipse .swt .graphics .Font ;
1213import org .eclipse .swt .layout .FillLayout ;
1314import org .eclipse .swt .layout .GridData ;
1415import org .eclipse .swt .layout .GridLayout ;
16+ import org .eclipse .swt .widgets .Button ;
1517import org .eclipse .swt .widgets .Composite ;
18+ import org .eclipse .swt .widgets .Display ;
19+ import org .eclipse .swt .widgets .Label ;
1620import org .eclipse .ui .IEditorInput ;
1721import org .eclipse .ui .IEditorSite ;
1822import org .eclipse .ui .PartInitException ;
1923import org .eclipse .ui .part .FileEditorInput ;
2024import org .eclipse .ui .part .MultiPageEditorPart ;
2125
26+ import com .espressif .idf .core .IDFEnvironmentVariables ;
2227import com .espressif .idf .core .logging .Logger ;
2328import com .espressif .idf .core .util .SDKConfigJsonReader ;
29+ import com .espressif .idf .core .util .StringUtil ;
2430
2531/**
2632 * @author Kondal Kolipaka <[email protected] > @@ -48,9 +54,61 @@ protected void createPages()
4854 {
4955 String osString = file .getLocation ().toOSString ();
5056 Logger .log ("Editor input:" + osString ); //$NON-NLS-1$
57+
58+ if (!verifyVersion ())
59+ {
60+ createErrorMessageOnEditor ();
61+ }
62+ else
63+ {
64+ createOverviewPage ();
65+ createChartsComposite ();
66+ createDetailsPage ();
67+ }
68+ }
69+
70+ private boolean verifyVersion ()
71+ {
72+ IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables ();
73+ String idfVersion = idfEnvironmentVariables .getEnvValue (IDFEnvironmentVariables .ESP_IDF_VERSION );
74+ if (StringUtil .isEmpty (idfVersion ))
75+ {
76+ return false ;
77+ }
78+
79+ if (idfVersion .toLowerCase ().startsWith ("v" )) //$NON-NLS-1$
80+ {
81+ idfVersion = idfVersion .substring (1 );
82+ }
83+
84+ String [] parts = idfVersion .split ("\\ ." );
85+ if (parts .length < 2 )
86+ {
87+ return false ; // Unexpected version format
88+ }
89+
90+ try
91+ {
92+ int major = Integer .parseInt (parts [0 ]);
93+ int minor = Integer .parseInt (parts [1 ]);
94+
95+ // Check if version >= 5.1
96+ if (major > 5 )
97+ {
98+ return true ;
99+ }
100+ else if (major == 5 && minor > 1 )
101+ {
102+ return true ;
103+ }
104+ }
105+ catch (NumberFormatException e )
106+ {
107+ return false ;
108+ }
109+
110+ return false ;
51111
52- createOverviewPage ();
53- createDetailsPage ();
54112 }
55113
56114 @ Override
@@ -70,6 +128,43 @@ public boolean isSaveAsAllowed()
70128 {
71129 return false ;
72130 }
131+
132+ private void createErrorMessageOnEditor ()
133+ {
134+ Composite parent = new Composite (getContainer (), SWT .NONE );
135+ GridLayout layout = new GridLayout (1 , false );
136+ layout .verticalSpacing = 20 ;
137+ layout .marginTop = 100 ;
138+ parent .setLayout (layout );
139+
140+ // Main error message with bold system font
141+ Label title = new Label (parent , SWT .CENTER );
142+ title .setText (Messages .IDFSizeEditorVersionError );
143+ GridData titleData = new GridData (SWT .CENTER , SWT .CENTER , true , false );
144+ title .setLayoutData (titleData );
145+
146+ // Apply bold style to default system font
147+ FontDescriptor boldFontDescriptor = FontDescriptor .createFrom (title .getFont ()).setStyle (SWT .BOLD );
148+ title .setFont (boldFontDescriptor .createFont (parent .getDisplay ()));
149+
150+ // Subtext explanation
151+ Label explanation = new Label (parent , SWT .CENTER | SWT .WRAP );
152+ explanation .setText (Messages .IDFSizeEditorVersionErrorDescription );
153+ GridData explanationData = new GridData (SWT .CENTER , SWT .CENTER , true , false );
154+ explanationData .widthHint = 500 ;
155+ explanation .setLayoutData (explanationData );
156+
157+ // Close Editor Button
158+ Button closeBtn = new Button (parent , SWT .PUSH );
159+ closeBtn .setText (Messages .IDFSizeEditorCloseButton );
160+ GridData buttonData = new GridData (SWT .CENTER , SWT .CENTER , true , false );
161+ closeBtn .setLayoutData (buttonData );
162+ closeBtn .addListener (SWT .Selection , e -> getSite ().getPage ().closeEditor (this , false ));
163+
164+ int index = addPage (parent );
165+ setPageText (index , Messages .IDFSizeEditorError );
166+ }
167+
73168
74169 /**
75170 * Create Size Analysis Details Page
@@ -107,7 +202,7 @@ private void createDetailsPage()
107202 new IDFSizeDetailsComposite ().createPartControl (tableComposite , file );
108203
109204 int index = addPage (parent );
110- setPageText (index , "Details" ); //$NON-NLS-1$
205+ setPageText (index , Messages . IDFSizeEditorDetails );
111206 }
112207
113208 /**
@@ -117,11 +212,22 @@ private void createOverviewPage()
117212 {
118213 Composite parent = new Composite (getContainer (), SWT .NONE );
119214 parent .setLayout (new FillLayout ());
215+ parent .setBackground (Display .getDefault ().getSystemColor (SWT .COLOR_WHITE ));
120216
121217 new IDFSizeOverviewComposite ().createPartControl (parent , file , getTarget ());
122218
123219 int index = addPage (parent );
124- setPageText (index , "Overview" ); //$NON-NLS-1$
220+ setPageText (index , Messages .IDFSizeEditorOverview );
221+ }
222+
223+ private void createChartsComposite ()
224+ {
225+ Composite parent = new Composite (getContainer (), SWT .NONE );
226+ parent .setLayout (new FillLayout ());
227+
228+ new IDFSizeChartsComposite ().createPartControl (parent , file , getTarget ());
229+ int index = addPage (parent );
230+ setPageText (index , Messages .IDFSizeEditorCharts );
125231 }
126232
127233 private String getTarget ()
0 commit comments