Revision 37425

View differences:

tags/v2_0_0_Build_2042/frameworks/_fwAndami/castor.properties
1
org.exolab.castor.indent=true
0 2

  
tags/v2_0_0_Build_2042/frameworks/_fwAndami/compile-classpath.xml
1
<project name="_fwAndami.compile-classpath" basedir=".">
2
	<!-- defines the classpath to be used for batch-compilation -->
3
	<property name="andami" location="../_fwAndami"/>
4
	<property name="andamiLibs" location="${andami}/lib"/>
5
	<path id="_fwAndami.compile-classpath">
6
	    <pathelement location="${andamiLibs}/beans.jar"/>
7
   	    <pathelement location="${andamiLibs}/castor-0.9.5.3-xml.jar"/>
8
  	    <pathelement location="${andamiLibs}/gvsig-i18n.jar"/>
9
	    <pathelement location="${andamiLibs}/iver-utiles.jar"/>
10
	    <pathelement location="${andamiLibs}/javaws.jar"/>
11
	    <pathelement location="${andamiLibs}/JWizardComponent.jar"/>
12
	    <pathelement location="${andamiLibs}/log4j-1.2.8.jar"/>
13
	    <pathelement location="${andamiLibs}/tempFileManager.jar"/>
14
	    <pathelement location="${andamiLibs}/xercesImpl.jar"/>
15
	    <pathelement location="${andamiLibs}/xml-apis.jar"/>
16
	    <pathelement location="${andamiLibs}/kxml2.jar"/>
17
	    <pathelement location="${andamiLibs}/jcalendar.jar"/>
18
	</path>
