1 11 package org.eclipse.jdt.internal.ui.refactoring.actions; 12 13 import org.eclipse.jdt.core.JavaModelException; 14 15 import org.eclipse.swt.widgets.Shell; 16 17 import org.eclipse.jface.dialogs.IDialogConstants; 18 19 import org.eclipse.jdt.internal.ui.refactoring.RefactoringSaveHelper; 20 21 import org.eclipse.ltk.core.refactoring.Refactoring; 22 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 23 import org.eclipse.ltk.ui.refactoring.RefactoringWizard; 24 import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; 25 26 29 public class RefactoringStarter { 30 31 private RefactoringStatus fStatus; 32 33 42 public boolean activate(Refactoring refactoring, RefactoringWizard wizard, Shell parent, String dialogTitle, int saveMode) throws JavaModelException { 43 RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(saveMode); 44 if (! canActivate(saveHelper, parent)) 45 return false; 46 47 try { 48 RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard); 49 int result= op.run(parent, dialogTitle); 50 fStatus= op.getInitialConditionCheckingStatus(); 51 if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) { 52 saveHelper.triggerBuild(); 53 return false; 54 } else { 55 return true; 56 } 57 } catch (InterruptedException e) { 58 return false; } 60 } 61 62 public RefactoringStatus getInitialConditionCheckingStatus() { 63 return fStatus; 64 } 65 66 private boolean canActivate(RefactoringSaveHelper saveHelper, Shell shell) { 67 return saveHelper.saveEditors(shell); 68 } 69 } 70 | Popular Tags |