Statistics
| Revision:

gvsig-gazetteer / trunk / extGazetteer / src / org / gvsig / gazetteer / DeleteSearchesExtension.java @ 12

History | View | Annotate | Download (5.55 KB)

1
package org.gvsig.gazetteer;
2

    
3
import java.util.Hashtable;
4

    
5
import org.gvsig.andami.IconThemeHelper;
6
import org.gvsig.andami.PluginServices;
7
import org.gvsig.andami.plugins.Extension;
8
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
9
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
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: DeleteSearchesExtension.java 499 2007-07-10 11:18:10 +0000 (Tue, 10 Jul 2007) jorpiell $
54
 * $Log$
55
 * Revision 1.1.2.1  2007/07/10 11:18:10  jorpiell
56
 * Added the registers
57
 *
58
 * Revision 1.7.2.4  2007/01/08 12:19:13  jcampos
59
 * Revert changes
60
 *
61
 * Revision 1.7.2.2  2006/11/15 00:08:16  jjdelcerro
62
 * *** empty log message ***
63
 *
64
 * Revision 1.9  2006/10/02 08:29:06  jorpiell
65
 * Modificados los cambios del Branch 10 al head
66
 *
67
 * Revision 1.7.2.1  2006/09/20 12:01:47  jorpiell
68
 * Se ha cambiado la versi?n de la jzkit, se ha incorporado la funcionalidad de cargar arcims
69
 *
70
 * Revision 1.8  2006/09/20 11:23:50  jorpiell
71
 * 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
72
 *
73
 * Revision 1.7  2006/08/29 07:56:34  cesar
74
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
75
 *
76
 * Revision 1.6  2006/08/29 07:13:58  cesar
77
 * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
78
 *
79
 * Revision 1.5  2006/07/24 10:10:06  jorpiell
80
 * Se ha a?adido una hashtable de vistas activas para asociar la goma de borrar con la vista activa
81
 *
82
 * Revision 1.4  2006/06/19 11:19:35  jorpiell
83
 * Cambiadas las comprobaciones de una clase con == por instanceof.
84
 *
85
 * Revision 1.3  2006/05/02 15:53:59  jorpiell
86
 * 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
87
 *
88
 * Revision 1.2  2006/03/10 12:40:20  jorpiell
89
 * Ahora la goma de borrar los resultados del gazetteer ya aparece y desaparece en lugar de habilitarse/deshabilitarse
90
 *
91
 * Revision 1.1  2006/03/10 11:59:31  jorpiell
92
 * Se habilita la gomita para borrar los resultados de la busqueda del gazetteer en funcion de si hay o no resultados para borrar.
93
 *
94
 *
95
 */
96
/**
97
 * @autor Jorge Piera Llodr? (piera_jor@gva.es)
98
 */
99
public class DeleteSearchesExtension extends Extension{
100
        private static Hashtable views = new Hashtable();
101
        
102
        /*
103
         * (non-Javadoc)
104
         * @see com.iver.andami.plugins.Extension#inicializar()
105
         */
106
        public void initialize() {
107
                // TODO Auto-generated method stub
108
                registerIcons();
109
        }
110
        
111
        private void registerIcons(){
112
        IconThemeHelper.registerIcon("gazetteer", "catalog-clear-point", this);
113
        IconThemeHelper.registerIcon("gazetteer", "gazetteer-search", this);
114
        }
115

    
116
        /*
117
         * (non-Javadoc)
118
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
119
         */
120
        public void execute(String actionCommand) {
121
                deteleAllFeatures();                
122
        }
123

    
124
        /*
125
         * (non-Javadoc)
126
         * @see com.iver.andami.plugins.Extension#isEnabled()
127
         */
128
        public boolean isEnabled() {
129
                return true;
130
        }
131

    
132
        /*
133
         * (non-Javadoc)
134
         * @see com.iver.andami.plugins.Extension#isVisible()
135
         */
136
        public boolean isVisible() {
137
                org.gvsig.andami.ui.mdiManager.IWindow activeView = PluginServices.getMDIManager()
138
                .getActiveWindow();
139
                
140
                if (activeView == null) {
141
                        return false;
142
                }
143
                
144
                if (activeView instanceof AbstractViewPanel){
145
                        Boolean bool = (Boolean)views.get(activeView);
146
                        if (bool == null){
147
                                return false;
148
                        }else{
149
                                return bool.booleanValue();
150
                        }
151
                }else{
152
                        return false;
153
                }
154
        
155
        
156
        }
157

    
158
        /**
159
         * Delete all the current view searches
160
         *
161
         */
162
        public static void deteleAllFeatures(){
163
                AbstractViewPanel activeView = 
164
                        (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
165
                GraphicLayer lyr = activeView.getMapControl().getMapContext().getGraphicsLayer();
166
                lyr.clearAllGraphics();
167
                activeView.getMapControl().getViewPort().setEnvelope(activeView.getMapControl().getViewPort().getAdjustedExtent());
168
                views.put(activeView,new Boolean(false));
169
        }
170
        
171
        /**
172
         * Sets the extension enabled
173
         *
174
         */
175
        public static void setVisible(){
176
                AbstractViewPanel activeView = 
177
                        (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
178
                views.put(activeView,new Boolean(true));
179
        }
180

    
181
}