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 @ 40558

History | View | Annotate | Download (23.4 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
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 IVER T.I. S.A.   {{Task}}
27
 */
28
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
29

    
30
import java.awt.Component;
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
33
import java.awt.Insets;
34
import java.awt.event.ActionEvent;
35
import java.awt.event.ActionListener;
36
import java.io.File;
37
import java.util.ArrayList;
38
import java.util.Iterator;
39
import java.util.List;
40
import java.util.prefs.Preferences;
41

    
42
import javax.swing.AbstractListModel;
43
import javax.swing.JButton;
44
import javax.swing.JList;
45
import javax.swing.JPanel;
46
import javax.swing.JScrollPane;
47
import javax.swing.ScrollPaneConstants;
48
import javax.swing.event.ListSelectionEvent;
49
import javax.swing.event.ListSelectionListener;
50
import javax.swing.filechooser.FileFilter;
51

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

    
76
/**
77
 * @author jmvivo
78
 * 
79
 */
80
public abstract class FilesystemExplorerWizardPanel extends WizardPanel
81
    implements ActionListener, ListSelectionListener {
82

    
83
    /**
84
         *
85
         */
86
    private static final long serialVersionUID = -3371957786521876903L;
87

    
88
    private static final Logger LOG = LoggerFactory
89
        .getLogger(FilesystemExplorerWizardPanel.class);
90

    
91
    public static final String OPEN_LAYER_FILE_CHOOSER_ID =
92
        "OPEN_LAYER_FILE_CHOOSER_ID";
93

    
94
    protected static final String ADD_COMMAND = "ADD";
95
    protected static final String EDIT_COMMAND = "PROPERTIES";
96
    protected static final String REMOVE_COMMAND = "REMOVE";
97
    protected static final String UP_COMMAND = "UP";
98
    protected static final String DOWN_COMMAND = "DOWN";
99

    
100
    private static String lastPath = null;
101
    private static MyFileFilter lastFilter = null;
102
    private static final String DEFAULT_FILTER = "All_supported";
103

    
104
    private JList fileList;
105
    private JScrollPane fileListScroll;
106
    private JPanel buttonsPanel;
107
    private JButton addButton;
108
    private JButton propertiesButton;
109
    private JButton removeButton;
110
    private JButton upButton;
111
    private JButton downButton;
112

    
113
    protected FilesystemServerExplorer explorer;
114
    private ArrayList<MyFileFilter> filters;
115
    
116
    public void setTabName(String name) {
117
        super.setTabName(name);
118
    }
119

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

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

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

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

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

    
180
    private void initUI() {
181
        this.setLayout(new GridBagLayout());
182
        GridBagConstraints constr = new GridBagConstraints();
183

    
184
        constr.gridwidth = GridBagConstraints.RELATIVE;
185
        constr.gridheight = GridBagConstraints.RELATIVE;
186
        constr.fill = GridBagConstraints.BOTH;
187
        constr.anchor = GridBagConstraints.FIRST_LINE_START;
188
        constr.weightx = 1;
189
        constr.weighty = 1;
190
        constr.ipadx = 3;
191
        constr.ipady = 3;
192

    
193
        this.add(getFileListScroll(), constr);
194

    
195
        constr.gridwidth = GridBagConstraints.REMAINDER;
196
        constr.gridheight = GridBagConstraints.RELATIVE;
197
        constr.fill = GridBagConstraints.NONE;
198
        constr.anchor = GridBagConstraints.FIRST_LINE_END;
199
        constr.weightx = 0;
200
        constr.weighty = 0;
201
        this.add(getButtonsPanel(), constr);
202

    
203
        this.updateButtons();
204
        this.updateContainingWizardAcceptButton();
205

    
206
    }
207

    
208
    protected class FilesystemStoreListModel extends AbstractListModel {
209

    
210
        private static final long serialVersionUID = -726119349962990665L;
211
        private ArrayList<FilesystemStoreParameters> theList;
212

    
213
        public FilesystemStoreListModel() {
214
            theList = new ArrayList<FilesystemStoreParameters>();
215
        }
216

    
217
        public DataStoreParameters[] getParameters() {
218
            return theList.toArray(new DataStoreParameters[0]);
219
        }
220

    
221
        public Object getElementAt(int index) {
222
            return theList.get(index).getFile().getName();
223
        }
224

    
225
        public FilesystemStoreParameters getStoreParameterAt(int index) {
226
            return theList.get(index);
227
        }
228

    
229
        public int getSize() {
230
            return theList.size();
231
        }
232

    
233
        public DynObject getDynObjectAt(int index) {
234
            return (DynObject) theList.get(index);
235
        }
236

    
237
        public void add(DynObject dynObject) {
238
            this.theList.add((FilesystemStoreParameters) dynObject);
239
            this.fireIntervalAdded(this, this.theList.size() - 1,
240
                this.theList.size() - 1);
241
        }
242

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

    
252
        public void remove(int i) {
253
            this.theList.remove(i);
254
            this.fireIntervalRemoved(this, i, i);
255

    
256
        }
257

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

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

    
285
    }
286

    
287
    protected JList getFileList() {
288
        if (fileList == null) {
289
            fileList = new JList(new FilesystemStoreListModel());
290

    
291
            fileList.addListSelectionListener(this);
292
        }
293
        return fileList;
294
    }
295

    
296
    private JScrollPane getFileListScroll() {
297
        if (fileListScroll == null) {
298
            fileListScroll = new JScrollPane();
299
            fileListScroll.setViewportView(getFileList());
300
            fileListScroll
301
                .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
302
            fileListScroll
303
                .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
304

    
305
        }
306
        return fileListScroll;
307
    }
308

    
309
    private Component getButtonsPanel() {
310
        if (buttonsPanel == null) {
311
            buttonsPanel = new JPanel();
312

    
313
            buttonsPanel.setLayout(new GridBagLayout());
314

    
315
            GridBagConstraints constr = new GridBagConstraints();
316

    
317
            constr.anchor = GridBagConstraints.CENTER;
318
            constr.fill = GridBagConstraints.NONE;
319
            constr.ipadx = 3;
320
            constr.ipady = 3;
321
            constr.insets = new Insets(3, 3, 3, 3);
322
            constr.gridwidth = GridBagConstraints.REMAINDER;
323

    
324
            buttonsPanel.add(getAddButton(), constr);
325
            buttonsPanel.add(getPropertiesButton(), constr);
326
            buttonsPanel.add(getRemoveButton(), constr);
327
            buttonsPanel.add(getUpButton(), constr);
328
            buttonsPanel.add(getDownButton(), constr);
329
            // buttonsPanel.add(new JLabel(), constrLbl);
330
        }
331
        return buttonsPanel;
332
    }
333

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

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

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

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

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

    
394
    private String getLocalizedText(String txt) {
395
        try {
396
            return PluginServices.getText(this, txt);
397
        } catch (Exception e) {
398
            return txt;
399
        }
400
    }
401

    
402
    public void actionPerformed(ActionEvent e) {
403
        String command = e.getActionCommand();
404
        FilesystemStoreListModel model =
405
            (FilesystemStoreListModel) getFileList().getModel();
406

    
407
        if (command == ADD_COMMAND) {
408
            List<FilesystemStoreParameters> toAdd = this.addFiles();
409
            if (toAdd.isEmpty()) {
410
                return;
411
            }
412
            model.addAll(toAdd);
413

    
414
            getFileList().setModel(model);
415
            
416
            this.updateContainingWizardAcceptButton();
417

    
418
        } else
419
            if (command == EDIT_COMMAND) {
420
                DynObject dynObject =
421
                    model.getDynObjectAt(getFileList().getSelectedIndex());
422

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

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

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

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

    
484
                        } else {
485
                            throw new IllegalArgumentException(command);
486
                        }
487

    
488
    }
489

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

    
498
    
499
    public boolean areSettingsValid() {
500
        int curr_add_file_count = getFileList().getModel().getSize();
501
        return (curr_add_file_count > 0);
502
    }
503

    
504
    public List<DynObject> getSelecteds() {
505
        ArrayList<DynObject> list = new ArrayList<DynObject>();
506
        JList fList = this.getFileList();
507
        int[] selecteds = fList.getSelectedIndices();
508
        FilesystemStoreListModel model =
509
            (FilesystemStoreListModel) fList.getModel();
510

    
511
        for (int index : selecteds) {
512
            list.add((DynObject) model.getStoreParameterAt(index));
513
        }
514
        return list;
515
    }
516

    
517
    public void valueChanged(ListSelectionEvent e) {
518
        this.updateButtons();
519
    }
520

    
521
    public class MyFileFilter extends FileFilter {
522

    
523
        public FilesystemFileFilter filter = null;
524

    
525
        public MyFileFilter(FilesystemFileFilter params) {
526
            this.filter = params;
527
        }
528

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

    
538
        }
539

    
540
        /**
541
         * @see javax.swing.filechooser.FileFilter#getDescription()
542
         */
543
        public String getDescription() {
544
            return filter.getDescription();
545
        }
546

    
547
        public String getName() {
548
            return filter.getDataStoreProviderName();
549
        }
550
    }
551

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

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

    
573
        // If there is a last filter, use it
574
        if (lastFilter != null && filters.contains(lastFilter)) {
575
            fileChooser.setFileFilter(lastFilter);
576
        }
577

    
578
        int result = fileChooser.showOpenDialog(this);
579

    
580
        List<FilesystemStoreParameters> toAdd =
581
            new ArrayList<FilesystemStoreParameters>();
582

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

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

    
631
    protected abstract PrepareContext getPrepareDataStoreContext();
632

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

    
653
                this.getDownButton().setEnabled(
654
                    selectedIndex > -1
655
                        && selecteds[selecteds.length - 1] < size - 1);
656
            }
657
        this.getPropertiesButton().setEnabled(
658
            selectedIndex > -1
659
                && this.getFileList().getSelectedIndices().length == 1);
660
        this.getRemoveButton().setEnabled(selectedIndex > -1);
661
    }
662

    
663
    public void close() {
664
        if (explorer != null) {
665
            explorer.dispose();
666
            explorer = null;
667
        }
668
        if (filters != null) {
669
            filters.clear();
670
            filters = null;
671
        }
672
    }
673
}