Revision 44017
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.desktop.framework</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.desktop</artifactId> |
|
11 |
<version>2.0.233</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.andami</module> |
|
16 |
<module>org.gvsig.andami.updater</module> |
|
17 |
</modules> |
|
18 |
|
|
19 |
<description>Contains the launcher and plugin framework used in gvSIG.</description> |
|
20 |
</project> |
|
21 |
|
|
0 | 22 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/test/java/org/gvsig/andami/AllTests.java | ||
---|---|---|
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 |
package org.gvsig.andami; |
|
25 |
|
|
26 |
import junit.framework.Test; |
|
27 |
import junit.framework.TestSuite; |
|
28 |
|
|
29 |
public class AllTests { |
|
30 |
|
|
31 |
public static Test suite() { |
|
32 |
TestSuite suite = new TestSuite("Test for com.iver.andami"); |
|
33 |
//$JUnit-BEGIN$ |
|
34 |
|
|
35 |
//$JUnit-END$ |
|
36 |
return suite; |
|
37 |
} |
|
38 |
|
|
39 |
} |
|
0 | 40 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/assembly/gvsig-andami-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-andami-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>.</baseDirectory> |
|
32 |
<!-- |
|
33 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
34 |
--> |
|
35 |
<files> |
|
36 |
<file> |
|
37 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
38 |
<outputDirectory>lib</outputDirectory> |
|
39 |
</file> |
|
40 |
<file> |
|
41 |
<source>src/main/resources/default-log4j/log4j.properties</source> |
|
42 |
<outputDirectory>.</outputDirectory> |
|
43 |
</file> |
|
44 |
</files> |
|
45 |
<fileSets> |
|
46 |
<fileSet> |
|
47 |
<directory>src/main/resources-application</directory> |
|
48 |
<outputDirectory>.</outputDirectory> |
|
49 |
</fileSet> |
|
50 |
<fileSet> |
|
51 |
<directory>src/main/resources/org/gvsig/andami</directory> |
|
52 |
<outputDirectory>i18n/andami</outputDirectory> |
|
53 |
</fileSet> |
|
54 |
</fileSets> |
|
55 |
|
|
56 |
<dependencySets> |
|
57 |
<dependencySet> |
|
58 |
<useProjectArtifact>false</useProjectArtifact> |
|
59 |
<useTransitiveDependencies>true</useTransitiveDependencies> |
|
60 |
<outputDirectory>lib</outputDirectory> |
|
61 |
</dependencySet> |
|
62 |
</dependencySets> |
|
63 |
|
|
64 |
</assembly> |
|
65 |
|
|
0 | 66 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ConfigurationException.java | ||
---|---|---|
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 |
package org.gvsig.andami; |
|
25 |
|
|
26 |
/** |
|
27 |
* Indica que se ha producido un error accediendo a los ficheros de configuraci?n |
|
28 |
* de la plicaci?n, de Andami o de los plugins |
|
29 |
*/ |
|
30 |
public class ConfigurationException extends Exception { |
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
public ConfigurationException() { |
|
35 |
super(); |
|
36 |
|
|
37 |
// TODO Auto-generated constructor stub |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* DOCUMENT ME! |
|
42 |
* |
|
43 |
* @param message |
|
44 |
*/ |
|
45 |
public ConfigurationException(String message) { |
|
46 |
super(message); |
|
47 |
|
|
48 |
// TODO Auto-generated constructor stub |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* DOCUMENT ME! |
|
53 |
* |
|
54 |
* @param message |
|
55 |
* @param cause |
|
56 |
*/ |
|
57 |
public ConfigurationException(String message, Throwable cause) { |
|
58 |
super(message, cause); |
|
59 |
|
|
60 |
// TODO Auto-generated constructor stub |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* DOCUMENT ME! |
|
65 |
* |
|
66 |
* @param cause |
|
67 |
*/ |
|
68 |
public ConfigurationException(Throwable cause) { |
|
69 |
super(cause); |
|
70 |
|
|
71 |
// TODO Auto-generated constructor stub |
|
72 |
} |
|
73 |
} |
|
0 | 74 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/messages/MessageEvent.java | ||
---|---|---|
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 |
package org.gvsig.andami.messages; |
|
25 |
|
|
26 |
public class MessageEvent { |
|
27 |
private String[] messages; |
|
28 |
private Throwable[] exceptions; |
|
29 |
|
|
30 |
public MessageEvent(String[] msgs, Throwable[] excps){ |
|
31 |
messages = msgs; |
|
32 |
exceptions = excps; |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* @return |
|
37 |
*/ |
|
38 |
public Throwable[] getExceptions() { |
|
39 |
return exceptions; |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* @return |
|
44 |
*/ |
|
45 |
public String[] getMessages() { |
|
46 |
return messages; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* @param throwables |
|
51 |
*/ |
|
52 |
public void setExceptions(Throwable[] throwables) { |
|
53 |
exceptions = throwables; |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* @param strings |
|
58 |
*/ |
|
59 |
public void setMessages(String[] strings) { |
|
60 |
messages = strings; |
|
61 |
} |
|
62 |
|
|
63 |
} |
|
0 | 64 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/messages/Messages.java | ||
---|---|---|
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 |
package org.gvsig.andami.messages; |
|
25 |
|
|
26 |
import java.util.Locale; |
|
27 |
import java.util.ResourceBundle; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* Clase que accede a los recursos para la i18n |
|
32 |
*/ |
|
33 |
public class Messages { |
|
34 |
/** DOCUMENT ME! */ |
|
35 |
private static final String BUNDLE_NAME = "org.gvsig.andami.text"; |
|
36 |
|
|
37 |
/** DOCUMENT ME! */ |
|
38 |
private static ResourceBundle RESOURCE_BUNDLE = null; |
|
39 |
|
|
40 |
/** |
|
41 |
* Inicializa la clase con el locale adecuado |
|
42 |
* |
|
43 |
* @param loc Locale de la aplicaci?n |
|
44 |
*/ |
|
45 |
public static void init(Locale loc) { |
|
46 |
return; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* @param strLocale. Ejemplo: va para valenciano |
|
51 |
* Se trata de permitir coexistir el valenciano con el catal?n. |
|
52 |
* El m?todo buscar? un fichero properties llamado "text_va.properties" |
|
53 |
* para usarlo con RESOURCE_BUNDLE de donde sacar los mensajes |
|
54 |
* traducidos. |
|
55 |
*/ |
|
56 |
public static void init(String strLocale) { |
|
57 |
return; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* Obtiene el valor del recurso con clave 'key' |
|
63 |
* |
|
64 |
* @param key clave del recurso que se quiere obtener |
|
65 |
* |
|
66 |
* @return recurso que se quiere obtener o !key! en caso de no encontrarlo. |
|
67 |
* En dicho caso no se notifica al framework ya que estos son los |
|
68 |
* mensajes propios de la aplicaci?n y deben de estar todos |
|
69 |
*/ |
|
70 |
public static String getString(String key) { |
|
71 |
return org.gvsig.i18n.Messages.getText(key, "org.gvsig.andami.messages.Messages"); |
|
72 |
} |
|
73 |
|
|
74 |
public static String get(String key) { |
|
75 |
return org.gvsig.i18n.Messages.getText(key, "org.gvsig.andami.messages.Messages"); |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/messages/ProgressListener.java | ||
---|---|---|
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 |
package org.gvsig.andami.messages; |
|
25 |
|
|
26 |
import java.util.EventListener; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* Interfaz implementada por las extensiones que quieran informar del estado de |
|
31 |
* su ejecuci?n. Por ejemplo un extension que tarda mucho en ejecutarse puede |
|
32 |
* implementar esta interfaz y a?adirse como ProgressListener de la |
|
33 |
* aplicacion. De esta manera la aplicaci?n le pedir? su estado a intervalos |
|
34 |
* regulares de tiempo y mostrar? esta informaci?n en la barra de estado |
|
35 |
* |
|
36 |
* @author Fernando Gonz?lez Cort?s |
|
37 |
*/ |
|
38 |
public interface ProgressListener extends EventListener { |
|
39 |
/** |
|
40 |
* M?todo invocado a intervalos regulares por la aplicaci?n y en el que se |
|
41 |
* debe devolver el estado de una supuesta ejecuci?n |
|
42 |
* |
|
43 |
* @return Cadena que se env?a a la aplicaci?n |
|
44 |
*/ |
|
45 |
public String getProgress(); |
|
46 |
|
|
47 |
/** |
|
48 |
* Devuelve un porcentaje que indica el progreso de la tarea |
|
49 |
* |
|
50 |
* @return n?mero del 0 al 100 |
|
51 |
*/ |
|
52 |
public int getProgressValue(); |
|
53 |
} |
|
0 | 54 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/messages/NotificationListener.java | ||
---|---|---|
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 |
package org.gvsig.andami.messages; |
|
25 |
|
|
26 |
/** |
|
27 |
* Interfaz que deber?n de implementar todas las clases que quieran recibir |
|
28 |
* informaci?n sobre los mensajes de informaci?n, de warning y de error que |
|
29 |
* recibe la aplicaci?n |
|
30 |
*/ |
|
31 |
public interface NotificationListener { |
|
32 |
/** |
|
33 |
* M?todo invocado cuando la aplicaci?n recibe mensajes de error |
|
34 |
* |
|
35 |
* @param app contexto de la aplicaci?n |
|
36 |
* @param text Texto del mensaje |
|
37 |
*/ |
|
38 |
public void errorEvent(MessageEvent e); |
|
39 |
|
|
40 |
/** |
|
41 |
* M?todo invocado cuando la aplicaci?n recibe mensajes de warning |
|
42 |
* |
|
43 |
* @param app contexto de la aplicaci?n |
|
44 |
* @param text Texto del mensaje |
|
45 |
*/ |
|
46 |
public void warningEvent(MessageEvent e); |
|
47 |
|
|
48 |
/** |
|
49 |
* M?todo invocado cuando la aplicaci?n recibe mensajes de informaci?n |
|
50 |
* |
|
51 |
* @param app contexto de la aplicaci?n |
|
52 |
* @param text Texto del mensaje |
|
53 |
*/ |
|
54 |
public void infoEvent(MessageEvent e); |
|
55 |
} |
|
0 | 56 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/messages/NotificationManager.java | ||
---|---|---|
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 |
package org.gvsig.andami.messages; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Vector; |
|
31 |
|
|
32 |
import javax.swing.JOptionPane; |
|
33 |
import javax.swing.Timer; |
|
34 |
|
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 |
import org.gvsig.andami.PluginServices; |
|
39 |
import org.gvsig.tools.exception.IBaseException; |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
/** |
|
44 |
* Clase que recibe los mensajes de error, warning e informaci?n y dispara los |
|
45 |
* eventos en los listeners que escuchan dichos eventos |
|
46 |
* |
|
47 |
* @version $Revision: 35350 $ |
|
48 |
*/ |
|
49 |
public class NotificationManager { |
|
50 |
private static int SIZE_MESSAGE=4; |
|
51 |
/** DOCUMENT ME! */ |
|
52 |
private static Logger logger = LoggerFactory.getLogger(NotificationManager.class.getName()); |
|
53 |
|
|
54 |
/** Timer de espera de nuevos mensajes */ |
|
55 |
private static Timer timer; |
|
56 |
|
|
57 |
/** Indica si se han a?adido mensajes desde la ?ltima vez que se comprob? */ |
|
58 |
private static boolean addedMessage = false; |
|
59 |
|
|
60 |
/** DOCUMENT ME! */ |
|
61 |
private static ArrayList info = new ArrayList(); |
|
62 |
private static ArrayList infoExceptions = new ArrayList(); |
|
63 |
|
|
64 |
/** DOCUMENT ME! */ |
|
65 |
private static ArrayList warnings = new ArrayList(); |
|
66 |
private static ArrayList warningsExceptions = new ArrayList(); |
|
67 |
|
|
68 |
/** DOCUMENT ME! */ |
|
69 |
private static ArrayList errors = new ArrayList(); |
|
70 |
private static ArrayList errorsExceptions = new ArrayList(); |
|
71 |
|
|
72 |
/** DOCUMENT ME! */ |
|
73 |
private static Vector listeners = new Vector(); |
|
74 |
private static boolean isFirst = true; |
|
75 |
|
|
76 |
/** |
|
77 |
* A?ade un objeto que escucha los mensajes de error, warning e informaci?n |
|
78 |
* |
|
79 |
* @param nl objeto que recibir? los eventos |
|
80 |
*/ |
|
81 |
public static synchronized void addNotificationListener(NotificationListener nl) { |
|
82 |
logger.info("Se a?ade un listener al manager de notificaciones (" + nl.getClass().getName() +"/"+ nl.toString() + ")"); |
|
83 |
listeners.add(nl); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @see com.iver.mdiApp.Notification#addError(java.lang.String) |
|
88 |
*/ |
|
89 |
public static synchronized void addError(final String err, Throwable e) { |
|
90 |
logger.error(err, e); |
|
91 |
try { |
|
92 |
dispatchError(err, e); |
|
93 |
} catch(Exception ex) { |
|
94 |
|
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public static synchronized void dispatchError(final String err, Throwable e) { |
|
99 |
errors.add(err); |
|
100 |
errorsExceptions.add(e); |
|
101 |
|
|
102 |
if (isFirst) { |
|
103 |
AddError((String[]) errors.toArray(new String[0]), |
|
104 |
(Throwable[]) errorsExceptions.toArray(new Throwable[0])); |
|
105 |
errors.clear(); |
|
106 |
errorsExceptions.clear(); |
|
107 |
isFirst = false; |
|
108 |
} |
|
109 |
|
|
110 |
dispatchMessages(); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @see com.iver.mdiApp.Notification#addWarning(java.lang.String) |
|
115 |
*/ |
|
116 |
public static synchronized void addWarning(final String warn, |
|
117 |
final Throwable e) { |
|
118 |
logger.warn(warn, e); |
|
119 |
dispatchWarning(warn, e); |
|
120 |
} |
|
121 |
|
|
122 |
public static synchronized void dispatchWarning(final String warn, |
|
123 |
final Throwable e) { |
|
124 |
warnings.add(warn); |
|
125 |
warningsExceptions.add(e); |
|
126 |
|
|
127 |
if (isFirst) { |
|
128 |
AddWarning((String[]) warnings.toArray(new String[0]), |
|
129 |
(Throwable[]) warningsExceptions.toArray(new Throwable[0])); |
|
130 |
warnings.clear(); |
|
131 |
warningsExceptions.clear(); |
|
132 |
isFirst = false; |
|
133 |
} |
|
134 |
|
|
135 |
dispatchMessages(); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* @see com.iver.mdiApp.Notification#addWarning(java.lang.String) |
|
140 |
*/ |
|
141 |
public static synchronized void addWarning(final String warn) { |
|
142 |
addWarning(warn,null); |
|
143 |
} |
|
144 |
|
|
145 |
/* |
|
146 |
* @see com.iver.mdiApp.Consola#addInfo(java.lang.String) |
|
147 |
*/ |
|
148 |
public static synchronized void addInfo(final String inf, final Throwable e) { |
|
149 |
logger.info(inf, e); |
|
150 |
info.add(inf); |
|
151 |
infoExceptions.add(e); |
|
152 |
|
|
153 |
if (isFirst) { |
|
154 |
AddInfo((String[]) info.toArray(new String[0]), |
|
155 |
(Throwable[]) infoExceptions.toArray(new Throwable[0])); |
|
156 |
info.clear(); |
|
157 |
infoExceptions.clear(); |
|
158 |
isFirst = false; |
|
159 |
} |
|
160 |
|
|
161 |
dispatchMessages(); |
|
162 |
} |
|
163 |
/* |
|
164 |
* @see com.iver.mdiApp.Consola#addInfo(java.lang.String) |
|
165 |
*/ |
|
166 |
public static synchronized void addInfo(final String inf) { |
|
167 |
addInfo(inf,null); |
|
168 |
} |
|
169 |
/** |
|
170 |
* M?todo que es ejecutado en el thread de la interfaz y que se encarga de |
|
171 |
* avisar del mensaje de error a todos los listeners registrados |
|
172 |
* |
|
173 |
* @param error Mensaje de error |
|
174 |
* @param e s que van a recibir las notificaciones |
|
175 |
*/ |
|
176 |
private static void AddError(String[] error, Throwable[] e) { |
|
177 |
for (int i = 0; i < listeners.size(); i++) { |
|
178 |
((NotificationListener) listeners.get(i)).errorEvent(new MessageEvent( |
|
179 |
error, e)); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* M?todo que es ejecutado en el thread de la interfaz y que se encarga de |
|
185 |
* avisar del mensaje de error a todos los listeners registrados |
|
186 |
* |
|
187 |
* @param warn Mensaje de warning |
|
188 |
* @param e objetos que van a recibir las notificaciones |
|
189 |
*/ |
|
190 |
private static void AddWarning(String[] warn, Throwable[] e) { |
|
191 |
for (int i = 0; i < listeners.size(); i++) { |
|
192 |
((NotificationListener) listeners.get(i)).warningEvent(new MessageEvent( |
|
193 |
warn, e)); |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* M?todo que es ejecutado en el thread de la interfaz y que se encarga de |
|
199 |
* avisar del mensaje de informaci?n a todos los listeners registrados |
|
200 |
* |
|
201 |
* @param info Mensaje de informaci?n |
|
202 |
* @param e objetos que van a recibir las notificaciones |
|
203 |
*/ |
|
204 |
private static void AddInfo(String[] info, Throwable[] e) { |
|
205 |
for (int i = 0; i < listeners.size(); i++) { |
|
206 |
((NotificationListener) listeners.get(i)).infoEvent(new MessageEvent( |
|
207 |
info, e)); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* DOCUMENT ME! |
|
213 |
*/ |
|
214 |
private static void dispatchMessages() { |
|
215 |
addedMessage = true; |
|
216 |
|
|
217 |
if (timer == null) { |
|
218 |
|
|
219 |
timer = new Timer(1000, new ActionListener() { |
|
220 |
public void actionPerformed(ActionEvent e) { |
|
221 |
|
|
222 |
if (errors.size() > 0) { |
|
223 |
AddError((String[]) errors.toArray(new String[0]), |
|
224 |
(Throwable[]) errorsExceptions.toArray(new Throwable[0])); |
|
225 |
errors.clear(); |
|
226 |
errorsExceptions.clear(); |
|
227 |
} |
|
228 |
|
|
229 |
if (warnings.size() > 0) { |
|
230 |
AddWarning((String[]) warnings.toArray(new String[0]), |
|
231 |
(Throwable[]) warningsExceptions.toArray(new Throwable[0])); |
|
232 |
warnings.clear(); |
|
233 |
warningsExceptions.clear(); |
|
234 |
} |
|
235 |
|
|
236 |
if (info.size() > 0) { |
|
237 |
AddInfo((String[]) info.toArray(new String[0]), |
|
238 |
(Throwable[]) infoExceptions.toArray(new Throwable[0])); |
|
239 |
info.clear(); |
|
240 |
infoExceptions.clear(); |
|
241 |
} |
|
242 |
|
|
243 |
if (!addedMessage) { |
|
244 |
if (timer != null) { |
|
245 |
timer.stop(); |
|
246 |
} |
|
247 |
|
|
248 |
timer = null; |
|
249 |
} |
|
250 |
|
|
251 |
addedMessage = false; |
|
252 |
isFirst = true; |
|
253 |
} |
|
254 |
}); |
|
255 |
timer.start(); |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
public static void addError(Throwable e1) { |
|
260 |
if( e1 instanceof IBaseException ) { |
|
261 |
IBaseException ex = (IBaseException) e1; |
|
262 |
String msg; |
|
263 |
try { |
|
264 |
msg = ex.getLocalizedMessageStack(); |
|
265 |
} catch(Exception ex1) { |
|
266 |
try { |
|
267 |
msg = ex.getMessageStack(); |
|
268 |
} catch(Exception ex2) { |
|
269 |
msg = ex.getMessage(); |
|
270 |
} |
|
271 |
} |
|
272 |
addError(msg, e1); |
|
273 |
} else { |
|
274 |
addError(e1.toString(), e1); |
|
275 |
} |
|
276 |
|
|
277 |
} |
|
278 |
|
|
279 |
public static void showMessageError(String message,Exception e) { |
|
280 |
message=splitMessage(message); |
|
281 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),message,PluginServices.getText(NotificationManager.class,"error"),JOptionPane.ERROR_MESSAGE); |
|
282 |
NotificationManager.addWarning(message,e); |
|
283 |
} |
|
284 |
public static void showMessageWarning(String message,Exception e) { |
|
285 |
message=splitMessage(message); |
|
286 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),message,PluginServices.getText(NotificationManager.class,"warning"),JOptionPane.WARNING_MESSAGE); |
|
287 |
NotificationManager.addWarning(message,e); |
|
288 |
} |
|
289 |
public static void showMessageInfo(String message,Exception e) { |
|
290 |
message=splitMessage(message); |
|
291 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),message,PluginServices.getText(NotificationManager.class,"info"),JOptionPane.INFORMATION_MESSAGE); |
|
292 |
NotificationManager.addInfo(message,e); |
|
293 |
} |
|
294 |
private static String splitMessage(String message) { |
|
295 |
String[] messages=message.split("\n"); |
|
296 |
String resultMessage=""; |
|
297 |
for (int i=0;i<messages.length && i<=SIZE_MESSAGE;i++){ |
|
298 |
resultMessage+=(messages[i]); |
|
299 |
resultMessage+=("\n"); |
|
300 |
} |
|
301 |
return resultMessage; |
|
302 |
} |
|
303 |
} |
|
0 | 304 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/LocaleManager.java | ||
---|---|---|
1 |
package org.gvsig.andami; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.Locale; |
|
6 |
import java.util.Set; |
|
7 |
|
|
8 |
public interface LocaleManager { |
|
9 |
|
|
10 |
public static final Locale SPANISH = new Locale("es"); |
|
11 |
|
|
12 |
public static final Locale ENGLISH = new Locale("en"); |
|
13 |
|
|
14 |
public Set<Locale> getDefaultLocales(); |
|
15 |
|
|
16 |
public Set<Locale> getInstalledLocales(); |
|
17 |
|
|
18 |
public Locale getDefaultSystemLocale(); |
|
19 |
|
|
20 |
public Locale getCurrentLocale(); |
|
21 |
|
|
22 |
public void setCurrentLocale(Locale locale); |
|
23 |
|
|
24 |
public boolean installLocale(Locale locale); |
|
25 |
|
|
26 |
public boolean uninstallLocale(Locale locale); |
|
27 |
|
|
28 |
public boolean installLocales(URL localesFile); |
|
29 |
|
|
30 |
public File getResourcesFolder(); |
|
31 |
|
|
32 |
public Locale[] getLocaleAlternatives(Locale locale); |
|
33 |
|
|
34 |
public String getLanguageDisplayName(Locale locale); |
|
35 |
|
|
36 |
public String getLocaleDisplayName(Locale locale); |
|
37 |
|
|
38 |
public Locale getNearestLocale(Locale locale); |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
*/ |
|
43 |
void updateInstalledLocales(); |
|
44 |
} |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/TranslatableButtonHelper.java | ||
---|---|---|
1 |
/* |
|
2 |
/** |
|
3 |
* gvSIG. Desktop Geographic Information System. |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 3 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
*/ |
|
25 |
package org.gvsig.andami.ui.mdiFrame; |
|
26 |
|
|
27 |
import java.util.Locale; |
|
28 |
import org.gvsig.andami.PluginsLocator; |
|
29 |
import org.gvsig.andami.PluginsManager; |
|
30 |
|
|
31 |
public class TranslatableButtonHelper { |
|
32 |
|
|
33 |
public interface TranslatableButton { |
|
34 |
|
|
35 |
public void setTextKey(String key); |
|
36 |
|
|
37 |
public void setToolTipKey(String key); |
|
38 |
|
|
39 |
public void translate(); |
|
40 |
} |
|
41 |
|
|
42 |
private String keyText = null; |
|
43 |
private String keyToolTip = null; |
|
44 |
private String text = null; |
|
45 |
private String tooltip = null; |
|
46 |
|
|
47 |
private Locale locale = null; |
|
48 |
private static PluginsManager pluginsManager = null; |
|
49 |
|
|
50 |
public void setText(String keyText) { |
|
51 |
this.keyText = keyText; |
|
52 |
} |
|
53 |
|
|
54 |
public void setTooltip(String keyTooltip) { |
|
55 |
this.keyToolTip = keyTooltip; |
|
56 |
} |
|
57 |
|
|
58 |
public String getText() { |
|
59 |
return this.text; |
|
60 |
} |
|
61 |
|
|
62 |
public String getTooltip() { |
|
63 |
return this.tooltip; |
|
64 |
} |
|
65 |
|
|
66 |
private PluginsManager getPluginsManager() { |
|
67 |
if ( pluginsManager == null ) { |
|
68 |
pluginsManager = PluginsLocator.getManager(); |
|
69 |
} |
|
70 |
return pluginsManager; |
|
71 |
} |
|
72 |
|
|
73 |
public void translate() { |
|
74 |
if ( this.keyText != null ) { |
|
75 |
this.text = getPluginsManager().translate(this.keyText); |
|
76 |
} |
|
77 |
if ( this.keyToolTip != null ) { |
|
78 |
this.tooltip = getPluginsManager().translate(this.keyToolTip); |
|
79 |
} |
|
80 |
locale = Locale.getDefault(); |
|
81 |
} |
|
82 |
|
|
83 |
public boolean needTranslation() { |
|
84 |
if ( this.locale == null ) { |
|
85 |
return true; |
|
86 |
} |
|
87 |
if ( this.locale.equals(Locale.getDefault()) ) { |
|
88 |
return false; |
|
89 |
} |
|
90 |
return true; |
|
91 |
} |
|
92 |
} |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JToolBarButton.java | ||
---|---|---|
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 |
package org.gvsig.andami.ui.mdiFrame; |
|
25 |
|
|
26 |
import javax.swing.Action; |
|
27 |
import javax.swing.Icon; |
|
28 |
import org.gvsig.andami.ui.mdiFrame.TranslatableButtonHelper.TranslatableButton; |
|
29 |
|
|
30 |
public class JToolBarButton extends javax.swing.JButton implements EnableTextSupport, TranslatableButton { |
|
31 |
|
|
32 |
private TranslatableButtonHelper i18nHelper = new TranslatableButtonHelper(); |
|
33 |
private String enableText; |
|
34 |
private String toolTip; |
|
35 |
|
|
36 |
public JToolBarButton() { |
|
37 |
super(); |
|
38 |
} |
|
39 |
|
|
40 |
public JToolBarButton(String text) { |
|
41 |
super(text); |
|
42 |
} |
|
43 |
|
|
44 |
public JToolBarButton(String text, Icon icon) { |
|
45 |
super(text, icon); |
|
46 |
} |
|
47 |
|
|
48 |
public JToolBarButton(Action a) { |
|
49 |
super(a); |
|
50 |
} |
|
51 |
|
|
52 |
public JToolBarButton(Icon icon) { |
|
53 |
super(icon); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* @return Returns the enableText. |
|
58 |
*/ |
|
59 |
public String getEnableText() { |
|
60 |
return enableText; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @param enableText The enableText to set. |
|
65 |
*/ |
|
66 |
public void setEnableText(String enableText) { |
|
67 |
this.enableText = enableText; |
|
68 |
} |
|
69 |
|
|
70 |
public void setEnabled(boolean aFlag) { |
|
71 |
super.setEnabled(aFlag); |
|
72 |
if ( aFlag ) { |
|
73 |
setToolTipText(toolTip); |
|
74 |
} else { |
|
75 |
setToolTipText(enableText); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public void setToolTip(String text) { |
|
80 |
toolTip = text; |
|
81 |
} |
|
82 |
|
|
83 |
public void setToolTipKey(String key) { |
|
84 |
this.i18nHelper.setTooltip(key); |
|
85 |
} |
|
86 |
|
|
87 |
public void setTextKey(String key) { |
|
88 |
this.i18nHelper.setText(key); |
|
89 |
} |
|
90 |
|
|
91 |
public void translate() { |
|
92 |
if ( this.i18nHelper.needTranslation() ) { |
|
93 |
this.i18nHelper.translate(); |
|
94 |
this.setText(this.i18nHelper.getText()); |
|
95 |
this.setToolTip(this.i18nHelper.getTooltip()); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
} |
|
0 | 100 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/ThreadSafeDialogs.java | ||
---|---|---|
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 |
package org.gvsig.andami.ui.mdiFrame; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
28 |
|
|
29 |
public interface ThreadSafeDialogs extends ThreadSafeDialogsManager { |
|
30 |
|
|
31 |
public void messageDialog(String message, String messageArgs[], String title, int messageType, String msgid); |
|
32 |
|
|
33 |
public int confirmDialog(String message, String title, int optionType, int messageType, String msgid) ; |
|
34 |
|
|
35 |
/** |
|
36 |
* Create a window with the contents and title specified as parameters |
|
37 |
* and show as a dialog windows of gvSIG. |
|
38 |
* |
|
39 |
* if this method is invoked out of the event dispatch thread of swing, |
|
40 |
* the dialog is presented in the thread of swing and the calling thread |
|
41 |
* wait to close to continue. in this case the dialog is not presented as modal to |
|
42 |
* other components of the gui. |
|
43 |
* |
|
44 |
* @param contents |
|
45 |
* @param title |
|
46 |
*/ |
|
47 |
public void showDialog(final Component contents, final String title); |
|
48 |
} |
|
0 | 49 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JToolBarToggleButton.java | ||
---|---|---|
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 |
package org.gvsig.andami.ui.mdiFrame; |
|
25 |
|
|
26 |
import javax.swing.Action; |
|
27 |
import javax.swing.Icon; |
|
28 |
import org.gvsig.andami.ui.mdiFrame.TranslatableButtonHelper.TranslatableButton; |
|
29 |
|
|
30 |
public class JToolBarToggleButton extends javax.swing.JToggleButton implements EnableTextSupport, TranslatableButton { |
|
31 |
|
|
32 |
private TranslatableButtonHelper i18nHelper = new TranslatableButtonHelper(); |
|
33 |
private String enableText; |
|
34 |
private String toolTip; |
|
35 |
|
|
36 |
public JToolBarToggleButton() { |
|
37 |
super(); |
|
38 |
} |
|
39 |
|
|
40 |
public JToolBarToggleButton(String text) { |
|
41 |
super(text); |
|
42 |
} |
|
43 |
|
|
44 |
public JToolBarToggleButton(String text, boolean selected) { |
|
45 |
super(text, selected); |
|
46 |
} |
|
47 |
|
|
48 |
public JToolBarToggleButton(String text, Icon icon) { |
|
49 |
super(text, icon); |
|
50 |
} |
|
51 |
|
|
52 |
public JToolBarToggleButton(String text, Icon icon, boolean selected) { |
|
53 |
super(text, icon, selected); |
|
54 |
} |
|
55 |
|
|
56 |
public JToolBarToggleButton(Action a) { |
|
57 |
super(a); |
|
58 |
} |
|
59 |
|
|
60 |
public JToolBarToggleButton(Icon icon) { |
|
61 |
super(icon); |
|
62 |
} |
|
63 |
|
|
64 |
public JToolBarToggleButton(Icon icon, boolean selected) { |
|
65 |
super(icon, selected); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* @return Returns the enableText. |
|
70 |
*/ |
|
71 |
public String getEnableText() { |
|
72 |
return enableText; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* @param enableText The enableText to set. |
|
77 |
*/ |
|
78 |
public void setEnableText(String enableText) { |
|
79 |
this.enableText = enableText; |
|
80 |
} |
|
81 |
|
|
82 |
public void setEnabled(boolean aFlag) { |
|
83 |
super.setEnabled(aFlag); |
|
84 |
if ( aFlag ) { |
|
85 |
setToolTipText(toolTip); |
|
86 |
} else { |
|
87 |
setToolTipText(enableText); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
public void setToolTip(String text) { |
|
92 |
toolTip = text; |
|
93 |
} |
|
94 |
|
|
95 |
public void setToolTipKey(String key) { |
|
96 |
this.i18nHelper.setTooltip(key); |
|
97 |
} |
|
98 |
|
|
99 |
public void setTextKey(String key) { |
|
100 |
this.i18nHelper.setText(key); |
|
101 |
} |
|
102 |
|
|
103 |
public void translate() { |
|
104 |
if ( this.i18nHelper.needTranslation() ) { |
|
105 |
this.i18nHelper.translate(); |
|
106 |
this.setText(this.i18nHelper.getText()); |
|
107 |
this.setToolTip(this.i18nHelper.getTooltip()); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
0 | 112 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/GlassPane.java | ||
---|---|---|
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 |
package org.gvsig.andami.ui.mdiFrame; |
|
25 |
import java.awt.Cursor; |
|
26 |
|
|
27 |
import javax.swing.JPanel; |
|
28 |
import javax.swing.event.MouseInputAdapter; |
|
29 |
|
|
30 |
public class GlassPane extends JPanel { |
|
31 |
|
|
32 |
public GlassPane(){ |
|
33 |
this.setOpaque(false); |
|
34 |
this.addMouseListener(new MouseInputAdapter(){}); |
|
35 |
this.addMouseMotionListener(new MouseInputAdapter(){}); |
|
36 |
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* @see java.awt.Component#setCursor(java.awt.Cursor) |
|
41 |
*/ |
|
42 |
public void setCursor(Cursor cursor) { |
|
43 |
super.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
44 |
} |
|
45 |
|
|
46 |
} |
|
47 |
|
|
0 | 48 |
tags/org.gvsig.desktop-2.0.233/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/DefaultThreadSafeDialogs.java | ||
---|---|---|
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 |
package org.gvsig.andami.ui.mdiFrame; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.awt.Component; |
|
28 |
import java.awt.Dimension; |
|
29 |
import java.awt.GridBagConstraints; |
|
30 |
import java.awt.event.ComponentEvent; |
|
31 |
import java.awt.event.ComponentListener; |
|
32 |
import java.io.File; |
|
33 |
import java.lang.reflect.Constructor; |
|
34 |
|
|
35 |
import javax.swing.JCheckBox; |
|
36 |
import javax.swing.JLabel; |
|
37 |
import javax.swing.JOptionPane; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.SwingUtilities; |
|
40 |
import javax.swing.filechooser.FileFilter; |
|
41 |
|
|
42 |
import org.slf4j.Logger; |
|
43 |
import org.slf4j.LoggerFactory; |
|
44 |
|
|
45 |
import org.gvsig.andami.PluginServices; |
|
46 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
47 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
48 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
49 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
50 |
import org.gvsig.tools.ToolsLocator; |
|
51 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
52 |
import org.gvsig.tools.swing.api.reminder.DialogReminder; |
|
53 |
import org.gvsig.tools.task.CancellableTask; |
|
54 |
import org.gvsig.tools.task.RunnableWithParameters; |
|
55 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* Thread safe functions for showing dialogs |
|
60 |
* |
|
61 |
* @author jjdelcerro |
|
62 |
* |
|
63 |
*/ |
|
64 |
public class DefaultThreadSafeDialogs implements ThreadSafeDialogs { |
|
65 |
|
|
66 |
private static Logger logger = LoggerFactory |
|
67 |
.getLogger(DefaultThreadSafeDialogs.class); |
|
68 |
private Component rootComponent; |
|
69 |
private NewStatusBar statusbar; |
|
70 |
|
|
71 |
public DefaultThreadSafeDialogs() { |
|
72 |
this(null, null); |
|
73 |
} |
|
74 |
|
|
75 |
public DefaultThreadSafeDialogs(Component rootComponent) { |
|
76 |
this(rootComponent,null); |
|
77 |
} |
|
78 |
|
|
79 |
public DefaultThreadSafeDialogs(Component rootComponent, |
|
80 |
NewStatusBar statusbar) { |
|
81 |
this.statusbar = statusbar; |
|
82 |
this.rootComponent = rootComponent; |
|
83 |
} |
|
84 |
|
|
85 |
private Component getRootComponent() { |
|
86 |
if (this.rootComponent == null) { |
|
87 |
try { |
|
88 |
this.rootComponent = (MDIFrame) PluginServices.getMainFrame(); |
|
89 |
} catch (Throwable t) { |
|
90 |
// Ignore and return null |
|
91 |
} |
|
92 |
} |
|
93 |
return this.rootComponent; |
|
94 |
} |
|
95 |
|
|
96 |
private NewStatusBar getStatusbar() { |
|
97 |
if (this.statusbar == null) { |
|
98 |
this.statusbar = PluginServices.getMainFrame().getStatusBar(); |
|
99 |
} |
|
100 |
return this.statusbar; |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void message(String message, int messageType) { |
|
105 |
this.getStatusbar().message(message, messageType); |
|
106 |
} |
|
107 |
|
|
108 |
private String translate(String message) { |
|
109 |
return translate(message, null); |
|
110 |
} |
|
111 |
|
|
112 |
private String translate(String message, String[] args) { |
|
113 |
String msg = message; |
|
114 |
if (msg == null) { |
|
115 |
msg = ""; |
|
116 |
} |
|
117 |
if (msg.startsWith("_")) { |
|
118 |
msg = org.gvsig.i18n.Messages.getText(msg, args); |
|
119 |
if (msg == null) { |
|
120 |
msg = "_" + message.replace("_", " "); |
|
121 |
} |
|
122 |
} |
|
123 |
return msg; |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public int confirmDialog(final String message, final String title, final int optionType, |
|
128 |
final int messageType) { |
|
129 |
return this.confirmDialog(message, title, optionType, messageType, null); |
|
130 |
} |
|
131 |
|
|
132 |
private static class JMessageWithCheck extends JPanel { |
|
133 |
|
|
134 |
private static final long serialVersionUID = -1902712909850016361L; |
|
135 |
private final JLabel label; |
|
136 |
private final JCheckBox check; |
|
137 |
|
|
138 |
public JMessageWithCheck(String msg, String msgchk) { |
|
139 |
if( !msg.toLowerCase().trim().startsWith("<html>") ) { |
|
140 |
msg = "<html>" + msg.replace("\n", "<br>\n") + "</html>"; |
|
141 |
} |
|
142 |
this.label = new JLabel(msg); |
|
143 |
this.check = new JCheckBox(msgchk); |
|
144 |
this.setLayout(new BorderLayout(10,10)); |
|
145 |
this.add(this.label,BorderLayout.CENTER); |
|
146 |
this.add(this.check,BorderLayout.PAGE_END); |
|
147 |
} |
|
148 |
|
|
149 |
public boolean isCheckSelected() { |
|
150 |
return this.check.isSelected(); |
|
151 |
} |
Also available in: Unified diff