Revision 40204

View differences:

tags/extensions/org.gvsig.datalocator/2.0/config/text_de.properties
1
#Translations for language [de]
2
#Wed Oct 08 17:44:19 CEST 2008
3
Campo=Feld
4
Capa=Layer
5
com.iver.cit.gvsig.Herramientas=
6
Localizador_por_atributo=Objekt mittels Attribut suchen
7
open_first_time=Mit dem View \u00f6ffnen
8
Salir=Schlie\u00dfen
9
Valor=Wert
10
Vista=Ansicht
11
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Eremua
4
Capa=Geruza
5
Localizador_por_atributo=Ezaugarrien araberako bilagailua
6
open_first_time=Bistarekin ireki
7
Salir=Irten
8
Valor=Balioa
9
Vista=Bista
10
Zoom=Zooma
tags/extensions/org.gvsig.datalocator/2.0/config/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
Campo=Campo
4
Capa=Layer
5
Localizador_por_atributo=Localizza per attributo
6
open_first_time=Apri con la vista
7
Salir=Esci
8
Valor=Valore
9
Vista=Vista
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Campo
4
Capa=Capa
5
Localizador_por_atributo=Localizador por atributo
6
open_first_time=Abrir con la vista
7
Salir=Salir
8
Valor=Valor
9
Vista=Vista
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_zh.properties
1
#Translations for language [en]
2
#Fri Nov 03 13:14:56 CET 2006
3
Campo=\u5b57\u6bb5
4
Capa=\u56fe\u5c42
5
Localizador_por_atributo=\u6839\u636e\u7279\u6027\u5b9a\u4f4d
6
open_first_time=\u4e0e\u89c6\u56fe\u6253\u5f00
7
Salir=\u9000\u51fa
8
Valor=\u6570\u636e
9
Vista=\u89c6\u56fe
10
Zoom=\u7f29\u653e
tags/extensions/org.gvsig.datalocator/2.0/config/text_en.properties
1
#Translations for language [en]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Field
4
Capa=Layer
5
Localizador_por_atributo=Locate by attribute
6
open_first_time=Open with the view
7
Salir=Exit
8
Valor=Value
9
Vista=View
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Campo
4
Capa=Capa
5
Localizador_por_atributo=Localizador por atributo
6
open_first_time=Abrir coa vista
7
Salir=Sa\u00edr
8
Valor=Valor
9
Vista=Vista
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Camp
4
Capa=Capa
5
Localizador_por_atributo=Localitzador per atribut
6
open_first_time=Obrir amb la vista
7
Salir=Eixir
8
Valor=Valor
9
Vista=Vista
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Campo
4
Capa=Capa
5
Localizador_por_atributo=Localizador por atributo
6
open_first_time=Abrir com a vista
7
Salir=Fechar
8
Valor=Valor
9
Vista=Vista
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib"/>
4
	<depends plugin-name="org.gvsig.app"/>
5
		<resourceBundle name="text"/>
6
	<extensions>
7
		<extension class-name="org.gvsig.datalocator.DataLocatorExtension"
8
			description="Extensi?n que permite hacer zooms en funci?n de los valores de la base de datos. Tambi?n permite guardar y recuperar estos zooms."
9
			active="true">
10
			
11
			<action 
12
                name="view-navigation-locator-by-attribute"
13
                label="Localizador_por_atributo" 
14
                tooltip="Localizador_por_atributo" 
15
                position="650102000" 
16
                action-command="view-navigation-locator-by-attribute"
17
                icon="view-navigation-locator-by-attribute"
18
                accelerator=""
19
                />
20
            
21
            <menu
22
                name="view-navigation-locator-by-attribute" 
23
                text="View/Navigation/Localizador_por_atributo"
24
                />
25
                
26
			<tool-bar name="Herramientas">
27
                <action-tool name="view-navigation-locator-by-attribute"/>
28
            </tool-bar>
29

  
30
		</extension>
31
	</extensions>
32
</plugin-config>
tags/extensions/org.gvsig.datalocator/2.0/config/text_cs.properties
1
#Translations for language [cs]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Pole
4
Capa=Vrstva
5
Localizador_por_atributo=Vyhledat podle atributu
6
open_first_time=Otev\u0159\u00edt spole\u010dn\u011b s pohledem
7
Salir=Konec
8
Valor=Hodnota
9
Vista=Pohled
10
Zoom=Zoom
tags/extensions/org.gvsig.datalocator/2.0/config/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
Campo=Champ
4
Capa=Couche
5
Localizador_por_atributo=Localisation par attribut
6
open_first_time=Ouvrir avec la vue
7
Salir=Quitter
8
Valor=Valeur
9
Vista=Vue
10
Zoom=Zoomer
tags/extensions/org.gvsig.datalocator/2.0/doc/gpl.txt
1
		    GNU GENERAL PUBLIC LICENSE
2
		       Version 2, June 1991
3

  
4
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
 Everyone is permitted to copy and distribute verbatim copies
7
 of this license document, but changing it is not allowed.
8

  
9
			    Preamble
10

  
11
  The licenses for most software are designed to take away your
12
freedom to share and change it.  By contrast, the GNU General Public
13
License is intended to guarantee your freedom to share and change free
14
software--to make sure the software is free for all its users.  This
15
General Public License applies to most of the Free Software
16
Foundation's software and to any other program whose authors commit to
17
using it.  (Some other Free Software Foundation software is covered by
18
the GNU Library General Public License instead.)  You can apply it to
19
your programs, too.
20

  
21
  When we speak of free software, we are referring to freedom, not
22
price.  Our General Public Licenses are designed to make sure that you
23
have the freedom to distribute copies of free software (and charge for
24
this service if you wish), that you receive source code or can get it
25
if you want it, that you can change the software or use pieces of it
26
in new free programs; and that you know you can do these things.
27

  
28
  To protect your rights, we need to make restrictions that forbid
29
anyone to deny you these rights or to ask you to surrender the rights.
30
These restrictions translate to certain responsibilities for you if you
31
distribute copies of the software, or if you modify it.
32

  
33
  For example, if you distribute copies of such a program, whether
34
gratis or for a fee, you must give the recipients all the rights that
35
you have.  You must make sure that they, too, receive or can get the
36
source code.  And you must show them these terms so they know their
37
rights.
38

  
39
  We protect your rights with two steps: (1) copyright the software, and
40
(2) offer you this license which gives you legal permission to copy,
41
distribute and/or modify the software.
42

  
43
  Also, for each author's protection and ours, we want to make certain
44
that everyone understands that there is no warranty for this free
45
software.  If the software is modified by someone else and passed on, we
46
want its recipients to know that what they have is not the original, so
47
that any problems introduced by others will not reflect on the original
48
authors' reputations.
49

  
50
  Finally, any free program is threatened constantly by software
