gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.app / org.gvsig.vcsgis.app.mainplugin / src / main / java / org / gvsig / vcsgis / app / addlayer / AbstractWizardVCSGis.java @ 3451
History | View | Annotate | Download (40.6 KB)
1 |
package org.gvsig.vcsgis.app.addlayer; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Cursor; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ItemEvent; |
8 |
import java.net.URL; |
9 |
import java.util.ArrayList; |
10 |
import java.util.Collection; |
11 |
import java.util.HashMap; |
12 |
import java.util.List; |
13 |
import java.util.Map; |
14 |
import javax.swing.ComboBoxModel; |
15 |
import javax.swing.DefaultComboBoxModel; |
16 |
import javax.swing.DefaultListModel; |
17 |
import javax.swing.DefaultListSelectionModel; |
18 |
import javax.swing.ImageIcon; |
19 |
import javax.swing.JOptionPane; |
20 |
import javax.swing.ListModel; |
21 |
import javax.swing.ListSelectionModel; |
22 |
import javax.swing.SwingUtilities; |
23 |
import javax.swing.event.ChangeEvent; |
24 |
import javax.swing.event.ListSelectionEvent; |
25 |
import org.apache.commons.io.FilenameUtils; |
26 |
import org.apache.commons.lang3.StringUtils; |
27 |
import org.cresques.cts.IProjection; |
28 |
import org.gvsig.app.gui.WizardPanel; |
29 |
import org.gvsig.expressionevaluator.Expression; |
30 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
31 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
32 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
33 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
34 |
import org.gvsig.fmap.dal.DALLocator; |
35 |
import org.gvsig.fmap.dal.DataManager; |
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
37 |
import org.gvsig.fmap.dal.DataTypes; |
38 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
39 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
42 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
43 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
44 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
45 |
import org.gvsig.fmap.dal.swing.dataStoreParameters.DataStoreParametersPanel; |
46 |
import org.gvsig.fmap.dal.swing.dataStoreParameters.DataStoreParametersPanelManager; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
import org.gvsig.tools.i18n.I18nManager; |
49 |
import org.gvsig.tools.swing.api.FilteredListController; |
50 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
51 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
52 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
53 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
54 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
55 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
56 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
57 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
58 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
59 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
60 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
61 |
import org.gvsig.tools.util.LabeledValue; |
62 |
import org.gvsig.tools.util.LabeledValueImpl; |
63 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
64 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
65 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
66 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
67 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
68 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
69 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
70 |
import org.slf4j.Logger; |
71 |
import org.slf4j.LoggerFactory; |
72 |
|
73 |
/**
|
74 |
*
|
75 |
* @author jjdelcerro
|
76 |
*/
|
77 |
@SuppressWarnings("UseSpecificCatch") |
78 |
public abstract class AbstractWizardVCSGis extends WizardPanel { |
79 |
|
80 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractWizardVCSGis.class); |
81 |
|
82 |
protected class TableInfo extends LabeledValueImpl<JDBCStoreParameters> { |
83 |
|
84 |
private final ListSelectionModel columnChecksModel; |
85 |
private FeatureType featureType;
|
86 |
private int geomFieldSelected = -1; |
87 |
private int idFieldSelected = -1; |
88 |
private ComboBoxModel<String> idFieldComboModel; |
89 |
private ComboBoxModel<String> geomFieldComboModel; |
90 |
private List<FeatureAttributeDescriptor> attributeDescriptors; |
91 |
private ListModel<LabeledValue<FeatureAttributeDescriptor>> columnsListModel; |
92 |
private Expression filter; |
93 |
private IProjection projection;
|
94 |
private boolean selected; |
95 |
private String documentName; |
96 |
|
97 |
public TableInfo(JDBCStoreParameters parameters) {
|
98 |
super(getLabelForTable(parameters), parameters);
|
99 |
this.columnChecksModel = new DefaultListSelectionModel(); |
100 |
this.selected = false; |
101 |
this.documentName = parameters.getTable();
|
102 |
this.projection = parameters.getCRS();
|
103 |
} |
104 |
|
105 |
public String getDocumentName() { |
106 |
return this.documentName; |
107 |
} |
108 |
|
109 |
public void setDocumentName(String name) { |
110 |
this.documentName = name;
|
111 |
} |
112 |
|
113 |
public boolean isSelected() { |
114 |
return selected;
|
115 |
} |
116 |
|
117 |
public void setSelected(boolean selected) { |
118 |
this.selected = selected;
|
119 |
} |
120 |
|
121 |
public ListSelectionModel getColumnChecksModel() { |
122 |
return this.columnChecksModel; |
123 |
} |
124 |
|
125 |
public JDBCStoreParameters getParameters() {
|
126 |
JDBCStoreParameters p = this.getValue();
|
127 |
StringBuilder fields = new StringBuilder(); |
128 |
List<FeatureAttributeDescriptor> attributes = this.getAttributeDescriptors(); |
129 |
boolean allSelected = true; |
130 |
for (int i = 0; i < attributes.size(); i++) { |
131 |
if (this.columnChecksModel.isSelectedIndex(i)) { |
132 |
if (fields.length() > 0) { |
133 |
fields.append(",");
|
134 |
} |
135 |
fields.append(attributes.get(i).getName()); |
136 |
|
137 |
} else {
|
138 |
allSelected = false;
|
139 |
} |
140 |
} |
141 |
if( !allSelected ) {
|
142 |
p.setFields(fields.toString()); |
143 |
} |
144 |
p.setPkFields(this.getFieldId());
|
145 |
p.setCRS(this.getProjection());
|
146 |
p.setDefaultGeometryField(this.getGeomField());
|
147 |
if (!ExpressionUtils.isEmpty(this.filter)) { |
148 |
p.setBaseFilter(this.filter.toString());
|
149 |
} else {
|
150 |
p.setBaseFilter(null);
|
151 |
} |
152 |
return p;
|
153 |
} |
154 |
|
155 |
public void setProjection(IProjection projection) { |
156 |
this.projection = projection;
|
157 |
} |
158 |
|
159 |
public IProjection getProjection() {
|
160 |
return projection;
|
161 |
} |
162 |
|
163 |
public String getFieldId() { |
164 |
if (this.idFieldSelected < 0) { |
165 |
return null; |
166 |
} |
167 |
return this.idFieldComboModel.getElementAt(this.idFieldSelected); |
168 |
} |
169 |
|
170 |
public String getGeomField() { |
171 |
if (this.geomFieldSelected < 0) { |
172 |
return null; |
173 |
} |
174 |
return this.geomFieldComboModel.getElementAt(this.geomFieldSelected); |
175 |
} |
176 |
|
177 |
public FeatureType getFeatureType() {
|
178 |
if (this.featureType == null) { |
179 |
DataManager dataManager = DALLocator.getDataManager(); |
180 |
try {
|
181 |
JDBCStoreParameters params = this.getValue();
|
182 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
183 |
params.getDataStoreName(), |
184 |
params |
185 |
); |
186 |
this.featureType = store.getDefaultFeatureType();
|
187 |
} catch (Exception ex) { |
188 |
LOGGER.trace("Can't get feature type.",ex); // To allow set break points |
189 |
} |
190 |
} |
191 |
return this.featureType; |
192 |
} |
193 |
|
194 |
public ComboBoxModel getGeomFieldComboModel() { |
195 |
if (this.geomFieldComboModel == null) { |
196 |
DefaultComboBoxModel<String> geomModel = new DefaultComboBoxModel<>(); |
197 |
geomModel.addElement(" ");
|
198 |
int geomIndex = -1; |
199 |
int n = 1; |
200 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
201 |
if (geomIndex < 0 && attr.getType() == DataTypes.GEOMETRY) { |
202 |
geomIndex = n; |
203 |
} |
204 |
int dataType = attr.getType();
|
205 |
if (dataType == DataTypes.GEOMETRY
|
206 |
|| dataType == DataTypes.BYTEARRAY |
207 |
|| dataType == DataTypes.STRING) { |
208 |
geomModel.addElement(attr.getName()); |
209 |
n++; |
210 |
} |
211 |
} |
212 |
if (geomIndex < 0) { |
213 |
geomIndex = 0;
|
214 |
} |
215 |
this.geomFieldComboModel = geomModel;
|
216 |
this.geomFieldSelected = geomIndex;
|
217 |
} |
218 |
return this.geomFieldComboModel; |
219 |
} |
220 |
|
221 |
public int getGeomFieldSelected() { |
222 |
return this.geomFieldSelected; |
223 |
} |
224 |
|
225 |
public ComboBoxModel getIdFieldComboModel() { |
226 |
if (this.idFieldComboModel == null) { |
227 |
StringBuilder pkName = new StringBuilder(); |
228 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
229 |
if (attr.isPrimaryKey()) {
|
230 |
if (!StringUtils.isBlank(pkName)) {
|
231 |
pkName.append(",");
|
232 |
} |
233 |
pkName.append(attr.getName()); |
234 |
} |
235 |
} |
236 |
DefaultComboBoxModel<String> idsModel = new DefaultComboBoxModel<>(); |
237 |
idsModel.addElement(" ");
|
238 |
int idsIndex = -1; |
239 |
int n = 1; |
240 |
if (!StringUtils.isBlank(pkName) && StringUtils.contains(pkName, "/")) { |
241 |
idsModel.addElement(pkName.toString()); |
242 |
idsIndex = n++; |
243 |
} |
244 |
for (FeatureAttributeDescriptor attr : getAttributeDescriptors()) {
|
245 |
if (idsIndex < 0 && attr.isPrimaryKey()) { |
246 |
idsIndex = n; |
247 |
} |
248 |
idsModel.addElement(attr.getName()); |
249 |
n++; |
250 |
} |
251 |
if (idsIndex < 0) { |
252 |
idsIndex = 0;
|
253 |
} |
254 |
this.idFieldComboModel = idsModel;
|
255 |
this.idFieldSelected = idsIndex;
|
256 |
} |
257 |
return this.idFieldComboModel; |
258 |
} |
259 |
|
260 |
public List<FeatureAttributeDescriptor> getAttributeDescriptors() { |
261 |
if (this.attributeDescriptors == null) { |
262 |
List<FeatureAttributeDescriptor> attrs = new ArrayList<>(); |
263 |
for (FeatureAttributeDescriptor attr : this.getFeatureType()) { |
264 |
attrs.add(attr); |
265 |
} |
266 |
attrs.sort((FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) -> |
267 |
o1.getName().compareTo(o2.getName()) |
268 |
); |
269 |
this.columnChecksModel.setSelectionInterval(0, attrs.size()); |
270 |
this.attributeDescriptors = attrs;
|
271 |
} |
272 |
return this.attributeDescriptors; |
273 |
} |
274 |
|
275 |
public ListModel<LabeledValue<FeatureAttributeDescriptor>> getColumnsListModel() { |
276 |
if (this.columnsListModel == null) { |
277 |
DefaultListModel<LabeledValue<FeatureAttributeDescriptor>> model = new DefaultListModel<>(); |
278 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
279 |
model.addElement(new LabeledValueImpl<>(
|
280 |
attr.getName() + " [" + attr.getDataTypeName() + "]", |
281 |
attr |
282 |
) |
283 |
); |
284 |
} |
285 |
this.columnsListModel = model;
|
286 |
} |
287 |
return this.columnsListModel; |
288 |
} |
289 |
|
290 |
public FeatureAttributeDescriptor getAttributeDescriptor(String attrName) { |
291 |
return this.getFeatureType().getAttributeDescriptor(attrName); |
292 |
} |
293 |
|
294 |
public int getIdFieldSelected() { |
295 |
return this.idFieldSelected; |
296 |
} |
297 |
|
298 |
public Expression getFilter() { |
299 |
return this.filter; |
300 |
} |
301 |
|
302 |
public void setFilter(Expression filter) { |
303 |
this.filter = filter;
|
304 |
} |
305 |
|
306 |
private void setIdFieldSelected(int selectedIndex) { |
307 |
this.idFieldSelected = selectedIndex;
|
308 |
} |
309 |
|
310 |
private void setGeomFieldSelected(int selectedIndex) { |
311 |
this.geomFieldSelected = selectedIndex;
|
312 |
} |
313 |
|
314 |
private boolean hasValidValues() { |
315 |
if (this.getGeomFieldSelected() < 0 && requireGeometry()) { |
316 |
return false; |
317 |
} |
318 |
JDBCStoreParameters p = this.getParameters();
|
319 |
try {
|
320 |
p.validate(); |
321 |
return true; |
322 |
} catch (ValidateDataParametersException ex) {
|
323 |
return false; |
324 |
} |
325 |
} |
326 |
|
327 |
} |
328 |
|
329 |
private WizardVCSGisViewExtended view;
|
330 |
private PickerController<VCSGisWorkspace> workspacePicker;
|
331 |
private PickerController<IProjection> pickerProjection;
|
332 |
private ExpressionPickerController pickerFilter;
|
333 |
private JListWithCheckbox lwcTables;
|
334 |
private JListWithCheckbox lwcColumns;
|
335 |
protected Map<String, TableInfo> tablesInfo = null; |
336 |
protected FilteredListController tablesFilterController;
|
337 |
private boolean processing; |
338 |
private TaskStatusController taskStatusController;
|
339 |
|
340 |
public AbstractWizardVCSGis() {
|
341 |
initComponents(); |
342 |
} |
343 |
|
344 |
private void initComponents() { |
345 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
346 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
347 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
348 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
349 |
|
350 |
this.view = new WizardVCSGisViewExtended(); |
351 |
|
352 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
353 |
|
354 |
this.taskStatusController = taskStatusManager.createTaskStatusController(
|
355 |
this.view.lblStatusTitle,
|
356 |
this.view.lblStatusMessages,
|
357 |
this.view.pbStatus
|
358 |
); |
359 |
this.taskStatusController.setShowCancelButton(false); |
360 |
this.taskStatusController.setShowRemoveTaskButton(false); |
361 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager());
|
362 |
|
363 |
toolsSwingManager.translate(this.view.btnDeselectAllColumns);
|
364 |
toolsSwingManager.translate(this.view.btnSelectAllColumns);
|
365 |
toolsSwingManager.translate(this.view.lblColumns);
|
366 |
toolsSwingManager.translate(this.view.lblWorkspace);
|
367 |
toolsSwingManager.translate(this.view.lblFilter);
|
368 |
toolsSwingManager.translate(this.view.lblGeometryField);
|
369 |
toolsSwingManager.translate(this.view.lblIdField);
|
370 |
toolsSwingManager.translate(this.view.lblName);
|
371 |
toolsSwingManager.translate(this.view.lblProjection);
|
372 |
toolsSwingManager.translate(this.view.lblTable);
|
373 |
toolsSwingManager.translate(this.view.cboWorkspaces);
|
374 |
toolsSwingManager.translate(this.view.btnAddWorkspace);
|
375 |
toolsSwingManager.translate(this.view.btnCheckout);
|
376 |
toolsSwingManager.translate(this.view.btnAdvancedProperties);
|
377 |
toolsSwingManager.translate(this.view.btnInitWorkspace);
|
378 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
379 |
toolsSwingManager.translate(this.view.txtRepositoryInfo);
|
380 |
|
381 |
toolsSwingManager.addClearButton(this.view.txtName);
|
382 |
toolsSwingManager.setDefaultPopupMenu(this.view.txtName);
|
383 |
|
384 |
this.view.btnInitWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
385 |
this.view.btnAddWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
386 |
this.view.btnSelectAllColumns.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
387 |
this.view.btnDeselectAllColumns.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
388 |
this.view.btnProjection.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
389 |
this.view.btnFilter.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
390 |
this.view.btnFilterBookmarks.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
391 |
this.view.btnFilterHistory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
392 |
this.view.btnAdvancedProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
393 |
this.view.btnAdvancedProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
394 |
|
395 |
|
396 |
|
397 |
|
398 |
this.lwcTables = toolsSwingManager.createJListWithCheckbox(
|
399 |
this.view.lstTables
|
400 |
); |
401 |
this.lwcColumns = toolsSwingManager.createJListWithCheckbox(
|
402 |
this.view.lstColumns
|
403 |
); |
404 |
|
405 |
this.workspacePicker = swingManager.createWorkspacePickerController(
|
406 |
this.view.cboWorkspaces,
|
407 |
this.view.btnAddWorkspace
|
408 |
); |
409 |
|
410 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
411 |
doChangeWorkspace(); |
412 |
setEditableTables(true);
|
413 |
}); |
414 |
|
415 |
|
416 |
this.pickerProjection = dataSwingManager.createProjectionPickerController(
|
417 |
this.view.txtProjection,
|
418 |
this.view.btnProjection
|
419 |
); |
420 |
|
421 |
this.pickerFilter = expressionSwingManager.createExpressionPickerController(
|
422 |
this.view.txtFilter,
|
423 |
this.view.btnFilter,
|
424 |
this.view.btnFilterBookmarks,
|
425 |
this.view.btnFilterHistory
|
426 |
); |
427 |
this.lwcTables.addListSelectionListener((ListSelectionEvent e) -> { |
428 |
doChangeTableSelected(); |
429 |
}); |
430 |
this.lwcTables.addChecksListener((ListSelectionEvent e) -> { |
431 |
doChangeTableSelected(); |
432 |
}); |
433 |
this.view.cboGeometryField.addItemListener((ItemEvent e) -> { |
434 |
if (e.getStateChange() == ItemEvent.SELECTED) { |
435 |
doChangeGeometryField(); |
436 |
} |
437 |
}); |
438 |
this.view.btnDeselectAllColumns.addActionListener((ActionEvent e) -> { |
439 |
doDeselectAllColumns(); |
440 |
}); |
441 |
this.view.btnSelectAllColumns.addActionListener((ActionEvent e) -> { |
442 |
doSelectAllColumns(); |
443 |
}); |
444 |
this.view.btnAdvancedProperties.addActionListener((ActionEvent e) -> { |
445 |
doShowAdvancedProperties(); |
446 |
}); |
447 |
this.view.btnInitWorkspace.addActionListener((ActionEvent e) -> { |
448 |
doShowInitWorkspace(); |
449 |
}); |
450 |
|
451 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
452 |
doCheckout(); |
453 |
}); |
454 |
|
455 |
|
456 |
|
457 |
this.tablesFilterController = toolsSwingManager.createFilteredListController(
|
458 |
this.view.lstTables,
|
459 |
this.view.txtTablesFilter,
|
460 |
this.view.btnTablesFilter
|
461 |
); |
462 |
|
463 |
this.clearTables();
|
464 |
this.setEditableTables(false); |
465 |
|
466 |
this.setLayout(new BorderLayout()); |
467 |
this.add(this.view, BorderLayout.CENTER); |
468 |
this.setPreferredSize(new Dimension(500, 400)); |
469 |
doUpdateComponents(); |
470 |
} |
471 |
|
472 |
protected abstract boolean requireGeometry(); |
473 |
|
474 |
protected Collection<TableInfo> getTablesInformation() { |
475 |
this.updateTableInfoFromUI();
|
476 |
if( this.tablesInfo == null ) { |
477 |
this.tablesInfo = new HashMap<>(); |
478 |
} |
479 |
return this.tablesInfo.values(); |
480 |
} |
481 |
|
482 |
private void doDeselectAllColumns() { |
483 |
TableInfo info = this.getCurrentTableInfo();
|
484 |
if (info == null) { |
485 |
return;
|
486 |
} |
487 |
info.getColumnChecksModel().clearSelection(); |
488 |
} |
489 |
|
490 |
private void doSelectAllColumns() { |
491 |
TableInfo info = this.getCurrentTableInfo();
|
492 |
if (info == null) { |
493 |
return;
|
494 |
} |
495 |
info.getColumnChecksModel().setSelectionInterval(0, info.getAttributeDescriptors().size());
|
496 |
} |
497 |
|
498 |
private void doShowAdvancedProperties() { |
499 |
final TableInfo info = this.getCurrentTableInfo(); |
500 |
if (info == null) { |
501 |
return;
|
502 |
} |
503 |
this.fetch(info);
|
504 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
505 |
WindowManager_v2 winmgr = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
506 |
DataStoreParametersPanelManager paramsPanelManager = DALSwingLocator.getDataStoreParametersPanelManager(); |
507 |
|
508 |
final DataStoreParametersPanel panel = paramsPanelManager.createDataStoreParametersPanel(info.getParameters());
|
509 |
final Dialog dialog = winmgr.createDialog( |
510 |
panel.asJComponent(), |
511 |
i18n.getTranslation("_Connection_parameters"),
|
512 |
null,
|
513 |
WindowManager_v2.BUTTONS_OK_CANCEL |
514 |
); |
515 |
dialog.addActionListener((ActionEvent e) -> {
|
516 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) {
|
517 |
panel.fetchParameters(info.getParameters()); |
518 |
} |
519 |
}); |
520 |
dialog.show(WindowManager.MODE.DIALOG); |
521 |
} |
522 |
|
523 |
private void clearTables() { |
524 |
this.lwcTables.setModel(new DefaultListModel()); |
525 |
this.lwcTables.getCheckedModel().clearSelection();
|
526 |
this.clearTableConfig();
|
527 |
} |
528 |
|
529 |
private void clearTableConfig() { |
530 |
this.lwcColumns.setModel(new DefaultListModel()); |
531 |
this.lwcColumns.getCheckedModel().clearSelection();
|
532 |
this.view.txtName.setText(""); |
533 |
this.view.cboGeometryField.setModel(new DefaultComboBoxModel()); |
534 |
this.view.cboIdField.setModel(new DefaultComboBoxModel()); |
535 |
this.pickerProjection.set(null); |
536 |
this.pickerFilter.set(null); |
537 |
} |
538 |
|
539 |
private void setEditableTables(boolean enable) { |
540 |
this.view.lstTables.setEnabled(enable);
|
541 |
this.setEditableTableConfig(enable);
|
542 |
this.view.btnDeselectAllColumns.setEnabled(enable);
|
543 |
this.view.btnSelectAllColumns.setEnabled(enable);
|
544 |
} |
545 |
|
546 |
private void setEditableTableConfig(boolean enable) { |
547 |
this.view.lstColumns.setEnabled(enable);
|
548 |
this.view.txtName.setEditable(enable);
|
549 |
this.view.cboGeometryField.setEnabled(enable);
|
550 |
this.view.cboIdField.setEnabled(enable);
|
551 |
this.pickerProjection.setEditable(enable);
|
552 |
this.pickerFilter.setEditable(enable);
|
553 |
this.view.btnAdvancedProperties.setEnabled(enable);
|
554 |
} |
555 |
|
556 |
private TableInfo getCurrentTableInfo() {
|
557 |
VCSGisEntity rEntity = getRemoteEntity(); |
558 |
if(rEntity == null){ |
559 |
return null; |
560 |
} |
561 |
|
562 |
TableInfo xx = this.tablesInfo.get(rEntity.getEntityName());
|
563 |
return xx;
|
564 |
} |
565 |
|
566 |
private void doChangeGeometryField() { |
567 |
TableInfo info = this.getCurrentTableInfo();
|
568 |
if (info == null) { |
569 |
return;
|
570 |
} |
571 |
String attrName = (String) this.view.cboGeometryField.getSelectedItem(); |
572 |
if (StringUtils.isBlank(attrName)) {
|
573 |
return;
|
574 |
} |
575 |
FeatureAttributeDescriptor attr = info.getAttributeDescriptor(attrName); |
576 |
IProjection srs = attr.getSRS(); |
577 |
if (srs == null) { |
578 |
return;
|
579 |
} |
580 |
this.pickerProjection.set(srs);
|
581 |
} |
582 |
|
583 |
private void doChangeWorkspace() { |
584 |
if (notInSwingThreadInvokeLater(this::doChangeWorkspace)) { |
585 |
return;
|
586 |
} |
587 |
|
588 |
this.lwcTables.clearSelection();
|
589 |
|
590 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
591 |
VCSGisWorkspace workspace = workspacePicker.get(); |
592 |
this.tablesFilterController.getModel().clear();
|
593 |
if (workspace == null) { |
594 |
return;
|
595 |
} |
596 |
|
597 |
this.view.txtRepositoryInfo.setText(workspace.getRepository().getLabel());
|
598 |
|
599 |
reloadEntities(workspace, i18n); |
600 |
} |
601 |
|
602 |
private void reloadEntities(VCSGisWorkspace workspace, I18nManager i18n) { |
603 |
this.tablesInfo = new HashMap<>(); |
604 |
|
605 |
//Rellenamos la lista de entidades
|
606 |
Thread task = new Thread(() -> { |
607 |
try {
|
608 |
processing = true;
|
609 |
doUpdateComponents(); |
610 |
List<VCSGisEntity> repoEntities = workspace.getRepositoryEntities();
|
611 |
List<VCSGisWorkspaceEntity> wsEntities = workspace.getWorkspaceEntities();
|
612 |
doReloadEntitiesList(repoEntities, wsEntities); |
613 |
|
614 |
|
615 |
} catch (Exception e) { |
616 |
LOGGER.warn("_Cant_retrieve_entities_from_repository", e);
|
617 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
618 |
dialogs.messageDialog( |
619 |
i18n.getTranslation("_Cant_retrieve_entities_from_repository") + "\n" + e.getMessage(), |
620 |
i18n.getTranslation("_Add_table"),
|
621 |
JOptionPane.WARNING_MESSAGE
|
622 |
); |
623 |
|
624 |
} finally {
|
625 |
processing = false;
|
626 |
doUpdateComponents(); |
627 |
} |
628 |
}, "VCSGisAddTable_getRepositoryEntities");
|
629 |
|
630 |
processing = true;
|
631 |
doUpdateComponents(); |
632 |
task.start(); |
633 |
} |
634 |
|
635 |
|
636 |
// private void doUpdateTables() {
|
637 |
// JDBCServerExplorerParameters connection = this.pickerConnection.get();
|
638 |
// if (connection == null) {
|
639 |
// this.clearTables();
|
640 |
// return;
|
641 |
// }
|
642 |
// DataManager dataManager = DALLocator.getDataManager();
|
643 |
// DataServerExplorer explorer = null;
|
644 |
// try {
|
645 |
// explorer = dataManager.openServerExplorer(
|
646 |
// connection.getDataStoreName(),
|
647 |
// connection
|
648 |
// );
|
649 |
// List<TableInfo> parameters = new ArrayList<>();
|
650 |
// for (DataStoreParameters params : explorer.list()) {
|
651 |
// parameters.add(new TableInfo((JDBCStoreParameters) params));
|
652 |
// }
|
653 |
// parameters.sort((TableInfo o1, TableInfo o2) ->
|
654 |
// o1.getLabel().compareTo(o2.getLabel())
|
655 |
// );
|
656 |
// this.tablesInfo = new HashMap<>();
|
657 |
// DefaultListModel<TableInfo> model = new DefaultListModel<>();
|
658 |
// for (TableInfo x : parameters) {
|
659 |
// model.addElement(x);
|
660 |
// this.tablesInfo.put(x.getDocumentName(), x);
|
661 |
// }
|
662 |
// this.lwcTables.setModel(model);
|
663 |
// this.lwcTables.getCheckedModel().clearSelection();
|
664 |
// } catch (Exception ex) {
|
665 |
// } finally {
|
666 |
// DisposeUtils.disposeQuietly(explorer);
|
667 |
// }
|
668 |
// }
|
669 |
|
670 |
private void doChangeTableSelected() { |
671 |
if( notInSwingThreadInvokeLater(() -> {doChangeTableSelected();}) ) {
|
672 |
return;
|
673 |
} |
674 |
boolean updatedTableInfo = false; |
675 |
|
676 |
VCSGisEntity rEntity = getRemoteEntity(); |
677 |
if(rEntity != null){ |
678 |
VCSGisWorkspaceEntity lEntity; |
679 |
lEntity = getWorkspace().getWorkspaceEntity(rEntity.getEntityName()); |
680 |
if(lEntity != null){ |
681 |
TableInfo tableInfo = tablesInfo.get(rEntity.getEntityName()); |
682 |
this.updateTableInfoFromUI();
|
683 |
this.put(tableInfo);
|
684 |
updatedTableInfo = true;
|
685 |
} else {
|
686 |
int index = this.lwcTables.getSelectedIndex(); |
687 |
this.lwcTables.getCheckedModel().removeIndexInterval(index, index);
|
688 |
} |
689 |
} |
690 |
|
691 |
if(!updatedTableInfo){
|
692 |
this.clearTableConfig();
|
693 |
} |
694 |
|
695 |
showMessage("");
|
696 |
doUpdateComponents(); |
697 |
} |
698 |
|
699 |
private void updateTableInfoFromUI() { |
700 |
String previousTableName = this.view.txtName.getText(); |
701 |
if (this.tablesInfo!=null && !this.tablesInfo.isEmpty()) { |
702 |
TableInfo previousInfo = this.tablesInfo.get(previousTableName);
|
703 |
if (previousInfo != null) { |
704 |
this.fetch(previousInfo);
|
705 |
} |
706 |
} |
707 |
} |
708 |
|
709 |
private void put(TableInfo tableInfo) { |
710 |
this.lwcColumns.setModel(tableInfo.getColumnsListModel());
|
711 |
this.lwcColumns.setCheckedModel(tableInfo.getColumnChecksModel());
|
712 |
|
713 |
this.view.cboGeometryField.setModel(tableInfo.getGeomFieldComboModel());
|
714 |
this.view.cboGeometryField.setSelectedIndex(tableInfo.getGeomFieldSelected());
|
715 |
|
716 |
this.view.cboIdField.setModel(tableInfo.getIdFieldComboModel());
|
717 |
this.view.cboIdField.setSelectedIndex(tableInfo.getIdFieldSelected());
|
718 |
|
719 |
this.pickerProjection.set(tableInfo.getProjection());
|
720 |
this.pickerFilter.set(tableInfo.getFilter());
|
721 |
this.view.txtName.setText(tableInfo.getDocumentName());
|
722 |
} |
723 |
|
724 |
private void fetch(TableInfo tableInfo) { |
725 |
tableInfo.setIdFieldSelected(this.view.cboIdField.getSelectedIndex());
|
726 |
tableInfo.setGeomFieldSelected(this.view.cboGeometryField.getSelectedIndex());
|
727 |
tableInfo.setFilter(this.pickerFilter.get());
|
728 |
tableInfo.setProjection(this.pickerProjection.get());
|
729 |
tableInfo.setDocumentName(this.view.txtName.getText());
|
730 |
int index = this.lwcTables.getSelectedIndex(); |
731 |
tableInfo.setSelected(this.lwcTables.getCheckedModel().isSelectedIndex(index));
|
732 |
} |
733 |
|
734 |
@Override
|
735 |
public void initWizard() { |
736 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
737 |
setTabName(i18n.getTranslation("_VCSGis"));
|
738 |
} |
739 |
|
740 |
@Override
|
741 |
public boolean areSettingsValid() { |
742 |
if(processing){
|
743 |
return false; |
744 |
} |
745 |
boolean hasInvalidValues = false; |
746 |
boolean hasSelectedTables = false; |
747 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
748 |
if (tableInfo.isSelected()) {
|
749 |
hasSelectedTables = true;
|
750 |
if (!tableInfo.hasValidValues()) {
|
751 |
hasInvalidValues = true;
|
752 |
} |
753 |
} |
754 |
} |
755 |
return hasSelectedTables && !hasInvalidValues;
|
756 |
} |
757 |
|
758 |
@Override
|
759 |
public DataStoreParameters[] getParameters() { |
760 |
int sz = 0; |
761 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
762 |
if( tableInfo.isSelected() ) {
|
763 |
sz++; |
764 |
} |
765 |
} |
766 |
if( sz == 0 ) { |
767 |
return null; |
768 |
} |
769 |
DataStoreParameters[] dbParameters = new DataStoreParameters[sz]; |
770 |
int n = 0; |
771 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
772 |
if( tableInfo.isSelected() ) {
|
773 |
dbParameters[n++] = tableInfo.getParameters(); |
774 |
} |
775 |
} |
776 |
return dbParameters;
|
777 |
} |
778 |
|
779 |
@Override
|
780 |
public void execute() { |
781 |
executeWizard(); |
782 |
} |
783 |
|
784 |
@Override
|
785 |
public void close() { |
786 |
|
787 |
} |
788 |
|
789 |
protected void checkFinishable() { |
790 |
boolean finishable = areSettingsValid();
|
791 |
callStateChanged(finishable); |
792 |
} |
793 |
|
794 |
private static String getLabelForTable(JDBCStoreParameters parameters) { |
795 |
String schema = parameters.getSchema();
|
796 |
String tableName = parameters.getTable();
|
797 |
if( StringUtils.isBlank(schema) ) {
|
798 |
return tableName;
|
799 |
} |
800 |
return schema +"."+tableName; |
801 |
} |
802 |
|
803 |
private void doUpdateComponents() { |
804 |
VCSGisEntity rEntity = getRemoteEntity(); |
805 |
boolean enabled = (rEntity != null); |
806 |
VCSGisWorkspace ws = getWorkspace(); |
807 |
if(enabled){
|
808 |
VCSGisWorkspaceEntity lEntity; |
809 |
lEntity = ws.getWorkspaceEntity(rEntity.getEntityName()); |
810 |
if (lEntity == null) { |
811 |
this.view.btnCheckout.setEnabled(!processing);
|
812 |
this.setEditableTables(false); |
813 |
} else {
|
814 |
this.view.btnCheckout.setEnabled(false); |
815 |
this.setEditableTables(!processing);
|
816 |
} |
817 |
} else {
|
818 |
this.view.btnCheckout.setEnabled(false); |
819 |
this.setEditableTables(false); |
820 |
} |
821 |
// this.lwcTables.setEnabled(!processing);
|
822 |
this.tablesFilterController.setEnabled(!processing && ws != null); |
823 |
this.workspacePicker.setEnabled(!processing);
|
824 |
this.view.btnInitWorkspace.setEnabled(!processing);
|
825 |
this.view.txtRepositoryInfo.setEnabled(!processing && ws != null); |
826 |
this.view.btnAdvancedProperties.setEnabled(!processing && enabled);
|
827 |
this.setVisibleStatus(processing);
|
828 |
this.checkFinishable();
|
829 |
} |
830 |
|
831 |
private void doShowInitWorkspace() { |
832 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
833 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
834 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
835 |
|
836 |
final VCSGisJInitWorkspace panelInitWorkspace = swingManager.createInitWorkspacePanel();
|
837 |
final Dialog dialogInitWorkspace = winManager.createDialog( |
838 |
panelInitWorkspace.asJComponent(), |
839 |
i18nManager.getTranslation("_VCS_Initialize_workspace"),
|
840 |
i18nManager.getTranslation("_VCS_Initialize_workspace"),
|
841 |
WindowManager_v2.BUTTONS_OK_CANCEL |
842 |
); |
843 |
|
844 |
panelInitWorkspace.setDialog(dialogInitWorkspace); |
845 |
dialogInitWorkspace.setButtonLabel( |
846 |
WindowManager_v2.BUTTON_OK, |
847 |
i18nManager.getTranslation("_VCS_Initialize_workspace")
|
848 |
); |
849 |
dialogInitWorkspace.addActionListener((ActionEvent e) -> {
|
850 |
switch (dialogInitWorkspace.getAction()) {
|
851 |
case WindowManager_v2.BUTTON_OK:
|
852 |
int r = panelInitWorkspace.initializeWorkspace();
|
853 |
if (r != 0) { |
854 |
String message = "_Cant_initialize_workspace_{0}"; |
855 |
|
856 |
StringBuilder compoundMessage = new StringBuilder(); |
857 |
String[] messageArgs = new String[]{panelInitWorkspace.getWorkspaceName()}; |
858 |
|
859 |
compoundMessage.append(i18nManager.getTranslation( |
860 |
message, |
861 |
messageArgs |
862 |
)); |
863 |
|
864 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
865 |
dialogsManager.messageDialog( |
866 |
compoundMessage.toString(), |
867 |
i18nManager.getTranslation("_VCS_Initialize_workspace"),
|
868 |
JOptionPane.WARNING_MESSAGE
|
869 |
); |
870 |
} |
871 |
|
872 |
break;
|
873 |
|
874 |
} |
875 |
}); |
876 |
dialogInitWorkspace.show(WindowManager.MODE.DIALOG); |
877 |
} |
878 |
|
879 |
public VCSGisWorkspace getWorkspace() {
|
880 |
return this.workspacePicker.get(); |
881 |
} |
882 |
|
883 |
private void doReloadEntitiesList(List<VCSGisEntity> repoEntities, List<VCSGisWorkspaceEntity> wsEntities) { |
884 |
if (notInSwingThreadInvokeLater(() -> {doReloadEntitiesList(repoEntities, wsEntities);}) ) {
|
885 |
return;
|
886 |
} |
887 |
|
888 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
889 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
890 |
try {
|
891 |
this.tablesFilterController.getModel().clear();
|
892 |
//Si estamos añadiendo capas, comprobamos que las entidades que tengan geometría (si no, no son capas)
|
893 |
for (VCSGisWorkspaceEntity lEntity : wsEntities) {
|
894 |
if(StringUtils.isNotBlank(lEntity.getGeometryFieldName()) || !requireGeometry()){
|
895 |
this.tablesFilterController.getModel().addElement(
|
896 |
new LabeledValueImpl(
|
897 |
swingManager.getHTMLColoredForEntity(lEntity, lEntity.getEntityName()), |
898 |
lEntity |
899 |
) |
900 |
); |
901 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(lEntity.getEntityName()); |
902 |
this.tablesInfo.put(lEntity.getEntityName(), new TableInfo(parameters)); |
903 |
} |
904 |
} |
905 |
// Si estamos añadiendo capas, comprobamos que las entidades que tengan geometría (si no, no son capas)
|
906 |
// Además, si ya pertenecen al workspace nos las saltamos
|
907 |
for (VCSGisEntity rEntity : repoEntities) {
|
908 |
if(StringUtils.isNotBlank(rEntity.getGeometryFieldName()) || !requireGeometry()){
|
909 |
VCSGisWorkspaceEntity lEntity = getWorkspace().getWorkspaceEntity(rEntity.getEntityName()); |
910 |
if(lEntity == null){ |
911 |
this.tablesFilterController.getModel().addElement(
|
912 |
new LabeledValueImpl(
|
913 |
swingManager.getHTMLColoredForEntity(lEntity, rEntity.getEntityName()), |
914 |
rEntity |
915 |
) |
916 |
); |
917 |
} |
918 |
} |
919 |
} |
920 |
} catch (Exception e) { |
921 |
LOGGER.warn("_Cant_update_layers_list", e);
|
922 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
923 |
dialogs.messageDialog( |
924 |
i18n.getTranslation("_Cant_update_layers_list")+"\n"+e.getMessage(), |
925 |
i18n.getTranslation("_Add_layer"),
|
926 |
JOptionPane.WARNING_MESSAGE
|
927 |
); |
928 |
} |
929 |
} |
930 |
|
931 |
private void doCheckout() { |
932 |
VCSGisWorkspace workspace = getWorkspace(); |
933 |
if (workspace == null) { |
934 |
return;
|
935 |
} |
936 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
937 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
938 |
VCSGisEntity rEntity = getRemoteEntity(); |
939 |
VCSGisWorkspaceEntity lEntity = workspace.getWorkspaceEntity(rEntity.getEntityName()); |
940 |
if (lEntity != null) { |
941 |
return;
|
942 |
} |
943 |
Thread task = new Thread(() -> { |
944 |
try {
|
945 |
processing = true;
|
946 |
doUpdateComponents(); |
947 |
|
948 |
showMessage(i18n.getTranslation("_Checking_out"));
|
949 |
int res = workspace.checkout(
|
950 |
rEntity.getEntityName(), |
951 |
null,
|
952 |
this.getTaskStatusController().getSimpleTaskStatus()
|
953 |
); |
954 |
if (res != ERR_OK) {
|
955 |
LOGGER.warn("_Cant_checkout_table");
|
956 |
dialogs.messageDialog( |
957 |
i18n.getTranslation("_Cant_checkout_table") + "\n" + workspace.getErrorMessage(res), |
958 |
i18n.getTranslation("_Add_table"),
|
959 |
JOptionPane.WARNING_MESSAGE
|
960 |
); |
961 |
return;
|
962 |
} |
963 |
showMessage(i18n.getTranslation("_Checkout_finished"));
|
964 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(rEntity.getEntityName()); |
965 |
this.tablesInfo.put(rEntity.getEntityName(), new TableInfo(parameters)); |
966 |
doChangeTableSelected(); |
967 |
} catch (Exception e) { |
968 |
LOGGER.warn("_Cant_add_table");
|
969 |
dialogs.messageDialog( |
970 |
i18n.getTranslation("_Cant_add_table") + "\n" + e.getMessage(), |
971 |
i18n.getTranslation("_Add_table"),
|
972 |
JOptionPane.WARNING_MESSAGE
|
973 |
); |
974 |
} finally {
|
975 |
processing = false;
|
976 |
doChangeWorkspace(); |
977 |
// VCSGisWorkspaceEntity localEntity = workspace.getWorkspaceEntity(rEntity.getEntityName());
|
978 |
// if (localEntity != null) {
|
979 |
// lwcTables.setSelectedValue(localEntity, true);
|
980 |
// }
|
981 |
doUpdateComponents(); |
982 |
} |
983 |
}, "VCSGisAddTableCheckout");
|
984 |
processing = true;
|
985 |
doUpdateComponents(); |
986 |
task.start(); |
987 |
} |
988 |
|
989 |
private VCSGisEntity getRemoteEntity() {
|
990 |
LabeledValue<VCSGisEntity> value = (LabeledValue<VCSGisEntity>) this.lwcTables.getSelectedValue();
|
991 |
if(value == null){ |
992 |
return null; |
993 |
} |
994 |
return value.getValue();
|
995 |
} |
996 |
|
997 |
private void showMessage(String message) { |
998 |
if( notInSwingThreadInvokeLater(() -> {showMessage(message);}) ) {
|
999 |
return;
|
1000 |
} |
1001 |
this.view.lblStatusMessages.setText(message);
|
1002 |
} |
1003 |
|
1004 |
public boolean isProcessing() { |
1005 |
return processing;
|
1006 |
} |
1007 |
|
1008 |
public void setVisibleStatus(boolean visible) { |
1009 |
if( notInSwingThreadInvokeLater(() -> {setVisibleStatus(visible);}) ) {
|
1010 |
return;
|
1011 |
} |
1012 |
this.view.lblStatusTitle.setVisible(visible);
|
1013 |
this.view.pbStatus.setVisible(visible);
|
1014 |
this.view.lblStatusMessages.setVisible(true); |
1015 |
} |
1016 |
|
1017 |
public TaskStatusController getTaskStatusController() {
|
1018 |
return this.taskStatusController; |
1019 |
} |
1020 |
|
1021 |
public static boolean notInSwingThreadInvokeLater(Runnable x) { |
1022 |
if( SwingUtilities.isEventDispatchThread() ) { |
1023 |
return false; |
1024 |
} |
1025 |
SwingUtilities.invokeLater(x);
|
1026 |
return true; |
1027 |
} |
1028 |
|
1029 |
private static class WizardVCSGisViewExtended extends AbstractWizardVCSGisView { |
1030 |
|
1031 |
@Override
|
1032 |
public ImageIcon loadImage(String imageName) { |
1033 |
String name = FilenameUtils.getBaseName(imageName);
|
1034 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
1035 |
if (theme.exists(name)) {
|
1036 |
return theme.get(name);
|
1037 |
} |
1038 |
URL url = WizardVCSGisViewExtended.class.getResource("images/" + name + ".png"); |
1039 |
if (url == null) { |
1040 |
return null; |
1041 |
} |
1042 |
return new ImageIcon(url); |
1043 |
} |
1044 |
} |
1045 |
|
1046 |
private String toHTML(String s) { |
1047 |
s = StringUtils.replace(s, "\n", "<br>"); |
1048 |
s = StringUtils.replace(s, "<html>", ""); |
1049 |
s = StringUtils.replace(s, "</html>", ""); |
1050 |
s = "<html>"+s+"</html>"; |
1051 |
return s;
|
1052 |
} |
1053 |
|
1054 |
} |