Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCatalogAndGazetteer / src / es / gva / cit / gvsig / gazetteer / DeleteSearchesModule.java @ 14817

History | View | Annotate | Download (4.88 KB)

1
package es.gva.cit.gvsig.gazetteer;
2

    
3
import java.util.Hashtable;
4

    
5
import com.iver.andami.PluginServices;
6
import com.iver.andami.plugins.Extension;
7
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
8
import com.iver.cit.gvsig.project.documents.view.gui.View;
9

    
10

    
11
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib��ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: DeleteSearchesModule.java 14817 2007-10-22 12:14:25Z jmvivo $
54
 * $Log$
55
 * Revision 1.9  2006-10-02 08:29:06  jorpiell
56
 * Modificados los cambios del Branch 10 al head
57
 *
58
 * Revision 1.7.2.1  2006/09/20 12:01:47  jorpiell
59
 * Se ha cambiado la versi�n de la jzkit, se ha incorporado la funcionalidad de cargar arcims
60
 *
61
 * Revision 1.8  2006/09/20 11:23:50  jorpiell
62
 * Se ha cambiado la versi�n de la librer�a jzkit de la 1 a la 2.0. Adem�s se ha modificado lo del document
63
 *
64
 * Revision 1.7  2006/08/29 07:56:34  cesar
65
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
66
 *
67
 * Revision 1.6  2006/08/29 07:13:58  cesar
68
 * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
69
 *
70
 * Revision 1.5  2006/07/24 10:10:06  jorpiell
71
 * Se ha a�adido una hashtable de vistas activas para asociar la goma de borrar con la vista activa
72
 *
73
 * Revision 1.4  2006/06/19 11:19:35  jorpiell
74
 * Cambiadas las comprobaciones de una clase con == por instanceof.
75
 *
76
 * Revision 1.3  2006/05/02 15:53:59  jorpiell
77
 * Se ha cambiado la interfaz Extension por dos clases: una interfaz (IExtension) y una clase abstract(Extension). A partir de ahora todas las extensiones deben heredar de Extension
78
 *
79
 * Revision 1.2  2006/03/10 12:40:20  jorpiell
80
 * Ahora la goma de borrar los resultados del gazetteer ya aparece y desaparece en lugar de habilitarse/deshabilitarse
81
 *
82
 * Revision 1.1  2006/03/10 11:59:31  jorpiell
83
 * Se habilita la gomita para borrar los resultados de la busqueda del gazetteer en funcion de si hay o no resultados para borrar.
84
 *
85
 *
86
 */
87
/**
88
 * @autor Jorge Piera Llodr� (piera_jor@gva.es)
89
 */
90
public class DeleteSearchesModule extends Extension{
91
        private static Hashtable views = new Hashtable();
92
        
93
        /*
94
         * (non-Javadoc)
95
         * @see com.iver.andami.plugins.Extension#inicializar()
96
         */
97
        public void initialize() {
98
                // TODO Auto-generated method stub
99
                PluginServices.getIconTheme().register(
100
                                "catalog-clear-point",
101
                                this.getClass().getClassLoader().getResource("images/delone.png")
102
                        );
103
        }
104

    
105
        /*
106
         * (non-Javadoc)
107
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
108
         */
109
        public void execute(String actionCommand) {
110
                deteleAllFeatures();                
111
        }
112

    
113
        /*
114
         * (non-Javadoc)
115
         * @see com.iver.andami.plugins.Extension#isEnabled()
116
         */
117
        public boolean isEnabled() {
118
                return true;
119
        }
120

    
121
        /*
122
         * (non-Javadoc)
123
         * @see com.iver.andami.plugins.Extension#isVisible()
124
         */
125
        public boolean isVisible() {
126
                com.iver.andami.ui.mdiManager.IWindow activeView = PluginServices.getMDIManager()
127
                .getActiveWindow();
128
                
129
                if (activeView == null) {
130
                        return false;
131
                }
132
                
133
                if (activeView instanceof View){
134
                        Boolean bool = (Boolean)views.get(activeView);
135
                        if (bool == null){
136
                                return false;
137
                        }else{
138
                                return bool.booleanValue();
139
                        }
140
                }else{
141
                        return false;
142
                }
143
        
144
        
145
        }
146

    
147
        /**
148
         * Delete all the current view searches
149
         *
150
         */
151
        public static void deteleAllFeatures(){
152
                View activeView = 
153
                        (View) PluginServices.getMDIManager().getActiveWindow();
154
                GraphicLayer lyr = activeView.getMapControl().getMapContext().getGraphicsLayer();
155
                lyr.clearAllGraphics();
156
                activeView.getMapControl().getViewPort().setExtent(activeView.getMapControl().getViewPort().getExtent());
157
                views.put(activeView,new Boolean(false));
158
        }
159
        
160
        /**
161
         * Sets the extension enabled
162
         *
163
         */
164
        public static void setVisible(){
165
                View activeView = 
166
                        (View) PluginServices.getMDIManager().getActiveWindow();
167
                views.put(activeView,new Boolean(true));
168
        }
169

    
170
}