51
patents.  We wish to avoid the danger that redistributors of a free
52
program will individually obtain patent licenses, in effect making the
53
program proprietary.  To prevent this, we have made it clear that any
54
patent must be licensed for everyone's free use or not licensed at all.
55

  
56
  The precise terms and conditions for copying, distribution and
57
modification follow.
58

59
		    GNU GENERAL PUBLIC LICENSE
60
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61

  
62
  0. This License applies to any program or other work which contains
63
a notice placed by the copyright holder saying it may be distributed
64
under the terms of this General Public License.  The "Program", below,
65
refers to any such program or work, and a "work based on the Program"
66
means either the Program or any derivative work under copyright law:
67
that is to say, a work containing the Program or a portion of it,
68
either verbatim or with modifications and/or translated into another
69
language.  (Hereinafter, translation is included without limitation in
70
the term "modification".)  Each licensee is addressed as "you".
71

  
72
Activities other than copying, distribution and modification are not
73
covered by this License; they are outside its scope.  The act of
74
running the Program is not restricted, and the output from the Program
75
is covered only if its contents constitute a work based on the
76
Program (independent of having been made by running the Program).
77
Whether that is true depends on what the Program does.
78

  
79
  1. You may copy and distribute verbatim copies of the Program's
80
source code as you receive it, in any medium, provided that you
81
conspicuously and appropriately publish on each copy an appropriate
82
copyright notice and disclaimer of warranty; keep intact all the
83
notices that refer to this License and to the absence of any warranty;
84
and give any other recipients of the Program a copy of this License
85
along with the Program.
86

  
87
You may charge a fee for the physical act of transferring a copy, and
88
you may at your option offer warranty protection in exchange for a fee.
89

  
90
  2. You may modify your copy or copies of the Program or any portion
91
of it, thus forming a work based on the Program, and copy and
92
distribute such modifications or work under the terms of Section 1
93
above, provided that you also meet all of these conditions:
94

  
95
    a) You must cause the modified files to carry prominent notices
96
    stating that you changed the files and the date of any change.
97

  
98
    b) You must cause any work that you distribute or publish, that in
99
    whole or in part contains or is derived from the Program or any
100
    part thereof, to be licensed as a whole at no charge to all third
101
    parties under the terms of this License.
102

  
103
    c) If the modified program normally reads commands interactively
104
    when run, you must cause it, when started running for such
105
    interactive use in the most ordinary way, to print or display an
106
    announcement including an appropriate copyright notice and a
107
    notice that there is no warranty (or else, saying that you provide
108
    a warranty) and that users may redistribute the program under
109
    these conditions, and telling the user how to view a copy of this
110
    License.  (Exception: if the Program itself is interactive but
111
    does not normally print such an announcement, your work based on
112
    the Program is not required to print an announcement.)
113

114
These requirements apply to the modified work as a whole.  If
115
identifiable sections of that work are not derived from the Program,
116
and can be reasonably considered independent and separate works in
117
themselves, then this License, and its terms, do not apply to those
118
sections when you distribute them as separate works.  But when you
119
distribute the same sections as part of a whole which is a work based
120
on the Program, the distribution of the whole must be on the terms of
121
this License, whose permissions for other licensees extend to the
122
entire whole, and thus to each and every part regardless of who wrote it.
123

  
124
Thus, it is not the intent of this section to claim rights or contest
125
your rights to work written entirely by you; rather, the intent is to
126
exercise the right to control the distribution of derivative or
127
collective works based on the Program.
128

  
129
In addition, mere aggregation of another work not based on the Program
130
with the Program (or with a work based on the Program) on a volume of
131
a storage or distribution medium does not bring the other work under
132
the scope of this License.
133

  
134
  3. You may copy and distribute the Program (or a work based on it,
135
under Section 2) in object code or executable form under the terms of
136
Sections 1 and 2 above provided that you also do one of the following:
137

  
138
    a) Accompany it with the complete corresponding machine-readable
139
    source code, which must be distributed under the terms of Sections
140
    1 and 2 above on a medium customarily used for software interchange; or,
141

  
142
    b) Accompany it with a written offer, valid for at least three
143
    years, to give any third party, for a charge no more than your
144
    cost of physically performing source distribution, a complete
145
    machine-readable copy of the corresponding source code, to be
146
    distributed under the terms of Sections 1 and 2 above on a medium
147
    customarily used for software interchange; or,
148

  
149
    c) Accompany it with the information you received as to the offer
150
    to distribute corresponding source code.  (This alternative is
151
    allowed only for noncommercial distribution and only if you
152
    received the program in object code or executable form with such
153
    an offer, in accord with Subsection b above.)
154

  
155
The source code for a work means the preferred form of the work for
156
making modifications to it.  For an executable work, complete source
157
code means all the source code for all modules it contains, plus any
158
associated interface definition files, plus the scripts used to
159
control compilation and installation of the executable.  However, as a
160
special exception, the source code distributed need not include
161
anything that is normally distributed (in either source or binary
162
form) with the major components (compiler, kernel, and so on) of the
163
operating system on which the executable runs, unless that component
164
itself accompanies the executable.
165

  
166
If distribution of executable or object code is made by offering
167
access to copy from a designated place, then offering equivalent
168
access to copy the source code from the same place counts as
169
distribution of the source code, even though third parties are not
170
compelled to copy the source along with the object code.
171

172
  4. You may not copy, modify, sublicense, or distribute the Program
173
except as expressly provided under this License.  Any attempt
174
otherwise to copy, modify, sublicense or distribute the Program is
175
void, and will automatically terminate your rights under this License.
176
However, parties who have received copies, or rights, from you under
177
this License will not have their licenses terminated so long as such
178
parties remain in full compliance.
179

  
180
  5. You are not required to accept this License, since you have not
181
signed it.  However, nothing else grants you permission to modify or
182
distribute the Program or its derivative works.  These actions are
183
prohibited by law if you do not accept this License.  Therefore, by
184
modifying or distributing the Program (or any work based on the
185
Program), you indicate your acceptance of this License to do so, and
186
all its terms and conditions for copying, distributing or modifying
187
the Program or works based on it.
188

  
189
  6. Each time you redistribute the Program (or any work based on the
190
Program), the recipient automatically receives a license from the
191
original licensor to copy, distribute or modify the Program subject to
192
these terms and conditions.  You may not impose any further
193
restrictions on the recipients' exercise of the rights granted herein.
194
You are not responsible for enforcing compliance by third parties to
195
this License.
196

  
197
  7. If, as a consequence of a court judgment or allegation of patent
