[vcs]: IDEA-154192 improve ok action enabled status for Unshelve Changes dialog; cleanUp;

This commit is contained in:
Nadya Zabrodina
2016-06-24 15:14:08 +03:00
committed by Nadya Zabrodina
parent 55da3bcd9a
commit e9bcb80a39
2 changed files with 14 additions and 7 deletions
@@ -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<AbstractFilePatchInProgress.PatchChange> changes,
ChangeNodeDecorator changeNodeDecorator) {
TreeModelBuilder builder = new TreeModelBuilder(myProject, isShowFlatten());
return builder.buildModel(ObjectsConvertor.convert(changes,
(Convertor<AbstractFilePatchInProgress.PatchChange, Change>)o -> o), changeNodeDecorator);
return builder.buildModel(ObjectsConvertor.convert(changes, o -> o), changeNodeDecorator);
}
@Override
@@ -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() {