root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerWizardPanel.java @ 31496
History | View | Annotate | Download (18.3 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 IVER T.I. S.A. {{Task}}
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing; |
32 |
|
33 |
import java.awt.Component; |
34 |
import java.awt.GridBagConstraints; |
35 |
import java.awt.GridBagLayout; |
36 |
import java.awt.Insets; |
37 |
import java.awt.event.ActionEvent; |
38 |
import java.awt.event.ActionListener; |
39 |
import java.io.File; |
40 |
import java.util.ArrayList; |
41 |
import java.util.Iterator; |
42 |
import java.util.List; |
43 |
import java.util.prefs.Preferences; |
44 |
|
45 |
import javax.swing.AbstractListModel; |
46 |
import javax.swing.JList; |
47 |
import javax.swing.JPanel; |
48 |
import javax.swing.JScrollPane; |
49 |
import javax.swing.ScrollPaneConstants; |
50 |
import javax.swing.event.ListSelectionEvent; |
51 |
import javax.swing.event.ListSelectionListener; |
52 |
import javax.swing.filechooser.FileFilter; |
53 |
|
54 |
import org.gvsig.andami.PluginServices; |
55 |
import org.gvsig.andami.messages.NotificationManager; |
56 |
import org.gvsig.app.ApplicationLocator; |
57 |
import org.gvsig.app.ApplicationManager; |
58 |
import org.gvsig.app.gui.WizardPanel; |
59 |
import org.gvsig.app.prepareAction.PrepareContext; |
60 |
import org.gvsig.fmap.dal.DALLocator; |
61 |
import org.gvsig.fmap.dal.DataManager; |
62 |
import org.gvsig.fmap.dal.DataStoreParameters; |
63 |
import org.gvsig.fmap.dal.exception.DataException; |
64 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
65 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter; |
66 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
67 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
68 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
69 |
import org.gvsig.gui.beans.swing.JButton; |
70 |
import org.gvsig.gui.beans.swing.JFileChooser; |
71 |
import org.gvsig.tools.dynobject.DynObject; |
72 |
|
73 |
|
74 |
/**
|
75 |
* @author jmvivo
|
76 |
*
|
77 |
*/
|
78 |
public abstract class FilesystemExplorerWizardPanel extends WizardPanel |
79 |
implements
|
80 |
ActionListener, ListSelectionListener { |
81 |
|
82 |
/**
|
83 |
*
|
84 |
*/
|
85 |
private static final long serialVersionUID = -3371957786521876903L; |
86 |
|
87 |
private static final String OPEN_LAYER_FILE_CHOOSER_ID = "OPEN_LAYER_FILE_CHOOSER_ID"; |
88 |
|
89 |
protected static final String ADD_COMMAND = "ADD"; |
90 |
protected static final String EDIT_COMMAND = "EDIT"; |
91 |
protected static final String REMOVE_COMMAND = "REMOVE"; |
92 |
protected static final String UP_COMMAND = "UP"; |
93 |
protected static final String DOWN_COMMAND = "DOWN"; |
94 |
|
95 |
private static String lastPath = null; |
96 |
private static MyFileFilter lastFilter = null; |
97 |
|
98 |
private JList fileList; |
99 |
private JScrollPane fileListScroll; |
100 |
private JPanel buttonsPanel; |
101 |
private JButton addButton; |
102 |
private JButton editButton; |
103 |
private JButton removeButton; |
104 |
private JButton upButton; |
105 |
private JButton downButton; |
106 |
private JScrollPane paramsListScroll; |
107 |
private JPanel paramsList; |
108 |
private GridBagConstraints paramsListLabelConstraint; |
109 |
private GridBagConstraints paramsListValueConstraint; |
110 |
|
111 |
protected FilesystemServerExplorer explorer;
|
112 |
private ArrayList<MyFileFilter> filters; |
113 |
|
114 |
private GridBagConstraints paramsListFillConstraint; |
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 = (FilesystemServerExplorerParameters) dm |
148 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
149 |
param.setInitialpath(lastPath); |
150 |
explorer = (FilesystemServerExplorer) dm |
151 |
.createServerExplorer(param); |
152 |
} catch (Exception e) { |
153 |
throw new RuntimeException(e); |
154 |
} |
155 |
|
156 |
this.filters = new ArrayList<MyFileFilter>(); |
157 |
Iterator<FilesystemFileFilter> iter = explorer.getFilters();
|
158 |
while (iter.hasNext()) {
|
159 |
this.filters.add(new MyFileFilter(iter.next())); |
160 |
} |
161 |
this.filters.add(new MyFileFilter(explorer.getGenericFilter())); |
162 |
initUI(); |
163 |
} |
164 |
|
165 |
private void initUI() { |
166 |
this.setLayout(new GridBagLayout()); |
167 |
GridBagConstraints constr = new GridBagConstraints(); |
168 |
|
169 |
constr.gridwidth = GridBagConstraints.RELATIVE;
|
170 |
constr.gridheight = GridBagConstraints.RELATIVE;
|
171 |
constr.fill = GridBagConstraints.BOTH;
|
172 |
constr.anchor = GridBagConstraints.FIRST_LINE_START;
|
173 |
constr.weightx = 1;
|
174 |
constr.weighty = 1;
|
175 |
constr.ipadx = 3;
|
176 |
constr.ipady = 3;
|
177 |
|
178 |
this.add(getFileListScroll(), constr);
|
179 |
|
180 |
constr.gridwidth = GridBagConstraints.REMAINDER;
|
181 |
constr.gridheight = GridBagConstraints.RELATIVE;
|
182 |
constr.fill = GridBagConstraints.NONE;
|
183 |
constr.anchor = GridBagConstraints.FIRST_LINE_END;
|
184 |
constr.weightx = 0;
|
185 |
constr.weighty = 0;
|
186 |
this.add(getButtonsPanel(), constr);
|
187 |
|
188 |
constr.gridwidth = GridBagConstraints.REMAINDER;
|
189 |
constr.gridheight = GridBagConstraints.REMAINDER;
|
190 |
constr.fill = GridBagConstraints.BOTH;
|
191 |
constr.anchor = GridBagConstraints.FIRST_LINE_START;
|
192 |
constr.weightx = 1;
|
193 |
constr.weighty = 1;
|
194 |
this.add(getParamsListScroll(), constr);
|
195 |
|
196 |
this.updateButtons();
|
197 |
|
198 |
} |
199 |
|
200 |
protected class FilesystemStoreListModel extends AbstractListModel { |
201 |
/**
|
202 |
*
|
203 |
*/
|
204 |
private static final long serialVersionUID = -726119349962990665L; |
205 |
private ArrayList<FilesystemStoreParameters> theList; |
206 |
|
207 |
public FilesystemStoreListModel() {
|
208 |
theList = new ArrayList<FilesystemStoreParameters>(); |
209 |
} |
210 |
|
211 |
public DataStoreParameters[] getParameters() { |
212 |
return theList.toArray(new DataStoreParameters[0]); |
213 |
} |
214 |
|
215 |
public Object getElementAt(int index) { |
216 |
return theList.get(index).getFile().getName();
|
217 |
} |
218 |
|
219 |
public FilesystemStoreParameters getStoreParameterAt(int index) { |
220 |
return theList.get(index);
|
221 |
} |
222 |
|
223 |
public int getSize() { |
224 |
return theList.size();
|
225 |
} |
226 |
|
227 |
public DynObject getDynObjectAt(int index) { |
228 |
return (DynObject) theList.get(index);
|
229 |
} |
230 |
|
231 |
public void add(DynObject dynObject) { |
232 |
this.theList.add((FilesystemStoreParameters) dynObject);
|
233 |
this.fireIntervalAdded(this, this.theList.size() - 1, this.theList |
234 |
.size() - 1);
|
235 |
} |
236 |
|
237 |
public void addAll(List<FilesystemStoreParameters> toAdd) { |
238 |
int index0 = this.getSize() - 1; |
239 |
if (index0 < 0) { |
240 |
index0 = 0;
|
241 |
} |
242 |
this.theList.addAll(toAdd);
|
243 |
this.fireIntervalAdded(this, index0, this.theList.size() - 1); |
244 |
} |
245 |
|
246 |
public void remove(int i) { |
247 |
this.theList.remove(i);
|
248 |
this.fireIntervalRemoved(this, i, i); |
249 |
|
250 |
} |
251 |
|
252 |
public void up(FilesystemStoreParameters item) { |
253 |
int curIndex = this.theList.indexOf(item); |
254 |
if (curIndex < 1){ |
255 |
return;
|
256 |
} |
257 |
this.theList.remove(item);
|
258 |
this.theList.add(curIndex - 1, item); |
259 |
this.fireContentsChanged(this, curIndex, curIndex - 1); |
260 |
} |
261 |
|
262 |
public void down(FilesystemStoreParameters item) { |
263 |
int curIndex = this.theList.indexOf(item); |
264 |
if (curIndex < 0) { |
265 |
return;
|
266 |
} else if (curIndex == this.theList.size() - 1) { |
267 |
return;
|
268 |
} |
269 |
this.theList.remove(item);
|
270 |
this.theList.add(curIndex + 1, item); |
271 |
this.fireContentsChanged(this, curIndex, curIndex + 1); |
272 |
} |
273 |
|
274 |
} |
275 |
|
276 |
protected JList getFileList() { |
277 |
if (fileList == null) { |
278 |
fileList = new JList(new FilesystemStoreListModel()); |
279 |
|
280 |
fileList.addListSelectionListener(this);
|
281 |
} |
282 |
return fileList;
|
283 |
} |
284 |
|
285 |
private JScrollPane getFileListScroll() { |
286 |
if (fileListScroll == null) { |
287 |
fileListScroll = new JScrollPane(); |
288 |
fileListScroll.setViewportView(getFileList()); |
289 |
fileListScroll |
290 |
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
291 |
fileListScroll |
292 |
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
293 |
|
294 |
} |
295 |
return fileListScroll;
|
296 |
} |
297 |
|
298 |
private Component getButtonsPanel() { |
299 |
if (buttonsPanel == null) { |
300 |
buttonsPanel = new JPanel(); |
301 |
|
302 |
buttonsPanel.setLayout(new GridBagLayout()); |
303 |
|
304 |
GridBagConstraints constr = new GridBagConstraints(); |
305 |
|
306 |
constr.anchor = GridBagConstraints.CENTER;
|
307 |
constr.fill = GridBagConstraints.NONE;
|
308 |
constr.ipadx = 3;
|
309 |
constr.ipady = 3;
|
310 |
constr.insets = new Insets(3, 3, 3, 3); |
311 |
constr.gridwidth = GridBagConstraints.REMAINDER;
|
312 |
|
313 |
buttonsPanel.add(getAddButton(), constr); |
314 |
buttonsPanel.add(getEditButton(), constr); |
315 |
buttonsPanel.add(getRemoveButton(), constr); |
316 |
buttonsPanel.add(getUpButton(), constr); |
317 |
buttonsPanel.add(getDownButton(), constr); |
318 |
// buttonsPanel.add(new JLabel(), constrLbl);
|
319 |
} |
320 |
return buttonsPanel;
|
321 |
} |
322 |
|
323 |
private JButton getAddButton() { |
324 |
if (addButton == null) { |
325 |
addButton = new JButton(); |
326 |
addButton.setText(getLocalizedText("add"));
|
327 |
addButton.setActionCommand(ADD_COMMAND); |
328 |
addButton.addActionListener(this);
|
329 |
} |
330 |
return addButton;
|
331 |
} |
332 |
|
333 |
private JButton getEditButton() { |
334 |
if (editButton == null) { |
335 |
editButton = new JButton(); |
336 |
editButton.setText(getLocalizedText("edit"));
|
337 |
editButton.setActionCommand(EDIT_COMMAND); |
338 |
editButton.addActionListener(this);
|
339 |
} |
340 |
return editButton;
|
341 |
} |
342 |
|
343 |
private JButton getRemoveButton() { |
344 |
if (removeButton == null) { |
345 |
removeButton = new JButton(); |
346 |
removeButton.setText(getLocalizedText("remove"));
|
347 |
removeButton.setActionCommand(REMOVE_COMMAND); |
348 |
removeButton.addActionListener(this);
|
349 |
} |
350 |
return removeButton;
|
351 |
} |
352 |
|
353 |
private JButton getUpButton() { |
354 |
if (upButton == null) { |
355 |
upButton = new JButton(); |
356 |
upButton.setText(getLocalizedText("up"));
|
357 |
upButton.setActionCommand(UP_COMMAND); |
358 |
upButton.addActionListener(this);
|
359 |
} |
360 |
return upButton;
|
361 |
} |
362 |
|
363 |
private JButton getDownButton() { |
364 |
if (downButton == null) { |
365 |
downButton = new JButton(); |
366 |
downButton.setText(getLocalizedText("down"));
|
367 |
downButton.setActionCommand(DOWN_COMMAND); |
368 |
downButton.addActionListener(this);
|
369 |
} |
370 |
return downButton;
|
371 |
} |
372 |
|
373 |
private String getLocalizedText(String txt) { |
374 |
try {
|
375 |
return PluginServices.getText(this, txt); |
376 |
} catch (Exception e) { |
377 |
return txt;
|
378 |
} |
379 |
} |
380 |
|
381 |
private Component getParamsListScroll() { |
382 |
if (paramsListScroll == null) { |
383 |
paramsListScroll = new JScrollPane(); |
384 |
paramsListScroll.setBorder(null);
|
385 |
paramsListScroll.setViewportView(getParamsList()); |
386 |
paramsListScroll |
387 |
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
388 |
paramsListScroll |
389 |
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
390 |
} |
391 |
return paramsListScroll;
|
392 |
} |
393 |
|
394 |
private JPanel getParamsList() { |
395 |
if (paramsList == null) { |
396 |
paramsList = new DynObjectViewer();
|
397 |
} |
398 |
return paramsList;
|
399 |
|
400 |
} |
401 |
|
402 |
protected void loadParamsList(DynObject dynObj) { |
403 |
DynObjectViewer panel = (DynObjectViewer) getParamsList(); |
404 |
|
405 |
panel.load(dynObj); |
406 |
} |
407 |
|
408 |
public void actionPerformed(ActionEvent e) { |
409 |
String command = e.getActionCommand();
|
410 |
FilesystemStoreListModel model = (FilesystemStoreListModel) getFileList() |
411 |
.getModel(); |
412 |
|
413 |
|
414 |
if (command == ADD_COMMAND) {
|
415 |
List<FilesystemStoreParameters> toAdd = this.addFiles(); |
416 |
if (toAdd.isEmpty()){
|
417 |
return;
|
418 |
} |
419 |
model.addAll(toAdd); |
420 |
|
421 |
getFileList().setModel(model); |
422 |
|
423 |
|
424 |
} else if (command == EDIT_COMMAND) { |
425 |
DynObject dynObject = model.getDynObjectAt(getFileList() |
426 |
.getSelectedIndex()); |
427 |
|
428 |
DynObjectEditor editor = new DynObjectEditor(dynObject);
|
429 |
editor.editObject(true);
|
430 |
this.loadParamsList(dynObject);
|
431 |
|
432 |
} else if (command == REMOVE_COMMAND) { |
433 |
int[] selecteds = getFileList().getSelectedIndices(); |
434 |
for (int i = selecteds.length - 1; i > -1; i--) { |
435 |
model.remove(selecteds[i]); |
436 |
} |
437 |
getFileList().setSelectedIndex(-1);
|
438 |
this.loadParamsList(null); |
439 |
|
440 |
|
441 |
} else if (command == UP_COMMAND) { |
442 |
List<FilesystemStoreParameters> items = new ArrayList<FilesystemStoreParameters>(); |
443 |
int[] selecteds = getFileList().getSelectedIndices(); |
444 |
if (selecteds.length == 0 || selecteds[0] == 0) { |
445 |
return;
|
446 |
} |
447 |
for (int i = 0; i < selecteds.length; i++) { |
448 |
items.add(model.getStoreParameterAt(selecteds[i])); |
449 |
selecteds[i]--; |
450 |
} |
451 |
Iterator<FilesystemStoreParameters> iter = items.iterator();
|
452 |
while (iter.hasNext()) {
|
453 |
model.up(iter.next()); |
454 |
} |
455 |
getFileList().setSelectedIndices(selecteds); |
456 |
|
457 |
} else if (command == DOWN_COMMAND) { |
458 |
List<FilesystemStoreParameters> items = new ArrayList<FilesystemStoreParameters>(); |
459 |
int[] selecteds = getFileList().getSelectedIndices(); |
460 |
if (selecteds.length == 0 |
461 |
|| selecteds[selecteds.length - 1] == model.getSize() - 1) { |
462 |
return;
|
463 |
} |
464 |
for (int i = selecteds.length - 1; i > -1; i--) { |
465 |
items.add(model.getStoreParameterAt(selecteds[i])); |
466 |
selecteds[i]++; |
467 |
} |
468 |
Iterator<FilesystemStoreParameters> iter = items.iterator();
|
469 |
while (iter.hasNext()) {
|
470 |
model.down(iter.next()); |
471 |
} |
472 |
getFileList().setSelectedIndices(selecteds); |
473 |
|
474 |
} else {
|
475 |
throw new IllegalArgumentException(command); |
476 |
} |
477 |
|
478 |
} |
479 |
|
480 |
public List<DynObject> getSelecteds() { |
481 |
ArrayList<DynObject> list = new ArrayList<DynObject>(); |
482 |
JList fList = this.getFileList(); |
483 |
int[] selecteds = fList.getSelectedIndices(); |
484 |
FilesystemStoreListModel model = (FilesystemStoreListModel) fList |
485 |
.getModel(); |
486 |
|
487 |
for (int index : selecteds) { |
488 |
list.add((DynObject) model.getStoreParameterAt(index)); |
489 |
} |
490 |
return list;
|
491 |
} |
492 |
|
493 |
public void valueChanged(ListSelectionEvent e) { |
494 |
int index = getFileList().getSelectedIndex();
|
495 |
if (index < 0) { |
496 |
loadParamsList(null);
|
497 |
} else {
|
498 |
FilesystemStoreListModel model = ((FilesystemStoreListModel) getFileList() |
499 |
.getModel()); |
500 |
this.loadParamsList((DynObject) model.getStoreParameterAt(index));
|
501 |
} |
502 |
this.updateButtons();
|
503 |
} |
504 |
|
505 |
public class MyFileFilter extends FileFilter { |
506 |
public FilesystemFileFilter filter = null; |
507 |
|
508 |
public MyFileFilter(FilesystemFileFilter params) {
|
509 |
this.filter = params;
|
510 |
} |
511 |
|
512 |
/**
|
513 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
|
514 |
*/
|
515 |
public boolean accept(File f) { |
516 |
if (f.isDirectory()) {
|
517 |
return true; |
518 |
} |
519 |
return filter.accept(f);
|
520 |
|
521 |
} |
522 |
|
523 |
/**
|
524 |
* @see javax.swing.filechooser.FileFilter#getDescription()
|
525 |
*/
|
526 |
public String getDescription() { |
527 |
return filter.getDescription();
|
528 |
} |
529 |
} |
530 |
|
531 |
private List<FilesystemStoreParameters> addFiles() { |
532 |
this.callStateChanged(true); |
533 |
JFileChooser fileChooser = new JFileChooser(OPEN_LAYER_FILE_CHOOSER_ID, |
534 |
explorer.getCurrentPath()); |
535 |
fileChooser.setMultiSelectionEnabled(true);
|
536 |
fileChooser.setAcceptAllFileFilterUsed(false);
|
537 |
|
538 |
Iterator<MyFileFilter> iter = this.filters.iterator(); |
539 |
while (iter.hasNext()) {
|
540 |
fileChooser.addChoosableFileFilter(iter.next()); |
541 |
} |
542 |
|
543 |
if (lastFilter != null && filters.contains(lastFilter)) { |
544 |
fileChooser.setFileFilter(lastFilter); |
545 |
} |
546 |
|
547 |
int result = fileChooser.showOpenDialog(this); |
548 |
|
549 |
List<FilesystemStoreParameters> toAdd = new ArrayList<FilesystemStoreParameters>(); |
550 |
|
551 |
if (result == JFileChooser.APPROVE_OPTION) { |
552 |
lastPath = fileChooser.getCurrentDirectory().getAbsolutePath(); |
553 |
try {
|
554 |
explorer.setCurrentPath(fileChooser.getCurrentDirectory()); |
555 |
} catch (FileNotFoundException e) { |
556 |
NotificationManager.addError(e); |
557 |
} |
558 |
lastFilter = (MyFileFilter) fileChooser.getFileFilter(); |
559 |
DataStoreParameters param, toAddParam; |
560 |
ApplicationManager appGvSIGMan = ApplicationLocator |
561 |
.getManager(); |
562 |
PrepareContext context = this.getPrepareDataStoreContext();
|
563 |
for (File aFile : fileChooser.getSelectedFiles()) { |
564 |
try {
|
565 |
param = explorer |
566 |
.getParametersFor(aFile); |
567 |
if (param == null) { |
568 |
// TODO show warning
|
569 |
continue;
|
570 |
} |
571 |
|
572 |
try {
|
573 |
toAddParam = appGvSIGMan |
574 |
.prepareOpenDataStoreParameters(param, context); |
575 |
} catch (Exception e) { |
576 |
NotificationManager.addError(e); |
577 |
continue;
|
578 |
} |
579 |
|
580 |
toAdd.add((FilesystemStoreParameters) toAddParam); |
581 |
} catch (DataException e) {
|
582 |
NotificationManager.addError(e); |
583 |
return null; |
584 |
} |
585 |
} |
586 |
|
587 |
// IFileOpen lastFileOpen = null;
|
588 |
// for (int i = 0; i < listFileOpen.size(); i++) {
|
589 |
// IFileOpen fileOpen = listFileOpen.get(i);
|
590 |
// List<FileFilter> aux = fileOpen.getFileFilter();
|
591 |
// for (int j = 0; j < aux.size(); j++) {
|
592 |
// if (fileChooser.getFileFilter() == aux.get(j)) {
|
593 |
// for (int iFile = 0; iFile < newFiles.length; iFile++) {
|
594 |
// newFiles[iFile] = fileOpen.post(newFiles[iFile]);
|
595 |
// }
|
596 |
// lastFileOpen = fileOpen;
|
597 |
// break;
|
598 |
// }
|
599 |
// }
|
600 |
// }
|
601 |
//
|
602 |
// for (int ind = 0; ind < newFiles.length; ind++) {
|
603 |
// if (newFiles[ind] == null) {
|
604 |
// break;
|
605 |
// }
|
606 |
// toAdd.add(new MyFile(newFiles[ind], (fileChooser
|
607 |
// .getFileFilter()), lastFileOpen));
|
608 |
// }
|
609 |
//
|
610 |
// return toAdd.toArray();
|
611 |
} |
612 |
return toAdd;
|
613 |
} |
614 |
|
615 |
protected abstract PrepareContext getPrepareDataStoreContext(); |
616 |
|
617 |
private void updateButtons() { |
618 |
int selectedIndex =this.getFileList().getSelectedIndex(); |
619 |
int size =this.getFileList().getModel().getSize(); |
620 |
int[] selecteds = this.getFileList().getSelectedIndices(); |
621 |
if ( size < 1) { |
622 |
this.getEditButton().setEnabled(false); |
623 |
this.getRemoveButton().setEnabled(false); |
624 |
this.getUpButton().setEnabled(false); |
625 |
this.getDownButton().setEnabled(false); |
626 |
return;
|
627 |
} else if (size == 1) { |
628 |
this.getUpButton().setEnabled(false); |
629 |
this.getDownButton().setEnabled(false); |
630 |
} else {
|
631 |
this.getUpButton().setEnabled(selectedIndex > 0); |
632 |
|
633 |
this.getDownButton().setEnabled(
|
634 |
selectedIndex > -1
|
635 |
&& selecteds[selecteds.length - 1] < size - 1); |
636 |
} |
637 |
this.getEditButton().setEnabled(
|
638 |
selectedIndex > -1
|
639 |
&& this.getFileList().getSelectedIndices().length == 1); |
640 |
this.getRemoveButton().setEnabled(selectedIndex > -1); |
641 |
} |
642 |
|
643 |
public void close() { |
644 |
if (explorer != null) { |
645 |
explorer.dispose(); |
646 |
explorer = null;
|
647 |
} |
648 |
if (filters != null) { |
649 |
filters.clear(); |
650 |
filters = null;
|
651 |
} |
652 |
} |
653 |
} |