package org.erlide.wrangler.refactoring.core.internal;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage;
import org.erlide.wrangler.refactoring.backend.WranglerBackendManager;
import org.erlide.wrangler.refactoring.core.SimpleOneStepWranglerRefactoring;
import org.erlide.wrangler.refactoring.selection.IErlSelection;

/**
 * Rename variable refactoring integration
 * 
 * @author Gyorgy Orosz
 * @version %I%, %G%
 */
public class CaseFunRefactoring extends SimpleOneStepWranglerRefactoring {

	@Override
	/*
	 * public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
	 * throws CoreException, OperationCanceledException { IErlSelection sel =
	 * GlobalParameters.getWranglerSelection(); if (sel instanceof
	 * IErlMemberSelection) { // SelectionKind kind = sel.getDetailedKind();
	 * return new RefactoringStatus(); }
	 * 
	 * return RefactoringStatus
	 * .createFatalErrorStatus("Selecciona una variable!"); }
	 */
	public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
			throws CoreException, OperationCanceledException {
		// since any selection contains a module, it can be applied
		return new RefactoringStatus();
	}

	@Override
	public String getName() {
		return "CaseFun";
	}

	@Override
	public IRefactoringRpcMessage run(IErlSelection sel) {

		/*
		 * return WranglerBackendManager.getRefactoringBackend().call(
		 * "prova_eclipse", "siisxi", sel.getFilePath(),
		 * sel.getSelectionRange().getStartLine(),
		 * sel.getSelectionRange().getStartCol(), userInput,
		 * sel.getSearchPath(), GlobalParameters.getTabWidth());
		 */
		return WranglerBackendManager.getRefactoringBackend().call(
				"refac_CaseFun_eclipse", "s", sel.getFilePath());

	}

}
