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

/*
 * Created by IntelliJ IDEA.
 * User: yole
 * Date: 23.11.2006
 * Time: 13:31:30
 */
package com.intellij.openapi.vcs.changes.shelf;

import com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.changes.ChangeList;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ActionPlaces;
import org.jetbrains.annotations.Nullable;

public class ShelveChangesAction extends AbstractCommonCheckinAction {
  protected String getActionName(VcsContext dataContext) {
    return VcsBundle.message("shelve.changes.action");
  }

  protected FilePath[] getRoots(VcsContext context) {
    return getAllContentRoots(context);
  }

  protected boolean filterRootsBeforeAction() {
    return false;
  }

  @Override @Nullable
  protected CommitExecutor getExecutor(Project project) {
    return new ShelveChangesCommitExecutor(project);
  }

  @Override
  protected void update(final VcsContext vcsContext, final Presentation presentation) {
    super.update(vcsContext, presentation);
    if (presentation.isVisible() && presentation.isEnabled() && vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) {
      final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists();
      final Change[] selectedChanges = vcsContext.getSelectedChanges();
      presentation.setEnabled ((selectedChangeLists != null && selectedChangeLists.length > 0) ||
                               (selectedChanges != null && selectedChanges.length > 0));
    }
  }
}
@@ -1701,33 +1701,11 @@
     
-presentation.setEnabled (
+if 
 (sel
@@ -1720,36 +1720,68 @@
 ngeLists != null
- && 
+) %7B%0A        presentation.setEnabled(
 selectedChangeLi
@@ -1795,36 +1795,44 @@
 gth 
-%3E 0) %7C%7C
+== 1);
 %0A      
+%7D%0A
       
+else %7B%0A
         
     
@@ -1827,26 +1827,39 @@
         
-          
+presentation.setEnabled
  (select
@@ -1906,18 +1906,25 @@
 gth %3E 0)
-)
 ;
+%0A      %7D
 %0A    %7D%0A 

disable "shelve changes" action for multiselected changelists (IDEADEV-13380)