19
</project>
0 20

  
tags/v2_0_0_Build_2042/frameworks/_fwAndami/src/iso_639.tab
1

  
2
## iso-639.tab
3
##
4
## Copyright (C) 2005 Alastair McKinstry   <mckinstry@computer.org> 
5
## Released under the GNU License; see file COPYING for details
6
##
7
## PLEASE NOTE: THIS FILE IS DEPRECATED AND SCHEDULED TO BE REMOVED.
8
## IT IS FOR BACKWARD-COMPATIBILITY ONLY: PLEASE USE THE ISO-639.XML
9
## FILE INSTEAD.
10
##
11
## This file gives a list of all languages in the ISO-639
12
## standard, and is used to provide translations (via gettext)
13
##
14
## Status: ISO 639-2:1998 + additions and changes until 2003-03-05
15
## Source: http://lcweb.loc.gov/standards/iso639-2/englangn.html
16
##
17
## Columns:
18
##   iso-639-2 terminology code
19
##   iso-639-2 bibliography code
20
##   iso-639-1 code (XX if none exists)
21
##   Name (English)
22
##
23
##
24
aar	aar	aa	Afar
25
abk	abk	ab	Abkhazian
26
ace	ace	XX	Achinese
27
ach	ach	XX	Acoli
28
ada	ada	XX	Adangme
29
ady	ady	XX	Adyghe; Adygei
30
afa	afa	XX	Afro-Asiatic (Other)
31
afh	afh	XX	Afrihili
32
afr	afr	af	Afrikaans
33
ain	ain	XX	Ainu
34
aka	aka	ak	Akan
35
akk	akk	XX	Akkadian
36
ale	ale	XX	Aleut
37
alg	alg	XX	Algonquian languages
38
alt	alt	XX	Southern Altai
39
amh	amh	am	Amharic
40
ang	ang	XX	English, Old (ca. 450-1100)
41
anp	anp	XX	Angika
42
apa	apa	XX	Apache languages
43
ara	ara	ar	Arabic
44
arc	arc	XX	Aramaic
45
arg	arg	an	Aragonese
46
arn	arn	XX	Araucanian
47
arp	arp	XX	Arapaho
48
art	art	XX	Artificial (Other)
49
arw	arw	XX	Arawak
50
asm	asm	as	Assamese
51
ast	ast	XX	Asturian; Bable
52
ath	ath	XX	Athapascan languages
53
aus	aus	XX	Australian languages
54
ava	ava	av	Avaric
55
ave	ave	ae	Avestan
56
awa	awa	XX	Awadhi
57
aym	aym	ay	Aymara
58
aze	aze	az	Azerbaijani
59
bad	bad	XX	Banda
60
bai	bai	XX	Bamileke languages
61
bak	bak	ba	Bashkir
62
bal	bal	XX	Baluchi
63
bam	bam	bm	Bambara
64
ban	ban	XX	Balinese
65
bas	bas	XX	Basa
66
bat	bat	XX	Baltic (Other)
67
bej	bej	XX	Beja
68
bel	bel	be	Belarusian
69
bem	bem	XX	Bemba
70
ben	ben	bn	Bengali
71
ber	ber	XX	Berber (Other)
72
bho	bho	XX	Bhojpuri
73
bih	bih	bh	Bihari
74
bik	bik	XX	Bikol
75
bin	bin	XX	Bini
76
bis	bis	bi	Bislama
77
bla	bla	XX	Siksika
78
bnt	bnt	XX	Bantu (Other)
79
bod	tib	bo	Tibetan
80
bos	bos	bs	Bosnian
81
bra	bra	XX	Braj
82
bre	bre	br	Breton
83
btk	btk	XX	Batak (Indonesia)
84
bua	bua	XX	Buriat
85
bug	bug	XX	Buginese
86
bul	bul	bg	Bulgarian
87
byn	byn	XX	Blin; Bilin
88
cad	cad	XX	Caddo
89
cai	cai	XX	Central American Indian (Other)
90
car	car	XX	Carib
91
cat	cat	ca	Catalan; Valencian
92
cau	cau	XX	Caucasian (Other)
93
ceb	ceb	XX	Cebuano
94
cel	cel	XX	Celtic (Other)
95
ces	cze	cs	Czech
96
cha	cha	ch	Chamorro
97
chb	chb	XX	Chibcha
98
che	che	ce	Chechen
99
chg	chg	XX	Chagatai
100
chk	chk	XX	Chuukese
101
chm	chm	XX	Mari
102
chn	chn	XX	Chinook jargon
103
cho	cho	XX	Choctaw
104
chp	chp	XX	Chipewyan
105
chr	chr	XX	Cherokee
106
chu	chu	cu	Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
107
chv	chv	cv	Chuvash
108
chy	chy	XX	Cheyenne
109
cmc	cmc	XX	Chamic languages
110
cop	cop	XX	Coptic
111
cor	cor	kw	Cornish
112
cos	cos	co	Corsican
113
cpe	cpe	XX	Creoles and pidgins, English based (Other)
114
cpf	cpf	XX	Creoles and pidgins, French-based (Other)
115
cpp	cpp	XX	Creoles and pidgins, Portuguese-based (Other)
116
cre	cre	cr	Cree
117
crh	crh	XX	Crimean Tatar; Crimean Turkish
118
crp	crp	XX	Creoles and pidgins (Other)
119
csb	csb	XX	Kashubian
120
cus	cus	XX	Cushitic (Other)
121
cym	wel	cy	Welsh
122
dak	dak	XX	Dakota
123
dan	dan	da	Danish
124
dar	dar	XX	Dargwa
125
day	day	XX	Dayak
126
del	del	XX	Delaware
127
den	den	XX	Slave (Athapascan)
128
deu	ger	de	German
129
dgr	dgr	XX	Dogrib
130
din	din	XX	Dinka
131
div	div	dv	Divehi; Dhivehi; Maldivian
132
doi	doi	XX	Dogri
133
dra	dra	XX	Dravidian (Other)
134
dsb	dsb	XX	Lower Sorbian
135
dua	dua	XX	Duala
136
dum	dum	XX	Dutch, Middle (ca. 1050-1350)
137
dyu	dyu	XX	Dyula
138
dzo	dzo	dz	Dzongkha
139
efi	efi	XX	Efik
140
egy	egy	XX	Egyptian (Ancient)
141
eka	eka	XX	Ekajuk
142
ell	gre	el	Greek, Modern (1453-)
143
elx	elx	XX	Elamite
144
eng	eng	en	English
145
enm	enm	XX	English, Middle (1100-1500)
146
epo	epo	eo	Esperanto
147
est	est	et	Estonian
148
eus	baq	eu	Basque
149
ewe	ewe	ee	Ewe
150
ewo	ewo	XX	Ewondo
151
fan	fan	XX	Fang
152
fao	fao	fo	Faroese
153
fas	per	fa	Persian
154
fat	fat	XX	Fanti
155
fij	fij	fj	Fijian
156
fil	fil	XX	Filipino; Pilipino
157
fin	fin	fi	Finnish
158
fiu	fiu	XX	Finno-Ugrian (Other)
159
fon	fon	XX	Fon
160
fra	fre	fr	French
161
frm	frm	XX	French, Middle (ca. 1400-1600)
162
fro	fro	XX	French, Old (842-ca. 1400)
163
frr	frr	XX	Northern Frisian
164
frs	frs	XX	Eastern Frisian
165
fry	fry	fy	Western Frisian
166
ful	ful	ff	Fulah
167
fur	fur	XX	Friulian
168
gaa	gaa	XX	Ga
169
gay	gay	XX	Gayo
170
gba	gba	XX	Gbaya
171
gem	gem	XX	Germanic (Other)
172
gez	gez	XX	Geez
173
gil	gil	XX	Gilbertese
174
gla	gla	gd	Gaelic; Scottish Gaelic
175
gle	gle	ga	Irish
176
glg	glg	gl	Galician
177
glv	glv	gv	Manx
178
gmh	gmh	XX	German, Middle High (ca. 1050-1500)
179
goh	goh	XX	German, Old High (ca. 750-1050)
180
gon	gon	XX	Gondi
181
gor	gor	XX	Gorontalo
182
got	got	XX	Gothic
183
grb	grb	XX	Grebo
184
grc	grc	XX	Greek, Ancient (to 1453)
185
grn	grn	gn	Guarani
186
gsw	gsw	XX	Alemanic; Swiss German
187
guj	guj	gu	Gujarati
188
gwi	gwi	XX	Gwich´in
189
hai	hai	XX	Haida
190
hat	hat	ht	Haitian; Haitian Creole
191
hau	hau	ha	Hausa
192
haw	haw	XX	Hawaiian
193
heb	heb	he	Hebrew
194
her	her	hz	Herero
195
hil	hil	XX	Hiligaynon
196
him	him	XX	Himachali
197
hin	hin	hi	Hindi
198
hit	hit	XX	Hittite
199
hmn	hmn	XX	Hmong
200
hmo	hmo	ho	Hiri Motu
201
hrv	scr	hr	Croatian
202
hsb	hsb	XX	Upper Sorbian
203
hun	hun	hu	Hungarian
204
hup	hup	XX	Hupa
205
hye	arm	hy	Armenian
206
iba	iba	XX	Iban
207
ibo	ibo	ig	Igbo
208
ido	ido	io	Ido
209
iii	iii	ii	Sichuan Yi
210
ijo	ijo	XX	Ijo
211
iku	iku	iu	Inuktitut
212
ile	ile	ie	Interlingue
213
ilo	ilo	XX	Iloko
214
ina	ina	ia	Interlingua (International Auxiliary Language Association)
215
inc	inc	XX	Indic (Other)
216
ind	ind	id	Indonesian
217
ine	ine	XX	Indo-European (Other)
218
inh	inh	XX	Ingush
219
ipk	ipk	ik	Inupiaq
220
ira	ira	XX	Iranian (Other)
221
iro	iro	XX	Iroquoian languages
222
isl	ice	is	Icelandic
223
ita	ita	it	Italian
224
jav	jav	jv	Javanese
225
jbo	jbo	XX	Lojban
226
jpn	jpn	ja	Japanese
227
jpr	jpr	XX	Judeo-Persian
228
jrb	jrb	XX	Judeo-Arabic
229
kaa	kaa	XX	Kara-Kalpak
230
kab	kab	XX	Kabyle
231
kac	kac	XX	Kachin
232
kal	kal	kl	Kalaallisut; Greenlandic
233
kam	kam	XX	Kamba
234
kan	kan	kn	Kannada
235
kar	kar	XX	Karen
236
kas	kas	ks	Kashmiri
237
kat	geo	ka	Georgian
238
kau	kau	kr	Kanuri
239
kaw	kaw	XX	Kawi
240
kaz	kaz	kk	Kazakh
241
kbd	kbd	XX	Kabardian
242
kha	kha	XX	Khasi
243
khi	khi	XX	Khoisan (Other)
244
khm	khm	km	Khmer
245
kho	kho	XX	Khotanese
246
kik	kik	ki	Kikuyu; Gikuyu
247
kin	kin	rw	Kinyarwanda
248
kir	kir	ky	Kirghiz
249
kmb	kmb	XX	Kimbundu
250
kok	kok	XX	Konkani
251
kom	kom	kv	Komi
252
kon	kon	kg	Kongo
253
kor	kor	ko	Korean
254
kos	kos	XX	Kosraean
255
kpe	kpe	XX	Kpelle
256
krc	krc	XX	Karachay-Balkar
257
krl	krl	XX	Karelian
258
kro	kro	XX	Kru
259
kru	kru	XX	Kurukh
260
kua	kua	kj	Kuanyama; Kwanyama
261
kum	kum	XX	Kumyk
262
kur	kur	ku	Kurdish
263
kut	kut	XX	Kutenai
264
lad	lad	XX	Ladino
265
lah	lah	XX	Lahnda
266
lam	lam	XX	Lamba
267
lao	lao	lo	Lao
268
lat	lat	la	Latin
269
lav	lav	lv	Latvian
270
lez	lez	XX	Lezghian
271
lim	lim	li	Limburgan; Limburger; Limburgish
272
lin	lin	ln	Lingala
273
lit	lit	lt	Lithuanian
274
lol	lol	XX	Mongo
275
loz	loz	XX	Lozi
276
ltz	ltz	lb	Luxembourgish; Letzeburgesch
277
lua	lua	XX	Luba-Lulua
278
lub	lub	lu	Luba-Katanga
279
lug	lug	lg	Ganda
280
lui	lui	XX	Luiseno
281
lun	lun	XX	Lunda
282
luo	luo	XX	Luo (Kenya and Tanzania)
283
lus	lus	XX	Lushai
284
mad	mad	XX	Madurese
285
mag	mag	XX	Magahi
286
mah	mah	mh	Marshallese
287
mai	mai	XX	Maithili
288
mak	mak	XX	Makasar
289
mal	mal	ml	Malayalam
290
man	man	XX	Mandingo
291
map	map	XX	Austronesian (Other)
292
mar	mar	mr	Marathi
293
mas	mas	XX	Masai
294
mdf	mdf	XX	Moksha
295
mdr	mdr	XX	Mandar
296
men	men	XX	Mende
297
mga	mga	XX	Irish, Middle (900-1200)
298
mic	mic	XX	Mi'kmaq; Micmac
299
min	min	XX	Minangkabau
300
mis	mis	XX	Miscellaneous languages
301
mkd	mac	mk	Macedonian
302
mkh	mkh	XX	Mon-Khmer (Other)
303
mlg	mlg	mg	Malagasy
304
mlt	mlt	mt	Maltese
305
mnc	mnc	XX	Manchu
306
mni	mni	XX	Manipuri
307
mno	mno	XX	Manobo languages
308
moh	moh	XX	Mohawk
309
mol	mol	mo	Moldavian
310
mon	mon	mn	Mongolian
311
mos	mos	XX	Mossi
312
mri	mao	mi	Maori
313
msa	may	ms	Malay
314
mul	mul	XX	Multiple languages
315
mun	mun	XX	Munda languages
316
mus	mus	XX	Creek
317
mwl	mwl	XX	Mirandese
318
mwr	mwr	XX	Marwari
319
mya	bur	my	Burmese
320
myn	myn	XX	Mayan languages
321
myv	myv	XX	Erzya
322
nah	nah	XX	Nahuatl
323
nai	nai	XX	North American Indian
324
nap	nap	XX	Neapolitan
325
nau	nau	na	Nauru
326
nav	nav	nv	Navajo; Navaho
327
nbl	nbl	nr	Ndebele, South; South Ndebele
328
nde	nde	nd	Ndebele, North; North Ndebele
329
ndo	ndo	ng	Ndonga
330
nds	nds	XX	Low German; Low Saxon; German, Low; Saxon, Low
331
nep	nep	ne	Nepali
332
new	new	XX	Newari; Nepal Bhasa
333
nia	nia	XX	Nias
334
nic	nic	XX	Niger-Kordofanian (Other)
335
niu	niu	XX	Niuean
336
nld	dut	nl	Dutch; Flemish
337
nno	nno	nn	Norwegian Nynorsk; Nynorsk, Norwegian
338
nob	nob	nb	Norwegian Bokmål; Bokmål, Norwegian
339
nog	nog	XX	Nogai
340
non	non	XX	Norse, Old
341
nor	nor	no	Norwegian
342
nqo	nqo	XX	N'ko
343
nso	nso	XX	Northern Sotho, Pedi; Sepedi
344
nub	nub	XX	Nubian languages
345
nwc	nwc	XX	Classical Newari; Old Newari; Classical Nepal Bhasa
346
nya	nya	ny	Chichewa; Chewa; Nyanja
347
nym	nym	XX	Nyamwezi
348
nyn	nyn	XX	Nyankole
349
nyo	nyo	XX	Nyoro
350
nzi	nzi	XX	Nzima
351
oci	oci	oc	Occitan (post 1500); Provençal
352
oji	oji	oj	Ojibwa
353
ori	ori	or	Oriya
354
orm	orm	om	Oromo
355
osa	osa	XX	Osage
356
oss	oss	os	Ossetian; Ossetic
357
ota	ota	XX	Turkish, Ottoman (1500-1928)
358
oto	oto	XX	Otomian languages
359
paa	paa	XX	Papuan (Other)
360
pag	pag	XX	Pangasinan
361
pal	pal	XX	Pahlavi
362
pam	pam	XX	Pampanga
363
pan	pan	pa	Panjabi; Punjabi
364
pap	pap	XX	Papiamento
365
pau	pau	XX	Palauan
366
peo	peo	XX	Persian, Old (ca. 600-400 B.C.)
367
phi	phi	XX	Philippine (Other)
368
phn	phn	XX	Phoenician
369
pli	pli	pi	Pali
370
pol	pol	pl	Polish
371
pon	pon	XX	Pohnpeian
372
por	por	pt	Portuguese
373
pra	pra	XX	Prakrit languages
374
pro	pro	XX	Provençal, Old (to 1500)
375
pus	pus	ps	Pushto
376
qaa-qtz	qaa-qtz	XX	Reserved for local use
377
que	que	qu	Quechua
378
raj	raj	XX	Rajasthani
379
rap	rap	XX	Rapanui
380
rar	rar	XX	Rarotongan
381
roa	roa	XX	Romance (Other)
382
roh	roh	rm	Raeto-Romance
383
rom	rom	XX	Romany
384
ron	rum	ro	Romanian
385
run	run	rn	Rundi
386
rup	rup	XX	Aromanian; Arumanian; Macedo-Romanian
387
rus	rus	ru	Russian
388
sad	sad	XX	Sandawe
389
sag	sag	sg	Sango
390
sah	sah	XX	Yakut
391
sai	sai	XX	South American Indian (Other)
392
sal	sal	XX	Salishan languages
393
sam	sam	XX	Samaritan Aramaic
394
san	san	sa	Sanskrit
395
sas	sas	XX	Sasak
396
sat	sat	XX	Santali
397
scn	scn	XX	Sicilian
398
sco	sco	XX	Scots
399
sel	sel	XX	Selkup
400
sem	sem	XX	Semitic (Other)
401
sga	sga	XX	Irish, Old (to 900)
402
sgn	sgn	XX	Sign Languages
403
shn	shn	XX	Shan
404
sid	sid	XX	Sidamo
405
sin	sin	si	Sinhala; Sinhalese
406
sio	sio	XX	Siouan languages
407
sit	sit	XX	Sino-Tibetan (Other)
408
sla	sla	XX	Slavic (Other)
409
slk	slo	sk	Slovak
410
slv	slv	sl	Slovenian
411
sma	sma	XX	Southern Sami
412
sme	sme	se	Northern Sami
413
smi	smi	XX	Sami languages (Other)
414
smj	smj	XX	Lule Sami
415
smn	smn	XX	Inari Sami
416
smo	smo	sm	Samoan
417
sms	sms	XX	Skolt Sami
418
sna	sna	sn	Shona
419
snd	snd	sd	Sindhi
420
snk	snk	XX	Soninke
421
sog	sog	XX	Sogdian
422
som	som	so	Somali
423
son	son	XX	Songhai
424
sot	sot	st	Sotho, Southern
425
spa	spa	es	Spanish; Castilian
426
sqi	alb	sq	Albanian
427
srd	srd	sc	Sardinian
428
srn	srn	XX	Sranan Tongo
429
srp	scc	sr	Serbian
430
srr	srr	XX	Serer
431
ssa	ssa	XX	Nilo-Saharan (Other)
432
ssw	ssw	ss	Swati
433
suk	suk	XX	Sukuma
434
sun	sun	su	Sundanese
435
sus	sus	XX	Susu
436
sux	sux	XX	Sumerian
437
swa	swa	sw	Swahili
438
swe	swe	sv	Swedish
439
syr	syr	XX	Syriac
440
tah	tah	ty	Tahitian
441
tai	tai	XX	Tai (Other)
442
tam	tam	ta	Tamil
443
tat	tat	tt	Tatar
444
tel	tel	te	Telugu
445
tem	tem	XX	Timne
446
ter	ter	XX	Tereno
447
tet	tet	XX	Tetum
448
tgk	tgk	tg	Tajik
449
tgl	tgl	tl	Tagalog
450
tha	tha	th	Thai
451
tig	tig	XX	Tigre
452
tir	tir	ti	Tigrinya
453
tiv	tiv	XX	Tiv
454
tkl	tkl	XX	Tokelau
455
tlh	tlh	XX	Klingon; tlhIngan-Hol
456
tli	tli	XX	Tlingit
457
tmh	tmh	XX	Tamashek
458
tog	tog	XX	Tonga (Nyasa)
459
ton	ton	to	Tonga (Tonga Islands)
460
tpi	tpi	XX	Tok Pisin
461
tsi	tsi	XX	Tsimshian
462
tsn	tsn	tn	Tswana
463
tso	tso	ts	Tsonga
464
tuk	tuk	tk	Turkmen
465
tum	tum	XX	Tumbuka
466
tup	tup	XX	Tupi languages
467
tur	tur	tr	Turkish
468
tut	tut	XX	Altaic (Other)
469
tvl	tvl	XX	Tuvalu
470
twi	twi	tw	Twi
471
tyv	tyv	XX	Tuvinian
472
udm	udm	XX	Udmurt
473
uga	uga	XX	Ugaritic
474
uig	uig	ug	Uighur; Uyghur
475
ukr	ukr	uk	Ukrainian
476
umb	umb	XX	Umbundu
477
und	und	XX	Undetermined
478
urd	urd	ur	Urdu
479
uzb	uzb	uz	Uzbek
480
vai	vai	XX	Vai
481
ven	ven	ve	Venda
482
vie	vie	vi	Vietnamese
483
vol	vol	vo	Volapük
484
vot	vot	XX	Votic
485
wak	wak	XX	Wakashan languages
486
wal	wal	XX	Walamo
487
war	war	XX	Waray
488
was	was	XX	Washo
489
wen	wen	XX	Sorbian languages
490
wln	wln	wa	Walloon
491
wol	wol	wo	Wolof
492
xal	xal	XX	Kalmyk; Oirat
493
xho	xho	xh	Xhosa
494
yao	yao	XX	Yao
495
yap	yap	XX	Yapese
496
yid	yid	yi	Yiddish
497
yor	yor	yo	Yoruba
498
ypk	ypk	XX	Yupik languages
499
zap	zap	XX	Zapotec
500
zen	zen	XX	Zenaga
501
zha	zha	za	Zhuang; Chuang
502
zho	chi	zh	Chinese
503
znd	znd	XX	Zande
504
zul	zul	zu	Zulu
505
zun	zun	XX	Zuni
506
zxx	zxx	XX	No linguistic content
0 507

  
tags/v2_0_0_Build_2042/frameworks/_fwAndami/src/org/gvsig/andami/PluginServices.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2007 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;
42

  
43
import java.awt.Component;
44
import java.awt.Frame;
45
import java.awt.KeyEventDispatcher;
46
import java.awt.Toolkit;
47
import java.awt.datatransfer.DataFlavor;
48
import java.awt.datatransfer.StringSelection;
49
import java.awt.datatransfer.UnsupportedFlavorException;
50
import java.awt.event.ActionListener;
51
import java.io.File;
52
import java.io.FileInputStream;
53
import java.io.FileNotFoundException;
54
import java.io.FileOutputStream;
55
import java.io.IOException;
56
import java.lang.reflect.InvocationTargetException;
57
import java.util.ArrayList;
58
import java.util.HashMap;
59
import java.util.Iterator;
60
import java.util.Properties;
61

  
62
import javax.swing.KeyStroke;
63
import javax.swing.SwingUtilities;
64
import javax.swing.Timer;
65

  
66
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
68

  
69
import org.gvsig.andami.authentication.IAuthentication;
70
import org.gvsig.andami.iconthemes.IIconTheme;
71
import org.gvsig.andami.iconthemes.IconThemeManager;
72
import org.gvsig.andami.messages.Messages;
73
import org.gvsig.andami.messages.NotificationManager;
74
import org.gvsig.andami.plugins.ExclusiveUIExtension;
75
import org.gvsig.andami.plugins.ExtensionDecorator;
76
import org.gvsig.andami.plugins.IExtension;
77
import org.gvsig.andami.plugins.PluginClassLoader;
78
import org.gvsig.andami.preferences.DlgPreferences;
79
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
80
import org.gvsig.andami.ui.mdiFrame.MainFrame;
81
import org.gvsig.andami.ui.mdiManager.MDIManager;
82
import org.gvsig.tools.ToolsLocator;
83
import org.gvsig.tools.dynobject.DynObject;
84
import org.gvsig.tools.dynobject.DynStruct;
85
import org.gvsig.tools.exception.BaseRuntimeException;
86
import org.gvsig.tools.persistence.PersistenceManager;
87
import org.gvsig.tools.persistence.PersistentState;
88
import org.gvsig.tools.persistence.exception.AddDefinitionException;
89
import org.gvsig.utils.XMLEntity;
90
import org.gvsig.utils.swing.threads.IMonitorableTask;
91
import org.gvsig.utils.swing.threads.IProgressMonitorIF;
92
import org.gvsig.utils.swing.threads.TaskMonitorTimerListener;
93
import org.gvsig.utils.swing.threads.UndefinedProgressMonitor;
94

  
95
/**
96
 * Provides services to Plugins. Each plugin has an associated PluginServices
97
 * object, which provides specific services. Main of them: translations,
98
 * logging, access to plugin's resources, background tasks, clipboard access
99
 * and data persistence.
100
 * 
101
 * @author Fernando Gonz?lez Cort?s
102
 */
