IDEA-82746 Disable "Push" button in Push dialog for Git when there is nothing to push

* HgPushOptionsPanel simplified;
* push button should not be disabled for hg single repo project, because we would like to push without loading commits
This commit is contained in:
Nadya Zabrodina
2014-10-29 13:58:25 +03:00
parent cc206c0fd2
commit 633cc944d7
2 changed files with 15 additions and 14 deletions
@@ -256,6 +256,13 @@ public class PushController implements Disposable {
}
private boolean isPushAllowed(@NotNull PushSupport<?, ?, ?> pushSupport) {
if (mySingleRepoProject) {
MyRepoModel repoModel = ContainerUtil.getFirstItem(myView2Model.values());
assert repoModel != null;
return hasSomethingToPush(myView2Model.keySet()) ||
!repoModel.getLoadedCommits().isEmpty() ||
myDialog.getAdditionalOptionValue(pushSupport) != null;
}
Collection<RepositoryNode> nodes = getNodesForSupport(pushSupport);
if (pushSupport.getRepositoryManager().isSyncEnabled()) {
return hasSomethingToPush(nodes) || (hasCheckedNode(nodes) && allNodesAreLoaded(nodes));
@@ -330,6 +337,7 @@ public class PushController implements Disposable {
boolean shouldBeSelected;
if (!errors.isEmpty()) {
shouldBeSelected = false;
model.setLoadedCommits(outgoing.getCommits());
myPushLog.setChildren(node, ContainerUtil.map(errors, new Function<VcsError, DefaultMutableTreeNode>() {
@Override
public DefaultMutableTreeNode fun(final VcsError error) {
@@ -16,31 +16,24 @@
package org.zmlx.hg4idea.push;
import com.intellij.dvcs.push.VcsPushOptionsPanel;
import com.intellij.openapi.ui.ComboBox;
import org.jetbrains.annotations.NotNull;
import com.intellij.ui.components.JBCheckBox;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
public class HgPushOptionsPanel extends VcsPushOptionsPanel {
private final ComboBox myReferenceStrategyCombobox;
private final JBCheckBox myPushBookmarkCheckBox;
public HgPushOptionsPanel() {
setLayout(new BorderLayout());
myReferenceStrategyCombobox = new ComboBox();
HgVcsPushOptionValue[] values = HgVcsPushOptionValue.values();
DefaultComboBoxModel comboModel = new DefaultComboBoxModel(values);
myReferenceStrategyCombobox.setModel(comboModel);
JLabel referenceStrategyLabel = new JLabel("Export Bookmarks: ");
add(referenceStrategyLabel, BorderLayout.WEST);
add(myReferenceStrategyCombobox, BorderLayout.CENTER);
myPushBookmarkCheckBox = new JBCheckBox("Export Active Bookmarks");
add(myPushBookmarkCheckBox, BorderLayout.WEST);
}
@Override
@NotNull
@Nullable
public HgVcsPushOptionValue getValue() {
return (HgVcsPushOptionValue)myReferenceStrategyCombobox.getSelectedItem();
return myPushBookmarkCheckBox.isSelected() ? HgVcsPushOptionValue.Current : null;
}
}