Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerWizardPanel.java @ 40596

History | View | Annotate | Download (23.3 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
25

    
26
import java.awt.Component;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
32
import java.io.File;
33
import java.util.ArrayList;
34
import java.util.Iterator;
35
import java.util.List;
36
import java.util.prefs.Preferences;
37

    
38
import javax.swing.AbstractListModel;
39
import javax.swing.JButton;
40
import javax.swing.JList;
41
import javax.swing.JPanel;
42
import javax.swing.JScrollPane;
43
import javax.swing.ScrollPaneConstants;
44
import javax.swing.event.ListSelectionEvent;
45
import javax.swing.event.ListSelectionListener;
46
import javax.swing.filechooser.FileFilter;
47

    
48
import org.gvsig.andami.PluginServices;
49
import org.gvsig.andami.messages.Messages;
50
import org.gvsig.andami.messages.NotificationManager;
51
import org.gvsig.app.ApplicationLocator;
52
import org.gvsig.app.ApplicationManager;
53
import org.gvsig.app.gui.WizardPanel;
54
import org.gvsig.app.prepareAction.PrepareContext;
55
import org.gvsig.fmap.dal.DALLocator;
56
import org.gvsig.fmap.dal.DataManager;
57
import org.gvsig.fmap.dal.DataStoreParameters;
58
import org.gvsig.fmap.dal.exception.DataException;
59
import org.gvsig.fmap.dal.exception.FileNotFoundException;
60
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter;
61
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
62
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
63
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
64
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
65
import org.gvsig.gui.beans.swing.JFileChooser;
66
import org.gvsig.tools.dynobject.DynObject;
67
import org.gvsig.tools.service.ServiceException;
68
import org.gvsig.tools.swing.api.ToolsSwingLocator;
69
import org.slf4j.Logger;
70
import org.slf4j.LoggerFactory;
71

    
72
/**
73
 * @author jmvivo
74
 * 
75
 */
76
public abstract class FilesystemExplorerWizardPanel extends WizardPanel
77
    implements ActionListener, ListSelectionListener {
78

    
79
    /**
80
         *
81
         */
82
    private static final long serialVersionUID = -3371957786521876903L;
83

    
84
    private static final Logger LOG = LoggerFactory
85
        .getLogger(FilesystemExplorerWizardPanel.class);
86

    
87
    public static final String OPEN_LAYER_FILE_CHOOSER_ID =
88
        "OPEN_LAYER_FILE_CHOOSER_ID";
89

    
90
    protected static final String ADD_COMMAND = "ADD";
91
    protected static final String EDIT_COMMAND = "PROPERTIES";
92
    protected static final String REMOVE_COMMAND = "REMOVE";
93
    protected static final String UP_COMMAND = "UP";
94
    protected static final String DOWN_COMMAND = "DOWN";
95

    
96
    private static String lastPath = null;
97
    private static MyFileFilter lastFilter = null;
98
    private static final String DEFAULT_FILTER = "All_supported";
99

    
100
    private JList fileList;
101
    private JScrollPane fileListScroll;
102
    private JPanel buttonsPanel;
103
    private JButton addButton;
104
    private JButton propertiesButton;
105
    private JButton removeButton;
106
    private JButton upButton;
107
    private JButton downButton;
108

    
109
    protected FilesystemServerExplorer explorer;
110
    private ArrayList<MyFileFilter> filters;
111
    
112
    public void setTabName(String name) {
113
        super.setTabName(name);
114
    }
115

    
116
    /*
117
     * (non-Javadoc)
118
     * 
119
     * @see com.iver.cit.gvsig.gui.WizardPanel#getParameters()
120
     */
121
    @Override
122
    public DataStoreParameters[] getParameters() {
123
        return ((FilesystemStoreListModel) getFileList().getModel())
124
            .getParameters();
125
    }
126

    
127
    /*
128
     * (non-Javadoc)
129
     * 
130
     * @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
131
     */
132
    @Override
133
    public void initWizard() {
134
        setTabName(PluginServices.getText(this, "Fichero"));
135
        if (lastPath == null) {
136
            Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
137
            lastPath = prefs.get("DataFolder", null);
138
        }
139

    
140
        DataManager dm = DALLocator.getDataManager();
141
        FilesystemServerExplorerParameters param;
142
        try {
143
            param =
144
                (FilesystemServerExplorerParameters) dm
145
                    .createServerExplorerParameters(FilesystemServerExplorer.NAME);
146
            param.setInitialpath(lastPath);
147
            explorer =
148
                (FilesystemServerExplorer) dm.openServerExplorer(
149
                    FilesystemServerExplorer.NAME, param);
150
        } catch (Exception e) {
151
            throw new RuntimeException(e);
152
        }
153

    
154
        int mode = FilesystemServerExplorer.MODE_ALL;
155
        this.filters = new ArrayList<MyFileFilter>();
156
        if (this.getMapCtrl() == null) {
157
            mode = FilesystemServerExplorer.MODE_FEATURE;
158
        } else {
159
            mode =
160
                FilesystemServerExplorer.MODE_GEOMETRY
161
                    | FilesystemServerExplorer.MODE_RASTER;
162
        }
163
        
164
        // First filter in list will be 'All formats' filter
165
        this.filters.add(new MyFileFilter(explorer.getFilter(mode,
166
            Messages.get(DEFAULT_FILTER))));
167

    
168
        @SuppressWarnings("unchecked")
169
        Iterator<FilesystemFileFilter> iter = explorer.getFilters(mode);
170
        while (iter.hasNext()) {
171
            this.filters.add(new MyFileFilter(iter.next()));
172
        }
173
        initUI();
174
    }
175

    
176
    private void initUI() {
177
        this.setLayout(new GridBagLayout());
178
        GridBagConstraints constr = new GridBagConstraints();
179

    
180
        constr.gridwidth = GridBagConstraints.RELATIVE;
181
        constr.gridheight = GridBagConstraints.RELATIVE;
182
        constr.fill = GridBagConstraints.BOTH;
183
        constr.anchor = GridBagConstraints.FIRST_LINE_START;
184
        constr.weightx = 1;
185
        constr.weighty = 1;
186
        constr.ipadx = 3;
187
        constr.ipady = 3;
188

    
189
        this.add(getFileListScroll(), constr);
190

    
191
        constr.gridwidth = GridBagConstraints.REMAINDER;
192
        constr.gridheight = GridBagConstraints.RELATIVE;
193
        constr.fill = GridBagConstraints.NONE;
194
        constr.anchor = GridBagConstraints.FIRST_LINE_END;
195
        constr.weightx = 0;
196
        constr.weighty = 0;
197
        this.add(getButtonsPanel(), constr);
198

    
199
        this.updateButtons();
200
        this.updateContainingWizardAcceptButton();
201

    
202
    }
203

    
204
    protected class FilesystemStoreListModel extends AbstractListModel {
205

    
206
        private static final long serialVersionUID = -726119349962990665L;
207
        private ArrayList<FilesystemStoreParameters> theList;
208

    
209
        public FilesystemStoreListModel() {
210
            theList = new ArrayList<FilesystemStoreParameters>();
211
        }
212

    
213
        public DataStoreParameters[] getParameters() {
214
            return theList.toArray(new DataStoreParameters[0]);
215
        }
216

    
217
        public Object getElementAt(int index) {
218
            return theList.get(index).getFile().getName();
219
        }
220

    
221
        public FilesystemStoreParameters getStoreParameterAt(int index) {
222
            return theList.get(index);
223
        }
224

    
225
        public int getSize() {
226
            return theList.size();
227
        }
228

    
229
        public DynObject getDynObjectAt(int index) {
230
            return (DynObject) theList.get(index);
231
        }
232

    
233
        public void add(DynObject dynObject) {
234
            this.theList.add((FilesystemStoreParameters) dynObject);
235
            this.fireIntervalAdded(this, this.theList.size() - 1,
236
                this.theList.size() - 1);
237
        }
238

    
239
        public void addAll(List<FilesystemStoreParameters> toAdd) {
240
            int index0 = this.getSize() - 1;
241
            if (index0 < 0) {
242
                index0 = 0;
243
            }
244
            this.theList.addAll(toAdd);
245
            this.fireIntervalAdded(this, index0, this.theList.size() - 1);
246
        }
247

    
248
        public void remove(int i) {
249
            this.theList.remove(i);
250
            this.fireIntervalRemoved(this, i, i);
251

    
252
        }
253

    
254
        public void up(FilesystemStoreParameters item) {
255
            int curIndex = this.theList.indexOf(item);
256
            if (curIndex < 1) {
257
                return;
258
            }
259
            this.theList.remove(item);
260
            this.theList.add(curIndex - 1, item);
261
            this.fireContentsChanged(this, curIndex, curIndex - 1);
262
        }
263

    
264
        public void down(FilesystemStoreParameters item) {
265
            int curIndex = this.theList.indexOf(item);
266
            if (curIndex < 0) {
267
                return;
268
            } else
269
                if (curIndex == this.theList.size() - 1) {
270
                    return;
271
                }
272
            this.theList.remove(item);
273
            this.theList.add(curIndex + 1, item);
274
            this.fireContentsChanged(this, curIndex, curIndex + 1);
275
        }
276
        
277
        public void forceUpdate(int index) {
278
            this.fireContentsChanged(this, index, index);
279
        }
280

    
281
    }
282

    
283
    protected JList getFileList() {
284
        if (fileList == null) {
285
            fileList = new JList(new FilesystemStoreListModel());
286

    
287
            fileList.addListSelectionListener(this);
288
        }
289
        return fileList;
290
    }
291

    
292
    private JScrollPane getFileListScroll() {
293
        if (fileListScroll == null) {
294
            fileListScroll = new JScrollPane();
295
            fileListScroll.setViewportView(getFileList());
296
            fileListScroll
297
                .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
298
            fileListScroll
299
                .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
300

    
301
        }
302
        return fileListScroll;
303
    }
304

    
305
    private Component getButtonsPanel() {
306
        if (buttonsPanel == null) {
307
            buttonsPanel = new JPanel();
308

    
309
            buttonsPanel.setLayout(new GridBagLayout());
310

    
311
            GridBagConstraints constr = new GridBagConstraints();
312

    
313
            constr.anchor = GridBagConstraints.CENTER;
314
            constr.fill = GridBagConstraints.NONE;
315
            constr.ipadx = 3;
316
            constr.ipady = 3;
317
            constr.insets = new Insets(3, 3, 3, 3);
318
            constr.gridwidth = GridBagConstraints.REMAINDER;
319

    
320
            buttonsPanel.add(getAddButton(), constr);
321
            buttonsPanel.add(getPropertiesButton(), constr);
322
            buttonsPanel.add(getRemoveButton(), constr);
323
            buttonsPanel.add(getUpButton(), constr);
324
            buttonsPanel.add(getDownButton(), constr);
325
            // buttonsPanel.add(new JLabel(), constrLbl);
326
        }
327
        return buttonsPanel;
328
    }
329

    
330
    private JButton getAddButton() {
331
        if (addButton == null) {
332
            addButton =
333
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
334
            addButton.setText(getLocalizedText("add"));
335
            addButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
336
            addButton.setActionCommand(ADD_COMMAND);
337
            addButton.addActionListener(this);
338
        }
339
        return addButton;
340
    }
341

    
342
    private JButton getPropertiesButton() {
343
        if (propertiesButton == null) {
344
            propertiesButton =
345
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
346
            propertiesButton.setText(getLocalizedText("properties"));
347
            propertiesButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
348
            propertiesButton.setActionCommand(EDIT_COMMAND);
349
            propertiesButton.addActionListener(this);
350
        }
351
        return propertiesButton;
352
    }
353

    
354
    private JButton getRemoveButton() {
355
        if (removeButton == null) {
356
            removeButton =
357
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
358
            removeButton.setText(getLocalizedText("remove"));
359
            removeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
360
            removeButton.setActionCommand(REMOVE_COMMAND);
361
            removeButton.addActionListener(this);
362
        }
363
        return removeButton;
364
    }
365

    
366
    private JButton getUpButton() {
367
        if (upButton == null) {
368
            upButton =
369
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
370
            upButton.setText(getLocalizedText("up"));
371
            upButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
372
            upButton.setActionCommand(UP_COMMAND);
373
            upButton.addActionListener(this);
374
        }
375
        return upButton;
376
    }
377

    
378
    private JButton getDownButton() {
379
        if (downButton == null) {
380
            downButton =
381
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
382
            downButton.setText(getLocalizedText("down"));
383
            downButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
384
            downButton.setActionCommand(DOWN_COMMAND);
385
            downButton.addActionListener(this);
386
        }
387
        return downButton;
388
    }
389

    
390
    private String getLocalizedText(String txt) {
391
        try {
392
            return PluginServices.getText(this, txt);
393
        } catch (Exception e) {
394
            return txt;
395
        }
396
    }
397

    
398
    public void actionPerformed(ActionEvent e) {
399
        String command = e.getActionCommand();
400
        FilesystemStoreListModel model =
401
            (FilesystemStoreListModel) getFileList().getModel();
402

    
403
        if (command == ADD_COMMAND) {
404
            List<FilesystemStoreParameters> toAdd = this.addFiles();
405
            if (toAdd.isEmpty()) {
406
                return;
407
            }
408
            model.addAll(toAdd);
409

    
410
            getFileList().setModel(model);
411
            
412
            this.updateContainingWizardAcceptButton();
413

    
414
        } else
415
            if (command == EDIT_COMMAND) {
416
                DynObject dynObject =
417
                    model.getDynObjectAt(getFileList().getSelectedIndex());
418

    
419
                try {
420
                    DynObjectEditor editor = new DynObjectEditor(dynObject);
421
                    editor.editObject(true);
422
                } catch (ServiceException ex) {
423
                    LOG.error(
424
                        "Error creating a Swing component for the DynObject: "
425
                            + dynObject, ex);
426
                }
427

    
428
            } else
429
                if (command == REMOVE_COMMAND) {
430
                    int[] selecteds = getFileList().getSelectedIndices();
431
                    for (int i = selecteds.length - 1; i > -1; i--) {
432
                        model.remove(selecteds[i]);
433
                    }
434
                    getFileList().setSelectedIndex(-1);
435
                    
436
                    this.updateContainingWizardAcceptButton();
437

    
438
                } else
439
                    if (command == UP_COMMAND) {
440
                        List<FilesystemStoreParameters> items =
441
                            new ArrayList<FilesystemStoreParameters>();
442
                        int[] selecteds = getFileList().getSelectedIndices();
443
                        if (selecteds.length == 0 || selecteds[0] == 0) {
444
                            return;
445
                        }
446
                        for (int i = 0; i < selecteds.length; i++) {
447
                            items.add(model.getStoreParameterAt(selecteds[i]));
448
                            selecteds[i]--;
449
                        }
450
                        Iterator<FilesystemStoreParameters> iter =
451
                            items.iterator();
452
                        while (iter.hasNext()) {
453
                            model.up(iter.next());
454
                        }
455
                        getFileList().setSelectedIndices(selecteds);
456

    
457
                    } else
458
                        if (command == DOWN_COMMAND) {
459
                            List<FilesystemStoreParameters> items =
460
                                new ArrayList<FilesystemStoreParameters>();
461
                            int[] selecteds =
462
                                getFileList().getSelectedIndices();
463
                            if (selecteds.length == 0
464
                                || selecteds[selecteds.length - 1] == model
465
                                    .getSize() - 1) {
466
                                return;
467
                            }
468
                            for (int i = selecteds.length - 1; i > -1; i--) {
469
                                items.add(model
470
                                    .getStoreParameterAt(selecteds[i]));
471
                                selecteds[i]++;
472
                            }
473
                            Iterator<FilesystemStoreParameters> iter =
474
                                items.iterator();
475
                            while (iter.hasNext()) {
476
                                model.down(iter.next());
477
                            }
478
                            getFileList().setSelectedIndices(selecteds);
479

    
480
                        } else {
481
                            throw new IllegalArgumentException(command);
482
                        }
483

    
484
    }
485

    
486
    /**
487
     * check number of files already selected for adding
488
     */
489
    private void updateContainingWizardAcceptButton() {
490
        int curr_add_file_count = getFileList().getModel().getSize();
491
        this.callStateChanged(curr_add_file_count > 0);
492
    }
493

    
494
    
495
    public boolean areSettingsValid() {
496
        int curr_add_file_count = getFileList().getModel().getSize();
497
        return (curr_add_file_count > 0);
498
    }
499

    
500
    public List<DynObject> getSelecteds() {
501
        ArrayList<DynObject> list = new ArrayList<DynObject>();
502
        JList fList = this.getFileList();
503
        int[] selecteds = fList.getSelectedIndices();
504
        FilesystemStoreListModel model =
505
            (FilesystemStoreListModel) fList.getModel();
506

    
507
        for (int index : selecteds) {
508
            list.add((DynObject) model.getStoreParameterAt(index));
509
        }
510
        return list;
511
    }
512

    
513
    public void valueChanged(ListSelectionEvent e) {
514
        this.updateButtons();
515
    }
516

    
517
    public class MyFileFilter extends FileFilter {
518

    
519
        public FilesystemFileFilter filter = null;
520

    
521
        public MyFileFilter(FilesystemFileFilter params) {
522
            this.filter = params;
523
        }
524

    
525
        /**
526
         * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
527
         */
528
        public boolean accept(File f) {
529
            if (f.isDirectory()) {
530
                return true;
531
            }
532
            return filter.accept(f);
533

    
534
        }
535

    
536
        /**
537
         * @see javax.swing.filechooser.FileFilter#getDescription()
538
         */
539
        public String getDescription() {
540
            return filter.getDescription();
541
        }
542

    
543
        public String getName() {
544
            return filter.getDataStoreProviderName();
545
        }
546
    }
547

    
548
    private List<FilesystemStoreParameters> addFiles() {
549
        
550
        // this.callStateChanged(true);
551
        
552
        JFileChooser fileChooser =
553
            new JFileChooser(OPEN_LAYER_FILE_CHOOSER_ID,
554
                explorer.getCurrentPath());
555
        fileChooser.setMultiSelectionEnabled(true);
556
        fileChooser.setAcceptAllFileFilterUsed(false);
557

    
558
        Iterator<MyFileFilter> iter = this.filters.iterator();
559
        while (iter.hasNext()) {
560
            fileChooser.addChoosableFileFilter(iter.next());
561
        }
562
        
563
        if (filters.size() > 0) {
564
            MyFileFilter firstf = filters.get(0);
565
            // Set first filter
566
            fileChooser.setFileFilter(firstf);
567
        }
568

    
569
        // If there is a last filter, use it
570
        if (lastFilter != null && filters.contains(lastFilter)) {
571
            fileChooser.setFileFilter(lastFilter);
572
        }
573

    
574
        int result = fileChooser.showOpenDialog(this);
575

    
576
        List<FilesystemStoreParameters> toAdd =
577
            new ArrayList<FilesystemStoreParameters>();
578

    
579
        if (result == JFileChooser.APPROVE_OPTION) {
580
            lastPath = fileChooser.getCurrentDirectory().getAbsolutePath();
581
            JFileChooser.setLastPath(OPEN_LAYER_FILE_CHOOSER_ID, fileChooser.getCurrentDirectory());
582
            try {
583
                explorer.setCurrentPath(fileChooser.getCurrentDirectory());
584
            } catch (FileNotFoundException e) {
585
                NotificationManager.addError(e);
586
            }
587
            lastFilter = (MyFileFilter) fileChooser.getFileFilter();
588
            ApplicationManager appGvSIGMan = ApplicationLocator.getManager();
589
            PrepareContext context = this.getPrepareDataStoreContext();
590
            List<DataStoreParameters> paramList = new ArrayList<DataStoreParameters>();
591
            List<DataStoreParameters> toAddParamList = null;
592
            for (File aFile : fileChooser.getSelectedFiles()) {
593
                try {
594
                        DataStoreParameters param =
595
                        explorer.createStoreParameters(aFile, lastFilter
596
                            .getDescription().compareTo(DEFAULT_FILTER) == 0
597
                            ? null : lastFilter.getName());
598
                    if (param == null) {
599
                        // TODO show warning
600
                        continue;
601
                    }
602

    
603
                    paramList.add(param);
604
                   
605
                } catch (DataException e) {
606
                    NotificationManager.addError(e);
607
                    return null;
608
                }
609
            }
610
            
611
            try {
612
                toAddParamList =
613
                    appGvSIGMan.prepareOpenDataStoreParameters(paramList, context);
614
            } catch (Exception e) {
615
                NotificationManager.addError(e);
616
            }
617
            
618
            if(toAddParamList != null) {
619
                    for (int i = 0; i < toAddParamList.size(); i++) {
620
                            toAdd.add((FilesystemStoreParameters)toAddParamList.get(i));
621
                    }
622
            }
623
        }
624
        return toAdd;
625
    }
626

    
627
    protected abstract PrepareContext getPrepareDataStoreContext();
628

    
629
    /**
630
     * Refers to up/down/remove buttons etc. Called when selection changes
631
     */
632
    private void updateButtons() {
633
        int selectedIndex = this.getFileList().getSelectedIndex();
634
        int size = this.getFileList().getModel().getSize();
635
        int[] selecteds = this.getFileList().getSelectedIndices();
636
        if (size < 1) {
637
            this.getPropertiesButton().setEnabled(false);
638
            this.getRemoveButton().setEnabled(false);
639
            this.getUpButton().setEnabled(false);
640
            this.getDownButton().setEnabled(false);
641
            return;
642
        } else
643
            if (size == 1) {
644
                this.getUpButton().setEnabled(false);
645
                this.getDownButton().setEnabled(false);
646
            } else {
647
                this.getUpButton().setEnabled(selectedIndex > 0);
648

    
649
                this.getDownButton().setEnabled(
650
                    selectedIndex > -1
651
                        && selecteds[selecteds.length - 1] < size - 1);
652
            }
653
        this.getPropertiesButton().setEnabled(
654
            selectedIndex > -1
655
                && this.getFileList().getSelectedIndices().length == 1);
656
        this.getRemoveButton().setEnabled(selectedIndex > -1);
657
    }
658

    
659
    public void close() {
660
        if (explorer != null) {
661
            explorer.dispose();
662
            explorer = null;
663
        }
664
        if (filters != null) {
665
            filters.clear();
666
            filters = null;
667
        }
668
    }
669
}