/*
 * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
 */

/*
 * Created by IntelliJ IDEA.
 * User: yole
 * Date: 02.11.2006
 * Time: 21:53:06
 */
package com.intellij.openapi.vcs.changes.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeList;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog;

import java.util.Arrays;

public class CommitAction extends AnAction {
  public void update(AnActionEvent e) {
    Project project = e.getData(DataKeys.PROJECT);
    Change[] changes = e.getData(DataKeys.CHANGES);
    e.getPresentation().setEnabled(ChangesUtil.getChangeListIfOnlyOne(project, changes) != null);
  }

  public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(DataKeys.PROJECT);
    Change[] changes = e.getData(DataKeys.CHANGES);
    final ChangeList list = ChangesUtil.getChangeListIfOnlyOne(project, changes);
    if (list == null) return;

    CommitChangeListDialog.commitChanges(project, Arrays.asList(changes), list,
                                         ChangeListManager.getInstance(project).getRegisteredExecutors(), true);
  }
}
@@ -910,39 +910,38 @@
     
-e.getPresentation().setEnabled(
+final ChangeList changeList = 
 Chan
@@ -992,16 +992,298 @@
 ges)
- != null
+;%0A    boolean enabled = false;%0A    if (changes != null && changeList != null) %7B%0A      for(Change c: changes) %7B%0A        if (ChangesUtil.getVcsForChange(c, project).getCheckinEnvironment() != null) %7B%0A          enabled = true;%0A        %7D%0A      %7D%0A    %7D%0A    e.getPresentation().setEnabled(enabled
 );%0A 

disable "commit" action in changes view if the affected VCSes don't have a checkin environment