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

History | View | Annotate | Download (23.5 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
            try {
414
                    fileList.setSelectedIndex(fileList.getModel().getSize()-1);
415
            } catch(Exception ex) {
416
                    // Ignore errors
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
}