103
public class PluginServices {
104

  
105
    private static Logger logger =
106
        LoggerFactory.getLogger(PluginServices.class);
107

  
108
    private static String[] arguments;
109

  
110
    private static IAuthentication authentication;
111

  
112
    private static ExclusiveUIExtension exclusiveUIExtension = null;
113

  
114
    private PluginClassLoader loader;
115

  
116
    private XMLEntity persistentXML;
117

  
118
    private DynObject pluginPersistence = null;
119

  
120
    /**
121
     * Creates a new PluginServices objetct.
122
     * 
123
     * @param loader
124
     *            The Plugin's ClassLoader.
125
     */
126
    public PluginServices(PluginClassLoader loader) {
127
        this.loader = loader;
128
    }
129

  
130
    /**
131
     * Returns the message in the current's locale language
132
     * corresponding to the provided translation key.
133
     * The key-message pairs are obtained from the plugin's
134
     * translation files (text_xx.properties files).
135
     * 
136
     * @param key
137
     *            Translation key whose associated message is to be obtained
138
     * 
139
     * @return The message associated with the provided key, in one of the
140
     *         current locale languages, or the key if the translation is not
141
     *         found.
142
     */
143
    public String getText(String key) {
144
        if (key == null)
145
            return null;
146
        String translation = org.gvsig.i18n.Messages.getText(key, false);
147
        if (translation != null)
148
            return translation;
149
        else {
150
            logger.debug("Can't find translation for ''{}'' in plugin ''{}''.",
151
                key,
152
                getPluginName());
153
            return key;
154
        }
155
    }
156

  
157
    /**
158
     * Gets the plugin's classloader.
159
     * 
160
     * @return Returns the loader.
161
     */
162
    public PluginClassLoader getClassLoader() {
163
        return loader;
164
    }
165

  
166
    /**
167
     * Gets the plugin's name
168
     * 
169
     * @return The plugin's name
170
     */
171
    String getPluginName() {
172
        return loader.getPluginName();
173
    }
174

  
175
    /**
176
     * Gets a reference to the PluginServices object associated with the
177
     * plugin containing the provided class.
178
     * 
179
     * Obtienen una referencia al PluginServices del plugin cuyo nombre se pasa
180
     * como par?metro
181
     * 
182
     * @param pluginClassInstance
183
     *            An instance of a class. This class is contained in a plugin,
184
     *            whose
185
     *            services are to be obtained
186
     * 
187
     * @return The PluginServices object associated to the containing plugin
188
     * 
189
     * @throws RuntimeException
190
     *             If the parameter was not loaded from a plugin
191
     */
192
    public static PluginServices getPluginServices(Object pluginClassInstance) {
193
        try {
194
            PluginClassLoader loader =
195
                (PluginClassLoader) pluginClassInstance.getClass()
196
                .getClassLoader();
197

  
198
            return Launcher.getPluginServices(loader.getPluginName());
199
        } catch (ClassCastException e) {
200
            /*
201
             * throw new RuntimeException( "Parameter is not a plugin class
202
             * instance");
203
             */
204
            return null;
205
        }
206
    }
207

  
208
    /**
209
     * Gets a reference to the PluginServices object associated with the
210
     * provided plugin.
211
     * 
212
     * @param pluginName
213
     *            Plugin's name whose services are going to be used
214
     * 
215
     * @return The PluginServices object associated with the provided plugin.
216
     */
217
    public static PluginServices getPluginServices(String pluginName) {
218
        return Launcher.getPluginServices(pluginName);
219
    }
220

  
221
    /**
222
     * Gets the window manager (MDIManager).
223
     * 
224
     * @return A reference to the window manager (MDIManager).
225
     */
226
    public static MDIManager getMDIManager() {
227
        return Launcher.getFrame().getMDIManager();
228
    }
229

  
230
    /**
231
     * Gets the application's main frame.
232
     * 
233
     * @return A reference to the application's main window
234
     */
235
    public static MainFrame getMainFrame() {
236
        return Launcher.getFrame();
237
    }
238

  
239
    public static void registerKeyStroke(KeyStroke key, KeyEventDispatcher a) {
240
        GlobalKeyEventDispatcher.getInstance().registerKeyStroke(key, a);
241
    }
242

  
243
    public static void unRegisterKeyStroke(KeyStroke key) {
244
        GlobalKeyEventDispatcher.getInstance().removeKeyStrokeBinding(key);
245
    }
246

  
247
    /**
248
     * Gets the instance of the extension whose class is provided.
249
     * 
250
     * @param extensionClass
251
     *            Class of the extension whose instance is to be returned
252
     * 
253
     * @return The instance of the extension, or null if the instance does
254
     *         not exist.Instancia de la extensi?n o null en caso de que no haya
255
     *         una
256
     */
257
    public static IExtension getExtension(Class extensionClass) {
258
        ExtensionDecorator extAux =
259
            (ExtensionDecorator) Launcher.getClassesExtensions()
260
            .get(extensionClass);
261
        try {
262
            return extAux.getExtension();
263
        } catch (NullPointerException ex) {
264
            return null;
265
        }
266
    }
267

  
268
    /**
269
     * Gets a reference to the Extension Decorator which adds some extra options
270
     * to the basic extension interface.
271
     * 
272
     * @param extensionClass
273
     *            The class of the extension whose decorator is to be returned
274
     * @return The ExtensionDecorator associated with the provided extension,
275
     *         or null if the extension does not exist.
276
     */
277
    public static ExtensionDecorator getDecoratedExtension(Class extensionClass) {
278
        return (ExtensionDecorator) Launcher.getClassesExtensions()
279
        .get(extensionClass);
280
    }
281

  
282
    /**
283
     * Returns an array containing references to all the loaded extensions.
284
     * 
285
     * @return ExtensionDecorator[] An array of ExtensionDecorators (each
286
     *         Decorator contains one extension).
287
     */
288
    public static ExtensionDecorator[] getDecoratedExtensions() {
289
        HashMap map = Launcher.getClassesExtensions();
290
        ExtensionDecorator[] extensions =
291
            (ExtensionDecorator[]) map.values()
292
            .toArray(new ExtensionDecorator[0]);
293
        return extensions;
294
    }
295

  
296
    /**
297
     * Gets an iterator with all the loaded Extensions.
298
     * 
299
     * @return Iterator over the decorated extensions (each member of
300
     *         the iterator is an ExtensionDecorator, which in turn contains
301
     *         one IExtension object).
302
     */
303
    public static Iterator getExtensions() {
304
        return Launcher.getClassesExtensions().values().iterator();
305
    }
306

  
307
    /**
308
     * Returns the message in the current's locale language
309
     * corresponding to the provided translation key.
310
     * The key-message pairs are obtained from the plugin's
311
     * translation files (text_xx.properties files).
312
     * 
313
     * @param pluginObject
314
     *            Any object which was loaded from a plugin
315
     * 
316
     * @param key
317
     *            Translation key whose associated message is to be obtained
318
     * 
319
     * @return The message associated with the provided key, in one of the
320
     *         current locale languages, or the key if the translation is not
321
     *         found.
322
     */
323
    public static String getText(Object pluginObject, String key) {
324
        if (key == null)
325
            return null;
326
        String translation = org.gvsig.i18n.Messages.getText(key, false);
327
        if (translation != null)
328
            return translation;
329
        else {
330
            logger.debug("Can't find translation for ''{}''.", key);
331
            return key;
332
        }
333
    }
334

  
335
    /**
336
     * Sets the XML data which should be saved on disk for this plugin. This
337
     * data can be retrieved on following sessions.
338
     * 
339
     * @param The
340
     *            XMLEntity object containing the data to be persisted.
341
     * 
342
     * @see PluginServices.getPersistentXML()
343
     * @see XMLEntity
344
     */
345
    public void setPersistentXML(XMLEntity entity) {
346
        persistentXML = entity;
347
    }
348

  
349
    /**
350
     * Gets the XML data which was saved on previous sessions for this
351
     * plugins.
352
     * 
353
     * @return An XMLEntity object containing the persisted data
354
     */
355
    public XMLEntity getPersistentXML() {
356
        if (persistentXML == null) {
357
            persistentXML = new XMLEntity();
358
        }
359
        return persistentXML;
360
    }
361

  
362
    /**
363
     * A?ade un listener a un popup menu registrado en el config.xml de alg?n
364
     * plugin
365
     * 
366
     * @param name
367
     *            Nombre del men? contextual
368
     * @param c
369
     *            Componente que desplegar? el men? cuando se haga click con el
370
     *            bot?n derecho
371
     * @param listener
372
     *            Listener que se ejecutar? cuando se seleccione cualquier
373
     *            entrada del men?
374
     * 
375
     * @throws RuntimeException
376
     *             Si la interfaz no est? preparada todav?a. S?lo puede darse
377
     *             durante el arranque
378
     */
379
    public void addPopupMenuListener(String name,
380
        Component c,
381
        ActionListener listener) {
382
        MDIFrame frame = Launcher.getFrame();
383

  
384
        if (frame == null) {
385
            throw new RuntimeException("MDIFrame not loaded yet");
386
        }
387

  
388
        frame.addPopupMenuListener(name, c, listener, loader);
389
    }
390

  
391
    /**
392
     * Gets the plugin's root directory.
393
     * 
394
     * @return A File pointing to the plugin's root directory.
395
     */
396
    public File getPluginDirectory() {
397
        return new File(Launcher.getPluginsDir() + File.separator
398
            + getPluginName());
399
    }
400

  
401
    /**
402
     * Runs a background task. The events produced on the main frame will
403
     * be inhibited.
404
     * 
405
     * @param r
406
     *            The task to run.
407
     * 
408
     * @return The Thread on which the task is executed.
409
     */
410
    public static Thread backgroundExecution(Runnable r) {
411
        Thread t = new Thread(new RunnableDecorator(r));
412
        t.start();
413

  
414
        return t;
415
    }
416

  
417
    /**
418
     * Runs a backbround task. This task may be monitored and canceled, and
419
     * does not inhibit any event.
420
     * 
421
     * @param task
422
     *            The task to run.
423
     */
424
    public static void cancelableBackgroundExecution(final IMonitorableTask task) {
425
        final org.gvsig.utils.swing.threads.SwingWorker worker =
426
            new org.gvsig.utils.swing.threads.SwingWorker() {
427

  
428
            public Object construct() {
429
                try {
430
                    task.run();
431
                    return task;
432
                } catch (Exception e) {
433
                    NotificationManager.addError(null, e);
434
                }
435
                return null;
436
            }
437

  
438
            /**
439
             * Called on the event dispatching thread (not on the worker
440
             * thread)
441
             * after the <code>construct</code> method has returned.
442
             */
443
            public void finished() {
444
                task.finished();
445
            }
446
        };
447

  
448
        Component mainFrame = (Component) PluginServices.getMainFrame();
449

  
450
        IProgressMonitorIF progressMonitor = null;
451
        String title = getText(null, "PluginServices.Procesando");
452
        progressMonitor =
453
            new UndefinedProgressMonitor((Frame) mainFrame, title);
454
        progressMonitor.setIndeterminated(!task.isDefined());
455
        progressMonitor.setInitialStep(task.getInitialStep());
456
        progressMonitor.setLastStep(task.getFinishStep());
457
        progressMonitor.setCurrentStep(task.getCurrentStep());
458
        progressMonitor.setMainTitleLabel(task.getStatusMessage());
459
        progressMonitor.setNote(task.getNote());
460
        progressMonitor.open();
461
        int delay = 500;
462
        TaskMonitorTimerListener timerListener =
463
            new TaskMonitorTimerListener(progressMonitor, task);
464
        Timer timer = new Timer(delay, timerListener);
465
        timerListener.setTimer(timer);
466
        timer.start();
467

  
468
        worker.start();
469

  
470
    }
471

  
472
    /**
473
     * Closes the application. Cleanly exits from the application:
474
     * terminates all the extensions, then exits.
475
     * 
476
     */
477
    public static void closeApplication() {
478
        Launcher.closeApplication();
479
    }
480

  
481
    /**
482
     * DOCUMENT ME!
483
     * 
484
     * @author Fernando Gonz?lez Cort?s
485
     */
486
    private static class RunnableDecorator implements Runnable {
487

  
488
        private Runnable r;
489

  
490
        /**
491
         * Crea un nuevo RunnableDecorator.
492
         * 
493
         * @param r
494
         *            DOCUMENT ME!
495
         */
496
        public RunnableDecorator(Runnable r) {
497
            this.r = r;
498
        }
499

  
500
        /**
501
         * @see java.lang.Runnable#run()
502
         */
503
        public void run() {
504
            try {
505
                SwingUtilities.invokeAndWait(new Runnable() {
506

  
507
                    public void run() {
508
                        try {
509
                            r.run();
510
                        } catch (RuntimeException e) {
511
                            NotificationManager.addError(Messages.getString("PluginServices.Bug_en_el_codigo"),
512
                                e);
513
                        } catch (Error e) {
514
                            NotificationManager.addError(Messages.getString("PluginServices.Error_grave_de_la_aplicaci?n"),
515
                                e);
516
                        }
517
                    }
518
                });
519
            } catch (InterruptedException e) {
520
                NotificationManager.addWarning(Messages.getString("PluginServices.No_se_pudo_poner_el_reloj_de_arena"),
521
                    e);
522
            } catch (InvocationTargetException e) {
523
                NotificationManager.addWarning(Messages.getString("PluginServices.No_se_pudo_poner_el_reloj_de_arena"),
524
                    e);
525
            }
526
        }
527
    }
528

  
529
    /**
530
     * Gets an array containing the application's startup arguments. <br>
531
     * <br>
532
     * Usually: <code>appName plugins-directory [locale] [other args]</code>
533
     * 
534
     * @return the original arguments that Andami received. (app-name
535
     *         plugins-directory, locale, etc)
536
     */
537
    public static String[] getArguments() {
538
        return arguments;
539
    }
540

  
541
    /**
542
     * Replaces the original Andami arguments with the provided arguments.
543
     * 
544
     * @param arguments
545
     *            An array of String, each element of the array
546
     *            represents one
547
     *            argument.
548
     */
549
    public static void setArguments(String[] arguments) {
550
        PluginServices.arguments = arguments;
551
    }
552

  
553
    /**
554
     * Returns the value of a command line named argument. <br>
555
     * <br>
556
     * The argument format is: <br>
557
     * -{argumentName}={argumentValue} <br>
558
     * <br>
559
     * example: <br>
560
     * ' -language=en '
561
     * 
562
     * @return String The value of the argument
563
     */
564
    public static String getArgumentByName(String name) {
565
        for (int i = 2; i < PluginServices.arguments.length; i++) {
566
            int index = PluginServices.arguments[i].indexOf(name + "=");
567
            if (index != -1)
568
                return PluginServices.arguments[i].substring(index
569
                    + name.length() + 1);
570
        }
571
        return null;
572
    }
573

  
574
    /**
575
     * Gets the logger. The logger is used to register important
576
     * events (errors, etc), which are stored on a file which
577
     * can be checked later.
578
     * 
579
     * @return A Logger object.
580
     * @see Logger object from the Log4j library.
581
     * 
582
     */
583
    public static Logger getLogger() {
584
        return logger;
585
    }
586

  
587
    public static IAuthentication getAuthentication() {
588
        return authentication;
589
    }
590

  
591
    public static void setAuthentication(IAuthentication authen) {
592
        authentication = authen;
593
    }
594

  
595
    public static DlgPreferences getDlgPreferences() {
596
        return DlgPreferences.getInstance();
597
    }
598

  
599
    /**
600
     * Stores the provided text data on the clipboard.
601
     * 
602
     * @param data
603
     *            An String containing the data to be stored
604
     *            on the clipboard.
605
     */
606
    public static void putInClipboard(String data) {
607
        StringSelection ss = new StringSelection(data);
608

  
609
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss);
610
    }
