KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > java > plugin > boot > BootErrorHandlerGui


1 /*****************************************************************************
2  * Java Plug-in Framework (JPF)
3  * Copyright (C) 2004-2005 Dmitry Olshansky
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *****************************************************************************/

19 package org.java.plugin.boot;
20
21 import java.util.Iterator JavaDoc;
22 import java.util.LinkedList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.java.plugin.registry.IntegrityCheckReport;
26 import org.java.plugin.registry.IntegrityCheckReport.ReportItem;
27 import org.java.plugin.util.ResourceManager;
28
29 /**
30  * Standard boot error handler for GUI applications. Uses Swing based dialogue
31  * to show error details to user and prompt for input.
32  *
33  * @version $Id: BootErrorHandlerGui.java,v 1.1 2005/10/22 15:22:24 ddimon Exp $
34  */

35 public class BootErrorHandlerGui implements BootErrorHandler {
36     /**
37      * @see org.java.plugin.boot.BootErrorHandler#handleFatalError(
38      * java.lang.String)
39      */

40     public void handleFatalError(String JavaDoc message) {
41         ErrorDialog.showError(null,
42                 ResourceManager.getMessage(Boot.PACKAGE_NAME,
43                 "errorDialogueHeaderFatal"), message); //$NON-NLS-1$
44
}
45
46     /**
47      * @see org.java.plugin.boot.BootErrorHandler#handleFatalError(
48      * java.lang.String, java.lang.Throwable)
49      */

50     public void handleFatalError(String JavaDoc message, Throwable JavaDoc t) {
51         ErrorDialog.showError(null,
52                 ResourceManager.getMessage(Boot.PACKAGE_NAME,
53                 "errorDialogueHeaderFatal"), message, t); //$NON-NLS-1$
54
}
55
56     /**
57      * @see org.java.plugin.boot.BootErrorHandler#handleError(java.lang.String,
58      * java.lang.Exception)
59      */

60     public boolean handleError(String JavaDoc message, Exception JavaDoc e) {
61         return ErrorDialog.showWarning(null, ResourceManager.getMessage(
62                 Boot.PACKAGE_NAME, "errorDialogueHeaderNonFatal"), message, e); //$NON-NLS-1$
63
}
64
65     /**
66      * @see org.java.plugin.boot.BootErrorHandler#handleError(java.lang.String,
67      * org.java.plugin.registry.IntegrityCheckReport)
68      */

69     public boolean handleError(String JavaDoc message, IntegrityCheckReport report) {
70         List JavaDoc items = new LinkedList JavaDoc();
71         for (Iterator JavaDoc it = report.getItems().iterator(); it.hasNext();) {
72             IntegrityCheckReport.ReportItem item =
73                 (IntegrityCheckReport.ReportItem) it.next();
74             if (item.getSeverity() != ReportItem.SEVERITY_ERROR) {
75                 continue;
76             }
77             items.add(item.getMessage());
78         }
79         //items.add("see log file " + Boot.BOOT_ERROR_FILE_NAME + " for details");
80
return ErrorDialog.showWarning(null, ResourceManager.getMessage(
81                 Boot.PACKAGE_NAME, "errorDialogueHeaderNonFatal"), //$NON-NLS-1$
82
message, items);
83     }
84 }
85
Popular Tags