Skip to content

Commit 5f89823

Browse files
authored
IEP-1405: New ESP-IDF Size Analysis (#1192)
* IEP-1405: New ESP-IDF Size Analysis * updated code for handling details section * added updated charts to a new section * Added option to select visible columns in details section * refined the chart composite to show green for free * fixed lib dependency issue due to rebase
1 parent b9c4315 commit 5f89823

21 files changed

+1113
-385
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/.DS_Store
1+
.DS_Store
22
tests/com.espressif.idf.ui.test/target/classes/default-test.properties
33
workspace/.metadata/.log
44
/docs/_build/

bundles/com.espressif.idf.ui/.classpath

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<attribute name="javadoc_location" value="jar:platform:/resource/com.espressif.idf.ui/lib/gson-2.8.7-javadoc.jar!/"/>
99
</attributes>
1010
</classpathentry>
11+
<classpathentry kind="lib" path="lib/jfreechart-1.5.5.jar" sourcepath="lib/jfreechart-1.5.5-sources.jar">
12+
<attributes>
13+
<attribute name="javadoc_location" value="jar:platform:/resource/com.espressif.idf.ui/lib/jfreechart-1.5.5-javadoc.jar!/"/>
14+
</attributes>
15+
</classpathentry>
1116
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
1217
<attributes>
1318
<attribute name="module" value="true"/>

bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ Export-Package: com.espressif.idf.ui,
5858
Bundle-ClassPath: .,
5959
lib/ini4j-0.5.4.jar,
6060
lib/gson-2.8.7.jar,
61-
lib/commonmark-0.24.0.jar
61+
lib/commonmark-0.24.0.jar,
62+
lib/jfreechart-1.5.5.jar
6263
Import-Package: com.espressif.idf.lsp.preferences

bundles/com.espressif.idf.ui/build.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ bin.includes = META-INF/,\
1414
introcontent.xml,\
1515
index.html,\
1616
go.css,\
17-
lib/commonmark-0.24.0.jar
17+
lib/commonmark-0.24.0.jar,\
18+
lib/jfreechart-1.5.5.jar
1819

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*-javadoc.jar
2+
/*-sources.jar
1.57 MB
Binary file not shown.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeAnalysisEditor.java

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@
77
import org.eclipse.core.resources.IFile;
88
import org.eclipse.core.resources.IProject;
99
import org.eclipse.core.runtime.IProgressMonitor;
10+
import org.eclipse.jface.resource.FontDescriptor;
1011
import org.eclipse.swt.SWT;
1112
import org.eclipse.swt.graphics.Font;
1213
import org.eclipse.swt.layout.FillLayout;
1314
import org.eclipse.swt.layout.GridData;
1415
import org.eclipse.swt.layout.GridLayout;
16+
import org.eclipse.swt.widgets.Button;
1517
import org.eclipse.swt.widgets.Composite;
18+
import org.eclipse.swt.widgets.Display;
19+
import org.eclipse.swt.widgets.Label;
1620
import org.eclipse.ui.IEditorInput;
1721
import org.eclipse.ui.IEditorSite;
1822
import org.eclipse.ui.PartInitException;
1923
import org.eclipse.ui.part.FileEditorInput;
2024
import org.eclipse.ui.part.MultiPageEditorPart;
2125

26+
import com.espressif.idf.core.IDFEnvironmentVariables;
2227
import com.espressif.idf.core.logging.Logger;
2328
import 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

Comments
 (0)