gvsig-raster / org.gvsig.raster.georeferencing / trunk / org.gvsig.raster.georeferencing / org.gvsig.raster.georeferencing.swing / org.gvsig.raster.georeferencing.swing.impl / src / main / java / org / gvsig / raster / georeferencing / swing / impl / GeoreferencingSwingImplLibrary.java @ 1692
History | View | Annotate | Download (5.1 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.raster.georeferencing.swing.impl; |
23 |
|
24 |
import java.awt.Component; |
25 |
import java.util.Locale; |
26 |
|
27 |
import javax.swing.JOptionPane; |
28 |
|
29 |
import org.gvsig.andami.IconThemeHelper; |
30 |
import org.gvsig.i18n.Messages; |
31 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLibrary; |
32 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLocator; |
33 |
import org.gvsig.tools.library.AbstractLibrary; |
34 |
import org.gvsig.tools.library.Library; |
35 |
import org.gvsig.tools.library.LibraryException; |
36 |
import org.slf4j.LoggerFactory; |
37 |
|
38 |
/**
|
39 |
* Library for default swing implementation initialization and configuration.
|
40 |
*
|
41 |
* @author gvSIG team
|
42 |
* @version $Id$
|
43 |
*/
|
44 |
public class GeoreferencingSwingImplLibrary extends AbstractLibrary { |
45 |
|
46 |
public GeoreferencingSwingImplLibrary() {
|
47 |
super();
|
48 |
} |
49 |
|
50 |
@Override
|
51 |
public void doRegistration() { |
52 |
this.registerAs(GeoreferencingSwingLibrary.class, Library.TYPE.IMPL);
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
protected void doInitialize() throws LibraryException { |
57 |
GeoreferencingSwingLocator |
58 |
.registerSwingManager(DefaultGeoreferencingSwingManager.class); |
59 |
|
60 |
|
61 |
if (!Messages.hasLocales()) {
|
62 |
Messages.addLocale(Locale.getDefault());
|
63 |
} |
64 |
|
65 |
Messages.addResourceFamily("org.gvsig.raster.swing.impl.i18n.text",
|
66 |
GeoreferencingSwingImplLibrary.class.getClassLoader(), |
67 |
GeoreferencingSwingImplLibrary.class.getClass().getName()); |
68 |
|
69 |
registerIcons(); |
70 |
} |
71 |
|
72 |
@Override
|
73 |
protected void doPostInitialize() throws LibraryException { |
74 |
} |
75 |
|
76 |
private void registerIcons() { |
77 |
IconThemeHelper.registerIcon(null, "exit-icon", this); |
78 |
IconThemeHelper.registerIcon(null, "process-icon", this); |
79 |
IconThemeHelper.registerIcon(null, "endprocess-icon", this); |
80 |
IconThemeHelper.registerIcon(null, "importfromcsv-icon", this); |
81 |
IconThemeHelper.registerIcon(null, "exporttocsv-icon", this); |
82 |
IconThemeHelper.registerIcon(null, "tfwload-icon", this); |
83 |
IconThemeHelper.registerIcon(null, "save-icon", this); |
84 |
IconThemeHelper.registerIcon(null, "options-icon", this); |
85 |
IconThemeHelper.registerIcon(null, "add-icon", this); |
86 |
IconThemeHelper.registerIcon(null, "centerpoint-icon", this); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Shows an error dialog with a text and a accept button
|
91 |
* @param msg Message to show in the dialog
|
92 |
* @param parentWindow Parent window
|
93 |
*/
|
94 |
public static void messageBoxError(String msg, Component c) { |
95 |
String string = Messages.getText("accept"); |
96 |
Object[] options = {string}; |
97 |
JOptionPane.showOptionDialog(c,
|
98 |
"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>", |
99 |
Messages.getText("confirmacion"),
|
100 |
JOptionPane.OK_OPTION,
|
101 |
JOptionPane.ERROR_MESSAGE,
|
102 |
null,
|
103 |
options, |
104 |
string); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Shows a error dialog with a text and a accept button
|
109 |
* @param msg Message to show in the dialog
|
110 |
* @param parentWindow Parent window
|
111 |
*/
|
112 |
public static void messageBoxError(String msg, Object parentWindow, Exception exception) { |
113 |
if(exception != null) { |
114 |
LoggerFactory.getLogger(GeoreferencingSwingImplLibrary.class).debug(Messages.getText(msg), exception); |
115 |
} |
116 |
String string = Messages.getText("accept"); |
117 |
Object[] options = {string}; |
118 |
JOptionPane.showOptionDialog((Component)parentWindow, |
119 |
"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>", |
120 |
Messages.getText("confirmacion"),
|
121 |
JOptionPane.OK_OPTION,
|
122 |
JOptionPane.ERROR_MESSAGE,
|
123 |
null,
|
124 |
options, |
125 |
string); |
126 |
} |
127 |
|
128 |
/**
|
129 |
* Shows an error dialog with a text and a YesOrNot button
|
130 |
* @param msg Message to show in the dialog.
|
131 |
* @param parentWindow Parent window
|
132 |
* @return Selected button by the button. Returns true if the user has selected Yes
|
133 |
* and false if he has selected No.
|
134 |
*/
|
135 |
public static boolean messageBoxYesOrNot(String msg, Component c){ |
136 |
String string1 = Messages.getText("yes"); |
137 |
String string2 = Messages.getText("no"); |
138 |
Object[] options = {string1, string2}; |
139 |
int n = JOptionPane.showOptionDialog(c, |
140 |
"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>", |
141 |
Messages.getText("confirmacion"),
|
142 |
JOptionPane.YES_NO_OPTION,
|
143 |
JOptionPane.QUESTION_MESSAGE,
|
144 |
null,
|
145 |
options, |
146 |
string1); |
147 |
if (n == JOptionPane.YES_OPTION) |
148 |
return true; |
149 |
else
|
150 |
return false; |
151 |
} |
152 |
} |