611

  
612
    /**
613
     * Gets text data from the Clipboard, if available.
614
     * 
615
     * @return An String containing the clipboard's data, or <code>null</code>
616
     *         if the data was not available.
617
     */
618
    public static String getFromClipboard() {
619

  
620
        try {
621
            return (String) Toolkit.getDefaultToolkit()
622
            .getSystemClipboard()
623
            .getContents(null)
624
            .getTransferData(DataFlavor.stringFlavor);
625
        } catch (UnsupportedFlavorException e) {
626
            return null;
627
        } catch (IOException e) {
628
            // TODO Auto-generated catch block
629
            return null;
630
        }
631
    }
632

  
633
    /**
634
     * Gets the ExclusiveUIExtension, an special extension which
635
     * will take
636
     * control over the UI and will decide which extensions may be
637
     * enable/disabled or visible/hidden.
638
     * 
639
     * @return If an ExclusiveUIExtension was set, return this extension.
640
     *         Otherwise, return <code>null</code>.
641
     * 
642
     * @see org.gvsig.andami.Launcher#initializeExclusiveUIExtension()
643
     * @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
644
     * @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
645
     */
646
    public static ExclusiveUIExtension getExclusiveUIExtension() {
647
        return PluginServices.exclusiveUIExtension;
648
    }