198
infringement or for any other reason (not limited to patent issues),
199
conditions are imposed on you (whether by court order, agreement or
200
otherwise) that contradict the conditions of this License, they do not
201
excuse you from the conditions of this License.  If you cannot
202
distribute so as to satisfy simultaneously your obligations under this
203
License and any other pertinent obligations, then as a consequence you
204
may not distribute the Program at all.  For example, if a patent
205
license would not permit royalty-free redistribution of the Program by
206
all those who receive copies directly or indirectly through you, then
207
the only way you could satisfy both it and this License would be to
208
refrain entirely from distribution of the Program.
209

  
210
If any portion of this section is held invalid or unenforceable under
211
any particular circumstance, the balance of the section is intended to
212
apply and the section as a whole is intended to apply in other
213
circumstances.
214

  
215
It is not the purpose of this section to induce you to infringe any
216
patents or other property right claims or to contest validity of any
217
such claims; this section has the sole purpose of protecting the
218
integrity of the free software distribution system, which is
219
implemented by public license practices.  Many people have made
220
generous contributions to the wide range of software distributed
221
through that system in reliance on consistent application of that
222
system; it is up to the author/donor to decide if he or she is willing
223
to distribute software through any other system and a licensee cannot
224
impose that choice.
225

  
226
This section is intended to make thoroughly clear what is believed to
227
be a consequence of the rest of this License.
228

229
  8. If the distribution and/or use of the Program is restricted in
230
certain countries either by patents or by copyrighted interfaces, the
231
original copyright holder who places the Program under this License
232
may add an explicit geographical distribution limitation excluding
233
those countries, so that distribution is permitted only in or among
234
countries not thus excluded.  In such case, this License incorporates
235
the limitation as if written in the body of this License.
236

  
237
  9. The Free Software Foundation may publish revised and/or new versions
238
of the General Public License from time to time.  Such new versions will
239
be similar in spirit to the present version, but may differ in detail to
240
address new problems or concerns.
241

  
242
Each version is given a distinguishing version number.  If the Program
243
specifies a version number of this License which applies to it and "any
244
later version", you have the option of following the terms and conditions
245
either of that version or of any later version published by the Free
246
Software Foundation.  If the Program does not specify a version number of
247
this License, you may choose any version ever published by the Free Software
248
Foundation.
249

  
250
  10. If you wish to incorporate parts of the Program into other free
251
programs whose distribution conditions are different, write to the author
252
to ask for permission.  For software which is copyrighted by the Free
253
Software Foundation, write to the Free Software Foundation; we sometimes
254
make exceptions for this.  Our decision will be guided by the two goals
255
of preserving the free status of all derivatives of our free software and
256
of promoting the sharing and reuse of software generally.
257

  
258
			    NO WARRANTY
259

  
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
REPAIR OR CORRECTION.
269

  
270
  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
POSSIBILITY OF SUCH DAMAGES.
279

  
280
		     END OF TERMS AND CONDITIONS
281

282
	    How to Apply These Terms to Your New Programs
283

  
284
  If you develop a new program, and you want it to be of the greatest
285
possible use to the public, the best way to achieve this is to make it
286
free software which everyone can redistribute and change under these terms.
287

  
288
  To do so, attach the following notices to the program.  It is safest
289
to attach them to the start of each source file to most effectively
290
convey the exclusion of warranty; and each file should have at least
291
the "copyright" line and a pointer to where the full notice is found.
292

  
293
    <one line to give the program's name and a brief idea of what it does.>
294
    Copyright (C) <year>  <name of author>
295

  
296
    This program is free software; you can redistribute it and/or modify
297
    it under the terms of the GNU General Public License as published by
298
    the Free Software Foundation; either version 2 of the License, or
299
    (at your option) any later version.
300

  
301
    This program is distributed in the hope that it will be useful,
302
    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
    GNU General Public License for more details.
305

  
306
    You should have received a copy of the GNU General Public License
307
    along with this program; if not, write to the Free Software
308
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
309

  
310

  
311
Also add information on how to contact you by electronic and paper mail.
312

  
313
If the program is interactive, make it output a short notice like this
314
when it starts in an interactive mode:
315

  
316
    Gnomovision version 69, Copyright (C) year name of author
317
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
    This is free software, and you are welcome to redistribute it
