Revision 6865

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/CopyPasteExtension.java
59 59

  
60 60
	public void initialize() {
61 61
		ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
62
		
63
		
64
		
62

  
63

  
64

  
65 65
		// TOC
66 66
		MyTocMenuEntry copy = new CopyTocMenuEntry();
67 67
		MyTocMenuEntry cut = new CutTocMenuEntry();
......
80 80
    	FPopupMenu.addEntry(cut);
81 81
    	FPopupMenu.addEntry(paste);
82 82
		*/
83
		
84
    	// ProjectWindow		
83

  
84
    	// ProjectWindow
85 85
		CopyProjectElement copyProjectElement = new CopyProjectElement();
86 86
		CutProjectElement cutProjectElement = new CutProjectElement();
87 87
		PasteProjectElement pasteProjectElementView = new PasteProjectElement();
88 88
		PasteProjectElement pasteProjectElementTable = new PasteProjectElement();
89 89
		PasteProjectElement pasteProjectElementMap = new PasteProjectElement();
90
		
90

  
91 91
		copyProjectElement.setUtiles(utiles);
92 92
		cutProjectElement.setUtiles(utiles);
93 93
		pasteProjectElementView.setUtiles(utiles);
94 94
		pasteProjectElementTable.setUtiles(utiles);
95 95
		pasteProjectElementMap.setUtiles(utiles);
96
		
96

  
97 97
		pasteProjectElementView.setType("views");
98 98
		pasteProjectElementTable.setType("tables");
99 99
		pasteProjectElementMap.setType("maps");
100
		
101
		
100

  
101

  
102 102
		extensionPoints.add("DocumentActions_View","Copy","Copy selectes documento to system clipboard",copyProjectElement);
103 103
		extensionPoints.add("DocumentActions_View","Cut","Cut selectes documento to system clipboard", cutProjectElement);
104 104
		extensionPoints.add("DocumentActions_View","Paste","Paste views from system clipboard",pasteProjectElementView);
......
116 116

  
117 117
	public void execute(String actionCommand) {
118 118
		// TODO Auto-generated method stub
119
		
119

  
120 120
	}
121 121

  
122 122
	public boolean isEnabled() {
......
136 136
	public void setUtiles(Utiles utiles) {
137 137
		this.utiles = utiles;
138 138
	}
139
	
139

  
140 140
	public String getGroup() {
141 141
		return "ClipboardActions";
142 142
	}
......
153 153

  
154 154
	public Object create(Map args) {
155 155
		// TODO Auto-generated method stub
156
		return this;		
157
	}	
156
		return this;
157
	}
158 158
}
159 159

  
160 160

  
......
164 164
		//return PluginServices.getText(this,"tooltip_copiar_al_portapapeles");
165 165
		return null;
166 166
	}
167
	
167

  
168 168
	public int getOrder() {
169
		
169

  
170 170
		return 0;
171 171
	}
172
	
172

  
173 173
	public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
174 174
		return true;
175 175
	}
176
	
176

  
177 177
	public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
178 178
		return selectedItems.length > 0;
179 179
	}
......
190 190
					);
191 191
			return;
192 192
		}
193
		
193

  
194 194
		String data = this.utiles.marshallXMLEntity(xml);
195 195
		if (data == null) {
196 196
			JOptionPane.showMessageDialog(
......
201 201
					);
202 202
			return;
203 203
		}
204
		this.utiles.putInClipboard(data);		
204
		this.utiles.putInClipboard(data);
205 205
	}
206 206

  
207 207
	public String getText() {
208 208
		return PluginServices.getText(this, "copiar");
209 209
	}
210
	
210

  
211 211
}
212 212

  
213 213
class CutProjectElement extends MyDocumentAction {
......
220 220
	public int getOrder() {
221 221
		return 1;
222 222
	}
223
	
223

  
224 224
	public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
225 225
		return true;
226 226
	}
227
	
227

  
228 228
	public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
229 229
		return selectedItems.length > 0;
230 230
	}
......
241 241
					);
242 242
			return;
243 243
		}
244
		
244

  
245 245
		String data = this.utiles.marshallXMLEntity(xml);
246 246
		if (data == null) {
247 247
			JOptionPane.showMessageDialog(
......
251 251
					JOptionPane.ERROR_MESSAGE
252 252
					);
253 253
			return;
254
		}		
254
		}
255 255
		this.utiles.putInClipboard(data);
256
		
257
		
256

  
257

  
258 258
    	int option=JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"desea_borrar_el_documento"));
259 259
    	if (option!=JOptionPane.OK_OPTION) {
260 260
    		return;
261
    	}		
262
		
263
		
264
		this.utiles.removeDocuments(selectedItems);			
265
		
261
    	}
262

  
263

  
264
		this.utiles.removeDocuments(selectedItems);
265

  
266 266
	}
267 267

  
268 268
	public String getText() {
269 269
		return PluginServices.getText(this, "cortar");
270 270
	}
271
	
271

  
272 272
}
273 273

  
274 274
class PasteProjectElement extends MyDocumentAction {
275 275
	private String type;
276
	
276

  
277 277
	public String getDescription() {
278 278
		//FIXME: Falta claves
279 279
		//return PluginServices.getText(this,"tooltip_pegar_desde_el_portapapeles");
......
283 283
	public int getOrder() {
284 284
		return 2;
285 285
	}
286
	
286

  
287 287
	public void setType(String type) {
288 288
		this.type = type;
289 289
	}
290
	
290

  
291 291
	public String getType(String type) {
292 292
		return this.type;
293 293
	}
294
	
294

  
295 295
	public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
296 296
		return true;
297 297
	}
298
	
298

  
299 299
	public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
300 300
		String sourceString = this.utiles.getFromClipboard();
301 301
		if (sourceString == null) return false;
302
		
302

  
303 303
		XMLEntity xml = this.utiles.unMarshallXMLEntity(sourceString);
304 304
		if (xml == null) return false;
305
		
305

  
306 306
		if (!this.utiles.checkXMLRootNode(xml)) return false;
307
		
307

  
308 308
		if (this.utiles.getXMLEntityChildOfType(xml,this.type) == null) return false;
309 309
		return true;
310 310
	}
