Skip to content

Commit 7f3e49f

Browse files
kolipakakondalalirana01sigmaaa
authored
Merge master to v4.0.0 branch (#1351)
* IEP-1549: Updating java version for release and builds (#1241) Co-authored-by: Kondal Kolipaka <[email protected]> * 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 * IEP-1652 Add project selector to ESP-IDF Terminal launch workflow (#1343) * feat: added a project selector on the terminal page * feat: update terminal title for better UX on windows * fix: added Project name label to the Messages * fix: allowing empty project --------- Co-authored-by: Ali Azam Rana <[email protected]> Co-authored-by: Denys Almazov <[email protected]>
1 parent d264866 commit 7f3e49f

File tree

14 files changed

+1472
-283
lines changed

14 files changed

+1472
-283
lines changed

bundles/com.espressif.idf.terminal.connector/src/com/espressif/idf/terminal/connector/controls/IDFConsoleWizardConfigurationPanel.java

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,34 @@
1313
package com.espressif.idf.terminal.connector.controls;
1414

1515
import java.util.Map;
16+
import java.util.Optional;
1617

17-
import org.eclipse.core.runtime.IAdaptable;
18+
import org.eclipse.core.resources.IProject;
19+
import org.eclipse.core.resources.ResourcesPlugin;
20+
import org.eclipse.core.runtime.CoreException;
1821
import org.eclipse.core.runtime.Platform;
1922
import org.eclipse.jface.dialogs.IDialogSettings;
20-
import org.eclipse.jface.viewers.ISelection;
21-
import org.eclipse.jface.viewers.IStructuredSelection;
22-
import org.eclipse.jface.viewers.StructuredSelection;
2323
import org.eclipse.swt.SWT;
2424
import org.eclipse.swt.layout.GridData;
2525
import org.eclipse.swt.layout.GridLayout;
26+
import org.eclipse.swt.widgets.Combo;
2627
import org.eclipse.swt.widgets.Composite;
2728
import org.eclipse.swt.widgets.Label;
2829
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
2930
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
3031
import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel;
31-
import org.eclipse.ui.ISelectionService;
32-
import org.eclipse.ui.PlatformUI;
3332
import org.eclipse.ui.WorkbenchEncoding;
34-
import org.osgi.framework.Bundle;
33+
34+
import com.espressif.idf.core.IDFProjectNature;
35+
import com.espressif.idf.core.logging.Logger;
36+
import com.espressif.idf.ui.EclipseUtil;
3537

3638
/**
3739
* IDF console wizard configuration panel implementation.
3840
*/
3941
public class IDFConsoleWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
4042

41-
private Object resource;
43+
private Combo projectCombo;
4244

4345
/**
4446
* Constructor.
@@ -55,6 +57,7 @@ public void setupPanel(Composite parent) {
5557
panel.setLayout(new GridLayout());
5658
panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
5759

60+
createProjectCombo(panel);
5861
// Create the encoding selection combo
5962
createEncodingUI(panel, false);
6063

@@ -76,12 +79,40 @@ public void setupPanel(Composite parent) {
7679
layoutData.heightHint = 80;
7780
label.setLayoutData(layoutData);
7881

79-
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
80-
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
81-
resource = getSelectionResource();
82+
setControl(panel);
83+
}
84+
85+
private void createProjectCombo(Composite parent) {
86+
87+
Composite panel = new Composite(parent, SWT.NONE);
88+
GridLayout layout = new GridLayout(2, false);
89+
layout.marginHeight = 0;
90+
layout.marginWidth = 0;
91+
panel.setLayout(layout);
92+
panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
93+
94+
Label projectLabel = new Label(panel, SWT.NONE);
95+
projectLabel
96+
.setText(Messages.IDFConsoleWizardConfigurationPanel_IDFConsoleWizardConfigurationPanel_ProjectLabel);
97+
98+
projectCombo = new Combo(panel, SWT.READ_ONLY);
99+
projectCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
100+
101+
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
102+
try {
103+
if (project.hasNature(IDFProjectNature.ID)) {
104+
projectCombo.add(project.getName());
105+
}
106+
} catch (CoreException e) {
107+
Logger.log(e);
108+
}
82109
}
83110

84-
setControl(panel);
111+
Optional<IProject> optProject = Optional.ofNullable(EclipseUtil.getSelectedIDFProjectInExplorer());
112+
optProject.ifPresentOrElse(project -> projectCombo.setText(project.getName()), () -> {
113+
if (projectCombo.getItemCount() > 0)
114+
projectCombo.select(0);
115+
});
85116
}
86117

87118
@Override
@@ -96,19 +127,17 @@ public void setupData(Map<String, Object> data) {
96127

97128
@Override
98129
public void extractData(Map<String, Object> data) {
99-
// set the terminal connector id for local terminal
130+
100131
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,
101132
"com.espressif.idf.terminal.connector.espidfConnector"); //$NON-NLS-1$
102133

103-
// Store the encoding
104134
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
105135

106-
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
107-
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
108-
// if we have a IResource selection use the location for working directory
109-
if (resource instanceof org.eclipse.core.resources.IResource) {
110-
String dir = ((org.eclipse.core.resources.IResource) resource).getProject().getLocation().toString();
111-
data.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, dir);
136+
if (projectCombo != null && !projectCombo.isDisposed() && !projectCombo.getText().isEmpty()) {
137+
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectCombo.getText());
138+
if (p != null && p.exists() && p.getLocation() != null) {
139+
data.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, p.getLocation().toOSString());
140+
data.put(ITerminalsConnectorConstants.PROP_TITLE, p.getName());
112141
}
113142
}
114143
}
@@ -147,25 +176,4 @@ protected String getHostFromSettings() {
147176
public boolean isWithHostList() {
148177
return false;
149178
}
150-
151-
/**
152-
* Returns the IResource from the current selection
153-
*
154-
* @return the IResource, or <code>null</code>.
155-
*/
156-
private org.eclipse.core.resources.IResource getSelectionResource() {
157-
ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
158-
ISelection selection = selectionService != null ? selectionService.getSelection() : StructuredSelection.EMPTY;
159-
160-
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
161-
Object element = ((IStructuredSelection) selection).getFirstElement();
162-
if (element instanceof org.eclipse.core.resources.IResource) {
163-
return ((org.eclipse.core.resources.IResource) element);
164-
}
165-
if (element instanceof IAdaptable) {
166-
return ((IAdaptable) element).getAdapter(org.eclipse.core.resources.IResource.class);
167-
}
168-
}
169-
return null;
170-
}
171179
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.espressif.idf.terminal.connector.controls;
2+
3+
import org.eclipse.osgi.util.NLS;
4+
5+
public class Messages extends NLS {
6+
private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
7+
static {
8+
// initialize resource bundle
9+
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
10+
}
11+
12+
private Messages() {
13+
}
14+
15+
public static String IDFConsoleWizardConfigurationPanel_MissingProjectErrorMsg;
16+
public static String IDFConsoleWizardConfigurationPanel_IDFConsoleWizardConfigurationPanel_ProjectLabel;
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IDFConsoleWizardConfigurationPanel_MissingProjectErrorMsg=Please create and select an ESP-IDF Project first.
2+
IDFConsoleWizardConfigurationPanel_IDFConsoleWizardConfigurationPanel_ProjectLabel=Project name:

0 commit comments

Comments
 (0)