fix commit executor API for TC

This commit is contained in:
irengrig
2011-09-19 19:22:40 +04:00
parent 9d8ebbf2e3
commit d96f8fe01e
8 changed files with 53 additions and 15 deletions
@@ -27,5 +27,5 @@ public interface CommitExecutor {
String getActionText();
@NotNull
CommitSession createCommitSession(CommitContext commitContext);
CommitSession createCommitSession();
}
@@ -0,0 +1,26 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.vcs.changes;
/**
* Created by IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 9/19/11
* Time: 7:04 PM
*/
public interface CommitSessionContextAware {
void setContext(final CommitContext context);
}
@@ -72,7 +72,10 @@ public class CreatePatchFromChangesAction extends AnAction implements DumbAware
Collections.addAll(changeCollection, changes);
project = project == null ? ProjectManager.getInstance().getDefaultProject() : project;
final CreatePatchCommitExecutor executor = CreatePatchCommitExecutor.getInstance(project);
CommitSession commitSession = executor.createCommitSession(new CommitContext());
CommitSession commitSession = executor.createCommitSession();
if (commitSession instanceof CommitSessionContextAware) {
((CommitSessionContextAware)commitSession).setContext(new CommitContext());
}
DialogWrapper sessionDialog = new SessionDialog(executor.getActionText(),
project,
commitSession,
@@ -82,8 +82,8 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec
}
@NotNull
public CommitSession createCommitSession(CommitContext commitContext) {
return new CreatePatchCommitSession(commitContext);
public CommitSession createCommitSession() {
return new CreatePatchCommitSession();
}
public void projectOpened() {
@@ -113,12 +113,16 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec
DefaultJDOMExternalizer.writeExternal(this, element);
}
private class CreatePatchCommitSession implements CommitSession {
private class CreatePatchCommitSession implements CommitSession, CommitSessionContextAware {
private final CreatePatchConfigurationPanel myPanel = new CreatePatchConfigurationPanel(myProject);
private final CommitContext myCommitContext;
private CommitContext myCommitContext;
public CreatePatchCommitSession(CommitContext commitContext) {
myCommitContext = commitContext;
public CreatePatchCommitSession() {
}
@Override
public void setContext(CommitContext context) {
myCommitContext = context;
}
@Nullable
@@ -52,7 +52,7 @@ public class ShelveChangesCommitExecutor implements CommitExecutorWithHelp {
}
@NotNull
public CommitSession createCommitSession(CommitContext commitContext) {
public CommitSession createCommitSession() {
return new ShelveChangesCommitSession();
}
@@ -61,13 +61,17 @@ public class ShelveChangesCommitExecutor implements CommitExecutorWithHelp {
return "reference.dialogs.vcs.shelve";
}
private class ShelveChangesCommitSession implements CommitSession {
private class ShelveChangesCommitSession implements CommitSession, CommitSessionContextAware {
@Nullable
public JComponent getAdditionalConfigurationUI() {
return null;
}
@Override
public void setContext(CommitContext context) {
}
@Nullable
public JComponent getAdditionalConfigurationUI(final Collection<Change> changes, final String commitMessage) {
return null;
@@ -512,7 +512,10 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
private void execute(final CommitExecutor commitExecutor) {
if (!saveDialogState()) return;
saveComments(true);
final CommitSession session = commitExecutor.createCommitSession(myCommitContext);
final CommitSession session = commitExecutor.createCommitSession();
if (session instanceof CommitSessionContextAware) {
((CommitSessionContextAware)session).setContext(myCommitContext);
}
if (session == CommitSession.VCS_COMMIT) {
doOKAction();
return;
@@ -15,7 +15,6 @@
*/
package git4idea.checkin;
import com.intellij.openapi.vcs.changes.CommitContext;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.changes.CommitSession;
import org.jetbrains.annotations.Nls;
@@ -37,7 +36,7 @@ public class GitCommitAndPushExecutor implements CommitExecutor {
}
@NotNull
public CommitSession createCommitSession(CommitContext commitContext) {
public CommitSession createCommitSession() {
myCheckinEnvironment.setNextCommitIsPushed(true);
return CommitSession.VCS_COMMIT;
}
@@ -15,7 +15,6 @@
*/
package org.zmlx.hg4idea.provider.commit;
import com.intellij.openapi.vcs.changes.CommitContext;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.changes.CommitSession;
import org.jetbrains.annotations.Nls;
@@ -37,7 +36,7 @@ public class HgCommitAndPushExecutor implements CommitExecutor {
}
@NotNull
public CommitSession createCommitSession(CommitContext commitContext) {
public CommitSession createCommitSession() {
myCheckinEnvironment.setNextCommitIsPushed(true);
return CommitSession.VCS_COMMIT;
}