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