KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > ValidationCheckResultQuery


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc fTitle;
24     public ValidationCheckResultQuery(Shell parent, String JavaDoc 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 JavaDoc r= new Runnable JavaDoc() {
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 JavaDoc r= new Runnable JavaDoc() {
41             public void run() {
42                 String JavaDoc message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
43                 MessageDialog.openWarning(fParent, fTitle, getFullMessage(message));
44             }
45         };
46         fParent.getDisplay().syncExec(r);
47     }
48     private String JavaDoc getFullMessage(String JavaDoc errorMessage) {
49         return Messages.format(
50             RefactoringUIMessages.ValidationCheckResultQuery_error_message,
51             errorMessage);
52     }
53 }
Popular Tags