svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.i18n.app / org.gvsig.i18n.app.mainplugin / src / main / java / org / gvsig / i18n / I18nException.java @ 40557
History | View | Annotate | Download (2.55 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2009 {DiSiD Technologies} {New extension for installation and update of text translations}
|
27 |
*/
|
28 |
package org.gvsig.i18n; |
29 |
|
30 |
import org.gvsig.andami.messages.NotificationManager; |
31 |
|
32 |
/**
|
33 |
* Exception for errors of the I18nManager.
|
34 |
*
|
35 |
* TODO: hacer que extienda BaseException cuando se pase a gvSIG trunk.
|
36 |
*
|
37 |
* @author <a href="mailto:dcervera@disid.com">David Cervera</a>
|
38 |
*/
|
39 |
public class I18nException extends Exception { |
40 |
|
41 |
private static final long serialVersionUID = 2877056472517898602L; |
42 |
|
43 |
private String key; |
44 |
|
45 |
/**
|
46 |
* Creates a new exception with an error message.
|
47 |
*
|
48 |
* @param message
|
49 |
* the error message
|
50 |
* @param key
|
51 |
* the i18n key to localize the exception message
|
52 |
*/
|
53 |
public I18nException(String message, String key) { |
54 |
super(message);
|
55 |
this.key = key;
|
56 |
} |
57 |
|
58 |
/**
|
59 |
* Creates a new exception with an error message and a cause exception.
|
60 |
*
|
61 |
* @param message
|
62 |
* the error message
|
63 |
* @param key
|
64 |
* the i18n key to localize the exception message
|
65 |
* @param cause
|
66 |
* the error that caused the exception
|
67 |
*/
|
68 |
public I18nException(String message, String key, Throwable cause) { |
69 |
super(message, cause);
|
70 |
this.key = key;
|
71 |
} |
72 |
|
73 |
public String getLocalizedMessage() { |
74 |
String msg = Messages.getText(key);
|
75 |
if (msg.equals(key)) {
|
76 |
msg = getMessage(); |
77 |
} |
78 |
return msg;
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Show the exception error in through the NotificationManager.
|
83 |
*/
|
84 |
public void showError() { |
85 |
NotificationManager.addError(getLocalizedMessage(), this);
|
86 |
} |
87 |
} |