Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGazetteer / src / org / gvsig / gazetteer / DeleteSearchesExtension.java @ 31496

History | View | Annotate | Download (5.51 KB)

1
package org.gvsig.gazetteer;
2

    
3
import java.util.Hashtable;
4

    
5
import org.gvsig.andami.PluginServices;
6
import org.gvsig.andami.plugins.Extension;
7
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
8
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
9

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

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

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

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

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

    
182
}