Skip to content

Commit

Permalink
Merge pull request #207 from couchbaselabs/1.1.1_bugfixes
Browse files Browse the repository at this point in the history
fixes in the named parameter dialog
  • Loading branch information
deniswsrosa authored May 27, 2024
2 parents 71e578c + 744a40f commit bd094d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class NamedParameterDialog extends DialogWrapper {
private final DefaultListModel<String> listModel = new DefaultListModel<>();
Expand All @@ -39,8 +40,8 @@ public class NamedParameterDialog extends DialogWrapper {
private final EditorEx editor;
private final EditorEx editorBuiltIn;
private final Map<String, String> editorContentMap = new HashMap<>();
private final JLabel errorLabel;
private Map<String, String> projectNamedParams;
private JLabel errorLabel;


protected NamedParameterDialog(Project project) {
Expand Down Expand Up @@ -142,7 +143,12 @@ public void actionPerformed(ActionEvent e) {
String selectedValue = list.getSelectedValue();
if (selectedValue != null) {
NamedParams params = NamedParamsStorage.getInstance().getValue();
String content = params.getParams().getOrDefault(selectedValue, "");
String content;
if (editorContentMap.containsKey(selectedValue)) {
content = editorContentMap.get(selectedValue);
} else {
content = params.getParams().getOrDefault(selectedValue, "");
}
ApplicationManager.getApplication().runWriteAction(() -> editor.getDocument().setText(content));
editor.setViewer(false);
} else {
Expand All @@ -153,20 +159,26 @@ public void actionPerformed(ActionEvent e) {
});

NamedParams params = NamedParamsStorage.getInstance().getValue();
params.getParams().forEach((key, value) -> addItem(key));
TreeMap<String, String> sortedMap = new TreeMap<>(params.getParams());
sortedMap.forEach((key, value) -> addItem(key));

try {
projectNamedParams = NamedParametersUtil.readProjectNamedParameters(project);
TreeMap<String, String> treeMap = new TreeMap<>(projectNamedParams);

for (String name : projectNamedParams.keySet()) {
for (String name : treeMap.keySet()) {
builtinListModel.addElement(name);
}

builtinList.addListSelectionListener(evt -> {
if (!evt.getValueIsAdjusting()) {
JBList list = (JBList) evt.getSource();
if (list.getSelectedIndex() != -1) {
ApplicationManager.getApplication().runWriteAction(() -> editorBuiltIn.getDocument().setText(projectNamedParams.get(list.getSelectedValue().toString())));
ApplicationManager.getApplication().runWriteAction(() -> {

editorBuiltIn.getDocument().setText(projectNamedParams.get(list.getSelectedValue().toString()));

});
}
}
});
Expand Down

0 comments on commit bd094d7

Please sign in to comment.