649

  
650
    /**
651
     * Sets the ExclusiveUIExtension, an special extension which
652
     * will take
653
     * control over the UI and will decide which extensions may be
654
     * enable/disabled or visible/hidden. <br>
655
     * <br>
656
     * The ExclusiveUIExtension is normally set by the following
657
     * Andami startup argument: <br>
658
     * <br>
659
     * <code>ExclusiveUIExtension=ExtensionName</code>
660
     * 
661
     * @see org.gvsig.andami.Launcher#initializeExclusiveUIExtension()
662
     * @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
663
     * @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
664
     */
665
    public static void setExclusiveUIExtension(ExclusiveUIExtension extension) {
666
        PluginServices.exclusiveUIExtension = extension;
667
    }
668

  
669
    public static void addLoaders(ArrayList classLoaders) {
670
        PluginClassLoader.addLoaders(classLoaders);
671
    }
672

  
673
    public static IconThemeManager getIconThemeManager() {
674
        return IconThemeManager.getIconThemeManager();
675
    }
676

  
677
    public static IIconTheme getIconTheme() {
678
        return IconThemeManager.getIconThemeManager().getCurrent();
679
    }
680

  
681
    /**
682
     * Try to detect if the application is running in a development
683
     * environment. <br>
684
     * This look for <b>.project</b> and <b>.classpath</b> files in the starts
685
     * path of the application.
686
     * 
687
     * @return true if <b>.project</b> and <b>.classpath</b> are in the
688
     *         development path
689
     */
