Search in sources :

Example 1 with RefactoringWorkflowController

use of org.erlide.wrangler.refactoring.core.RefactoringWorkflowController in project erlide_eclipse by erlang.

the class IntroduceLetRefactoring method getWorkflowController.

@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            RefactoringRpcMessage message = (RefactoringRpcMessage) run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else if (message.getRefactoringState() == RefactoringState.QUESTION) {
                if (ask("Question", message.getMessageString())) {
                    final OtpErlangTuple res = message.getResultObject();
                    expr = ((OtpErlangTuple) res.elementAt(2)).elementAt(0);
                    parentExpr = ((OtpErlangTuple) res.elementAt(2)).elementAt(1);
                    message = (RefactoringRpcMessage) runAlternative(sel);
                    if (message.isSuccessful()) {
                        status = new RefactoringStatus();
                        changedFiles = message.getRefactoringChangeset();
                    } else {
                        status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                    }
                } else {
                    status = RefactoringStatus.createFatalErrorStatus("Refactoring failed: the expression selected is not a QuickCheck generator.");
                }
            } else if (message.getRefactoringState() == RefactoringState.ERROR) {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.internal.RefactoringRpcMessage) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 2 with RefactoringWorkflowController

use of org.erlide.wrangler.refactoring.core.RefactoringWorkflowController in project erlide_eclipse by erlang.

the class ExtractFunctionRefactoring method getWorkflowController.

@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            IRefactoringRpcMessage message = run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else if (message.getRefactoringState() == RefactoringState.WARNING) {
                final boolean answer = !ask("Warning", message.getMessageString());
                if (answer) {
                    message = runAlternative(sel);
                    if (message.getRefactoringState() == RefactoringState.OK) {
                        status = new RefactoringStatus();
                    } else {
                        status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                    }
                } else {
                    stop();
                }
            } else {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Example 3 with RefactoringWorkflowController

use of org.erlide.wrangler.refactoring.core.RefactoringWorkflowController in project erlide_eclipse by erlang.

the class RenameModuleRefactoring method getWorkflowController.

@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            IRefactoringRpcMessage message = run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else if (message.getRefactoringState() == RefactoringState.QUESTION) {
                renameTestMod = ask("Question", message.getMessageString());
                message = runAlternative(sel);
                if (message.getRefactoringState() == RefactoringState.OK) {
                    changedFiles = message.getRefactoringChangeset();
                    status = new RefactoringStatus();
                } else {
                    status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                }
            } else if (message.getRefactoringState() == RefactoringState.WARNING) {
                renameTestMod = !ask("Warning", message.getMessageString());
                if (!renameTestMod) {
                    message = runAlternative(sel);
                    if (message.getRefactoringState() == RefactoringState.OK) {
                        changedFiles = message.getRefactoringChangeset();
                        status = new RefactoringStatus();
                    } else {
                        status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                    }
                } else {
                    stop();
                }
            } else {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Example 4 with RefactoringWorkflowController

use of org.erlide.wrangler.refactoring.core.RefactoringWorkflowController in project erlide_eclipse by erlang.

the class UserRefactoring method getWorkflowController.

/**
 * Defines workflow of the refactoring, sets changed files and status
 *
 * @param shell
 * @return
 */
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            final IRefactoringRpcMessage message = run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Example 5 with RefactoringWorkflowController

use of org.erlide.wrangler.refactoring.core.RefactoringWorkflowController in project erlide_eclipse by erlang.

the class RenameFunctionRefactoring method getWorkflowController.

@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            IRefactoringRpcMessage message = run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else if (message.getRefactoringState() == RefactoringState.WARNING) {
                if (ask("Warning", message.getMessageString())) {
                    message = runAlternative(sel);
                    if (message.getRefactoringState() == RefactoringState.OK) {
                        status = new RefactoringStatus();
                    } else {
                        status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                    }
                } else {
                    stop();
                }
            } else {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Aggregations

RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 IRefactoringRpcMessage (org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage)5 RefactoringWorkflowController (org.erlide.wrangler.refactoring.core.RefactoringWorkflowController)5 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)5 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 RefactoringRpcMessage (org.erlide.wrangler.refactoring.backend.internal.RefactoringRpcMessage)1