Statistics
| Revision:

svn-gvsig-desktop / trunk / prototypes / mobile / desktop / extensions / extExportMobile / src / es / prodevelop / gvsig / exportMobile / ui / panels / ExportPanel.java @ 19124

History | View | Annotate | Download (22.5 KB)

1
package es.prodevelop.gvsig.exportMobile.ui.panels;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.Color;
5
import java.awt.Dimension;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
import java.awt.geom.Rectangle2D;
9
import java.io.File;
10
import java.util.ArrayList;
11

    
12
import javax.swing.BorderFactory;
13
import javax.swing.ButtonGroup;
14
import javax.swing.JButton;
15
import javax.swing.JCheckBox;
16
import javax.swing.JComboBox;
17
import javax.swing.JLabel;
18
import javax.swing.JPanel;
19
import javax.swing.JRadioButton;
20
import javax.swing.JScrollPane;
21
import javax.swing.JTextField;
22
import javax.swing.border.TitledBorder;
23

    
24
import org.apache.log4j.Logger;
25

    
26
import com.iver.andami.PluginServices;
27
import com.iver.andami.ui.mdiManager.IWindow;
28
import com.iver.andami.ui.mdiManager.WindowInfo;
29
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
30
import com.iver.cit.gvsig.fmap.layers.FLayer;
31
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
32
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
33
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
34
import com.iver.cit.gvsig.project.ProjectExtent;
35
import com.iver.cit.gvsig.project.documents.view.gui.View;
36

    
37
import es.prodevelop.gvsig.exportMobile.LayerObject;
38
import es.prodevelop.gvsig.exportMobile.files.NewDir;
39
import es.prodevelop.gvsig.exportMobile.layerexporters.ExportProcess;
40
import es.prodevelop.gvsig.exportMobile.layerexporters.VectorialExporterTask;
41
import es.prodevelop.gvsig.exportMobile.rectangle.DrawRectangle;
42

    
43
/**
44
 * Principal panel extension 
45
 * @author Anabel Moreno
46
 *
47
 */