690
    public static boolean runningInDevelopment() {
691
        String andamiPath;
692
        Properties props = System.getProperties();
693

  
694
        try {
695
            try {
696
                andamiPath =
697
                    (new File(Launcher.class.getResource(".").getFile()
698
                        + File.separator + ".." + File.separator + ".."
699
                        + File.separator + ".." + File.separator + "..")).getCanonicalPath();
700
            } catch (IOException e) {
701
                andamiPath =
702
                    (new File(Launcher.class.getResource(".").getFile()
703
                        + File.separator + ".." + File.separator + ".."
704
                        + File.separator + ".." + File.separator + "..")).getAbsolutePath();
705
            }
706
        } catch (Exception e1) {
707
            andamiPath = (String) props.get("user.dir");
708
        }
709

  
710
        File andamiJar = new File(andamiPath + File.separator + "andami.jar");
711
        if (!andamiJar.exists())
712
            return false;
713
        File projectFile = new File(andamiPath + File.separator + ".project");
714
        File classpathFile =
715
            new File(andamiPath + File.separator + ".classpath");
716
        return projectFile.exists() && classpathFile.exists();
717

  
718
    }
719

  
720
    public PluginsManager getManager() {
721
        return PluginsLocator.getManager();
722
    }
723

  
724
    public DynObject getPluginProperties() {
725
        if (this.pluginPersistence == null) {
726
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
727
            DynStruct dynStruct = manager.getDynObjectDefinition(getPluginName());
728
            if ( dynStruct == null) {
729
                File persistenceDefinitionFile =
730
                    new File(getManager().getPluginsDirectory().getAbsolutePath()
731
                        + File.separator + this.getPluginName()
732
                        + File.separator + "plugin-persistence.def");
733
                try {
734
                    dynStruct = manager.addDefinition(DynObject.class,
735
                        this.getPluginName(),
736
                        new FileInputStream(persistenceDefinitionFile),
737
                        this.getClassLoader(),
738
                        null,
739
                        null);
740
                } catch (AddDefinitionException e) {
741
                    throw new PluginPersistenceAddDefinitionException(this.getPluginName());
742
                } catch (FileNotFoundException e) {
743
                    throw new PluginPersistenceNeedDefinitionException(this.getPluginName());
744
                }
745
            }
746

  
747

  
748
			File persistenceFile = getPluginPersistenceFile();
749
            if (persistenceFile.exists()) {
750
                PersistentState state;
751

  
752
                try {
753
                    state = manager.loadState(new FileInputStream(persistenceFile));
754
                    pluginPersistence = (DynObject) manager.create(state);
755
                } catch (Exception e) {
756
                    logger.error("Can't retrieve persistent values from plugin "+this.getPluginName(), e);
757
                }
758
            }
759
            if (this.pluginPersistence == null) {
760
                this.pluginPersistence =
761
                    ToolsLocator.getDynObjectManager()
762
                    .createDynObject(dynStruct); 
763
            }
764
        }
765
        return pluginPersistence;
766
    }