......
313 313
	public void execute(ProjectElement item, ProjectElement[] selectedItems) {
314 314
		String sourceString = this.utiles.getFromClipboard();
315 315
		if (sourceString == null) return;
316
		
316

  
317 317
		XMLEntity xml = this.utiles.unMarshallXMLEntity(sourceString);
318 318
		if (xml == null) return;
319
		
319

  
320 320
		if (!this.utiles.checkXMLRootNode(xml)) return;
321
		
321

  
322 322
		if (this.type.equals("views")) {
323 323
			this.utiles.loadViewsFromXML(xml);
324 324
		} else if (this.type.equals("tables")) {
325
			this.utiles.loadTablesFromXML(xml);			
325
			this.utiles.loadTablesFromXML(xml);
326 326
		} else if (this.type.equals("maps")) {
327 327
			this.utiles.loadMapsFromXML(xml);
328 328
		} else {
329 329
			//TODO que hacer aqui??
330 330
			return;
331 331
		}
332
		
332

  
333 333
	}
334 334

  
335 335
	public String getText() {
336 336
		return PluginServices.getText(this, "pegar");
337 337
	}
338
	
338

  
339 339
}
340 340

  
341 341

  
342 342

  
343
abstract class  MyTocMenuEntry extends AbstractTocContextMenuAction {	
343
abstract class  MyTocMenuEntry extends AbstractTocContextMenuAction {
344 344
	protected Utiles utiles;
345
		
345

  
346 346
	public void setUtiles(Utiles utiles) {
347 347
		this.utiles = utiles;
348 348
	}
......
354 354
	public int getGroupOrder() {
355 355
		return 60;
356 356
	}
357
	
357

  
358 358
}
359 359

  
360 360
class CopyTocMenuEntry extends MyTocMenuEntry{
361 361
	public int getOrder() {
362 362
		return 0;
363 363
	}
364
	
364

  
365 365
	public String getText() {
366
		return PluginServices.getText(this, "copiar");	
366
		return PluginServices.getText(this, "copiar");
367 367
	}
368
	
368

  
369 369
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
370
		return selectedItems.length >= 1 && isTocItemBranch(item);		
370
		return selectedItems.length >= 1 && isTocItemBranch(item);
371 371
	}
372 372

  
373 373

  
374
	public void execute(ITocItem item, FLayer[] selectedItems) {		
374
	public void execute(ITocItem item, FLayer[] selectedItems) {
375 375
		XMLEntity xml = this.utiles.generateXMLCopyLayers(selectedItems);
376 376
		if (xml == null) {
377 377
			JOptionPane.showMessageDialog(
......
382 382
					);
383 383
			return;
384 384
		}
385
		
385

  
386 386
		String data = this.utiles.marshallXMLEntity(xml);
387 387
		if (data == null) {
388 388
			JOptionPane.showMessageDialog(
......
393 393
					);
394 394
			return;
395 395
		}
396
		
397
		this.utiles.putInClipboard(data);		
398
		
396

  
397
		this.utiles.putInClipboard(data);
398

  
399 399
	}
400 400

  
401 401

  
......
405 405
	public int getOrder() {
406 406
		return 1;
407 407
	}
408
	
408

  
409 409
	public String getText() {
410
		return PluginServices.getText(this, "cortar");	
410
		return PluginServices.getText(this, "cortar");
411 411
	}
412
	
412

  
413 413
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
414
		return selectedItems.length >= 1 && isTocItemBranch(item);		
414
		return selectedItems.length >= 1 && isTocItemBranch(item);
415 415
	}
416 416

  
417 417

  
418
	public void execute(ITocItem item, FLayer[] selectedItems) {		
418
	public void execute(ITocItem item, FLayer[] selectedItems) {
419 419
		XMLEntity xml = this.utiles.generateXMLCopyLayers(selectedItems);
420 420
		if (xml == null) {
421 421
			JOptionPane.showMessageDialog(
......
426 426
					);
427 427
			return;
428 428
		}
429
		
429

  
430 430
		String data = this.utiles.marshallXMLEntity(xml);
431 431
		if (data == null) {
432 432
			JOptionPane.showMessageDialog(
......
438 438
			return;
439 439
		}
440 440

  
441
		
441

  
442 442
		this.utiles.putInClipboard(data);
443
		
444
    	
443

  
444

  
445 445
    	int option=JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"desea_borrar_la_capa"));
446 446
    	if (option!=JOptionPane.OK_OPTION) {
447 447
    		return;
448 448
    	}
449 449
		getMapContext().beginAtomicEvent();
450
		
451
		
452
		boolean isOK =this.utiles.removeLayers(selectedItems);			
453
		
450

  
451

  
452
		boolean isOK =this.utiles.removeLayers(selectedItems);
453

  
454 454
		getMapContext().endAtomicEvent();
455
		
455

  
456 456
		if (isOK) {
457 457
			getMapContext().invalidate();
458 458
			if (getMapContext().getLayers().getLayersCount()==0) {
......
466 466

  
467 467
class PasteTocMenuEntry extends MyTocMenuEntry{
468 468
	private XMLEntity xml=null;
469
	
469

  
470 470
	public int getOrder() {
471 471
		return 2;
472 472
	}
473
	
473

  
474 474
	public String getText() {
475
		return PluginServices.getText(this, "pegar");	
475
		return PluginServices.getText(this, "pegar");
476 476
	}
477
	
477

  
478 478
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
479 479
		if (isTocItemBranch(item)) {
480 480
			FLayer lyr = getNodeLayer(item);
481 481
			if (lyr instanceof FLayers) {
482 482
				this.xml = this.getCheckedXMLFromClipboard();
483
				return true;				
483
				return true;
484 484
			}
485
			
485

  
486 486
		} else if (!isTocItemLeaf(item)) {
487 487
			if (getNodeLayer(item) == null) {
488 488
				this.xml = this.getCheckedXMLFromClipboard();
489 489
				return this.xml != null;
490
			}			
491
		}	
490
			}
491
		}
492 492
		return false;
493 493
	}
494
		
494

  
495 495
	private XMLEntity getCheckedXMLFromClipboard() {
496 496
		String sourceString = this.utiles.getFromClipboard();
497 497
		if (sourceString == null) return null;
498
		
498

  
499 499
		XMLEntity xml = this.utiles.unMarshallXMLEntity(sourceString);
500 500
		if (xml == null) return null;
501
		
501

  
502 502
		if (!this.utiles.checkXMLRootNode(xml)) return null;
503
		
503

  
504 504
		if (this.utiles.getXMLEntityChildOfType(xml,"layers") == null) return null;
505
		
505

  
506 506
		return  xml;
507 507
	}
508 508

  
509
	public void execute(ITocItem item, FLayer[] selectedItems) {	
509
	public void execute(ITocItem item, FLayer[] selectedItems) {
510 510
		FLayers root;
511
		
511

  
512 512
		if (this.xml == null) return;
513
		
513

  
514 514
		if (isTocItemBranch(item)) {
515 515
			root = (FLayers)getNodeLayer(item);
516 516
		} else if (getNodeLayer(item) == null){
......
519 519
			return;
520 520
		}
521 521
		getMapContext().beginAtomicEvent();
522
		
522

  
523 523
		boolean isOK = this.utiles.loadLayersFromXML(this.xml,root);
524
		
524

  
525 525
		getMapContext().endAtomicEvent();
526
		
526

  
527 527
		if (isOK) getMapContext().invalidate();
528 528
	}
529
	
529

  
530 530
}
531 531

  
532 532

  
533 533
class Utiles {
534
	
534

  
535 535
	/*
536 536
	 *
537 537
======================================
538 538
 Comportamiento del Pegar documentos:
539 539
======================================
540
 
540

  
541 541
?Pegar vista.
542 542
	Si ya existe una vista en el proyecto con el mismo nombre.
543 543
		1. Abortar
544 544
		2. Pedir nuevo nombre.
545 545
			Que hacemos con las tablas asociadas.
546 546
				No se pegan
547
	Si alguna de las tablas a pegar de las que van en 
547
	Si alguna de las tablas a pegar de las que van en
548 548
	el portapapeles ya existen en el proyecto.
549 549
		1. abortamos
550 550
		2. Informamos al usuario y no se pegan las tablas.
551
 
551

  
552 552
Pegar tabla.
553 553
	Si alguna de las tablas existe.
554 554
		Se pega igualmente (apareceran tablas duplicadas)
555
 
555

  
556 556
Pegar mapa.
557 557
	Si el mapa ya existe en el proyecto.
558 558
		1. Abortar
......
561 561
		1. Abortar
562 562
		2. Usar la vista que ya existe en el proyecto y no
563 563
		   pegar la nueva vista.
564
	Si alguna de las tablas a pegar de las que van en 
565
		el portapapeles ya existen en el proyecto.	
564
	Si alguna de las tablas a pegar de las que van en
565
		el portapapeles ya existen en el proyecto.
566 566
			1. abortamos
567 567
			2. Informamos al usuario y no se pegan las tablas.
568
	
569
 
568

  
569

  
570 570
	 */
571
	
572
	
571

  
572

  
573 573
	/*
574
	 * 
575
	 * 
576
	 * 
574
	 *
575
	 *
576
	 *
577 577
	 * Funciones Publicas para generar XML (copiar)
578
	 * 
579
	 *  
578
	 *
579
	 *
580 580
	*/
581
	
581

  
582 582
	/**
583 583
	 * Genera un XMLEntity con la informacion necesaria
584 584
	 * para copiar los elementos de selectedItems en
......
586 586
	 */
587 587
	public XMLEntity generateXMLCopyDocuments(ProjectElement[] selectedItems) {
588 588
		if (selectedItems.length == 0) return null;
589
		
589

  
590 590
		if (selectedItems[0] instanceof ProjectView) {
591 591
			ProjectView[] views = new ProjectView[selectedItems.length];
592 592
			System.arraycopy(selectedItems,0,views,0,selectedItems.length);
593
			return this.generateXMLCopyViews(views);			
593
			return this.generateXMLCopyViews(views);
594 594
		} else if (selectedItems[0] instanceof ProjectMap) {
595 595
			ProjectMap[] maps = new ProjectMap[selectedItems.length];
596 596
			System.arraycopy(selectedItems,0,maps,0,selectedItems.length);
......
598 598
		} else if (selectedItems[0] instanceof ProjectTable) {
599 599
			ProjectTable[] tables = new ProjectTable[selectedItems.length];
600 600
			System.arraycopy(selectedItems,0,tables,0,selectedItems.length);
601
			return this.generateXMLCopyTables(tables);			
601
			return this.generateXMLCopyTables(tables);
602 602
		} else {
603 603
			//FIXME:????
604 604
			return null;
605 605
		}
606 606
	}
607
	
607

  
608 608
	public XMLEntity generateXMLCopyViews(ProjectView[] selectedItems) {
609 609
		XMLEntity xml = this.newRootNode();
610
		
610

  
611 611
		XMLEntity xmlTables = this.newTablesNode();
612 612
		XMLEntity xmlDataSources = this.newDataSourcesNode();
613 613
		XMLEntity xmlViews = this.newViewsNode();
614 614

  
615 615
		for (int i=0;i < selectedItems.length; i++) {
616 616
			if (!this.addToXMLView(selectedItems[i],xmlViews,xmlTables,xmlDataSources)) return null;
617
				
617

  
618 618
		}
619
		
620
		
621
		if (xmlDataSources.getNumChild() > 0) {
619

  
620

  
621
		if (xmlDataSources.getChildrenCount() > 0) {
622 622
			xml.addChild(xmlDataSources);
623
		}		
624
		if (xmlViews.getNumChild() > 0) {
623
		}
624
		if (xmlViews.getChildrenCount() > 0) {
625 625
			xml.addChild(xmlViews);
626 626
		}
627
		if (xmlTables.getNumChild() > 0) {
627
		if (xmlTables.getChildrenCount() > 0) {
628 628
			xml.addChild(xmlTables);
629 629
		}
630
		
630

  
631 631
		return xml;
632
		
632

  
633 633
	}
634 634

  
635
	
635

  
636 636
	public XMLEntity generateXMLCopyMaps(ProjectMap[] selectedItems) {
637 637
		XMLEntity xml = this.newRootNode();
638
		
638

  
639 639
		XMLEntity xmlTables = this.newTablesNode();
640 640
		XMLEntity xmlDataSources = this.newDataSourcesNode();
641 641
		XMLEntity xmlViews = this.newViewsNode();
......
643 643

  
644 644
		for (int i=0;i < selectedItems.length; i++) {
645 645
			if (!this.addToXMLMap(selectedItems[i],xmlMaps,xmlViews,xmlTables,xmlDataSources)) return null;
646
				
646

  
647 647
		}
648
		
649
		
650
		if (xmlDataSources.getNumChild() > 0) {
648

  
649

  
650
		if (xmlDataSources.getChildrenCount() > 0) {
651 651
			xml.addChild(xmlDataSources);
652
		}		
653
		if (xmlViews.getNumChild() > 0) {
652
		}
653
		if (xmlViews.getChildrenCount() > 0) {
654 654
			xml.addChild(xmlViews);
655 655
		}
656
		if (xmlTables.getNumChild() > 0) {
656
		if (xmlTables.getChildrenCount() > 0) {
657 657
			xml.addChild(xmlTables);
658 658
		}
659
		if (xmlMaps.getNumChild() > 0) {
659
		if (xmlMaps.getChildrenCount() > 0) {
660 660
			xml.addChild(xmlMaps);
661 661
		}
662 662

  
663
		
664
		return xml;		
663

  
664
		return xml;
665 665
	}
666
	
666

  
667 667
	public XMLEntity generateXMLCopyTables(ProjectTable[] selectedItems) {
668 668
		XMLEntity xml = this.newRootNode();
669
		
669

  
670 670
		XMLEntity xmlTables = this.newTablesNode();
671 671
		XMLEntity xmlDataSources = this.newDataSourcesNode();
672 672

  
673 673
		for (int i=0;i < selectedItems.length; i++) {
674 674
			if (!this.addToXMLTable(selectedItems[i],xmlTables,xmlDataSources,null)) return null;
675 675
		}
676
		
677
		
678
		if (xmlDataSources.getNumChild() > 0) {
676

  
677

  
678
		if (xmlDataSources.getChildrenCount() > 0) {
679 679
			xml.addChild(xmlDataSources);
680
		}		
681
		if (xmlTables.getNumChild() > 0) {
680
		}
681
		if (xmlTables.getChildrenCount() > 0) {
682 682
			xml.addChild(xmlTables);
683 683
		}
684
		
685
		return xml;		
684

  
685
		return xml;
686 686
	}
687 687

  
688
	
688

  
689 689
	public XMLEntity generateXMLCopyLayers(FLayer[] actives) {
690
		
690

  
691 691
		XMLEntity xml = this.newRootNode();
692 692
		XMLEntity xmlLayers = this.newLayersNode();
693 693
		XMLEntity xmlTables = this.newTablesNode();
694 694
		XMLEntity xmlDataSources = this.newDataSourcesNode();
695
				
695

  
696 696
		for (int i=0;i < actives.length; i++) {
697 697
			if (!this.addToXMLLayer(actives[i],xmlLayers ,xmlTables,xmlDataSources)) return null;
698
				
698

  
699 699
		}
700
		
701
		if (xmlDataSources.getNumChild() > 0) {
700

  
701
		if (xmlDataSources.getChildrenCount() > 0) {
702 702
			xml.addChild(xmlDataSources);
703
		}		
704
		if (xmlLayers.getNumChild() > 0) {
703
		}
704
		if (xmlLayers.getChildrenCount() > 0) {
705 705
			xml.addChild(xmlLayers);
706 706
		}
707
		if (xmlTables.getNumChild() > 0) {
707
		if (xmlTables.getChildrenCount() > 0) {
708 708
			xml.addChild(xmlTables);
709 709
		}
710
		
710

  
711 711
		return xml;
712
		
712

  
713 713
	}
714
	
715 714

  
716 715

  
716

  
717 717
	/*
718
	 * 
719
	 * 
720
	 * 
718
	 *
719
	 *
720
	 *
721 721
	 * Funciones Publicas de carga de un XML (pegar)
722
	 * 
723
	 * 
724
	 *  
722
	 *
723
	 *
724
	 *
725 725
	*/
726 726

  
727 727
	public boolean loadLayersFromXML(XMLEntity xml, FLayers root) {
728 728
		XMLEntity xmlLayers = this.getXMLEntityChildOfType(xml,"layers");
729 729
		XMLEntity xmlTables = this.getXMLEntityChildOfType(xml,"tables");
730 730
		XMLEntity xmlDataSources = this.getXMLEntityChildOfType(xml,"dataSources");
731
		
731

  
732 732
		if (xmlLayers == null ) return false;
733
		
734
		// Se pegan las tablas igualmente 
733

  
734
		// Se pegan las tablas igualmente
735 735
		/*
736 736
		Project project = this.getProject();
737
		
737

  
738 738
		Hashtable tablesConfits = this.getConflicts(xmlTables,project.getTables());
739 739
		*/
740
		
741
		
740

  
741

  
742 742
		if (xmlDataSources != null)  {
743 743
			if (!this.registerDataSources(xmlDataSources)) return false;
744 744
		}
745
		
745

  
746 746
		if (!this.addLayers(xmlLayers,root)) return false;
747
		
747

  
748 748
		if (xmlTables != null)  {
749 749
			if (!this.addTables(xmlTables)) return false;
750 750
		}
751
		
751

  
752 752
		return true;
753
		
753

  
754 754
	}
755
	
756
	
755

  
756

  
757 757
	public boolean loadViewsFromXML(XMLEntity xml) {
758 758
		XMLEntity xmlViews = this.getXMLEntityChildOfType(xml,"views");
759 759
		XMLEntity xmlTables = this.getXMLEntityChildOfType(xml,"tables");
760 760
		XMLEntity xmlDataSources = this.getXMLEntityChildOfType(xml,"dataSources");
761
		
761

  
762 762
		if (xmlViews == null ) return false;
763 763

  
764 764
		Project project = this.getProject();
765 765

  
766 766
		Hashtable viewsConflits = this.getConflicts(xmlViews,project.getViews());
767
		
767

  
768 768
		Hashtable tablesConflits = this.getConflicts(xmlTables,project.getTables());
769
		
769

  
770 770
		if (viewsConflits != null && viewsConflits.size() > 0) {
771 771
			int option = JOptionPane.showConfirmDialog(
772 772
					(Component)PluginServices.getMainFrame(),
......
803 803
					JOptionPane.showMessageDialog(
804 804
							(Component)PluginServices.getMainFrame(),
805 805
							"<html>"+
806
								PluginServices.getText(this,"operacion_cancelada") +":<br>" + 
806
								PluginServices.getText(this,"operacion_cancelada") +":<br>" +
807 807
								PluginServices.getText(this,"nombre_no_valido")+
808 808
							"</html>",//Mensaje
809 809
							PluginServices.getText(this,"pegar_vistas"),//FIXME: getText
......
812 812
					return false;
813 813
				}
814 814
				view.setName(newName);
815
			}			
815
			}
816 816
			if (xmlTables != null) xmlTables.removeAllChilds();
817 817
			tablesConflits = null;
818 818
		}
819
		
819

  
820 820
		if (tablesConflits != null && tablesConflits.size() > 0) {
821 821
			int option = JOptionPane.showConfirmDialog(
822 822
					(Component)PluginServices.getMainFrame(),
......
831 831
			if (option != JOptionPane.YES_OPTION) {
832 832
				return false;
833 833
			}
834
			xmlTables.removeAllChilds();			
834
			xmlTables.removeAllChilds();
835 835
		}
836 836

  
837 837

  
838 838
		if (xmlDataSources != null)  {
839 839
			if (!this.registerDataSources(xmlDataSources)) return false;
840 840
		}
841
		
841

  
842 842
		if (!this.addViews(xmlViews)) return false;
843
		
843

  
844 844
		if (xmlTables != null)  {
845 845
			if (!this.addTables(xmlTables)) return false;
846 846
		}
......
851 851
	public boolean loadTablesFromXML(XMLEntity xml) {
852 852
		XMLEntity xmlTables = this.getXMLEntityChildOfType(xml,"tables");
853 853
		XMLEntity xmlDataSources = this.getXMLEntityChildOfType(xml,"dataSources");
854
		
855
		
854

  
855

  
856 856
		if (xmlTables == null ) return false;
857
		
857

  
858 858
		/*
859 859
		Project project = this.getProject();
860
		
860

  
861 861
		Hashtable tablesConfits = this.getConflicts(xmlTables,project.getTables());
862 862
		*/
863 863

  
864 864
		if (xmlDataSources != null)  {
865 865
			if (!this.registerDataSources(xmlDataSources)) return false;
866 866
		}
867
		
868
	
869
		
867

  
868

  
869

  
870 870
		return this.addTables(xmlTables);
871 871
	}
872
	
872

  
873 873
	public boolean loadMapsFromXML(XMLEntity xml) {
874 874
		XMLEntity xmlMaps = this.getXMLEntityChildOfType(xml,"Maps");
875 875
		XMLEntity xmlViews = this.getXMLEntityChildOfType(xml,"views");
876 876
		XMLEntity xmlTables = this.getXMLEntityChildOfType(xml,"tables");
877 877
		XMLEntity xmlDataSources = this.getXMLEntityChildOfType(xml,"dataSources");
878
		
878

  
879 879
		if (xmlMaps == null ) return false;
880
		
880

  
881 881
		Project project = this.getProject();
882 882

  
883 883
		Hashtable mapsConflits = this.getConflicts(xmlMaps,project.getMaps());
884
		
884

  
885 885
		Hashtable viewsConflits = this.getConflicts(xmlViews,project.getViews());
886
		
886

  
887 887
		Hashtable tablesConflits = this.getConflicts(xmlTables,project.getTables());
888
		
889
		
888

  
889

  
890 890
		if (mapsConflits != null && mapsConflits.size() > 0) {
891 891
			int option = JOptionPane.showConfirmDialog(
892 892
					(Component)PluginServices.getMainFrame(),
......
921 921
					JOptionPane.showMessageDialog(
922 922
							(Component)PluginServices.getMainFrame(),
923 923
							"<html>"+
924
								PluginServices.getText(this,"operacion_cancelada") +":<br>" + 
924
								PluginServices.getText(this,"operacion_cancelada") +":<br>" +
925 925
								PluginServices.getText(this,"nombre_no_valido")+
926
							"</html>",//Mensaje							
926
							"</html>",//Mensaje
927 927
							PluginServices.getText(this,"pegar_mapas"),//titulo
928 928
							JOptionPane.ERROR_MESSAGE
929 929
							);
930 930
					return false;
931 931
				}
932 932
				map.setName(newName);
933
			}			
933
			}
934 934
		}
935
		
935

  
936 936
		if (viewsConflits != null && viewsConflits.size() > 0) {
937 937
			int option = JOptionPane.showConfirmDialog(
938 938
					(Component)PluginServices.getMainFrame(),
939 939
					"<html>"+
940
						PluginServices.getText(this,"conflicto_de_nombres_de_vistas_al_pegar") + "<br>" +						
940
						PluginServices.getText(this,"conflicto_de_nombres_de_vistas_al_pegar") + "<br>" +
941 941
						PluginServices.getText(this,"no_se_pegaran_las_vistas_del_conflicto") + "<br>" +
942 942
						PluginServices.getText(this,"desea_continuar") +
943 943
					"</html>",
......
948 948
				return false;
949 949
			}
950 950
			// Eliminamos las vistas del xml que no vamos a importar
951
			
951

  
952 952
			// Esto me devuelve los indices en orden inverso
953 953
			int[] indexes = this.getIndexOfConflict(viewsConflits);
954 954
			for (int i=0;i < indexes.length;i++) {
955 955
				xmlViews.removeChild(indexes[i]);
956 956
			}
957
			viewsConflits = null;			
958
			
957
			viewsConflits = null;
958

  
959 959
		}
960
		
961 960

  
961

  
962 962
		if (tablesConflits != null && tablesConflits.size() > 0) {
963 963
			int option = JOptionPane.showConfirmDialog(
964 964
					(Component)PluginServices.getMainFrame(),
......
973 973
			if (option != JOptionPane.YES_OPTION) {
974 974
				return false;
975 975
			}
976
			xmlTables.removeAllChilds();			
976
			xmlTables.removeAllChilds();
977 977
		}
978 978

  
979 979

  
980 980
		if (xmlDataSources != null)  {
981 981
			if (!this.registerDataSources(xmlDataSources)) return false;
982 982
		}
983
		
983

  
984 984
		if (xmlViews != null)  {
985 985
			if (!this.addViews(xmlViews)) return false;
986 986
		}
987 987

  
988 988
		if (xmlTables != null)  {
989 989
			if (!this.addTables(xmlTables)) return false;
990
		}		
991
		
990
		}
991

  
992 992
		return this.addMaps(xmlMaps);
993 993

  
994 994
	}
995 995

  
996
	
997
	
998
	
999
	
1000
	
1001
	
1002
	
1003
	
1004
	
1005
	
996

  
997

  
998

  
999

  
1000

  
1001

  
1002

  
1003

  
1004

  
1005

  
1006 1006
	/**
1007 1007
	 * Devuelve las claves de conflits ordenados
1008 1008
	 * en orden inverso. Las claves se esperan que
1009 1009
	 * sean instancias de Integer
1010
	 */	
1010
	 */
1011 1011
	private int[] getIndexOfConflict(Hashtable conflits) {
1012 1012
		Object[] tmpArray = conflits.keySet().toArray();
1013 1013
		Arrays.sort(tmpArray,new Comparator() {
......
1020 1020
		for (int i = 0;i< tmpArray.length;i++) {
1021 1021
			indexes[i] = ((Integer)tmpArray[i]).intValue();
1022 1022
		}
1023
		return indexes; 
1024
	
1025
		
1023
		return indexes;
1024

  
1025

  
1026 1026
	}
1027
	
1028
	
1027

  
1028

  
1029 1029
	private boolean addToXMLMapDependencies(ProjectMap map, XMLEntity xmlViews,XMLEntity xmlTables, XMLEntity xmlDataSources) {
1030 1030
		IFFrame[] components = map.getModel().getFFrames();
1031
		for (int i=0; i < components.length; i++) {			
1032
			if (components[i] instanceof FFrameView) {				
1031
		for (int i=0; i < components.length; i++) {
1032
			if (components[i] instanceof FFrameView) {
1033 1033
				ProjectView view = ((FFrameView)components[i]).getView();
1034 1034
				if (findChildInXML(xmlViews,"name",view.getName())==null) {
1035 1035
					if (!this.addToXMLView(view,xmlViews,xmlTables,xmlDataSources)) return false;
1036 1036
				}
1037 1037
			}
1038 1038
		}
1039
		
1039

  
1040 1040
		return true;
1041 1041
	}
1042
	
1042

  
1043 1043
	private boolean addToXMLMap(ProjectMap map,XMLEntity xmlMaps,XMLEntity xmlViews,XMLEntity xmlTables,XMLEntity xmlDataSources) {
1044 1044
		try {
1045 1045
			xmlMaps.addChild(map.getXMLEntity());
1046
			
1046

  
1047 1047
			return this.addToXMLMapDependencies(map,xmlViews,xmlTables,xmlDataSources);
1048
			
1048

  
1049 1049
		} catch (SaveException e) {
1050 1050
			// TODO Auto-generated catch block
1051 1051
			e.printStackTrace();
1052 1052
			return false;
1053 1053
		}
1054 1054
	}
1055
	
1055

  
1056 1056
	private boolean addToXMLView(ProjectView view,XMLEntity xmlViews,XMLEntity xmlTables,XMLEntity xmlDataSources) {
1057 1057
		try {
1058 1058
			xmlViews.addChild(view.getXMLEntity());
1059
			
1059

  
1060 1060
			if (!this.addToXMLLayerDependencies(view.getMapContext().getLayers(),xmlTables,xmlDataSources)) return false;
1061
			
1061

  
1062 1062
			if (view.getMapOverViewContext() != null) {
1063 1063
				return this.addToXMLLayerDependencies(view.getMapOverViewContext().getLayers(),xmlTables,xmlDataSources);
1064 1064
			} else {
1065 1065
				return true;
1066 1066
			}
1067
			
1068
			
1069
			
1067

  
1068

  
1069

  
1070 1070
		} catch (SaveException e) {
1071 1071
			// TODO Auto-generated catch block
1072 1072
			e.printStackTrace();
......
1079 1079
	public boolean checkXMLRootNode(XMLEntity xml) {
1080 1080
		if (!xml.contains("applicationName")) return false;
1081 1081
		if (!xml.getStringProperty("applicationName").equalsIgnoreCase("gvSIG")) return false;
1082
		
1082

  
1083 1083
		if (!xml.contains("version")) return false;
1084 1084
		if (!xml.getStringProperty("version").equalsIgnoreCase(Version.format())) return false;
1085
		
1085

  
1086 1086
		return true;
1087 1087
	}
1088
	
1088

  
1089 1089
	private void fillXMLRootNode(XMLEntity xml) {
1090 1090
		xml.putProperty("applicationName","gvSIG");
1091
		xml.putProperty("version",Version.format());		
1091
		xml.putProperty("version",Version.format());
1092 1092
	}
1093
	
1093

  
1094 1094
	public XMLEntity getXMLEntityChildOfType(XMLEntity xml,String type) {
1095
		int childCount = xml.getNumChild();
1095
		int childCount = xml.getChildrenCount();
1096 1096
		XMLEntity child;
1097 1097
		for (int i=0; i < childCount; i++  ) {
1098 1098
			child = xml.getChild(i);
......
1103 1103
			}
1104 1104
		}
1105 1105
		return null;
1106
		
1106

  
1107 1107
	}
1108
			
1109
	private Hashtable getConflicts(XMLEntity xml,ArrayList elements) {		
1110
		if (xml == null || xml.getNumChild() < 1) return null;			
1108

  
1109
	private Hashtable getConflicts(XMLEntity xml,ArrayList elements) {
1110
		if (xml == null || xml.getChildrenCount() < 1) return null;
1111 1111
		Hashtable conflits = new Hashtable();
1112
		for (int iXML=0;iXML < xml.getNumChild();iXML++) {
1112
		for (int iXML=0;iXML < xml.getChildrenCount();iXML++) {
1113 1113
			XMLEntity child = xml.getChild(iXML);
1114 1114
			Iterator iter = elements.iterator();
1115 1115
			while (iter.hasNext()) {
......
1118 1118
					conflits.put(new Integer(iXML),child);
1119 1119
					break;
1120 1120
				}
1121
				
1121

  
1122 1122
			}
1123 1123
		}
1124 1124
		return conflits;
......
1128 1128

  
1129 1129
	private boolean registerDataSources(XMLEntity xmlDataSources) {
1130 1130
		try {
1131
			int numDataSources = xmlDataSources.getNumChild();
1132
			
1131
			int numDataSources = xmlDataSources.getChildrenCount();
1132

  
1133 1133
			if (numDataSources == 0) return true;
1134 1134
			DataSourceFactory dsFactory = LayerFactory.getDataSourceFactory();
1135
			
1135

  
1136 1136
			for (int i = 0; i < numDataSources; i++) {
1137 1137
				XMLEntity child = xmlDataSources.getChild(i);
1138 1138
				String name = child.getStringProperty("gdbmsname");
1139
				
1139

  
1140 1140
				if (dsFactory.getDriverInfo(name) == null) {
1141
					if (child.getStringProperty("type").equals("otherDriverFile")) {					
1141
					if (child.getStringProperty("type").equals("otherDriverFile")) {
1142 1142
						LayerFactory.getDataSourceFactory().addFileDataSource(
1143
								child.getStringProperty("driverName"), 
1143
								child.getStringProperty("driverName"),
1144 1144
								name,
1145 1145
								child.getStringProperty("file")
1146 1146
						);
1147
						
1148
						
1147

  
1148

  
1149 1149
					} else if (child.getStringProperty("type").equals("sameDriverFile")) {
1150 1150
						/*                                String layerName = child.getStringProperty("layerName");
1151 1151
						 ProjectView vista = project.getViewByName(child.getStringProperty(
1152 1152
						 "viewName"));
1153 1153
						 FLayer layer = vista.getMapContext().getLayers().getLayer(layerName);
1154
						 
1154

  
1155 1155
						 modelo = ((AlphanumericData) layer).getRecordset();
1156 1156
						 associatedTable = (AlphanumericData) layer;
1157 1157
						 */
......
1169 1169
					}
1170 1170
				}
1171 1171
			}
1172
			
1172

  
1173 1173
			return true;
1174 1174
		} catch (Exception e) {
1175 1175
			e.printStackTrace();
1176 1176
			return false;
1177 1177
		}
1178 1178
	}
1179
	
1179

  
1180 1180
	private boolean addTables(XMLEntity xmlTables) {
1181 1181
		try {
1182
			int numTables = xmlTables.getNumChild();
1182
			int numTables = xmlTables.getChildrenCount();
1183 1183
			if (numTables == 0) return true;
1184
			
1184

  
1185 1185
			Project project = this.getProject();
1186
			
1186

  
1187 1187
			for (int i = 0; i < numTables; i++) {
1188 1188
				try{
1189 1189
					ProjectTable ptable = (ProjectTable) ProjectTable.createFromXML(xmlTables.getChild(i), project);
......
1199 1199
					return false;
1200 1200
				}
1201 1201
			}
1202
			
1202

  
1203 1203
			project.setLinkTable();
1204 1204

  
1205 1205
			return true;
1206 1206
		} catch (Exception e) {
1207 1207
			e.printStackTrace();
1208
			return false;			
1208
			return false;
1209 1209
		}
1210 1210
	}
1211
	
1211

  
1212 1212
	public XMLEntity findChildInXML(XMLEntity xml,String propName,String value) {
1213
		int num = xml.getNumChild();
1213
		int num = xml.getChildrenCount();
1214 1214
		XMLEntity child;
1215 1215
		for (int i=0;i < num; i++) {
1216 1216
			child = xml.getChild(i);
......
1220 1220
		}
1221 1221
		return null;
1222 1222
	}
1223
	
1223

  
1224 1224
	private boolean addLayers(XMLEntity xmlLayers,FLayers root) {
1225 1225
		try {
1226 1226
			XMLEntity child;
1227
			int numLayers = xmlLayers.getNumChild();
1227
			int numLayers = xmlLayers.getChildrenCount();
1228 1228
			for (int i = 0; i < numLayers; i++) {
1229 1229
				child = xmlLayers.getChild(i);
1230 1230
				if (!root.addLayerFromXMLEntity(child,null)) return false;
......
1232 1232
			return true;
1233 1233
		} catch (Exception e) {
1234 1234
			e.printStackTrace();
1235
			return false;			
1235
			return false;
1236 1236
		}
1237
		
1237

  
1238 1238
	}
1239
	
1240
	
1239

  
1240

  
1241 1241
	private boolean addViews(XMLEntity xmlViews) {
1242 1242
		try {
1243 1243
			Project project = this.getProject();
1244 1244
			XMLEntity child;
1245
			int numLayers = xmlViews.getNumChild();
1245
			int numLayers = xmlViews.getChildrenCount();
1246 1246
			for (int i = 0; i < numLayers; i++) {
1247 1247
				child = xmlViews.getChild(i);
1248 1248

  
1249 1249
				ProjectView pv = (ProjectView) ProjectView.createFromXML(child, project);
1250
				project.addView(pv);				
1251
				
1250
				project.addView(pv);
1251

  
1252 1252
			}
1253 1253
			return true;
1254 1254
		} catch (Exception e) {
1255 1255
			e.printStackTrace();
1256
			return false;			
1256
			return false;
1257 1257
		}
1258
		
1258

  
1259 1259
	}
1260
	
1260

  
1261 1261
	private boolean addMaps(XMLEntity xmlMaps) {
1262 1262
		try {
1263 1263
			Project project = this.getProject();
1264 1264
			XMLEntity child;
1265
			int numLayers = xmlMaps.getNumChild();
1265
			int numLayers = xmlMaps.getChildrenCount();
1266 1266
			for (int i = 0; i < numLayers; i++) {
1267 1267
				child = xmlMaps.getChild(i);
1268 1268

  
1269 1269
				ProjectMap pm = (ProjectMap) ProjectMap.createFromXML(child, project);
1270
				project.addMap(pm);				
1271
				
1270
				project.addMap(pm);
1271

  
1272 1272
			}
1273 1273
			return true;
1274 1274
		} catch (Exception e) {
1275 1275
			e.printStackTrace();
1276
			return false;			
1276
			return false;
1277 1277
		}
1278
		
1278

  
1279 1279
	}
1280
	
1280

  
1281 1281
	private Project getProject() {
1282 1282
		 return ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
1283 1283
	}
1284
	
1284

  
1285 1285
	private boolean addToXMLDataSource(SourceInfo source,XMLEntity xmlDataSources, Project project) {
1286 1286
		if (project== null) {
1287 1287
			project = this.getProject();
1288
		}		
1288
		}
1289 1289
  	  	xmlDataSources.addChild(project.getSourceInfoXMLEntity(source));
1290
  	  	
1290

  
1291 1291
  	  	return true;
1292 1292
	}
1293
	
1294
	private boolean addToXMLTable(ProjectTable pt,XMLEntity xmlTables,XMLEntity xmlDataSources,Project project) {		
1293

  
1294
	private boolean addToXMLTable(ProjectTable pt,XMLEntity xmlTables,XMLEntity xmlDataSources,Project project) {
1295 1295
		if (project== null) {
1296 1296
			project = this.getProject();
1297 1297
		}
......
1299 1299
		XMLEntity xmlTable = null;
1300 1300
		try {
1301 1301
			xmlTable = pt.getXMLEntity();
1302
			
1302

  
1303 1303
			xmlTables.addChild(xmlTable);
1304
			
1304

  
1305 1305
			if (pt.getAssociatedTable() != null) {
1306 1306
				this.addToXMLDataSource(pt.getAssociatedTable().getRecordset().getSourceInfo(),xmlDataSources,project);
1307 1307
			}
1308
			
1308

  
1309 1309
			if (pt.getLinkTable() != null) {
1310 1310
				if (findChildInXML(xmlTables,"name",pt.getLinkTable()) == null)  {
1311 1311
					ProjectTable ptLink = project.getTable(pt.getLinkTable());
......
1320 1320
			// TODO Auto-generated catch block
1321 1321
			e.printStackTrace();
1322 1322
			return false;
1323
		}		
1324
		
1325
  	  	return true;		
1323
		}
1324

  
1325
  	  	return true;
1326 1326
	}
1327
	
1327

  
1328 1328
	private boolean addToXMLLayerDependencies(FLayer lyr,XMLEntity xmlTables,XMLEntity xmlDataSources) {
1329 1329
		try {
1330 1330
			Project project = this.getProject();
1331
			
1331

  
1332 1332
			if (lyr instanceof FLayers) {
1333 1333
				FLayers lyrs = (FLayers)lyr;
1334 1334
				int count = lyrs.getLayersCount();
......
1337 1337
					this.addToXMLLayerDependencies(subLyr,xmlTables,xmlDataSources);
1338 1338
				}
1339 1339

  
1340
		    } else if (lyr instanceof AlphanumericData){            	
1340
		    } else if (lyr instanceof AlphanumericData){
1341 1341
            	if (!this.addToXMLDataSource(
1342 1342
        			((AlphanumericData)lyr).getRecordset().getSourceInfo(),
1343 1343
        			xmlDataSources,
1344 1344
        			project
1345
        			
1345

  
1346 1346
            	)) return false;
1347
            	
1347

  
1348 1348
                ProjectTable pt = project.getTable((AlphanumericData) lyr);
1349
                if (pt != null) { 
1349
                if (pt != null) {
1350 1350
                	if (!this.addToXMLTable(pt,xmlTables,xmlDataSources,project)) return false;
1351 1351
                }
1352 1352

  
......
1358 1358
			return false;
1359 1359
		} catch (Exception e) {
1360 1360
			e.printStackTrace();
1361
			return false;			
1362
		
1361
			return false;
1362

  
1363 1363
		}
1364 1364
		return true;
1365
		
1365

  
1366 1366
	}
1367
	
1368
	private boolean addToXMLLayer(FLayer lyr,XMLEntity xmlLayers,XMLEntity xmlTables,XMLEntity xmlDataSources) {		
1367

  
1368
	private boolean addToXMLLayer(FLayer lyr,XMLEntity xmlLayers,XMLEntity xmlTables,XMLEntity xmlDataSources) {
1369 1369
		try {
1370 1370
			xmlLayers.addChild(lyr.getXMLEntity());
1371
			
1371

  
1372 1372
			return this.addToXMLLayerDependencies(lyr,xmlTables,xmlDataSources);
1373 1373

  
1374 1374
		} catch (XMLException e) {
......
1376 1376
			return false;
1377 1377
		} catch (Exception e) {
1378 1378
			e.printStackTrace();
1379
			return false;			
1379
			return false;
1380 1380
		}
1381 1381
	}
1382
	
1382

  
1383 1383
	private XMLEntity newRootNode() {
1384 1384
		XMLEntity xml = new XMLEntity();
1385 1385
		fillXMLRootNode(xml);
......
1403 1403
		xmlTables.putProperty("type","tables");
1404 1404
		return xmlTables;
1405 1405
	}
1406
	
1406

  
1407 1407
	private XMLEntity newViewsNode() {
1408 1408
		XMLEntity xmlTables = new XMLEntity();
1409 1409
		xmlTables.putProperty("type","views");
......
1419 1419

  
1420 1420
	public void putInClipboard(String data) {
1421 1421
		StringSelection ss = new StringSelection(data);
1422
		
1423
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,ss);		
1422

  
1423
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,ss);
1424 1424
	}
1425
	
1425

  
1426 1426
	public String marshallXMLEntity(XMLEntity xml) {
1427 1427
		StringWriter buffer = new StringWriter();
1428 1428

  
......
1448 1448
			e3.printStackTrace();
1449 1449
			return null;
1450 1450
		}
1451
		
1451

  
1452 1452
		return buffer.toString();
1453
		
1453

  
1454 1454
	}
1455
	
1455

  
1456 1456
	public XMLEntity unMarshallXMLEntity(String data) {
1457 1457
		StringReader reader = new StringReader(data);
1458
		
1458

  
1459 1459
		XmlTag tag;
1460 1460
		try {
1461 1461
			tag = (XmlTag) XmlTag.unmarshal(reader);
......
1465 1465
			return null;
1466 1466
		}
1467 1467
		XMLEntity xml=new XMLEntity(tag);
1468
		
1468

  
1469 1469
		return xml;
1470 1470
	}
1471 1471

  
1472
	public String getFromClipboard() {	
1473
			 
1472
	public String getFromClipboard() {
1473

  
1474 1474
		 try {
1475 1475
			return (String)Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
1476 1476
		} catch (UnsupportedFlavorException e) {
......
1478 1478
		} catch (IOException e) {
1479 1479
			// TODO Auto-generated catch block
1480 1480
			return null;
1481
		}		 
1481
		}
1482 1482
	}
1483
	
1483

  
1484 1484
	public boolean removeLayers(FLayer[] actives) {
1485 1485
    	for (int i = actives.length-1; i>=0; i--){
1486 1486
        	try {
......
1512 1512
    	}
1513 1513
		return true;
1514 1514
	}
1515
	
1515

  
1516 1516
	public boolean removeDocuments(ProjectElement[] selectedItems) {
1517 1517
		Project p = this.getProject();
1518 1518
		ProjectElement element;
1519 1519
		int index;
1520 1520
		for (int i=selectedItems.length-1;i>=0;i--) {
1521
			
1521

  
1522 1522
			element = selectedItems[i];
1523
			
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff