From e9bcb80a3938dc5598279545ad5e6e09ebf9102c Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Fri, 17 Jun 2016 15:27:37 +0300 Subject: [PATCH] [vcs]: IDEA-154192 improve ok action enabled status for Unshelve Changes dialog; cleanUp; --- .../patch/ApplyPatchDifferentiatedDialog.java | 17 ++++++++++++----- .../vcs/changes/ui/ChangeListChooserPanel.java | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java index 3a4f74e753e6..6d234ea67fd7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java @@ -60,7 +60,6 @@ import com.intellij.ui.*; import com.intellij.util.Alarm; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.Convertor; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -196,7 +195,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { myReset = myCanChangePatchFile ? this::reset : EmptyRunnable.getInstance(); myChangeListChooser = new ChangeListChooserPanel(project, errorMessage -> { - setOKActionEnabled(errorMessage == null); + setOKActionEnabled(errorMessage == null && isChangeTreeEnabled()); setErrorText(errorMessage); }); ChangeListManager changeListManager = ChangeListManager.getInstance(project); @@ -244,7 +243,15 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } private void updateOkActions() { - setOKActionEnabled(!myChangesTreeList.getIncludedChanges().isEmpty()); + boolean changeTreeEnabled = isChangeTreeEnabled(); + setOKActionEnabled(changeTreeEnabled); + if (changeTreeEnabled) { + myChangeListChooser.updateEnabled(); + } + } + + private boolean isChangeTreeEnabled() { + return !myChangesTreeList.getIncludedChanges().isEmpty(); } private void queueRequest() { @@ -371,6 +378,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { myReader = patchReader; updateTree(true); paintBusy(false); + updateOkActions(); }, ModalityState.stateForComponent(myCenterPanel)); } } @@ -519,8 +527,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { protected DefaultTreeModel buildTreeModel(List changes, ChangeNodeDecorator changeNodeDecorator) { TreeModelBuilder builder = new TreeModelBuilder(myProject, isShowFlatten()); - return builder.buildModel(ObjectsConvertor.convert(changes, - (Convertor)o -> o), changeNodeDecorator); + return builder.buildModel(ObjectsConvertor.convert(changes, o -> o), changeNodeDecorator); } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java index 842e79e66848..7d4a4c21d50e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java @@ -132,7 +132,7 @@ public class ChangeListChooserPanel extends JPanel { } } - private void updateEnabledItems() { + public void updateEnabled() { if (myProject != null) { myListPanel.nameChangedImpl(myProject, null); } @@ -170,7 +170,7 @@ public class ChangeListChooserPanel extends JPanel { myExistingListsCombo.setSelectedItem(defaultSelection.getName()); } updateDescription(); - updateEnabledItems(); + updateEnabled(); } private void updateDescription() {