767

  
768
    public void savePluginProperties() {
769
        if (this.pluginPersistence == null) {
770
            return;
771
        }
772
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
773
		File persistenceFile = getPluginPersistenceFile();
774
        PersistentState state;
775
        FileOutputStream fos;
776
        try {
777
            state = manager.getState(pluginPersistence);
778
            manager.saveState(state, new FileOutputStream(persistenceFile));
779
        } catch (Exception e) {
780
            throw new PluginSaveDataException(this.getPluginName(), e);
781
        }
782

  
783

  
784
    }
785

  
786
	/**
787
	 * Returns the plugin persistence file.
788
	 * 
789
	 * @return the plugin persistence file
790
	 */
791
	private File getPluginPersistenceFile() {
792
		return new File(getPluginHomeFolder(), "plugin-persistence.dat");
793
	}
794

  
795
	/**
796
	 * Returns the folder where the plugin stores its resources. That folder
797
	 * will be usually a subfolder into the application folder in the user home
798
	 * folder.
799
	 * 
800
	 * @return the folder where the plugin stores its resources
801
	 */
802
	public File getPluginHomeFolder() {
803
		File persistenceFolder = new File(Launcher.getAppHomeDir()
804
				+ File.separator + "plugins" + File.separator
805
				+ this.getPluginName());
806

  
807
		if (!persistenceFolder.exists()) {
808
			persistenceFolder.mkdirs();
809
		}
810

  
811
		return persistenceFolder;
812
	}
