mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -88,8 +88,12 @@ public class PushController implements Disposable {
|
||||
myPushLog.getTree().addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
// when user starts edit we need to force disable ok actions, because tree.isEditing() still false;
|
||||
// after editing completed okActions will be enabled automatically by dialog validation
|
||||
Boolean isEditMode = (Boolean)evt.getNewValue();
|
||||
myDialog.enableOkActions(!isEditMode && isPushAllowed());
|
||||
if (isEditMode) {
|
||||
myDialog.disableOkActions();
|
||||
}
|
||||
}
|
||||
});
|
||||
startLoadingCommits();
|
||||
@@ -234,7 +238,7 @@ public class PushController implements Disposable {
|
||||
|
||||
@Override
|
||||
public void onSelectionChanged(boolean isSelected) {
|
||||
myDialog.enableOkActions(isPushAllowed());
|
||||
myDialog.updateOkActions();
|
||||
if (isSelected) {
|
||||
boolean forceLoad = myExcludedRepositoryRoots.remove(model.getRepository().getRoot().getPath());
|
||||
if (!model.hasCommitInfo() && (forceLoad || !model.getSupport().shouldRequestIncomingChangesForNotCheckedRepositories())) {
|
||||
@@ -277,21 +281,21 @@ public class PushController implements Disposable {
|
||||
return names;
|
||||
}
|
||||
|
||||
public boolean isPushAllowed() {
|
||||
public boolean isPushAllowed(final boolean force) {
|
||||
JTree tree = myPushLog.getTree();
|
||||
return !tree.isEditing() &&
|
||||
ContainerUtil.exists(myPushSupports, new Condition<PushSupport<?, ?, ?>>() {
|
||||
@Override
|
||||
public boolean value(PushSupport<?, ?, ?> support) {
|
||||
return isPushAllowed(support);
|
||||
return isPushAllowed(support, force);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isPushAllowed(@NotNull PushSupport<?, ?, ?> pushSupport) {
|
||||
private boolean isPushAllowed(@NotNull PushSupport<?, ?, ?> pushSupport, boolean force) {
|
||||
Collection<RepositoryNode> nodes = getNodesForSupport(pushSupport);
|
||||
if (hasSomethingToPush(nodes)) return true;
|
||||
if (hasCheckedNodesWithContent(nodes, myDialog.getAdditionalOptionValue(pushSupport) != null)) {
|
||||
if (hasCheckedNodesWithContent(nodes, force || myDialog.getAdditionalOptionValue(pushSupport) != null)) {
|
||||
return !pushSupport.getRepositoryManager().isSyncEnabled() || allNodesAreLoaded(nodes);
|
||||
}
|
||||
return false;
|
||||
@@ -399,7 +403,7 @@ public class PushController implements Disposable {
|
||||
if (shouldBeSelected) { // never remove selection; initially all checkboxes are not selected
|
||||
node.setChecked(true);
|
||||
}
|
||||
myDialog.enableOkActions(isPushAllowed());
|
||||
myDialog.updateOkActions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
|
||||
private static final String ID = "Vcs.Push.Dialog";
|
||||
|
||||
@NotNull private final Project myProject;
|
||||
private final PushLog myListPanel;
|
||||
private final PushController myController;
|
||||
private final Map<PushSupport, VcsPushOptionsPanel> myAdditionalPanels;
|
||||
@@ -48,13 +47,12 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
@NotNull List<? extends Repository> selectedRepositories,
|
||||
@Nullable Repository currentRepo) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
myController = new PushController(project, this, selectedRepositories, currentRepo);
|
||||
myAdditionalPanels = myController.createAdditionalPanels();
|
||||
myListPanel = myController.getPushPanelLog();
|
||||
|
||||
init();
|
||||
enableOkActions(myController.isPushAllowed());
|
||||
updateOkActions();
|
||||
setOKButtonText("Push");
|
||||
setOKButtonMnemonic('P');
|
||||
setTitle("Push Commits");
|
||||
@@ -80,7 +78,7 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
@Nullable
|
||||
@Override
|
||||
protected ValidationInfo doValidate() {
|
||||
enableOkActions(myController.isPushAllowed());
|
||||
updateOkActions();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -103,8 +101,12 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
return actions.toArray(new Action[actions.size()]);
|
||||
}
|
||||
|
||||
private boolean canPush() {
|
||||
return myController.isPushAllowed(false);
|
||||
}
|
||||
|
||||
private boolean canForcePush() {
|
||||
return myController.isForcePushEnabled() && myController.getProhibitedTarget() == null;
|
||||
return myController.isForcePushEnabled() && myController.getProhibitedTarget() == null && myController.isPushAllowed(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -123,11 +125,12 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
protected String getHelpId() {
|
||||
return ID;
|
||||
}
|
||||
public void enableOkActions(boolean isEnabled) {
|
||||
myPushAction.setEnabled(isEnabled);
|
||||
|
||||
public void updateOkActions() {
|
||||
myPushAction.setEnabled(canPush());
|
||||
if (myForcePushAction != null) {
|
||||
boolean canForcePush = canForcePush();
|
||||
myForcePushAction.setEnabled(isEnabled && canForcePush);
|
||||
myForcePushAction.setEnabled(canForcePush);
|
||||
String tooltip = null;
|
||||
if (!canForcePush) {
|
||||
PushTarget target = myController.getProhibitedTarget();
|
||||
@@ -139,6 +142,10 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void disableOkActions() {
|
||||
myPushAction.setEnabled(false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VcsPushOptionValue getAdditionalOptionValue(@NotNull PushSupport support) {
|
||||
VcsPushOptionsPanel panel = myAdditionalPanels.get(support);
|
||||
|
||||
@@ -24,7 +24,9 @@ import org.zmlx.hg4idea.command.HgLogCommand;
|
||||
import org.zmlx.hg4idea.execution.HgCommandException;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
import org.zmlx.hg4idea.repo.HgRepositoryImpl;
|
||||
import org.zmlx.hg4idea.util.HgEncodingUtil;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.vcs.Executor.cd;
|
||||
@@ -49,6 +51,7 @@ public class HgEncodingTest extends HgPlatformTest {
|
||||
cd(myRepository);
|
||||
String fileName = "file.txt";
|
||||
echo(fileName, "lalala");
|
||||
Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
|
||||
String comment = "öäüß";
|
||||
HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
|
||||
HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
|
||||
@@ -59,6 +62,6 @@ public class HgEncodingTest extends HgPlatformTest {
|
||||
assert file != null;
|
||||
List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
|
||||
HgFileRevision rev = revisions.get(0);
|
||||
assertEquals(comment, rev.getCommitMessage());
|
||||
assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user