48

    
49
public class ExportPanel extends JPanel implements IWindow, ActionListener {
50

    
51
        /**
52
         * 
53
         */
54
        private static final long serialVersionUID = 1L;
55
        
56
        private static Logger logger = Logger.getLogger(ExportPanel.class);
57
        
58
        private ArrayList listLyrsObj = new ArrayList();
59

    
60
        private ArrayList arLayers = new ArrayList();
61

    
62
        public ArrayList arrDescLayers;
63
        
64
        private File newdirout;
65

    
66
        private int cont = 0 ;
67
        private int indxsele;
68

    
69
        private JPanel topPanel = new JPanel();
70

    
71
        private JPanel bottomPanel = new JPanel();
72

    
73
        private JPanel topPathPanel = new JPanel();
74

    
75
        private JPanel topOptionsPanel = new JPanel();
76

    
77
        private JPanel centerPanel = new JPanel();
78

    
79
        private JPanel titlePanel = new JPanel();
80

    
81
        private JTextField pathImport;
82

    
83
        private JTextField nameProy;
84

    
85
        private JLabel path;
86
        private JLabel typLayer;
87
        private JLabel nomLayer;
88
        private JLabel atLayer;
89
        private JLabel cboLayer;
90
        private JLabel lyrInView;
91

    
92
        private JLabel proyect;
93

    
94
        private JButton execute;
95

    
96
        //private JButton synchro;
97

    
98
        private JButton pathBoton;
99

    
100
        private JButton cancel;
101

    
102
        private JButton save;
103

    
104
        private JButton open;
105

    
106
        private JCheckBox allSelect;
107

    
108
        private JRadioButton viewAc;
109

    
110
        private JRadioButton extent;
111

    
112
        private String namePath;
113

    
114
        private String namProy = "";
115

    
116
        private String exportZone;
117

    
118
        private ButtonGroup actionsTopPanel;
119

    
120
        private boolean proyEmpty;
121

    
122
        private boolean dirEmpty;
123

    
124
        private JComboBox comboExtents;
125

    
126
        private JScrollPane scroll = new JScrollPane();
127

    
128
        private ProjectExtent[] listExtents;
129

    
130
        private PanelIntoScroll panelScroll;
131

    
132
        private View view;
133

    
134
        private DrawRectangle rect;
135

    
136
        private Rectangle2D rectangle;
137
        
138
        private static String EMPTY = "";
139

    
140
        private static String VIEW_ACTUAL = "VA";
141

    
142
        private static String EXTENT = "EN";
143

    
144
        private static int WIDTH_PANEL = 560;
145

    
146
        private static int HEIGHT_PANEL = 500;
147

    
148
        private static int HEIGHT_TOP_PANEL = 140;
149

    
150
        private static int HEIGTH_TOP_PATH_PANEL = 80;
151

    
152
        private static int HEIGTH_TOP_OPTIONS_PANEL = 60;
153

    
154
        private static int HEIGTH_BOTTOM_PANEL = 45;
155

    
156
        private static int HEIGTH_CENTER_PANEL = 30;
157
        
158
        private static int HEIGTH_TITLE_PANEL = 24;
159

    
160
        private static int PROY_X = 20;
161

    
162
        private static int PROY_Y = 10;
163

    
164
        private static int PROY_W = 100;
165

    
166
        private static int PROY_H = 20;
167

    
168
        private static int NPROY_X = 140;
169

    
170
        private static int NPROY_Y = 10;
171

    
172
        private static int NPROY_W = 400;
173

    
174
        private static int NPROY_H = 20;
175

    
176
        private static int PATH_X = 20;
177

    
178
        private static int PATH_Y = 45;
179

    
180
        private static int PATH_W = 100;
181

    
182
        private static int PATH_H = 20;
183

    
184
        private static int PATHIMPORT_X = 140;
185

    
186
        private static int PATHIMPORT_Y = 45;
187

    
188
        private static int PATHIMPORT_W = 350;
189

    
190
        private static int PATHIMPORT_H = 20;
191

    
192
        private static int PATHBUTTON_X = 510;
193

    
194
        private static int PATHBUTTON_Y = 40;
195

    
196
        private static int PATHBUTTON_W = 30;
197

    
198
        private static int PATHBUTTON_H = 30;
199

    
200
        private static int VIEWACT_X = 120;
201

    
202
        private static int VIEWACT_Y = 20;
203

    
204
        private static int VIEWACT_W = 100;
205

    
206
        private static int VIEWACT_H = 20;
207

    
208
        private static int EXTENT_X = 290;
209

    
210
        private static int EXTENT_Y = 20;
211

    
212
        private static int EXTENT_W = 80;
213

    
214
        private static int EXTENT_H = 20;
215

    
216
        private static int EXTENTCOMBO_X = 390;
217

    
218
        private static int EXTENTCOMBO_Y = 20;
219

    
220
        private static int EXTENTCOMBO_W = 120;
221

    
222
        private static int EXTENTCOMBO_H = 20;
223

    
224
        private static int EX_X = 15;
225

    
226
        private static int BUTT_Y = 10;
227

    
228
        private static int BUTT_W = 90;
229

    
230
        private static int BUTT_H = 25;
231

    
232
        private static int SY_X = 125;
233

    
234
        private static int CAN_X = 235;
235

    
236
        private static int OP_X = 345;
237

    
238
        private static int SAVE_X = 455;
239

    
240
        private static int ALLSEL_X = 30;
241

    
242
        private static int LABEL_Y = 5;
243

    
244
        private static int LABEL_H = 14;
245

    
246
        private static int ALLSEL_W = 17;
247

    
248
        private static int ALLSEL_H = 13;
249

    
250
        private static int TYPLYR_X = 77;
251

    
252
        private static int TYPLYR_W = 20;
253

    
254
        private static int LYRINVIEW_X = 135;
255

    
256
        private static int LYRINVIEW_W = 40;
257

    
258
        private static int NAMELAYER_X = 200;
259

    
260
        private static int NAMELAYER_W = 100;
261

    
262
        private static int ATLYR_X = 325;
263

    
264
        private static int ATLYR_W = 50;
265

    
266
        private static int CBOLYR_X = 450;
267

    
268
        private static int CBOLYR_W = 70;
269
        
270

    
271
        public WindowInfo getWindowInfo() {
272

    
273
                WindowInfo m_viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
274
                m_viewInfo.setWidth(566);
275
                m_viewInfo.setHeight(506);
276
                m_viewInfo.setTitle(PluginServices.getText(this, "exporMob"));
277
                return m_viewInfo;
278
        }
279

    
280
        /**
281
         * Create export panel
282
         * 
283
         * @param arrLayers,
284
         *            list with all layers
285
         * @param listExt,
286
         *            list extents
287
         */
288
        public ExportPanel(ArrayList arrLayers, ProjectExtent[] listExt) {
289

    
290
                super();
291

    
292
                view = (View) PluginServices.getMDIManager().getActiveWindow();
293
                
294
                
295
                listExtents = listExt;
296
                arLayers = arrLayers;
297

    
298
                /* PRINCIPAL PANEL */
299
                setSize(WIDTH_PANEL, HEIGHT_PANEL);
300
                this.setLayout(new BorderLayout());
301

    
302
                /* TOP PANEL */
303
                topPanel.setLayout(new BorderLayout());
304
                topPanel.setSize(new Dimension(WIDTH_PANEL, HEIGHT_TOP_PANEL));
305

    
306
                path = new JLabel(PluginServices.getText(this, "direxport"));
307
                pathImport = new JTextField(EMPTY);
308
                pathImport.setEditable(false);
309
                pathImport.setBackground(Color.WHITE);
310

    
311
                nameProy = new JTextField(EMPTY);
312
                proyect = new JLabel(PluginServices.getText(this, "nomproy"));
313
                pathBoton = new JButton("...");
314
                viewAc = new JRadioButton(PluginServices.getText(this, "viewA"));
315
                viewAc.setSelected(true);
316
                extent = new JRadioButton(PluginServices.getText(this, "exent"));
317
                extent.setSelected(false);
318

    
319
                actionsTopPanel = new ButtonGroup();
320
                actionsTopPanel.add(viewAc);
321
                actionsTopPanel.add(extent);
322

    
323
                topPathPanel.setLayout(null);
324
                topPathPanel.setPreferredSize(new Dimension(WIDTH_PANEL,
325
                                HEIGTH_TOP_PATH_PANEL));
326

    
327
                proyect.setBounds(PROY_X, PROY_Y, PROY_W, PROY_H);
328
                nameProy.setBounds(NPROY_X, NPROY_Y, NPROY_W, NPROY_H);
329
                path.setBounds(PATH_X, PATH_Y, PATH_W, PATH_H);
330
                pathImport.setBounds(PATHIMPORT_X, PATHIMPORT_Y, PATHIMPORT_W,
331
                                PATHIMPORT_H);
332
                pathBoton.setBounds(PATHBUTTON_X, PATHBUTTON_Y, PATHBUTTON_W,
333
                                PATHBUTTON_H);
334
                topPathPanel.add(proyect);
335
                topPathPanel.add(path);
336
                topPathPanel.add(nameProy);
337
                topPathPanel.add(pathImport);
338
                topPathPanel.add(pathBoton);
339

    
340
                topOptionsPanel.setLayout(null);
341
                topOptionsPanel.setPreferredSize(new Dimension(WIDTH_PANEL,
342
                                HEIGTH_TOP_OPTIONS_PANEL));
343

    
344
                comboExtents = new JComboBox();
345
                comboExtents.setEnabled(false);
346
                comboExtents.addActionListener(this);
347

    
348
                int dimListExt = listExtents.length;
349
                if (dimListExt == 0) {
350

    
351
                        extent.setEnabled(false);
352
                        comboExtents.setEnabled(false);
353
                }
354
                if (dimListExt > 0) {
355

    
356
                        extent.setEnabled(true);
357
                        if (cont == 0) {
358
                                for (int i = 0; i < dimListExt; i++) {
359

    
360
                                        String name = listExtents[i].getDescription();
361
                                        comboExtents.addItem(name);
362
                                        comboExtents.repaint();
363
                                }
364
                                cont++;
365
                        }
366
                }
367

    
368
                viewAc.setBounds(VIEWACT_X, VIEWACT_Y, VIEWACT_W, VIEWACT_H);
369
                extent.setBounds(EXTENT_X, EXTENT_Y, EXTENT_W, EXTENT_H);
370
                comboExtents.setBounds(EXTENTCOMBO_X, EXTENTCOMBO_Y, EXTENTCOMBO_W,
371
                                EXTENTCOMBO_H);
372
                topOptionsPanel.add(viewAc);
373
                topOptionsPanel.add(extent);
374
                topOptionsPanel.add(comboExtents);
375

    
376
                TitledBorder title1 = BorderFactory.createTitledBorder(PluginServices
377
                                .getText(this, "actExtent"));
378
                title1.setTitleColor(Color.BLUE);
379
                topOptionsPanel.setBorder(title1);
380

    
381
                topPanel.add(topPathPanel, BorderLayout.NORTH);
382
                topPanel.add(topOptionsPanel, BorderLayout.SOUTH);
383

    
384
                /* BOTTOM PANEL */
385
                bottomPanel.setPreferredSize(new Dimension(WIDTH_PANEL,
386
                                HEIGTH_BOTTOM_PANEL));
387
                bottomPanel.setLayout(null);
388

    
389
                execute = new JButton(PluginServices.getText(this, "acept"));
390
                execute.setBounds(EX_X, BUTT_Y, BUTT_W, BUTT_H);
391
                //synchro = new JButton(PluginServices.getText(this, "synchro"));
392
                //synchro.setBounds(SY_X, BUTT_Y, BUTT_W, BUTT_H);
393
                
394
                // ------------------------ jldominguez nov 2007
395
                // synchro.setVisible(false);
396
                // ------------------------
397
                
398
                cancel = new JButton(PluginServices.getText(this, "close"));
399
                cancel.setBounds(CAN_X, BUTT_Y, BUTT_W, BUTT_H);
400
                open = new JButton(PluginServices.getText(this, "open"));
401
                open.setBounds(OP_X, BUTT_Y, BUTT_W, BUTT_H);
402
                open.setEnabled(false);
403
                save = new JButton(PluginServices.getText(this, "save"));
404
                save.setBounds(SAVE_X, BUTT_Y, BUTT_W, BUTT_H);
405
                save.setEnabled(false);
406

    
407
                
408
                bottomPanel.add(execute);
409
                //bottomPanel.add(synchro);
410
                bottomPanel.add(cancel);
411
                bottomPanel.add(open);
412
                bottomPanel.add(save);
413

    
414
                /* DISABLED BUTTON */
415
                execute.setEnabled(false);
416

    
417
                /* CENTER PANEL */
418
                centerPanel.setSize(new Dimension(WIDTH_PANEL, HEIGTH_CENTER_PANEL));
419
                centerPanel.setLayout(new BorderLayout());
420

    
421
                TitledBorder title = BorderFactory.createTitledBorder(PluginServices
422
                                .getText(this, "layers"));
423
                title.setTitleColor(Color.BLUE);
424
                centerPanel.setBorder(title);
425

    
426
                allSelect = new JCheckBox();
427
                allSelect.addActionListener(this);
428
                allSelect.setBackground(Color.LIGHT_GRAY);
429

    
430
                typLayer = new JLabel(PluginServices.getText(this, "tLayer"));
431
                lyrInView = new JLabel(PluginServices.getText(this, "lyrview"));
432
                nomLayer = new JLabel(PluginServices.getText(this, "nLayer"));
433
                atLayer = new JLabel(PluginServices.getText(this, "batLayer"));
434
                cboLayer = new JLabel(PluginServices.getText(this, "comLayer"));
435

    
436
                titlePanel.setPreferredSize(new Dimension(WIDTH_PANEL, HEIGTH_TITLE_PANEL));
437
                titlePanel.setLayout(null);
438
                titlePanel.setBackground(Color.LIGHT_GRAY);
439

    
440
                allSelect.setBounds(1 + PanelIntoScroll.EXPORT_X, LABEL_Y, ALLSEL_W, ALLSEL_H);
441
                typLayer.setBounds(1 + PanelIntoScroll.ICON_X, LABEL_Y, TYPLYR_W, LABEL_H);
442
                lyrInView.setBounds(1 + PanelIntoScroll.IN_VIEW_X, LABEL_Y, LYRINVIEW_W, LABEL_H);
443
                nomLayer.setBounds(1 + PanelIntoScroll.NAME_X, LABEL_Y, NAMELAYER_W, LABEL_H);
444
                atLayer.setBounds(1 + PanelIntoScroll.ATRIB_X, LABEL_Y, ATLYR_W, LABEL_H);
445
                cboLayer.setBounds(1 + PanelIntoScroll.CMBOATR_X, LABEL_Y, CBOLYR_W, LABEL_H);
446

    
447
                titlePanel.add(allSelect);
448
                titlePanel.add(typLayer);
449
                titlePanel.add(lyrInView);
450
                titlePanel.add(nomLayer);
451
                titlePanel.add(atLayer);
452
                titlePanel.add(cboLayer);
453

    
454
                rect = new DrawRectangle(view);
455
                rect.setRectView();
456
                rectangle = rect.getRectangle();
457
                
458
                panelScroll = new PanelIntoScroll(arLayers, this, rectangle);
459
                scroll.setViewportView(panelScroll.getPanel());
460
                
461
                // to activate selAll
462
                dimArrBx();
463

    
464
                centerPanel.add(scroll, BorderLayout.CENTER);
465
                centerPanel.add(titlePanel, BorderLayout.NORTH);
466

    
467
                pathBoton.addActionListener(this);
468
                execute.addActionListener(this);
469
                open.addActionListener(this);
470
                cancel.addActionListener(this);
471
                save.addActionListener(this);
472
                extent.addActionListener(this);
473
                viewAc.addActionListener(this);
474
                comboExtents.addActionListener(this);
475
                //synchro.addActionListener(this);
476

    
477
                /* ADD PANELS TO PRINCIPAL PANEL */
478
                this.add(topPanel, BorderLayout.NORTH);
479
                this.add(centerPanel, BorderLayout.CENTER);
480
                this.add(bottomPanel, BorderLayout.SOUTH);
481

    
482
        }
483

    
484
        /**
485
         * To set enabled the executed button. If directory is ok and any layer is
486
         * selected, the button is enabled
487
         */
488
        public void activateOk() {
489

    
490
                dirEmpty = pathImport.getText().equals(EMPTY);
491

    
492
                if ((dirEmpty == false) && (allSelect.isSelected() == true)) {
493

    
494
                        execute.setEnabled(true);
495
                } else {
496

    
497
                        execute.setEnabled(false);
498
                }
499
        }
500

    
501
        /**
502
         * Get the number of boxes selected and active the box All Selected
503
         * 
504
         * @return number of boxes selected
505
         */
506
        public int dimArrBx() {
507

    
508
                int c = 0;
509
                int dim = panelScroll.getarrBox().size();
510
                for (int i = 0; i < dim; i++) {
511

    
512
                        JCheckBox box = (JCheckBox) panelScroll.getarrBox().get(i);
513
                        if (box.isSelected() == true)
514
                                c++;
515
                }
516
                if (c == 0) {
517
                        allSelect.setSelected(false);
518
                } else {
519
                        allSelect.setSelected(true);
520

    
521
                }
522
                return c;
523
        }
524

    
525
        public void actionPerformed(ActionEvent arg0) {
526

    
527
                Object src = arg0.getSource();
528

    
529
                if (src == pathBoton) {
530

    
531
                        Chooser fc = new Chooser();
532
                        namePath = fc.getNameDir();
533

    
534
                        /* COMPLETE TEXTBOX WITH THE PATH */
535
                        pathImport.setText(namePath);
536
                        dirEmpty = pathImport.getText().equals(EMPTY);
537
                        proyEmpty = nameProy.getText().equals(EMPTY);
538
                                
539
                        if (proyEmpty == false) {
540

    
541
                                namProy = pathImport.getText() + "/" + nameProy.getText();
542

    
543
                        }
544
                        activateOk();
545
                        return;
546
                }
547

    
548
        
549
                if (src == viewAc) {
550

    
551
                        viewAc.setSelected(true);
552
                        extent.setSelected(false);
553
                        comboExtents.setEnabled(false);
554
                        rect = new DrawRectangle(view);
555
                        rect.setRectView();
556
                        rectangle = rect.getRectangle();
557

    
558
                        ArrayList arrL = panelScroll.getNewArrayLayers();
559
                        
560
                        for(int k=0;k<arrL.size();k++){
561
                                
562
                                LayerObject lo = (LayerObject) arrL.get(k);
563
                                FLayer l = lo.getLyr();
564
                                JPanel parentPanel = lo.getParent();
565
                                parentPanel.remove(lo.getImgLbl());
566
                                                        
567
                                JLabel lbl = new JLabel();
568
                                lo.setImage(lbl);
569
                                JLabel newLabel = panelScroll.paintImage(l, rectangle, parentPanel,lo.getCombo());
570
                                lo.setImage(newLabel);
571
                                
572
                                parentPanel.repaint();
573
                                
574
                        }
575
                        return;
576
                }
577

    
578
                if (src == extent) {
579

    
580
                        extent.setSelected(true);
581
                        viewAc.setSelected(false);
582
                        int dimListExtents = listExtents.length;
583
                        if (dimListExtents == 0) {
584

    
585
                                comboExtents.setEnabled(false);
586

    
587
                        }
588
                        if (dimListExtents > 0) {
589

    
590
                                if (cont == 0) {
591
                                        for (int i = 0; i < dimListExtents; i++) {
592

    
593
                                                String name = listExtents[i].getDescription();
594
                                                comboExtents.addItem(name);
595
                                                comboExtents.repaint();
596
                                        }
597
                                        cont++;
598
                                }
599
                                comboExtents.setEnabled(true);
600
                                indxsele = comboExtents.getSelectedIndex();
601
                                rectangle = listExtents[indxsele].getExtent();
602
                                
603
                                
604
                                ArrayList arrL = panelScroll.getNewArrayLayers();
605
                                
606
                                for(int k=0;k<arrL.size();k++){
607
                                        
608
                                        LayerObject lo = (LayerObject) arrL.get(k);
609
                                        FLayer l = lo.getLyr();
610
                                        JPanel parentPanel = lo.getParent();
611
                                        parentPanel.remove(lo.getImgLbl());
612
                                        
613
                                        JLabel newLabel = panelScroll.paintImage(l, rectangle, parentPanel,lo.getCombo());
614
                                        lo.setImage(newLabel);
615
                                        
616
                                        parentPanel.repaint();
617
                                        
618
                                }
619
                        }
620
                        return;
621
                }
622

    
623
                if (src == comboExtents) {
624

    
625
                        if (comboExtents.isEnabled()) {
626
                                indxsele = comboExtents.getSelectedIndex();
627
                                rectangle = listExtents[indxsele].getExtent();
628
                                
629
                                ArrayList arrL = panelScroll.getNewArrayLayers();
630
                                
631
                                for(int k=0;k<arrL.size();k++){
632
                                        
633
                                        LayerObject lo = (LayerObject) arrL.get(k);
634
                                        FLayer l = lo.getLyr();
635
                                        JPanel parentPanel = lo.getParent();
636
                                        parentPanel.remove(lo.getImgLbl());
637
                                        
638
                                        JLabel lbl = new JLabel();
639
                                        lo.setImage(lbl);
640
                                        
641
                                        JLabel newLabel = panelScroll.paintImage(l, rectangle, parentPanel,lo.getCombo());
642
                                        lo.setImage(newLabel);
643
                                        
644
                                        parentPanel.repaint();
645
                                        
646
                                }
647
                        }
648
                        return;
649
                }
650

    
651
                if (src == allSelect) {
652
                        FLayer lyr;
653

    
654
                        listLyrsObj = panelScroll.getNewArrayLayers();
655
                        
656
                        if (allSelect.isSelected() == true) {
657

    
658
                                for (int i = 0; i < listLyrsObj.size(); i++) {
659

    
660
                                        LayerObject lyrObj = (LayerObject) listLyrsObj.get(i);
661
                                        lyr = (FLayer) lyrObj.getLyr();
662
                                        JCheckBox aux = (JCheckBox) lyrObj.getBox();
663
                                        aux.setSelected(true);
664
                                        JButton buttonAux = (JButton) lyrObj.getButton();
665
                                        JComboBox comboAux = (JComboBox)lyrObj.getCombo();
666
                                        if(lyr instanceof FLyrVect){
667
                                                
668
                                                buttonAux.setEnabled(true);
669
                                                comboAux.setEnabled(true);
670
                                        }        
671
                                        if(lyr instanceof FLyrRaster)
672
                                                comboAux.setEnabled(true);
673
                                }
674
                                activateOk();
675
                        }
676

    
677
                        if (allSelect.isSelected() == false) {
678

    
679
                                for (int i = 0; i < listLyrsObj.size(); i++) {
680

    
681
                                        LayerObject lyrObj = (LayerObject) listLyrsObj.get(i);
682
                                        lyr = (FLayer) lyrObj.getLyr();
683
                                        JCheckBox aux = (JCheckBox) lyrObj.getBox();
684
                                        aux.setSelected(false);
685
                                        JButton buttonAux = (JButton) lyrObj.getButton();
686
                                        JComboBox comboAux = (JComboBox)lyrObj.getCombo();
687
                                        buttonAux.setEnabled(false);
688
                                        comboAux.setEnabled(false);
689
                                }
690
                                activateOk();
691
                        }
692
                        return;
693
                }
694

    
695
                if (src == execute) {
696
                        ExportProcess process = null;
697
                        
698
                        if (pathImport.getText().equals(EMPTY) || nameProy.getText().equals(EMPTY)) {
699
                                return;
700
                        } else {
701
                                process = new ExportProcess(rectangle, nameProy.getText(), pathImport.getText() + File.separator + nameProy.getText(),view.getProjection());
702
                                 
703
                                NewDir dirOut = new NewDir(namProy);
704
                                newdirout = dirOut.ifExistDir();
705
                                
706
                                //get layer list
707
                                listLyrsObj = panelScroll.getNewArrayLayers();                                
708

    
709
                                for (int i = 0; i < listLyrsObj.size(); i++) {
710

    
711
                                        LayerObject objLyr = (LayerObject)listLyrsObj.get(i);
712
                                        JCheckBox box = (JCheckBox) objLyr.getBox();
713
                                        FLayer layer2 = objLyr.getLyr();
714
                                        
715
                                        if (box.isSelected()==true) {
716
                                                logger.debug("Layer " + layer2.getName() + " to be exported");
717
                                                if(layer2 instanceof FLyrVect){
718
                                                        JComboBox combo = objLyr.getCombo();
719
                                                        // get active combo option
720
                                                        int indxSel = combo.getSelectedIndex();
721
                                                        String nameOption = (String) combo.getItemAt(indxSel);
722
                                                        //Export clip,select, all layer
723
                                                        FLyrVect lyr = (FLyrVect) layer2;
724
                                                        FieldDescription[] desLayer = objLyr.getDescription();
725
                                                        String name = lyr.getName();
726
                                                        if (name.toLowerCase().endsWith(".shp"))
727
                                                                name=name.substring(0,name.lastIndexOf("."));
728
                                                        
729
                                                        int processType = VectorialExporterTask.ALL;
730
                                                        if (nameOption == PluginServices.getText(this, "cut")) {
731
                                                                processType = VectorialExporterTask.CLIPRECT;
732
                                                        }
733
                                                        if (nameOption == PluginServices.getText(this, "select")) {
734
                                                                processType = VectorialExporterTask.SELECTRECT;
735
                                                        }
736
                                                        if (nameOption == PluginServices.getText(this, "allyr")) {
737
                                                                processType = VectorialExporterTask.ALL;
738
                                                        }
739
                                                        
740
                                                        process.addVectorialTask(lyr, desLayer, processType);
741

    
742
                                                }
743
                                                if(layer2 instanceof FLyrRaster){
744
                                                        process.addRasterTask(layer2);
745
                                                        
746
                                                }
747
                                                if(layer2 instanceof FLyrWMS){
748
                                                        process.addWMSTask(layer2);
749
                                                }
750
                                        }
751
                                }                        
752
                        
753
                        process.preProcess();
754
                        PluginServices.cancelableBackgroundExecution(process);
755

    
756
                        
757
                        }
758
                        return;
759
                }
760
                
761
                /* CLOSE WINDOW */
762
                if (src == cancel) {
763

    
764
                                PluginServices.getMDIManager().closeWindow(this);
765
                                return;
766

    
767
                }
768

    
769
                if (src instanceof JCheckBox) {
770

    
771
                        dimArrBx();
772
                        activateOk();
773

    
774
                }
775

    
776
                // -------------------------------------------------------------------
777
                /*
778
                 * START SYNCHRONISATION AFTER EXPORTATION
779
                 */
780
                /*
781
                if (src == synchro) {
782
                        
783
                        int opt = JOptionPane.showConfirmDialog(this,
784
                                        // 
785
                                        PluginServices.getText(this, "initial_synchro") + "?",
786
                                        PluginServices.getText(this, "synchro"),
787
                                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
788

789
                        String errorMessage=null;
790
                        
791
                        //list All files in destination exportation folder
792
                        File directory = new File(pathImport.getText()+File.separator+nameProy.getText());
793
                        if(directory.exists() && directory.isDirectory()){
794
                                
795
                                
796
                                if (opt == JOptionPane.YES_OPTION) {
797

798
                                        // ------------------------------------- yes ----------------
799
                                        //send ListFileTo OpenMIS synchro
800
                                        
801
                                        try {
802
                                                errorMessage = synchro.sendNewListFile(directory.listFiles(), nameProy.getText());
803
                                        } catch (Exception e) {
804
                                                e.printStackTrace();
805
                                                JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n","error", JOptionPane.ERROR_MESSAGE);
806
                                        }
807
                                        if(errorMessage != null) {
808
                                                JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n"+errorMessage,"error", JOptionPane.ERROR_MESSAGE);
809
                                                
810
                                        }else{
811
                                                //start OpenMIS synchro 
812
                                                try {
813
                                                        errorMessage = synchro.launchProjectSynchronisation(nameProy.getText());
814
                                                } catch (Exception e) {
815
                                                        JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n","error", JOptionPane.ERROR_MESSAGE);
816
                                                        e.printStackTrace();
817
                                                }
818
                                                if(errorMessage != null)
819
                                                        JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n"+errorMessage,"error", JOptionPane.ERROR_MESSAGE);
820
                                        }        
821
                                        // ------------------------------------- yes end ----------------
822
                                        
823
                                } else if (opt == JOptionPane.NO_OPTION) {
824
                                        
825
                                        // ------------------------------------- no ----------------
826
                                        try {
827
                                                errorMessage = synchro.launchProjectSynchronisation(nameProy.getText());
828
                                        } catch (Exception e) {
829
                                                JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n","error", JOptionPane.ERROR_MESSAGE);
830
                                                e.printStackTrace();
831
                                        }
832
                                        if(errorMessage != null)
833
                                                JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\n"+errorMessage,"error", JOptionPane.ERROR_MESSAGE);
834
                                        // ------------------------------------- no end ----------------
835
                                }
836
                                
837
                        }else{
838
                                JOptionPane.showMessageDialog(null,"Synchronisation Impossible!\nProject directory Not Found","error", JOptionPane.ERROR_MESSAGE);
839
                        }
840
                
841
                }                
842
*/
843
                
844
                
845
        }
846
        }
847