813

  
814
    public class PluginPersistenceNeedDefinitionException extends
815
    BaseRuntimeException {
816

  
817
        /**
818
         * 
819
         */
820
        private static final long serialVersionUID = -2036279527440882712L;
821

  
822
        PluginPersistenceNeedDefinitionException(String name) {
823
            super("Can't load persistence definition of plugin %(name).",
824
                "_cant_load_persistence_definition_of_plugin_XnameX",
825
                serialVersionUID);
826
            setValue("name", name);
827
        }
828
    }
829

  
830
    public class PluginPersistenceAddDefinitionException extends
831
    BaseRuntimeException {
832

  
833
        /**
834
         * 
835
         */
836
        private static final long serialVersionUID = 2227722796640780361L;
837

  
838
        PluginPersistenceAddDefinitionException(String name) {
839
            super("Can't add persistence definition of plugin %(name).",
840
                "_cant_add_persistence_definition_of_plugin_XnameX",
841
                serialVersionUID);
842
            setValue("name", name);
843
        }
844
    }
845

  
846
    public class PluginLoadDataException extends
847
    BaseRuntimeException {
848

  
849
        /**
850
         * 
851
         */
852
        private static final long serialVersionUID = 1168749231143949111L;
853

  
854
        PluginLoadDataException(String name) {
855
            super("Can't load data of plugin %(name).",
856
                "_cant_load_data_of_plugin_XnameX",
857
                serialVersionUID);
858
            setValue("name", name);
859
        }
860
    }
861

  
862
    public class PluginSaveDataException extends
863
    BaseRuntimeException {
864

  
865
        /**
866
         * 
867
         */
868
        private static final long serialVersionUID = 4893241183911774542L;
869
        private final static String MESSAGE_FORMAT = "Can't save data of plugin %(name).";
870
        private final static String MESSAGE_KEY = "_cant_save_data_of_plugin_XnameX";
871

  
872
        PluginSaveDataException(String name) {
873
            super(MESSAGE_FORMAT,
874
                MESSAGE_KEY,
875
                serialVersionUID);
876
            setValue("name", name);
877
        }
878

  
879
        public PluginSaveDataException(String name, Throwable cause) {
880
            super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
881
            setValue("name", name);
882

  
883
        }
884
    }
885
    
886
    @Override
887
    public String toString() {
888
        return super.toString()+" "+this.getPluginName();
889
    }
890
}
0 891

  
tags/v2_0_0_Build_2042/frameworks/_fwAndami/src/org/gvsig/andami/persistence/generate/ToolBarDescriptor.java
1
/*
2
 * This class was automatically generated with 
3
 * <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML
4
 * Schema.
5
 * $Id$
6
 */
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff