
package com.intellij.refactoring.actions;

import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.move.MoveHandler;
import com.intellij.lang.Language;

public class MoveAction extends BaseRefactoringAction {

  private MoveHandler.TargetContainerFinder myFinder = new MoveHandler.TargetContainerFinder() {
    public PsiElement getTargetContainer(DataContext dataContext) {
      return (PsiElement)dataContext.getData(DataConstantsEx.TARGET_PSI_ELEMENT);
    }
  };

  public boolean isAvailableInEditorOnly() {
    return false;
  }

  protected boolean isAvailableForLanguage(Language language){
    // move is supported in any language
    return true;
  }

  public boolean isEnabledOnElements(PsiElement[] elements) {
    return MoveHandler.canMove(elements, null);
  }

  public RefactoringActionHandler getHandler(DataContext dataContext) {
    return new MoveHandler(myFinder);
  }
}
@@ -387,16 +387,104 @@
 Action %7B
+%0A  /**%0A   * @fabrique%0A   */%0A  public static final String MOVE_PROVIDER = %22MoveProvider%22;
 %0A%0A  priv
@@ -734,16 +734,305 @@
   %7D%0A  %7D;
+%0A  private MoveProvider myDefaultMoveProvider = new MoveProvider() %7B%0A    public boolean isEnabledOnDataContext(DataContext dataContext) %7B%0A      return false;%0A    %7D%0A%0A    public RefactoringActionHandler getHandler(DataContext dataContext) %7B%0A      return new MoveHandler(myFinder);%0A    %7D%0A  %7D;
 %0A%0A  publ
@@ -1341,112 +1341,716 @@
 %0A  p
-ublic RefactoringActionHandler getHandler(DataContext dataContext) %7B%0A    return new MoveHandler(myFinder
+rotected boolean isEnabledOnDataContext(DataContext dataContext) %7B%0A    return getMoveProvider(dataContext).isEnabledOnDataContext(dataContext);%0A  %7D%0A%0A  private MoveProvider getMoveProvider(DataContext dataContext) %7B%0A    final MoveProvider moveProvider = (MoveProvider)dataContext.getData(MOVE_PROVIDER);%0A    if (moveProvider != null) %7B%0A      return moveProvider;%0A    %7D%0A%0A    return myDefaultMoveProvider;%0A  %7D%0A%0A  public RefactoringActionHandler getHandler(DataContext dataContext) %7B%0A    return getMoveProvider(dataContext).getHandler(dataContext);%0A  %7D%0A%0A  public interface MoveProvider %7B%0A    boolean isEnabledOnDataContext(DataContext dataContext);%0A    RefactoringActionHandler getHandler(DataContext dataContext
 );%0A 

move refactoring made more extensible