mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-19607 don't recreate settings panels each selection
This commit is contained in:
+9
@@ -76,6 +76,11 @@ public class ProjectSettingsStepBase<T> extends AbstractActionWithPanel implemen
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelSelected() {
|
||||
checkWebProjectValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel createPanel() {
|
||||
final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
@@ -181,6 +186,10 @@ public class ProjectSettingsStepBase<T> extends AbstractActionWithPanel implemen
|
||||
};
|
||||
myLocationField.getTextField().getDocument().addDocumentListener(documentAdapter);
|
||||
Disposer.register(this, () -> myLocationField.getTextField().getDocument().removeDocumentListener(documentAdapter));
|
||||
checkWebProjectValid();
|
||||
}
|
||||
|
||||
private void checkWebProjectValid() {
|
||||
if (myProjectGenerator instanceof WebProjectTemplate && !((WebProjectTemplate)myProjectGenerator).postponeValidation()) {
|
||||
checkValid();
|
||||
}
|
||||
|
||||
+1
@@ -24,4 +24,5 @@ public abstract class AbstractActionWithPanel extends AnAction implements DumbAw
|
||||
|
||||
public abstract JPanel createPanel();
|
||||
|
||||
public void onPanelSelected() {}
|
||||
}
|
||||
|
||||
+6
-2
@@ -75,6 +75,7 @@ import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -876,7 +877,8 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
|
||||
if (back != null && !singleProjectGenerator) {
|
||||
actionsListPanel.add(back, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
|
||||
final HashMap<Object, JPanel> panelsMap = ContainerUtil.newHashMap();
|
||||
ListSelectionListener selectionListener = e -> {
|
||||
if (e.getValueIsAdjusting()) {
|
||||
// Update when a change has been finalized.
|
||||
@@ -888,7 +890,9 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
|
||||
}
|
||||
Object value = list.getSelectedValue();
|
||||
if (value instanceof AbstractActionWithPanel) {
|
||||
JPanel panel = ((AbstractActionWithPanel)value).createPanel();
|
||||
final JPanel panel = panelsMap.computeIfAbsent(value, o -> ((AbstractActionWithPanel)value).createPanel());
|
||||
((AbstractActionWithPanel)value).onPanelSelected();
|
||||
|
||||
panel.setBorder(JBUI.Borders.empty(7, 10));
|
||||
selected.set(panel);
|
||||
main.add(selected.get());
|
||||
|
||||
Reference in New Issue
Block a user