319
    under certain conditions; type `show c' for details.
320

  
321
The hypothetical commands `show w' and `show c' should show the appropriate
322
parts of the General Public License.  Of course, the commands you use may
323
be called something other than `show w' and `show c'; they could even be
324
mouse-clicks or menu items--whatever suits your program.
325

  
326
You should also get your employer (if you work as a programmer) or your
327
school, if any, to sign a "copyright disclaimer" for the program, if
328
necessary.  Here is a sample; alter the names:
329

  
330
  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331
  `Gnomovision' (which makes passes at compilers) written by James Hacker.
332

  
333
  <signature of Ty Coon>, 1 April 1989
334
  Ty Coon, President of Vice
335

  
336
This General Public License does not permit incorporating your program into
337
proprietary programs.  If your program is a subroutine library, you may
338
consider it more useful to permit linking proprietary applications with the
339
library.  If this is what you want to do, use the GNU Library General
340
Public License instead of this License.
tags/extensions/org.gvsig.datalocator/2.0/doc/install.txt
1
Plugin de Localizaci?n por atributo para gvSIG. Instrucciones de instalaci?n
2

  
3
- Copiar el contenido de la carpeta bin/ en:
4
  gvSIG/extensiones/
5

  
tags/extensions/org.gvsig.datalocator/2.0/doc/version_history.txt
1
Location by attribute Plugin for gvSIG. Version history
2

  
3
This document lists the Change History of release versions of the Location by attribute
4
Plugin for gvSIG
5

  
6

  
7
Version 0.1
8
Release Date: 27-06-2005
9

  
10
- Baseline version
11

  
12

  
13
Version 0.2
14
Release Date: 27-07-2005
15

  
16
- Soporte multilenguaje
17

  
18
- Implementaci?n con capas raster
19

  
20
- Di?logos adaptados a Windows y a Linux
21

  
22
- Correcci?n de bugs
23

  
tags/extensions/org.gvsig.datalocator/2.0/src/org/gvsig/datalocator/gui/DataSelectionPanel.java
1
/*
2
 * Created on 22-jun-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package org.gvsig.datalocator.gui;
45

  
46
import java.awt.FlowLayout;
47
import java.awt.event.ItemListener;
48
import java.util.Comparator;
49
import java.util.Date;
50
import java.util.TreeSet;
51
import java.util.Vector;
52
import java.util.prefs.Preferences;
53

  
54
import javax.swing.DefaultComboBoxModel;
55
import javax.swing.JButton;
56
import javax.swing.JCheckBox;
57
import javax.swing.JComboBox;
58
import javax.swing.JDialog;
59
import javax.swing.JLabel;
60
import javax.swing.JOptionPane;
61
import javax.swing.JPanel;
62

  
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65

  
66
import org.gvsig.andami.PluginServices;
67
import org.gvsig.andami.ui.mdiManager.IWindow;
68
import org.gvsig.andami.ui.mdiManager.IWindowListener;
69
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
70
import org.gvsig.andami.ui.mdiManager.WindowInfo;
71
import org.gvsig.app.ApplicationLocator;
72
import org.gvsig.datalocator.DataLocatorExtension;
73
import org.gvsig.fmap.dal.exception.DataException;
74
import org.gvsig.fmap.dal.feature.Feature;
75
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
76
import org.gvsig.fmap.dal.feature.FeatureQuery;
77
import org.gvsig.fmap.dal.feature.FeatureSelection;
78
import org.gvsig.fmap.dal.feature.FeatureSet;
79
import org.gvsig.fmap.dal.feature.FeatureStore;
80
import org.gvsig.fmap.geom.primitive.Envelope;
81
import org.gvsig.fmap.mapcontext.MapContext;
82
import org.gvsig.fmap.mapcontext.layers.CancelationException;
83
import org.gvsig.fmap.mapcontext.layers.FLayer;
84
import org.gvsig.fmap.mapcontext.layers.FLayers;
85
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
86
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
87
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent;
88
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
89
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection;
90
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
91
import org.gvsig.fmap.mapcontext.rendering.strategies.SelectedZoomVisitor;
92
import org.gvsig.tools.dispose.DisposableIterator;
93
import org.gvsig.tools.dispose.DisposeUtils;
94
import org.gvsig.tools.evaluator.Evaluator;
95
import org.gvsig.tools.evaluator.EvaluatorData;
96
import org.gvsig.tools.evaluator.EvaluatorException;
97
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
98

  
99

  
100
/**
101
 * @author jmorell
102
 */
103
public class DataSelectionPanel extends JPanel implements IWindow, IWindowListener, SingletonWindow {
104

  
105
	private static final long serialVersionUID = 1L;
106
	
107
	private static final Logger logger =
108
        LoggerFactory.getLogger(DataSelectionPanel.class);
109
            
110
    private JComboBox layerComboBox = null;
111
	private JLabel jLabel = null; 
112
	private JLabel jLabel1 = null; 
113
	private JComboBox fieldValueComboBox = null;
114
	private JLabel jLabel2 = null;  
115
	private JComboBox fieldNameComboBox = null;
116
    private WindowInfo viewInfo = null;
117
	private JButton jButton = null;
118
	private JButton jButton1 = null;
119
	private FLayer layerToZoom = null;
120
	private int fieldToZoomIndex = 0;
121
	private Object itemToZoom = null;
122
	private MapContext mapContext = null;
123
	private Preferences prefUsuario = null;
124
	private Vector<LayersListener> layersListenerList = new Vector<LayersListener>();
125
    private Vector<FLayer> vectorialLayers = null;
126
	private JCheckBox jChkBoxOpenFirstTime = null;
127
	private JPanel jPanelButtons = null;
128

  
129
	/**
130
	 * This method initializes
131
	 *
132
	 */
133
	public DataSelectionPanel(MapContext mapContext) {
134
		super();
135
		this.mapContext = mapContext;
136
		prefUsuario = Preferences.userRoot();
137
		initializeVectorialLayers();
138
        initializeLayerToZoom();
139
		initializeFieldToZoomIndex();
140
        initialize();
141

  
142
        int userOpen = prefUsuario.getInt("gvSIG.DataLocator.open_first_time", -1);
143
        if (userOpen == 1)
144
        	getJChkBoxOpenFirstTime().setSelected(true);
145
	}
146
    private void initializeVectorialLayers() {
147
    	unregisterLayersListener();
148
        vectorialLayers = new Vector<FLayer>();
149
        LayersIterator iter = DataLocatorExtension.newValidLayersIterator(mapContext.getLayers());
150

  
151

  
152
        while (iter.hasNext()) {
153
        	vectorialLayers.add(iter.nextLayer());
154
        }
155

  
156
        registerLayersListener();
157
    }
158
	private void initializeLayerToZoom() {
159
		String layerName = prefUsuario.get("LAYERNAME_FOR_DATA_LOCATION", "");
160
        if (layerName.equals("")) layerToZoom = (FLayer)vectorialLayers.get(0);
161
        boolean layerFound = false;
162
        for (int i=0;i<vectorialLayers.size();i++) {
163
            if (((FLayer)vectorialLayers.get(i)).getName().equals(layerName)) {
164
                layerFound = true;
165
                layerToZoom = (FLayer)vectorialLayers.get(i);
166
                break;
167
            }
168
        }
169
        if (!layerFound) layerToZoom = (FLayer)vectorialLayers.get(0);
170
        prefUsuario.put("LAYERNAME_FOR_DATA_LOCATION", layerToZoom.getName());
171

  
172
	}
173
	private void initializeFieldToZoomIndex() {
174
        fieldToZoomIndex = prefUsuario.getInt("FIELDINDEX_FOR_DATA_LOCATION", 0);
175
		FLyrVect lyr = (FLyrVect)layerToZoom;
176
		FeatureStore featureStore;
177
        try {
178
            featureStore = lyr.getFeatureStore();
179
            if (fieldToZoomIndex > (featureStore.getDefaultFeatureType().size()-1)) {
180
            	fieldToZoomIndex = 0;
181
            } else if (featureStore.getDefaultFeatureType().size() == 0) {
182
            	fieldToZoomIndex = -1;
183
            }
184
        } catch (DataException e) {
185
			fieldToZoomIndex = -1;
186
            e.printStackTrace();
187
		}
188
	}
189
	/**
190
	 * This method initializes this
191
	 *
192
	 * @return void
193
	 */
194
	private void initialize() {
195
        jLabel2 = new JLabel();
196
        jLabel1 = new JLabel();
197
        jLabel = new JLabel();
198
        this.setLayout(null);
199
        this.setSize(350, 161);
200
        jLabel.setBounds(6, 6, 80, 23);
201
        jLabel.setText(PluginServices.getText(this,"Capa") + ":");
202
        jLabel1.setBounds(6, 34, 80, 23);
203
        jLabel1.setText(PluginServices.getText(this,"Campo") + ":");
204
        jLabel2.setBounds(6, 61, 80, 23);
205
        jLabel2.setText(PluginServices.getText(this,"Valor") + ":");
206
        this.add(getJComboBox(), null);
207
        this.add(jLabel, null);
208
        this.add(jLabel1, null);
209
        this.add(getJComboBox1(), null);
210
        this.add(jLabel2, null);
211
        this.add(getJComboBox2(), null);
212

  
213
        jPanelButtons = new JPanel();
214
        FlowLayout flowLayor = new FlowLayout(FlowLayout.RIGHT);
215
        flowLayor.setHgap(5);
216

  
217
        jPanelButtons.setLayout(flowLayor);
218
        jPanelButtons.setBounds(15,121,335,35);
219
        jPanelButtons.add(getJButton(), null);
220
        jPanelButtons.add(getJButton1(), null);
221

  
222
        this.add(jPanelButtons);
223

  
224
        this.add(getJChkBoxOpenFirstTime(), null);
225

  
226

  
227
	}
228
	private void registerLayersListener() {
229
		int i,j;
230
		FLayer layer;
231
		LayersListener listener;
232
		boolean found;
233
		for (i=0;i< vectorialLayers.size();i++) {
234
			found = false;
235
			layer = ((FLayer)vectorialLayers.get(i));
236
			for (j=0;j < layersListenerList.size(); j++) {
237
				listener = (LayersListener)layersListenerList.get(j);
238
				if ( layer.getParentLayer() == listener.getLayerCollection()) {
239
					found = true;
240
					break;
241
				}
242
			}
243
			if (!found) {
244
				listener = new LayersListener(layer.getParentLayer());
245
				layer.getParentLayer().addLayerCollectionListener(listener);
246
				layersListenerList.add(listener);
247
			}
248

  
249
		}
250
	}
251

  
252

  
253
	private void unregisterLayersListener() {
254
		int i;
255
		LayersListener listener;
256
		for (i=0;i<layersListenerList.size();i++) {
257
			listener = (LayersListener)layersListenerList.get(i);
258
			listener.getLayerCollection().removeLayerCollectionListener(listener);
259
		}
260
	}
261

  
262
	private String[] getLayerNames() {
263
		String[] layerNames = new String[vectorialLayers.size()];
264
	    for (int i=0;i<vectorialLayers.size();i++) {
265
	        layerNames[i] = ((FLayer)vectorialLayers.get(i)).getName();
266
	    }
267
	    return layerNames;
268
	}
269
	private String[] getFieldNames() {
270
		FLyrVect lyr = (FLyrVect)layerToZoom;
271
		FeatureStore featureStore;
272
        String[] fieldNames = null;
273
		try {
274
            featureStore = lyr.getFeatureStore();
275
			fieldNames = new String[featureStore.getDefaultFeatureType().size()];
276
			for (int i = 0; i < featureStore.getDefaultFeatureType().size(); i++) {
277
				fieldNames[i] = ((FeatureAttributeDescriptor)featureStore.getDefaultFeatureType().get(i)).getName();
278
			}
279
        } catch (DataException e) {
280
			e.printStackTrace();
281
		}
282
		return fieldNames;
283
	}
284

  
285

  
286
	private Object[] getNewValues() {
287
		FLyrVect lyr = (FLyrVect)layerToZoom;
288
		FeatureStore featureStore;
289
		Object[] newValues = null;
290
		if (fieldToZoomIndex < 0)
291
			return null;
292
		FeatureSet set = null;
293
		DisposableIterator features = null;
294

  
295
		try {
296
			featureStore = lyr.getFeatureStore();
297

  
298
//		String sql = "select " + ((FeatureAttributeDescriptor)featureStore.getDefaultFeatureType().get(fieldToZoomIndex)).getName() + " from " + featureStore.getName() + " where " + featureStore.getFieldName(fieldToZoomIndex) + " is not null;";
299
			FeatureQuery query = featureStore.createFeatureQuery();
300
			String field =
301
					((FeatureAttributeDescriptor) featureStore.getDefaultFeatureType()
302
							.get(fieldToZoomIndex)).getName();
303
			Evaluator myEvaluator = new MyEvaluator(field);
304
			query.setFilter(myEvaluator);
305
			query.setAttributeNames(new String[] { field });
306
			set = featureStore.getFeatureSet(query);
307
			// ds = ds.getDataSourceFactory().executeSQL(sql,
308
			// DataSourceFactory.AUTOMATIC_OPENING);
309

  
310
			// Quitar los nombres repetidos y ordenarlos
311
			TreeSet<Object> treeSet =
312
					new TreeSet<Object>(new Comparator<Object>() {
313
						public int compare(Object o1, Object o2) {
314
							if (o1 instanceof Number && o2 instanceof Number) {
315
								if (((Number) o1).doubleValue() < ((Number) o2).doubleValue())
316
									return -1;
317
								if (((Number) o1).doubleValue() > ((Number) o2).doubleValue())
318
									return 1;
319
							} else if (o1 instanceof String
320
									&& o2 instanceof String) {
321
								return ((String) o1).compareTo((String) o2);
322
							} else if (o1 instanceof Date && o2 instanceof Date) {
323
								return ((Date) o1).compareTo((Date) o2);
324
							}
325
							return 0;
326
				}
327
					});
328
			features = set.iterator();
329
			while (features.hasNext()) {
330
				Feature feature = (Feature) features.next();
331
				Object obj = feature.get(0);
332
				treeSet.add(obj);
333
			}
334
			newValues = (Object[]) treeSet.toArray(new Object[0]);
335
		} catch (DataException e) {
336
			e.printStackTrace();
337
		} finally {
338
			if (features != null) {
339
				features.dispose();
340
			}
341
			if (set != null) {
342
				set.dispose();
343
			}
344
		}
345
		return newValues;
346
	}
347
	private class LayersListener implements LayerCollectionListener {
348
		private LayerCollection theLayerCollection;
349
	    public LayersListener(FLayers layers){
350
	    	theLayerCollection = layers;
351
	    }
352

  
353
	    public LayerCollection getLayerCollection() {
354
	    	return theLayerCollection;
355
	    }
356
        /* (non-Javadoc)
357
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdded(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
358
         */
359
        public void layerAdded(LayerCollectionEvent e) {
360
            initializeVectorialLayers();
361
            ((ChangeLayerToZoomItemListener)layerComboBox.getItemListeners()[0]).setLayers(vectorialLayers);
362
            layerComboBox.removeAllItems();
363
		    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getLayerNames());
364
		    layerComboBox.setModel(defaultModel);
365
			layerComboBox.setSelectedItem(layerToZoom.getName());
366
        }
367
        /* (non-Javadoc)
368
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoved(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
369
         */
370
        public void layerRemoved(LayerCollectionEvent e) {
371
            initializeVectorialLayers();
372
            ((ChangeLayerToZoomItemListener)layerComboBox.getItemListeners()[0]).setLayers(vectorialLayers);
373
		    if (vectorialLayers.size()>0) {
374
	            layerComboBox.removeAllItems();
375
				String[] layerNames = new String[vectorialLayers.size()];
376
			    boolean currentLayerRemoved = true;
377
				for (int i=0;i<vectorialLayers.size();i++) {
378
			        layerNames[i] = ((FLayer)vectorialLayers.get(i)).getName();
379
			        if (layerToZoom.getName().equals(layerNames[i])) currentLayerRemoved = false;
380
			    }
381
			    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(layerNames);
382
			    layerComboBox.setModel(defaultModel);
383
			    if (currentLayerRemoved) {
384
			        layerToZoom = ((FLayer)vectorialLayers.get(0));
385
	    			defaultModel = new DefaultComboBoxModel(getFieldNames());
386
	    		    fieldValueComboBox.setModel(defaultModel);
387
	    		    fieldToZoomIndex = 0;
388
	    		    fieldValueComboBox.setSelectedIndex(fieldToZoomIndex);
389
	    		    Object[] values =getNewValues();
390
	    			defaultModel = new DefaultComboBoxModel(values);
391
	    			fieldNameComboBox.setModel(defaultModel);
392
	    			if (values != null) {
393
	    				itemToZoom = getNewValues()[0];
394
	    				fieldNameComboBox.setSelectedItem(itemToZoom);
395
	    			}else {
396
	    				itemToZoom = null;
397
	    			}
398

  
399
			    }
400
			    layerComboBox.setSelectedItem(layerToZoom.getName());
401
		    }else {
402
            	if (PluginServices.getMainFrame() == null)
403
            		((JDialog) (getParent().getParent().getParent().getParent())).dispose();
404
            	else
405
            		PluginServices.getMDIManager().closeWindow(DataSelectionPanel.this);
406
		    }
407
        }
408
        /* (non-Javadoc)
409
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoved(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
410
         */
411
        public void layerMoved(LayerPositionEvent e) {
412
            // TODO Auto-generated method stub
413

  
414
        }
415
        /* (non-Javadoc)
416
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdding(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
417
         */
418
        public void layerAdding(LayerCollectionEvent e) throws CancelationException {
419
            // TODO Auto-generated method stub
420

  
421
        }
422
        /* (non-Javadoc)
423
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoving(com.iver.cit.gvsig.fmap.layers.LayerPositionEvent)
424
         */
425
        public void layerMoving(LayerPositionEvent e) throws CancelationException {
426
            // TODO Auto-generated method stub
427

  
428
        }
429
        /* (non-Javadoc)
430
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoving(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
431
         */
432
        public void layerRemoving(LayerCollectionEvent e) throws CancelationException {
433
            // TODO Auto-generated method stub
434

  
435
        }
436
        /* (non-Javadoc)
437
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#activationChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
438
         */
439
        public void activationChanged(LayerCollectionEvent e) throws CancelationException {
440
            // TODO Auto-generated method stub
441

  
442
        }
443
        /* (non-Javadoc)
444
         * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#visibilityChanged(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
445
         */
446
        public void visibilityChanged(LayerCollectionEvent e) throws CancelationException {
447
            // TODO Auto-generated method stub
448

  
449
        }
450
	}
451
    /* (non-Javadoc)
452
     * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
453
     */
454
    public WindowInfo getWindowInfo() {
455
        if (viewInfo == null) {
456
            viewInfo=new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.PALETTE);
457
            viewInfo.setTitle(PluginServices.getText(this,"Localizador_por_atributo"));
458
            viewInfo.setHeight(getPreferredSize().height);
459
            viewInfo.setWidth(getPreferredSize().width);
460
        }
461
        return viewInfo;
462
    }
463
	/**
464
	 * This method initializes jComboBox
465
	 *
466
	 * @return javax.swing.JComboBox
467
	 */
468
	private JComboBox getJComboBox() {
469
		if (layerComboBox == null) {
470
			layerComboBox = new JComboBox();
471
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getLayerNames());
472
            layerComboBox.setModel(defaultModel);
473
			layerComboBox.setBounds(90, 6, 250, 23);
474
			layerComboBox.setSelectedItem(layerToZoom.getName());
475
			ChangeLayerToZoomItemListener changeLayerToZoomItemListener = new ChangeLayerToZoomItemListener(vectorialLayers);
476
			layerComboBox.addItemListener(changeLayerToZoomItemListener);
477
		}
478
		return layerComboBox;
479
	}
480
	private class ChangeLayerToZoomItemListener implements ItemListener {
481
	    private Vector<FLayer> layers;
482
	    public ChangeLayerToZoomItemListener(Vector<FLayer> layers) {
483
	        this.layers = layers;
484
	    }
485
		public void itemStateChanged(java.awt.event.ItemEvent e) {
486
		    if (layerComboBox.getItemCount()>0) {
487
                for (int i=0;i<layers.size();i++) {
488
                    if (((FLayer)layers.get(i)).getName().equals((String)layerComboBox.getSelectedItem())) {
489
                        layerToZoom = (FLayer)layers.get(i);
490
                        break;
491
                    }
492
                }
493
    			fieldToZoomIndex = 0;
494
				prefUsuario.put("LAYERNAME_FOR_DATA_LOCATION", (String)layerComboBox.getSelectedItem());
495
    		    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames());
496
    		    fieldValueComboBox.setModel(defaultModel);
497
    		    Object[] values =getNewValues();
498
    		    defaultModel = new DefaultComboBoxModel(values);
499
    			fieldNameComboBox.setModel(defaultModel);
500
    			if ( values != null) {
501
    				fieldNameComboBox.setSelectedIndex(0);
502
    				itemToZoom = values[0];
503
    			} else {
504
    				itemToZoom = null;
505
    			}
506
		    }
507
		}
508
        /**
509
         * @param layers The layers to set.
510
         */
511
        public void setLayers(Vector<FLayer> layers) {
512
            this.layers = layers;
513
        }
514
	}
515
	/**
516
	 * This method initializes jComboBox1
517
	 *
518
	 * @return javax.swing.JComboBox
519
	 */
520
	private JComboBox getJComboBox1() {
521
		if (fieldValueComboBox == null) {
522
			fieldValueComboBox = new JComboBox();
523
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames());
524
            fieldValueComboBox.setModel(defaultModel);
525
			fieldValueComboBox.setBounds(90, 34, 250, 23);
526
			fieldValueComboBox.setSelectedIndex(fieldToZoomIndex);
527
			ChangeFieldItemListener changeFieldItemListener = new ChangeFieldItemListener(vectorialLayers);
528
			fieldValueComboBox.addItemListener(changeFieldItemListener);
529
		}
530
		return fieldValueComboBox;
531
	}
532
	private class ChangeFieldItemListener implements ItemListener {
533
		public ChangeFieldItemListener(Vector<FLayer> layers) {
534
		}
535
		public void itemStateChanged(java.awt.event.ItemEvent itemEvent) {
536
			String fieldToZoom = ((String)fieldValueComboBox.getSelectedItem());
537
			FLyrVect lyr = (FLyrVect)layerToZoom;
538
			FeatureStore featureStore;
539
			FeatureSet set = null;
540
			DisposableIterator features = null;
541
			try {
542
				featureStore = lyr.getFeatureStore();				
543
				prefUsuario.putInt("FIELDINDEX_FOR_DATA_LOCATION", fieldToZoomIndex);
544

  
545
				//Quitar los nombres repetidos y ordenarlos
546
				TreeSet<Object> treeSet = new TreeSet<Object>(new Comparator<Object>() {
547
					public int compare(Object o1, Object o2) {
548
						if (o1 instanceof Number && o2 instanceof Number){
549
							if (((Number)o1).doubleValue()<((Number)o2).doubleValue())
550
								return -1;
551
							if (((Number)o1).doubleValue()>((Number)o2).doubleValue())
552
								return 1;
553
						}else if (o1 instanceof String && o2 instanceof String){
554
							return ((String)o1).compareTo((String)o2);
555
						}else if (o1 instanceof Date && o2 instanceof Date){
556
							return ((Date)o1).compareTo((Date)o2);
557
						}
558
						return 0;
559
					}
560
				});
561

  
562
				Evaluator myEvaluator = new MyEvaluator(fieldToZoom);
563
				FeatureQuery query = featureStore.createFeatureQuery();
564
				query.setFilter(myEvaluator);	
565
				set = featureStore.getFeatureSet(query);
566
				features = set.fastIterator();
567
				int index = set.getDefaultFeatureType().getAttributeDescriptor(fieldToZoom).getIndex();
568
				while (features.hasNext()) {
569
					Feature feature = (Feature) features.next();		
570
					treeSet.add(feature.get(index));
571
				}
572
				Object[] newValues = (Object[])treeSet.toArray(new Object[0]);
573
				DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(newValues);
574
				fieldNameComboBox.setModel(defaultModel);
575
				if (newValues.length>0) fieldNameComboBox.setSelectedIndex(0);
576
				if (newValues.length>0) {
577
					itemToZoom = newValues[0];
578
				} else {
579
					itemToZoom = null;
580
				}
581
			} catch (DataException e) {
582
				e.printStackTrace();
583
			} finally {
584
				if (features != null) {
585
					features.dispose();
586
				}
587
				if (set != null) {
588
					set.dispose();
589
				}
590
			}
591
		}
592
	}
593
	/**
594
	 * This method initializes jComboBox2
595
	 *
596
	 * @return javax.swing.JComboBox
597
	 */
598
	private JComboBox getJComboBox2() {
599
		if (fieldNameComboBox == null) {
600
			fieldNameComboBox = new JComboBox();
601
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getNewValues());
602
            fieldNameComboBox.setModel(defaultModel);
603
			fieldNameComboBox.setSelectedIndex(-1);
604
			fieldNameComboBox.setBounds(90, 61, 250, 23);
605
			ChangeItemToZoomItemListener changeItemToZoomItemListener = new ChangeItemToZoomItemListener(vectorialLayers);
606
			fieldNameComboBox.addItemListener(changeItemToZoomItemListener);
607
		}
608
		return fieldNameComboBox;
609
	}
610
	private class ChangeItemToZoomItemListener implements ItemListener {
611
	    private Vector<FLayer> layers;
612
	    public ChangeItemToZoomItemListener(Vector<FLayer> layers) {
613
	        this.layers = layers;
614
	    }
615
		public void itemStateChanged(java.awt.event.ItemEvent e) {
616
            for (int i=0;i<layers.size();i++) {
617
                if (((FLayer)layers.get(i)).getName().equals((String)layerComboBox.getSelectedItem())) {
618
                    layerToZoom = (FLayer)layers.get(i);
619
                    break;
620
                }
621
            }
622
			itemToZoom = ((Object)fieldNameComboBox.getSelectedItem());
623
		}
624
	}
625
	/**
626
	 * This method initializes jButton
627
	 *
628
	 * @return javax.swing.JButton
629
	 */
630
	private JButton getJButton() {
631
		if (jButton == null) {
632
			jButton = new JButton();
633
			//jButton.setBounds(8, 121, 128, 23);
634
			jButton.setText(PluginServices.getText(this,"Zoom"));
635
			jButton.addActionListener(new java.awt.event.ActionListener() {
636
				public void actionPerformed(java.awt.event.ActionEvent e) {
637
					if (layerToZoom == null || fieldToZoomIndex < 0 || itemToZoom == null)
638
						return;
639
				    if (fieldNameComboBox.getSelectedIndex()!=-1) {
640
						FLyrVect lyr = (FLyrVect)layerToZoom;
641
						FeatureStore featureStore;
642
						FeatureSet featureSet = null;
643
						DisposableIterator features = null;
644
						try {
645
			                featureStore = lyr.getFeatureStore();
646
							FeatureSelection selection = (FeatureSelection)featureStore.createFeatureSelection();
647
							featureSet = featureStore.getFeatureSet();
648
							features = featureSet.fastIterator();
649
							String fieldToZoom = ((String)fieldValueComboBox.getSelectedItem());
650
						    int index = featureSet.getDefaultFeatureType().getAttributeDescriptor(fieldToZoom).getIndex();
651
				         
652
							while (features.hasNext()) {
653
								Feature feature = (Feature) features.next();
654
								if (itemToZoom.equals(feature.get(index))){
655
									selection.select(feature);
656
								}
657
							}
658
							// featureStore.setSelection(selection);
659
							SelectedZoomVisitor visitor = new SelectedZoomVisitor();
660
	                        selection.accept(visitor);
661
	                        Envelope env_data = visitor.getSelectBound();
662
	                        
663
	                        if (lyr.getCoordTrans() != null) {
664
	                            env_data = env_data.convert(lyr.getCoordTrans());
665
	                        }
666
	                        
667
							mapContext.getViewPort().setEnvelope(env_data);
668

  
669
			            } catch (Exception e1) {
670
			                logger.debug("While doing zoom: " + e1.getMessage(), e1);
671
			                ApplicationLocator.getManager().message(
672
			                    "While doing zoom: " + e1.getMessage(),
673
			                    JOptionPane.ERROR_MESSAGE);
674
			                
675
						} finally {
676
							DisposeUtils.dispose(featureSet);
677
							DisposeUtils.dispose(features);
678
						}
679
                    } else if (itemToZoom == null) {
680
                        logger.debug("Localizador por atributo: El campo valor debe tener elementos no nulos para hacer el Zoom.");
681
                    } else {
682
                        logger.debug("Localizador por atributo: El campo valor debe estar inicializado antes de hacer Zoom.");
683
				    }
684
				}
685
			});
686
		}
687
		return jButton;
688
	}
689
	/**
690
	 * This method initializes jButton1
691
	 *
692
	 * @return javax.swing.JButton
693
	 */
694
	private JButton getJButton1() {
695
		if (jButton1 == null) {
696
			jButton1 = new JButton();
697
			//jButton1.setBounds(141, 121, 128, 23);
698
			jButton1.setText(PluginServices.getText(this,"Salir"));
699
			jButton1.addActionListener(new java.awt.event.ActionListener() {
700
				public void actionPerformed(java.awt.event.ActionEvent e) {
701
	            	if (PluginServices.getMainFrame() == null)
702
	            		((JDialog) (getParent().getParent().getParent().getParent())).dispose();
703
	            	else
704
	            		PluginServices.getMDIManager().closeWindow(DataSelectionPanel.this);
705
				}
706
			});
707
		}
708
		return jButton1;
709
	}
710
    /* (non-Javadoc)
711
     * @see com.iver.andami.ui.mdiManager.ViewListener#viewActivated()
712
     */
713
    public void windowActivated() {
714
        // TODO Auto-generated method stub
715

  
716
    }
717
    /* (non-Javadoc)
718
     * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
719
     */
720
    public void windowClosed() {
721
		unregisterLayersListener();
722
		// Guardamos la posici?n en las preferencias del usuario.
723
		WindowInfo vi = PluginServices.getMDIManager().getWindowInfo(this);
724
		prefUsuario.putInt("gvSIG.DataLocator.x", vi.getX());
725
		prefUsuario.putInt("gvSIG.DataLocator.y", vi.getY());
726
		prefUsuario.putInt("gvSIG.DataLocator.w", vi.getWidth());
727
		prefUsuario.putInt("gvSIG.DataLocator.h", vi.getHeight());
728
		vi.setClosed(true);
729
    }
730
    /* (non-Javadoc)
731
     * @see com.iver.andami.ui.mdiManager.SingletonView#getViewModel()
732
     */
733
    public Object getWindowModel() {
734
        // Debe devolver una cadena. Mirar Console del CorePlugin
735
        return "DataSelectionPanel";
736
    }
737
	/**
738
	 * This method initializes jChkBoxOpenFirstTime
739
	 *
740
	 * @return javax.swing.JCheckBox
741
	 */
742
	private JCheckBox getJChkBoxOpenFirstTime() {
743
		if (jChkBoxOpenFirstTime == null) {
744
			jChkBoxOpenFirstTime = new JCheckBox();
745
			jChkBoxOpenFirstTime.setBounds(new java.awt.Rectangle(90,89,179,23));
746
			jChkBoxOpenFirstTime.setText(PluginServices.getText(this, "open_first_time"));
747
			jChkBoxOpenFirstTime.addActionListener(new java.awt.event.ActionListener() {
748
				public void actionPerformed(java.awt.event.ActionEvent e) {
749
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
750
					if (jChkBoxOpenFirstTime.isSelected())
751
					{
752
						prefUsuario.putInt("gvSIG.DataLocator.open_first_time",1);
753
					}
754
					else
755
					{
756
						prefUsuario.putInt("gvSIG.DataLocator.open_first_time",0);
757
					}
758
				}
759
			});
760
		}
761
		return jChkBoxOpenFirstTime;
762
	}
763
	public Object getWindowProfile() {
764
		return WindowInfo.TOOL_PROFILE;
765
	}
766
	class MyEvaluator implements Evaluator{
767
		private String name=null;
768
		private EvaluatorFieldsInfo info = null;
769

  
770
		public MyEvaluator(String name){
771
			this.name=name;
772
			info = new EvaluatorFieldsInfo();
773
			this.info.addFieldValue(name);
774
		}
775

  
776
		public Object evaluate(EvaluatorData data)
777
				throws EvaluatorException {
778
			Feature feature = (Feature) data.getContextValue("feature");
779
			if (feature.get(name)!=null)
780
				return new Boolean(true);
781
			return new Boolean(false);
782
		}
783

  
784
		public String getSQL() {
785
			return name + " is not null";
786
		}
787

  
788
		public String getDescription() {
789
			return "Evaluates if a field is not null";
790
		}
791

  
792
		public EvaluatorFieldsInfo getFieldsInfo() {
793
			return this.info;
794
		}
795

  
796
		public String getName() {
797
			return this.getClass().getName();
798
		}
799

  
800
    }
801
}  //  @jve:decl-index=0:visual-constraint="10,10"
tags/extensions/org.gvsig.datalocator/2.0/src/org/gvsig/datalocator/DataLocatorExtension.java
1
/*
2
 * Created on 22-jun-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package org.gvsig.datalocator;
45

  
46
import java.util.prefs.Preferences;
47

  
48
import org.gvsig.andami.IconThemeHelper;
49
import org.gvsig.andami.PluginServices;
50
import org.gvsig.andami.plugins.Extension;
51
import org.gvsig.andami.ui.mdiManager.IWindow;
52
import org.gvsig.andami.ui.mdiManager.WindowInfo;
53
import org.gvsig.app.project.documents.view.ViewDocument;
54
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
55
import org.gvsig.datalocator.gui.DataSelectionPanel;
56
import org.gvsig.fmap.dal.feature.FeatureStore;
57
import org.gvsig.fmap.mapcontext.MapContext;
58
import org.gvsig.fmap.mapcontext.layers.FLayer;
59
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
60
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection;
61
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
62

  
63

  
64
/**
65
 * The DataLocatorExtension class allows to make a quick zoom based on an
66
 * alphanumeric attribute.
67
 *
68
 * @author jmorell
69
 */
70
public class DataLocatorExtension extends Extension {
71

  
72
	IWindow iWDataSelection = null;
73
	IWindow previousView = null;
74

  
75
    /* (non-Javadoc)
76
     * @see com.iver.andami.plugins.Extension#inicializar()
77
     */
78
    public void initialize() {
79
    	registerIcons();
80

  
81
    }
82

  
83
    private void registerIcons(){
84
    	IconThemeHelper.registerIcon("action", "view-navigation-locator-by-attribute", this);
85
    }
86

  
87
    /* (non-Javadoc)
88
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
89
     */
90
    public void execute(String actionCommand) {
91
    	if( "view-navigation-locator-by-attribute".equalsIgnoreCase(actionCommand))  {
92
			DefaultViewPanel vista = (DefaultViewPanel)PluginServices.getMDIManager().getActiveWindow();
93
			MapContext mapContext = vista.getViewDocument().getMapContext();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff