1 11 package org.eclipse.ltk.internal.ui.refactoring; 12 13 import org.eclipse.swt.widgets.Shell; 14 import org.eclipse.ltk.core.refactoring.IValidationCheckResultQuery; 15 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 16 import org.eclipse.jface.dialogs.Dialog; 17 import org.eclipse.jface.dialogs.IDialogConstants; 18 import org.eclipse.jface.dialogs.MessageDialog; 19 import org.eclipse.ltk.ui.refactoring.RefactoringUI; 20 21 public class ValidationCheckResultQuery implements IValidationCheckResultQuery { 22 private Shell fParent; 23 private String fTitle; 24 public ValidationCheckResultQuery(Shell parent, String title) { 25 fParent= parent; 26 fTitle= title; 27 } 28 public boolean proceed(RefactoringStatus status) { 29 final Dialog dialog= RefactoringUI.createRefactoringStatusDialog(status, fParent, fTitle, false); 30 final int[] result= new int[1]; 31 Runnable r= new Runnable () { 32 public void run() { 33 result[0]= dialog.open(); 34 } 35 }; 36 fParent.getDisplay().syncExec(r); 37 return result[0] == IDialogConstants.OK_ID; 38 } 39 public void stopped(final RefactoringStatus status) { 40 Runnable r= new Runnable () { 41 public void run() { 42 String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); 43 MessageDialog.openWarning(fParent, fTitle, getFullMessage(message)); 44 } 45 }; 46 fParent.getDisplay().syncExec(r); 47 } 48 private String getFullMessage(String errorMessage) { 49 return Messages.format( 50 RefactoringUIMessages.ValidationCheckResultQuery_error_message, 51 errorMessage); 52 } 53 } | Popular Tags |