Statistics
| Revision:

root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / ui / AndamiEventQueue.java @ 38564

History | View | Annotate | Download (2.85 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program 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
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.andami.ui;
42

    
43
import java.awt.AWTEvent;
44
import java.awt.EventQueue;
45
import java.awt.event.MouseEvent;
46

    
47
import javax.swing.JOptionPane;
48

    
49
import org.gvsig.andami.PluginServices;
50
import org.gvsig.andami.messages.Messages;
51
import org.gvsig.andami.messages.NotificationManager;
52
import org.slf4j.Logger;
53
import org.slf4j.LoggerFactory;
54

    
55

    
56

    
57
/**
58
 * DOCUMENT ME!
59
 *
60
 * @author Fernando Gonz?lez Cort?s
61
 */
62
public class AndamiEventQueue extends EventQueue {
63
        private static Logger logger = LoggerFactory.getLogger(AndamiEventQueue.class);
64
        
65
        protected void dispatchEvent(AWTEvent event){
66
                try{
67
                        super.dispatchEvent(event);
68
                } catch(RuntimeException e){
69
                        if( event instanceof MouseEvent ) {
70
                                MouseEvent me = (MouseEvent)event;
71
                                if( me.getButton() == 0 && me.getClickCount()==0 ) {
72
                                        // Intentamos que los errores que se produzcan con los eventos de movimiento del raton
73
                                        // no provoquen la aparicion de la ventana de errores ya que llega a bloquear al usuario.
74
                                        // Intentaremos sacarlos en la barra de estado si podemos.
75
                                        try {
76
                                                PluginServices.getMainFrame().getStatusBar().message(e.getMessage(), JOptionPane.ERROR_MESSAGE);
77
                                        } catch(Throwable ex) {
78
                                                // Ignora cualquier error que se produzca intentando mostrar el mensaje de error y nos
79
                                                // conformaremos con que este en el log.
80
                                        }
81
                                        logger.info("Error dispaching event",e);
82
                                        return;
83
                                }
84
                        }
85
                        NotificationManager.addError(e);//Messages.getString("PluginServices.Bug en el c?digo"), e);
86
                } catch (Error e){
87
                        NotificationManager.addError(
88
                            Messages.getString("Error de la applicacion.  \nEs conveniente que salga de la aplicaci?n\n\n"+e.getLocalizedMessage()), e);
89
                }
90
        }
91
}