Search in sources :

Example 1 with PrepareApplyRefactoringsJob

use of org.autorefactor.jdt.internal.corext.dom.PrepareApplyRefactoringsJob in project AutoRefactor by JnRouvignac.

the class AutoRefactorHandler method execute.

/**
 * Execute.
 *
 * @param event The event
 *
 * @return An object
 *
 * @throws ExecutionException ExecutionException
 */
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    try {
        Environment environment = AutoRefactorPlugin.getEnvironment();
        new PrepareApplyRefactoringsJob(getSelectedJavaElements(event), AllCleanUpRules.getConfiguredRefactoringRules(environment.getPreferences()), environment).schedule();
    } catch (Exception e) {
        final Shell shell = HandlerUtil.getActiveShell(event);
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        // $NON-NLS-1$
        showMessage(shell, "An error has occurred:\n\n" + sw);
    }
    // resolvedTypeBinding().
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) StringWriter(java.io.StringWriter) PrepareApplyRefactoringsJob(org.autorefactor.jdt.internal.corext.dom.PrepareApplyRefactoringsJob) Environment(org.autorefactor.environment.Environment) CoreException(org.eclipse.core.runtime.CoreException) UnhandledException(org.autorefactor.util.UnhandledException) ExecutionException(org.eclipse.core.commands.ExecutionException) PrintWriter(java.io.PrintWriter)

Example 2 with PrepareApplyRefactoringsJob

use of org.autorefactor.jdt.internal.corext.dom.PrepareApplyRefactoringsJob in project AutoRefactor by JnRouvignac.

the class ChooseCleanupsWizard method performFinish.

@Override
public boolean performFinish() {
    final List<RefactoringRule> refactoringRules = chooseCleanupsPage.getSelectedRefactorings();
    new PrepareApplyRefactoringsJob(javaElements, refactoringRules, AutoRefactorPlugin.getEnvironment()).schedule();
    return !refactoringRules.isEmpty();
}
Also used : RefactoringRule(org.autorefactor.jdt.internal.corext.dom.RefactoringRule) PrepareApplyRefactoringsJob(org.autorefactor.jdt.internal.corext.dom.PrepareApplyRefactoringsJob)

Aggregations

PrepareApplyRefactoringsJob (org.autorefactor.jdt.internal.corext.dom.PrepareApplyRefactoringsJob)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Environment (org.autorefactor.environment.Environment)1 RefactoringRule (org.autorefactor.jdt.internal.corext.dom.RefactoringRule)1 UnhandledException (org.autorefactor.util.UnhandledException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 CoreException (org.eclipse.core.runtime.CoreException)1 Shell (org.eclipse.swt.widgets.Shell)1