svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / copytable / CopyTable2Panel.java @ 46737
History | View | Annotate | Download (34.5 KB)
1 | 46403 | jjdelcerro | package org.gvsig.app.extension.copytable; |
---|---|---|---|
2 | |||
3 | import java.awt.Component; |
||
4 | 46629 | fdiaz | import java.awt.event.ActionEvent; |
5 | import java.awt.event.ActionListener; |
||
6 | 46698 | jjdelcerro | import java.net.URL; |
7 | 46403 | jjdelcerro | import java.util.ArrayList; |
8 | 46427 | jjdelcerro | import java.util.Iterator; |
9 | 46403 | jjdelcerro | import java.util.List; |
10 | import java.util.Objects; |
||
11 | import javax.swing.AbstractCellEditor; |
||
12 | 46698 | jjdelcerro | import javax.swing.ImageIcon; |
13 | 46403 | jjdelcerro | import javax.swing.JComboBox; |
14 | 46615 | jjdelcerro | import javax.swing.JLabel; |
15 | 46403 | jjdelcerro | import javax.swing.JTable; |
16 | import javax.swing.ListSelectionModel; |
||
17 | import javax.swing.SwingUtilities; |
||
18 | 46660 | jjdelcerro | import javax.swing.event.ChangeEvent; |
19 | import javax.swing.event.ChangeListener; |
||
20 | 46403 | jjdelcerro | import javax.swing.event.TreeSelectionEvent; |
21 | import javax.swing.table.AbstractTableModel; |
||
22 | import javax.swing.table.DefaultTableColumnModel; |
||
23 | import javax.swing.table.TableCellEditor; |
||
24 | import javax.swing.table.TableColumn; |
||
25 | 46698 | jjdelcerro | import org.apache.commons.io.FilenameUtils; |
26 | 46575 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
27 | 46621 | fdiaz | import org.apache.commons.text.similarity.LevenshteinDistance; |
28 | 46629 | fdiaz | import org.gvsig.app.extension.copytable.CopyTable2ProcessParameters.ProcessFieldParameters; |
29 | import org.gvsig.configurableactions.ConfigurableActionsMamager; |
||
30 | 46403 | jjdelcerro | import org.gvsig.expressionevaluator.Expression; |
31 | 46621 | fdiaz | import org.gvsig.expressionevaluator.ExpressionBuilder; |
32 | 46615 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionUtils; |
33 | 46403 | jjdelcerro | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
34 | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
||
35 | import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
||
36 | 46615 | jjdelcerro | import org.gvsig.expressionevaluator.swing.JExpressionPicker; |
37 | 46403 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
38 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
39 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
40 | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
||
41 | import org.gvsig.fmap.dal.swing.DataSwingManager; |
||
42 | import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
||
43 | 46737 | jjdelcerro | import org.gvsig.fmap.dal.swing.storesrepository.StoresRepositoryController; |
44 | 46427 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
45 | 46629 | fdiaz | import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
46 | import org.gvsig.tools.bookmarksandhistory.History; |
||
47 | 46586 | fdiaz | import org.gvsig.tools.dispose.DisposeUtils; |
48 | 46436 | fdiaz | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
49 | 46403 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingUtils; |
50 | 46629 | fdiaz | import org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue; |
51 | import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_GETVALUE; |
||
52 | import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_SETVALUE; |
||
53 | import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
||
54 | import org.gvsig.tools.swing.api.bookmarkshistory.HistoryController; |
||
55 | 46615 | jjdelcerro | import org.gvsig.tools.swing.api.documentfilters.IntegerDocumentFilter; |
56 | 46436 | fdiaz | import org.gvsig.tools.swing.api.task.TaskStatusController; |
57 | 46698 | jjdelcerro | import org.gvsig.tools.swing.icontheme.IconTheme; |
58 | 46403 | jjdelcerro | import org.gvsig.tools.task.SimpleTaskStatus; |
59 | 46629 | fdiaz | import org.gvsig.tools.util.ToolsUtilLocator; |
60 | 46403 | jjdelcerro | |
61 | /**
|
||
62 | *
|
||
63 | * @author jjdelcerro
|
||
64 | */
|
||
65 | 46615 | jjdelcerro | public class CopyTable2Panel extends CopyTable2PanelView { |
66 | 46403 | jjdelcerro | |
67 | 46629 | fdiaz | private static final String BOOKMARKSANDHISTORY_NAME = "CopyTablePanel"; |
68 | private static final String CONFIGURABLE_PANEL_ID = "CopyTablePanel"; |
||
69 | |||
70 | private static final Integer MAX_DISTANCE_TO_ASSIGN_FIELD = 3; |
||
71 | 46403 | jjdelcerro | private AttributeDescriptorPickerController pickerSourceFieldJoin;
|
72 | private FeatureStore source;
|
||
73 | private FeatureStore target;
|
||
74 | private AttributeDescriptorPickerController pickerTargetFieldJoin;
|
||
75 | private ExpressionPickerController pickerSourceFilter;
|
||
76 | private ExpressionPickerController pickerTargetUpdateExpression;
|
||
77 | private DefaultTableColumnModel fieldsColumnModel; |
||
78 | 46427 | jjdelcerro | private SimpleTaskStatus taskStatus;
|
79 | 46436 | fdiaz | private TaskStatusController status;
|
80 | 46575 | jjdelcerro | private StoresRepositoryController treeSourceTableController;
|
81 | private StoresRepositoryController treeTargetTableController;
|
||
82 | 46629 | fdiaz | |
83 | private final Bookmarks bookmarks; |
||
84 | private final History history; |
||
85 | private BookmarksController bookmarksController;
|
||
86 | private HistoryController historyController;
|
||
87 | 46698 | jjdelcerro | private ExpressionPickerController pickerJoinExpression;
|
88 | 46403 | jjdelcerro | |
89 | 46629 | fdiaz | |
90 | 46403 | jjdelcerro | private class FeatureAttributeCellEditor extends AbstractCellEditor implements TableCellEditor { |
91 | |||
92 | private final AttributeDescriptorPickerController picker; |
||
93 | private final JComboBox combo; |
||
94 | |||
95 | public FeatureAttributeCellEditor() {
|
||
96 | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
||
97 | this.combo = new JComboBox(); |
||
98 | this.picker = dataSwingManager.createAttributeDescriptorPickerController(this.combo); |
||
99 | } |
||
100 | |||
101 | @Override
|
||
102 | 46615 | jjdelcerro | public Component getTableCellEditorComponent(JTable jtable, Object value, boolean isSelected, int row, int column) { |
103 | 46403 | jjdelcerro | if( value == null ) { |
104 | this.picker.clean();
|
||
105 | return this.combo; |
||
106 | } |
||
107 | this.picker.setFeatureType(source.getDefaultFeatureTypeQuietly());
|
||
108 | this.picker.setAllowNull(true); |
||
109 | this.picker.set(Objects.toString(value,"")); |
||
110 | return this.combo; |
||
111 | } |
||
112 | |||
113 | @Override
|
||
114 | public Object getCellEditorValue() { |
||
115 | return this.picker.getName(); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | 46615 | jjdelcerro | private class ExpressionCellEditor extends AbstractCellEditor implements TableCellEditor { |
120 | |||
121 | private final JExpressionPicker picker; |
||
122 | |||
123 | public ExpressionCellEditor() {
|
||
124 | ExpressionEvaluatorSwingManager manager = ExpressionEvaluatorSwingLocator.getManager(); |
||
125 | this.picker = manager.createJExpressionPicker();
|
||
126 | this.picker.removeBorder();
|
||
127 | } |
||
128 | |||
129 | @Override
|
||
130 | public Component getTableCellEditorComponent(JTable jtable, Object value, boolean isSelected, int row, int column) { |
||
131 | try {
|
||
132 | DataSwingManager manager = DALSwingLocator.getDataSwingManager(); |
||
133 | manager.configureExpressionBuilder(picker.getConfig(), source); |
||
134 | if( value == null ) { |
||
135 | this.picker.setExpression(null); |
||
136 | } else {
|
||
137 | this.picker.setExpression(ExpressionUtils.createExpression((String) value)); |
||
138 | } |
||
139 | return this.picker.asJComponent(); |
||
140 | } catch(Exception ex) { |
||
141 | return new JLabel(); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | @Override
|
||
146 | public Object getCellEditorValue() { |
||
147 | Expression exp = this.picker.getExpression(); |
||
148 | if( exp==null ) { |
||
149 | return null; |
||
150 | } |
||
151 | return exp.getPhrase();
|
||
152 | } |
||
153 | } |
||
154 | |||
155 | 46427 | jjdelcerro | private class MyTableModel extends AbstractTableModel implements Iterable<MyTableModel.Row>{ |
156 | 46403 | jjdelcerro | |
157 | private final List<Row> rows; |
||
158 | private final String[] columnNames; |
||
159 | private final Class[] columnClass; |
||
160 | 46615 | jjdelcerro | private final FeatureType tableType; |
161 | 46403 | jjdelcerro | |
162 | private class Row { |
||
163 | 46615 | jjdelcerro | String attrname;
|
164 | String expression;
|
||
165 | 46403 | jjdelcerro | boolean update;
|
166 | |||
167 | public Object get(int index) { |
||
168 | switch(index) {
|
||
169 | case 0: |
||
170 | 46615 | jjdelcerro | return update;
|
171 | 46403 | jjdelcerro | case 1: |
172 | 46615 | jjdelcerro | return attrname;
|
173 | 46403 | jjdelcerro | case 2: |
174 | 46615 | jjdelcerro | return expression;
|
175 | 46403 | jjdelcerro | default:
|
176 | return null; |
||
177 | } |
||
178 | } |
||
179 | |||
180 | public void set(int index, Object value) { |
||
181 | switch(index) {
|
||
182 | case 0: |
||
183 | 46615 | jjdelcerro | this.update = (boolean) value; |
184 | 46403 | jjdelcerro | break;
|
185 | case 1: |
||
186 | 46615 | jjdelcerro | this.attrname = (String) value; |
187 | 46403 | jjdelcerro | break;
|
188 | case 2: |
||
189 | 46615 | jjdelcerro | this.expression = (String) value; |
190 | 46403 | jjdelcerro | break;
|
191 | default:
|
||
192 | break;
|
||
193 | } |
||
194 | } |
||
195 | } |
||
196 | |||
197 | public MyTableModel() {
|
||
198 | this.rows = new ArrayList<>(); |
||
199 | 46621 | fdiaz | this.tableType = target.getDefaultFeatureTypeQuietly();
|
200 | 46615 | jjdelcerro | for (FeatureAttributeDescriptor targetAttr : tableType) {
|
201 | 46403 | jjdelcerro | Row row = new Row();
|
202 | 46615 | jjdelcerro | row.attrname = targetAttr.getName(); |
203 | 46621 | fdiaz | |
204 | row.expression = getSourceExpression(row.attrname); |
||
205 | 46698 | jjdelcerro | if( targetAttr.isComputed()) {
|
206 | 46403 | jjdelcerro | row.update = false;
|
207 | } else {
|
||
208 | row.update = true;
|
||
209 | } |
||
210 | this.rows.add(row);
|
||
211 | } |
||
212 | 46621 | fdiaz | |
213 | for (Row row : this.rows) { |
||
214 | if(row.expression == null){ |
||
215 | continue;
|
||
216 | } |
||
217 | // Row first = null;
|
||
218 | boolean dup = false; |
||
219 | for (Row row1 : this.rows) { |
||
220 | if(row == row1){
|
||
221 | continue;
|
||
222 | } |
||
223 | if(StringUtils.equalsIgnoreCase(row.expression, row1.expression)){
|
||
224 | // if(first == null){
|
||
225 | // first = row;
|
||
226 | // }
|
||
227 | dup = true;
|
||
228 | row1.expression = null;
|
||
229 | } |
||
230 | } |
||
231 | // if (first != null) {
|
||
232 | // first.expression = null;
|
||
233 | // }
|
||
234 | if(dup){
|
||
235 | row.expression = null;
|
||
236 | } |
||
237 | } |
||
238 | 46403 | jjdelcerro | this.columnNames = new String[] { |
239 | 46615 | jjdelcerro | "Actualizar",
|
240 | "Campo",
|
||
241 | "Expresion"
|
||
242 | 46403 | jjdelcerro | }; |
243 | this.columnClass = new Class[] { |
||
244 | 46615 | jjdelcerro | Boolean.class,
|
245 | 46403 | jjdelcerro | String.class,
|
246 | 46615 | jjdelcerro | String.class
|
247 | 46403 | jjdelcerro | }; |
248 | } |
||
249 | 46621 | fdiaz | |
250 | String getSourceExpression(String targetFieldName){ |
||
251 | FeatureType sourceType = source.getDefaultFeatureTypeQuietly(); |
||
252 | ExpressionBuilder expBuilder = source.createExpressionBuilder(); |
||
253 | Integer minDistance = Integer.MAX_VALUE; |
||
254 | String minDistanceSourceFieldName = null; |
||
255 | FeatureAttributeDescriptor attr = sourceType.getAttributeDescriptor(targetFieldName); |
||
256 | if(attr!=null){ |
||
257 | return expBuilder.identifier(attr.getName());
|
||
258 | } |
||
259 | for (FeatureAttributeDescriptor featureAttributeDescriptor : sourceType) {
|
||
260 | String sourceFieldName = featureAttributeDescriptor.getName();
|
||
261 | // if(StringUtils.equalsIgnoreCase(targetFieldName, sourceFieldName)){
|
||
262 | // return expBuilder.identifier(sourceFieldName);
|
||
263 | // }
|
||
264 | if(StringUtils.containsIgnoreCase(targetFieldName, sourceFieldName)){
|
||
265 | return expBuilder.identifier(sourceFieldName);
|
||
266 | } |
||
267 | if(StringUtils.containsIgnoreCase(sourceFieldName, targetFieldName)){
|
||
268 | return expBuilder.identifier(sourceFieldName);
|
||
269 | } |
||
270 | Integer distance = LevenshteinDistance.getDefaultInstance().apply(targetFieldName, sourceFieldName);
|
||
271 | if(distance < minDistance){
|
||
272 | minDistanceSourceFieldName = sourceFieldName; |
||
273 | minDistance = distance; |
||
274 | } |
||
275 | } |
||
276 | if(minDistance <= MAX_DISTANCE_TO_ASSIGN_FIELD) {
|
||
277 | return expBuilder.identifier(minDistanceSourceFieldName);
|
||
278 | } |
||
279 | return null; |
||
280 | } |
||
281 | 46403 | jjdelcerro | |
282 | @Override
|
||
283 | public String getColumnName(int column) { |
||
284 | return this.columnNames[column]; |
||
285 | } |
||
286 | |||
287 | @Override
|
||
288 | public Class<?> getColumnClass(int columnIndex) { |
||
289 | return this.columnClass[columnIndex]; |
||
290 | } |
||
291 | |||
292 | @Override
|
||
293 | public int getRowCount() { |
||
294 | return this.rows.size(); |
||
295 | } |
||
296 | |||
297 | @Override
|
||
298 | public int getColumnCount() { |
||
299 | return 3; |
||
300 | } |
||
301 | |||
302 | @Override
|
||
303 | public Object getValueAt(int rowIndex, int columnIndex) { |
||
304 | 46621 | fdiaz | switch (columnIndex) {
|
305 | case 0: |
||
306 | case 2: |
||
307 | return this.rows.get(rowIndex).get(columnIndex); |
||
308 | case 1: |
||
309 | FeatureAttributeDescriptor attrdesc = this.tableType.getAttributeDescriptor(this.rows.get(rowIndex).attrname); |
||
310 | return attrdesc;
|
||
311 | default:
|
||
312 | return null; |
||
313 | } |
||
314 | 46403 | jjdelcerro | } |
315 | |||
316 | @Override
|
||
317 | public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
||
318 | this.rows.get(rowIndex).set(columnIndex, aValue);
|
||
319 | } |
||
320 | |||
321 | @Override
|
||
322 | public boolean isCellEditable(int rowIndex, int columnIndex) { |
||
323 | 46615 | jjdelcerro | FeatureAttributeDescriptor attrdesc = this.tableType.getAttributeDescriptor(rowIndex);
|
324 | if( attrdesc == null ) { |
||
325 | return false; |
||
326 | } |
||
327 | 46698 | jjdelcerro | // Dejamos marcarlos todos, y el proceso de copia decidira saltarselos
|
328 | // segun se este insertando registro nuevo o actualizando.
|
||
329 | // if( attrdesc.isAutomatic() || attrdesc.isReadOnly() ) { //|| attrdesc.isPrimaryKey() ) {
|
||
330 | // return false;
|
||
331 | // }
|
||
332 | 46403 | jjdelcerro | switch(columnIndex) {
|
333 | 46621 | fdiaz | case 1: |
334 | return false; |
||
335 | 46403 | jjdelcerro | case 0: |
336 | case 2: |
||
337 | 46615 | jjdelcerro | default:
|
338 | 46403 | jjdelcerro | return true; |
339 | } |
||
340 | } |
||
341 | |||
342 | 46427 | jjdelcerro | @Override
|
343 | public Iterator<Row> iterator() { |
||
344 | return this.rows.iterator(); |
||
345 | } |
||
346 | 46663 | jjdelcerro | |
347 | @Override
|
||
348 | public void fireTableDataChanged() { |
||
349 | super.fireTableDataChanged();
|
||
350 | } |
||
351 | |||
352 | |||
353 | 46403 | jjdelcerro | } |
354 | |||
355 | 46615 | jjdelcerro | public CopyTable2Panel() {
|
356 | 46629 | fdiaz | this.bookmarks = ToolsLocator.getBookmarksAndHistoryManager().getBookmarksGroup(BOOKMARKSANDHISTORY_NAME);
|
357 | this.history = ToolsLocator.getBookmarksAndHistoryManager().getHistoryGroup(BOOKMARKSANDHISTORY_NAME);
|
||
358 | |||
359 | 46403 | jjdelcerro | this.initComponents();
|
360 | } |
||
361 | |||
362 | private void initComponents() { |
||
363 | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
||
364 | ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
||
365 | 46436 | fdiaz | this.status = ToolsSwingLocator.getTaskStatusSwingManager().createTaskStatusController(lblStatusLabel, lblStatusMessage, pbStatus);
|
366 | 46403 | jjdelcerro | |
367 | 46629 | fdiaz | ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
368 | cfgActionsManager.addConfigurableActions(CONFIGURABLE_PANEL_ID, this, btnConfigurableActions);
|
||
369 | |||
370 | this.bookmarksController = ToolsSwingLocator.getToolsSwingManager().createBookmarksController(this.bookmarks, btnBookmarks); |
||
371 | this.historyController = ToolsSwingLocator.getToolsSwingManager().createHistoryController(this.history, btnHistory); |
||
372 | |||
373 | this.historyController.setFilter(null); |
||
374 | |||
375 | ActionListener bookmarksAndHistoryListener = (ActionEvent e) -> { |
||
376 | ActionEventWithCurrentValue<CopyTable2ProcessParameters> event = (ActionEventWithCurrentValue<CopyTable2ProcessParameters>) e; |
||
377 | switch (event.getID()) {
|
||
378 | case ID_GETVALUE:
|
||
379 | event.setCurrentValue(fetch(null));
|
||
380 | break;
|
||
381 | case ID_SETVALUE:
|
||
382 | put(event.getCurrentValue()); |
||
383 | 46660 | jjdelcerro | doUpdateComponents(); |
384 | 46629 | fdiaz | break;
|
385 | } |
||
386 | }; |
||
387 | this.historyController.addActionListener(bookmarksAndHistoryListener);
|
||
388 | this.bookmarksController.addActionListener(bookmarksAndHistoryListener);
|
||
389 | |||
390 | 46737 | jjdelcerro | this.treeSourceTableController = dataSwingManager.createStoresRepositoryController(this.treeSourceTable); |
391 | this.treeSourceTable.addTreeSelectionListener((TreeSelectionEvent e) -> { |
||
392 | 46403 | jjdelcerro | doChangeSource(); |
393 | 46660 | jjdelcerro | doUpdateComponents(); |
394 | 46403 | jjdelcerro | }); |
395 | this.pickerSourceFieldJoin = dataSwingManager.createAttributeDescriptorPickerController(cboSourceJoinField);
|
||
396 | 46660 | jjdelcerro | this.pickerSourceFieldJoin.setAllowNull(true); |
397 | this.pickerSourceFieldJoin.addChangeListener((ChangeEvent e) -> { |
||
398 | doUpdateComponents(); |
||
399 | }); |
||
400 | 46403 | jjdelcerro | |
401 | 46737 | jjdelcerro | this.treeTargetTableController = dataSwingManager.createStoresRepositoryController(this.treeTargetTable); |
402 | this.treeTargetTable.addTreeSelectionListener((TreeSelectionEvent e) -> { |
||
403 | 46403 | jjdelcerro | doChangeTarget(); |
404 | 46660 | jjdelcerro | doUpdateComponents(); |
405 | 46403 | jjdelcerro | }); |
406 | this.pickerTargetFieldJoin = dataSwingManager.createAttributeDescriptorPickerController(cboTargetJoinField);
|
||
407 | 46660 | jjdelcerro | this.pickerTargetFieldJoin.setAllowNull(true); |
408 | this.pickerTargetFieldJoin.addChangeListener((ChangeEvent e) -> { |
||
409 | doUpdateComponents(); |
||
410 | }); |
||
411 | 46403 | jjdelcerro | |
412 | this.pickerSourceFilter = expressionSwingManager.createExpressionPickerController(
|
||
413 | txtSourceFilter, |
||
414 | btnSourceFilter, |
||
415 | btnSourceFilterBookmarks, |
||
416 | btnSourceFilterHistory |
||
417 | ); |
||
418 | |||
419 | this.pickerTargetUpdateExpression = expressionSwingManager.createExpressionPickerController(
|
||
420 | 46427 | jjdelcerro | txtTargetUpdateWhenExpression, |
421 | btnTargetUpdateWhenExpression, |
||
422 | btnTargetUpdateWhenExpressionBookmarks, |
||
423 | btnTargetUpdateWhenExpressionHistory |
||
424 | 46403 | jjdelcerro | ); |
425 | 46427 | jjdelcerro | this.chkTargetInsertIfNotExistsInTarget.setSelected(false); |
426 | 46660 | jjdelcerro | this.chkTargetInsertIfNotExistsInTarget.addChangeListener((e) -> {
|
427 | doUpdateComponents(); |
||
428 | }); |
||
429 | |||
430 | this.chkTargetUpdateIfExistsInTarget.setSelected(false); |
||
431 | this.chkTargetUpdateIfExistsInTarget.addChangeListener((e) -> {
|
||
432 | doUpdateComponents(); |
||
433 | }); |
||
434 | |||
435 | this.chkTargetDeleteIfNotExiststInSource.setEnabled(false); |
||
436 | this.chkTargetDeleteIfNotExiststInSource.addChangeListener((e) -> {
|
||
437 | doUpdateComponents(); |
||
438 | }); |
||
439 | 46403 | jjdelcerro | |
440 | this.tableFields.setAutoCreateColumnsFromModel(false); |
||
441 | this.tableFields.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
||
442 | this.fieldsColumnModel = new DefaultTableColumnModel(); |
||
443 | |||
444 | 46698 | jjdelcerro | this.rdbUseJoinExpression.addActionListener((ActionEvent e) -> { |
445 | doUpdateComponents(); |
||
446 | }); |
||
447 | this.rdbUseJoinField.addActionListener((ActionEvent e) -> { |
||
448 | doUpdateComponents(); |
||
449 | }); |
||
450 | this.pickerJoinExpression = expressionSwingManager.createExpressionPickerController(
|
||
451 | txtJoinExpression, |
||
452 | btnJoinExpression, |
||
453 | btnJoinExpressionBookmarks, |
||
454 | btnJoinExpressionHistory |
||
455 | ); |
||
456 | |||
457 | 46403 | jjdelcerro | TableColumn column = new TableColumn(); |
458 | 46621 | fdiaz | column.setHeaderValue("Actualizar");
|
459 | 46403 | jjdelcerro | column.setCellRenderer(null);
|
460 | column.setResizable(true);
|
||
461 | column.setModelIndex(0);
|
||
462 | this.fieldsColumnModel.addColumn(column);
|
||
463 | |||
464 | column = new TableColumn(); |
||
465 | 46621 | fdiaz | column.setHeaderValue("Campo destino");
|
466 | column.setCellRenderer(dataSwingManager.createDefaultFeatureAttributeTableCellRenderer()); |
||
467 | column.setCellEditor(null);
|
||
468 | 46403 | jjdelcerro | column.setResizable(true);
|
469 | column.setModelIndex(1);
|
||
470 | this.fieldsColumnModel.addColumn(column);
|
||
471 | |||
472 | column = new TableColumn(); |
||
473 | 46621 | fdiaz | column.setHeaderValue("Campo origen");
|
474 | 46403 | jjdelcerro | column.setCellRenderer(null);
|
475 | 46621 | fdiaz | column.setCellEditor(new ExpressionCellEditor());
|
476 | 46403 | jjdelcerro | column.setResizable(true);
|
477 | column.setModelIndex(2);
|
||
478 | this.fieldsColumnModel.addColumn(column);
|
||
479 | 46621 | fdiaz | |
480 | 46663 | jjdelcerro | this.btnCheckAllFields.addActionListener((ActionEvent e) -> { |
481 | doSetAllChecksOfFields(true);
|
||
482 | }); |
||
483 | this.btnUnCheckAllFields.addActionListener((ActionEvent e) -> { |
||
484 | doSetAllChecksOfFields(false);
|
||
485 | }); |
||
486 | 46403 | jjdelcerro | |
487 | this.tableFields.setColumnModel(this.fieldsColumnModel); |
||
488 | |||
489 | SwingUtilities.invokeLater(() -> {
|
||
490 | lblStatusLabel.setText("");
|
||
491 | lblStatusMessage.setText("");
|
||
492 | pbStatus.setVisible(false);
|
||
493 | }); |
||
494 | 46698 | jjdelcerro | this.lblJoinExpressionMsg.setText("<html>"+this.lblJoinExpressionMsg.getText()+"</html>"); |
495 | 46660 | jjdelcerro | doUpdateComponents(); |
496 | 46403 | jjdelcerro | |
497 | 46698 | jjdelcerro | ToolsSwingUtils.ensureRowsCols(this, 25, 80, 30, 100); |
498 | 46403 | jjdelcerro | } |
499 | |||
500 | 46663 | jjdelcerro | private void doSetAllChecksOfFields(boolean check) { |
501 | MyTableModel model = (MyTableModel) this.tableFields.getModel();
|
||
502 | for (MyTableModel.Row row : model) {
|
||
503 | row.set(0, check);
|
||
504 | } |
||
505 | model.fireTableDataChanged(); |
||
506 | } |
||
507 | |||
508 | 46660 | jjdelcerro | private void doUpdateComponents() { |
509 | this.treeSourceTableController.setEnabled(
|
||
510 | true
|
||
511 | ); |
||
512 | |||
513 | this.pickerSourceFieldJoin.setEnabled(
|
||
514 | this.source != null |
||
515 | ); |
||
516 | |||
517 | this.pickerSourceFilter.setEnabled(
|
||
518 | this.source != null |
||
519 | ); |
||
520 | |||
521 | this.treeTargetTableController.setEnabled(
|
||
522 | this.source != null |
||
523 | ); |
||
524 | |||
525 | 46698 | jjdelcerro | this.btnCheckAllFields.setEnabled(
|
526 | this.source != null && |
||
527 | this.target != null |
||
528 | ); |
||
529 | this.btnUnCheckAllFields.setEnabled(
|
||
530 | this.source != null && |
||
531 | this.target != null |
||
532 | ); |
||
533 | this.rdbUseJoinField.setEnabled(
|
||
534 | this.source != null && |
||
535 | this.target != null |
||
536 | ); |
||
537 | this.rdbUseJoinExpression.setEnabled(
|
||
538 | this.source != null && |
||
539 | this.target != null |
||
540 | ); |
||
541 | this.rdbNotJoin.setEnabled(
|
||
542 | this.source != null && |
||
543 | this.target != null |
||
544 | ); |
||
545 | 46660 | jjdelcerro | this.pickerTargetFieldJoin.setEnabled(
|
546 | this.source != null && |
||
547 | this.target != null && |
||
548 | 46698 | jjdelcerro | (this.rdbUseJoinField.isSelected() && this.rdbUseJoinField.isEnabled()) && |
549 | 46660 | jjdelcerro | this.pickerSourceFieldJoin.getName() != null |
550 | ); |
||
551 | 46698 | jjdelcerro | this.pickerJoinExpression.setEnabled(
|
552 | this.source != null && |
||
553 | this.target != null && |
||
554 | (this.rdbUseJoinExpression.isSelected() && this.rdbUseJoinExpression.isEnabled()) |
||
555 | ); |
||
556 | 46660 | jjdelcerro | |
557 | 46698 | jjdelcerro | |
558 | 46660 | jjdelcerro | this.chkTargetInsertIfNotExistsInTarget.setEnabled(
|
559 | this.source != null && |
||
560 | 46698 | jjdelcerro | this.target != null && ( |
561 | (this.pickerSourceFieldJoin.getName() != null && this.pickerTargetFieldJoin.getName() != null) || |
||
562 | this.rdbUseJoinExpression.isSelected()
|
||
563 | ) |
||
564 | 46660 | jjdelcerro | ); |
565 | |||
566 | this.chkTargetUpdateIfExistsInTarget.setEnabled(
|
||
567 | this.source != null && |
||
568 | 46698 | jjdelcerro | this.target != null && ( |
569 | (this.pickerSourceFieldJoin.getName() != null && this.pickerTargetFieldJoin.getName() != null) || |
||
570 | this.rdbUseJoinExpression.isSelected()
|
||
571 | ) |
||
572 | 46660 | jjdelcerro | ); |
573 | this.chkTargetDeleteIfNotExiststInSource.setEnabled(
|
||
574 | false // No esta implementado |
||
575 | // this.source != null &&
|
||
576 | 46698 | jjdelcerro | // this.target != null && (
|
577 | // (this.pickerSourceFieldJoin.getName() != null && this.pickerTargetFieldJoin.getName() != null) ||
|
||
578 | // this.rdbUseJoinExpression.isSelected()
|
||
579 | // )
|
||
580 | 46660 | jjdelcerro | ); |
581 | this.pickerTargetUpdateExpression.setEnabled(
|
||
582 | this.chkTargetUpdateIfExistsInTarget.isSelected()
|
||
583 | ); |
||
584 | |||
585 | if( !this.pickerSourceFieldJoin.isEnabled() ) { |
||
586 | this.pickerSourceFieldJoin.clean();
|
||
587 | } |
||
588 | if( !this.pickerTargetFieldJoin.isEnabled() ) { |
||
589 | this.pickerTargetFieldJoin.clean();
|
||
590 | } |
||
591 | if( !this.chkTargetInsertIfNotExistsInTarget.isEnabled() ) { |
||
592 | this.chkTargetInsertIfNotExistsInTarget.setSelected(false); |
||
593 | } |
||
594 | if( !this.chkTargetUpdateIfExistsInTarget.isEnabled() ) { |
||
595 | this.chkTargetUpdateIfExistsInTarget.setSelected(false); |
||
596 | } |
||
597 | if( !this.chkTargetDeleteIfNotExiststInSource.isEnabled() ) { |
||
598 | this.chkTargetDeleteIfNotExiststInSource.setSelected(false); |
||
599 | } |
||
600 | if( !this.pickerSourceFilter.isEnabled() ) { |
||
601 | this.pickerSourceFilter.set(null); |
||
602 | } |
||
603 | |||
604 | } |
||
605 | |||
606 | |||
607 | 46403 | jjdelcerro | private void doChangeSource() { |
608 | 46586 | fdiaz | FeatureStore theSource = this.treeSourceTableController.getSelectedFeatureStore();
|
609 | if( theSource==null ) { |
||
610 | 46403 | jjdelcerro | return;
|
611 | } |
||
612 | 46586 | fdiaz | if(this.source != null){ |
613 | DisposeUtils.disposeQuietly(this.source);
|
||
614 | } |
||
615 | this.source = theSource;
|
||
616 | 46621 | fdiaz | |
617 | 46403 | jjdelcerro | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
618 | 46586 | fdiaz | dataSwingManager.resetExpressionBuilder(this.pickerTargetUpdateExpression.getConfig());
|
619 | 46698 | jjdelcerro | dataSwingManager.resetExpressionBuilder(this.pickerJoinExpression.getConfig());
|
620 | 46586 | fdiaz | dataSwingManager.addToExpressionBuilder(this.pickerTargetUpdateExpression.getConfig(), this.source, "source"); |
621 | 46698 | jjdelcerro | dataSwingManager.addToExpressionBuilder(this.pickerJoinExpression.getConfig(), this.source, "source", true); |
622 | 46403 | jjdelcerro | |
623 | this.pickerSourceFieldJoin.setFeatureType(this.source.getDefaultFeatureTypeQuietly()); |
||
624 | 46621 | fdiaz | try {
|
625 | this.pickerSourceFieldJoin.set(this.source.getDefaultFeatureTypeQuietly().getPrimaryKey()[0]); |
||
626 | } catch (Exception e) { |
||
627 | //Do nothing
|
||
628 | } |
||
629 | 46403 | jjdelcerro | |
630 | if( this.target!=null ) { |
||
631 | this.tableFields.setModel(new MyTableModel()); |
||
632 | 46586 | fdiaz | dataSwingManager.addToExpressionBuilder(this.pickerTargetUpdateExpression.getConfig(), this.target, "target"); |
633 | 46698 | jjdelcerro | dataSwingManager.addToExpressionBuilder(this.pickerJoinExpression.getConfig(), this.target, "target"); |
634 | 46403 | jjdelcerro | } |
635 | } |
||
636 | |||
637 | private void doChangeTarget() { |
||
638 | 46586 | fdiaz | FeatureStore theTarget = this.treeTargetTableController.getSelectedFeatureStore();
|
639 | if( theTarget==null ) { |
||
640 | 46403 | jjdelcerro | return;
|
641 | } |
||
642 | 46586 | fdiaz | if(this.target != null){ |
643 | DisposeUtils.disposeQuietly(this.target);
|
||
644 | } |
||
645 | this.target = theTarget;
|
||
646 | 46403 | jjdelcerro | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
647 | 46586 | fdiaz | dataSwingManager.resetExpressionBuilder(this.pickerTargetUpdateExpression.getConfig());
|
648 | 46698 | jjdelcerro | dataSwingManager.resetExpressionBuilder(this.pickerJoinExpression.getConfig());
|
649 | 46586 | fdiaz | dataSwingManager.addToExpressionBuilder(this.pickerTargetUpdateExpression.getConfig(), this.target, "target"); |
650 | 46698 | jjdelcerro | dataSwingManager.addToExpressionBuilder(this.pickerJoinExpression.getConfig(), this.target, "target"); |
651 | 46403 | jjdelcerro | |
652 | this.pickerTargetFieldJoin.setFeatureType(this.target.getDefaultFeatureTypeQuietly()); |
||
653 | 46621 | fdiaz | try {
|
654 | this.pickerTargetFieldJoin.set(this.target.getDefaultFeatureTypeQuietly().getPrimaryKey()[0]); |
||
655 | } catch (Exception e) { |
||
656 | //Do nothing
|
||
657 | } |
||
658 | 46403 | jjdelcerro | |
659 | if( this.source!=null ) { |
||
660 | this.tableFields.setModel(new MyTableModel()); |
||
661 | 46586 | fdiaz | dataSwingManager.addToExpressionBuilder(this.pickerTargetUpdateExpression.getConfig(), this.source, "source"); |
662 | 46698 | jjdelcerro | dataSwingManager.addToExpressionBuilder(this.pickerJoinExpression.getConfig(), this.source, "source", true); |
663 | 46403 | jjdelcerro | } |
664 | } |
||
665 | |||
666 | 46615 | jjdelcerro | // public FeatureStore getSource() {
|
667 | // return this.source;
|
||
668 | // }
|
||
669 | //
|
||
670 | // public String getSourceFieldJoin() {
|
||
671 | // return this.pickerSourceFieldJoin.getName();
|
||
672 | // }
|
||
673 | //
|
||
674 | // public Expression getSourceFilter() {
|
||
675 | // return this.pickerSourceFilter.get();
|
||
676 | // }
|
||
677 | 46403 | jjdelcerro | |
678 | 46615 | jjdelcerro | // public FeatureStore getTarget() {
|
679 | // return this.target;
|
||
680 | // }
|
||
681 | //
|
||
682 | // public String getTargetFieldJoin() {
|
||
683 | // return this.pickerTargetFieldJoin.getName();
|
||
684 | // }
|
||
685 | //
|
||
686 | // public Expression getUpdateIfExistsInTargetCondition() {
|
||
687 | // return this.pickerTargetUpdateExpression.get();
|
||
688 | // }
|
||
689 | //
|
||
690 | // public boolean getInsertIfNotExistsTarget() {
|
||
691 | // return this.chkTargetInsertIfNotExistsInTarget.isSelected();
|
||
692 | // }
|
||
693 | //
|
||
694 | // public boolean getUpdateIfExistsInTarget() {
|
||
695 | // return this.chkTargetUpdateIfExistsInTarget.isSelected();
|
||
696 | // }
|
||
697 | //
|
||
698 | // public boolean getDeleteIfNotExiststInSource() {
|
||
699 | // return this.chkTargetDeleteIfNotExiststInSource.isSelected();
|
||
700 | // }
|
||
701 | 46403 | jjdelcerro | |
702 | public SimpleTaskStatus getStatus() {
|
||
703 | 46427 | jjdelcerro | if( this.taskStatus == null ) { |
704 | this.taskStatus = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Copy table"); |
||
705 | 46436 | fdiaz | this.status.bind(this.taskStatus); |
706 | 46427 | jjdelcerro | } |
707 | 46436 | fdiaz | lblStatusLabel.setVisible(true);
|
708 | lblStatusMessage.setVisible(true);
|
||
709 | pbStatus.setVisible(true);
|
||
710 | |||
711 | 46427 | jjdelcerro | return this.taskStatus; |
712 | 46403 | jjdelcerro | } |
713 | |||
714 | 46615 | jjdelcerro | // public Map<String/*target*/, String/*source*/> getFields() {
|
715 | // Map<String/*target*/, String/*source*/> fields = new HashMap<>();
|
||
716 | // MyTableModel model = (MyTableModel) this.tableFields.getModel();
|
||
717 | // for (MyTableModel.Row row : model) {
|
||
718 | // if( StringUtils.isNotBlank(row.source) ) {
|
||
719 | // fields.put(row.target, row.source);
|
||
720 | // }
|
||
721 | // }
|
||
722 | // return fields;
|
||
723 | // }
|
||
724 | //
|
||
725 | // public List<String/*target*/> getFieldsToUpdate() {
|
||
726 | // List<String> fields = new ArrayList<>();
|
||
727 | // MyTableModel model = (MyTableModel) this.tableFields.getModel();
|
||
728 | // for (MyTableModel.Row row : model) {
|
||
729 | // if( StringUtils.isNotBlank(row.source) && row.update) {
|
||
730 | // fields.add(row.target);
|
||
731 | // }
|
||
732 | // }
|
||
733 | // return fields;
|
||
734 | // }
|
||
735 | //
|
||
736 | 46629 | fdiaz | public void put(CopyTable2ProcessParameters params) { |
737 | FeatureStore sourceStore = params.getSourceStore(); |
||
738 | this.treeSourceTableController.setSelectedStore(sourceStore);
|
||
739 | doChangeSource(); |
||
740 | |||
741 | FeatureStore targetStore = params.getTargetStore(); |
||
742 | this.treeTargetTableController.setSelectedStore(targetStore);
|
||
743 | doChangeTarget(); |
||
744 | |||
745 | this.pickerSourceFieldJoin.set(params.getSourceFieldForJoin());
|
||
746 | this.pickerSourceFilter.set(params.getSourceFilter());
|
||
747 | |||
748 | this.pickerTargetFieldJoin.set(params.getTargetFieldForJoin());
|
||
749 | |||
750 | this.pickerTargetUpdateExpression.set(params.getUpdateIfExistsInTargetCondition());
|
||
751 | this.chkTargetInsertIfNotExistsInTarget.setSelected(params.isInsertIfNotExistsTargetActive());
|
||
752 | this.chkTargetUpdateIfExistsInTarget.setSelected(params.isUpdateIfExistsTargetActive());
|
||
753 | this.chkTargetDeleteIfNotExiststInSource.setSelected(params.isDeleteIfNotExiststInSourceActive());
|
||
754 | |||
755 | MyTableModel fieldsModel = new MyTableModel();
|
||
756 | this.tableFields.setModel(fieldsModel);
|
||
757 | for (MyTableModel.Row row : fieldsModel.rows) {
|
||
758 | ProcessFieldParameters paramfield = params.get(row.attrname); |
||
759 | row.attrname = paramfield.getName(); |
||
760 | Expression expression = paramfield.getExpression();
|
||
761 | if (expression != null) { |
||
762 | row.expression = expression.getPhrase(); |
||
763 | } else {
|
||
764 | row.expression = null;
|
||
765 | } |
||
766 | row.update = paramfield.isCopyThisFieldActive(); |
||
767 | } |
||
768 | |||
769 | //Options
|
||
770 | fieldsModel.fireTableDataChanged(); |
||
771 | |||
772 | switch (params.getEditMode()) {
|
||
773 | case FeatureStore.MODE_FULLEDIT:
|
||
774 | default:
|
||
775 | this.rdoOptionsFulledit.setSelected(true); |
||
776 | this.rdoOptionsPassthrought.setSelected(false); |
||
777 | break;
|
||
778 | case FeatureStore.MODE_PASS_THROUGH:
|
||
779 | this.rdoOptionsFulledit.setSelected(false); |
||
780 | this.rdoOptionsPassthrought.setSelected(true); |
||
781 | break;
|
||
782 | } |
||
783 | |||
784 | this.chkOptionsBeginEditIfNeed.setSelected(params.isBeginEditIfNeed());
|
||
785 | this.chkOptionsFinishAndRestarEditEach.setSelected(params.isFinishAndRestarEdit());
|
||
786 | this.chkOptionsNotifyUserIfNeedBeginEditing.setSelected(params.isNotifyUserIfNeedBeginEditing());
|
||
787 | this.chkOptionsFinishEditAfterTerminate.setSelected(params.isFinishEditAfterTerminate());
|
||
788 | IntegerDocumentFilter.setValue(txtOptionsFinishAndRestarEditEach, params.getFinishAndRestarEditEach()); |
||
789 | |||
790 | } |
||
791 | |||
792 | |||
793 | 46615 | jjdelcerro | public CopyTable2ProcessParameters fetch(CopyTable2ProcessParameters params) {
|
794 | if( params == null ) { |
||
795 | params = new CopyTable2ProcessParametersImpl();
|
||
796 | 46427 | jjdelcerro | } |
797 | 46615 | jjdelcerro | params.setSourceStore(this.source);
|
798 | params.setSourceFilter(this.pickerSourceFilter.get());
|
||
799 | params.setSourceFieldForJoin(this.pickerSourceFieldJoin.getName());
|
||
800 | |||
801 | params.setTargetStore(this.target);
|
||
802 | 46698 | jjdelcerro | if( this.rdbUseJoinExpression.isSelected() ) { |
803 | params.setTargetFieldForJoin(null);
|
||
804 | params.setJoinExpression(this.pickerJoinExpression.get());
|
||
805 | } else if( this.rdbUseJoinField.isSelected() ) { |
||
806 | params.setTargetFieldForJoin(this.pickerTargetFieldJoin.getName());
|
||
807 | params.setJoinExpression(null);
|
||
808 | } else {
|
||
809 | params.setTargetFieldForJoin(null);
|
||
810 | params.setJoinExpression(null);
|
||
811 | } |
||
812 | 46615 | jjdelcerro | |
813 | params.setUpdateIfExistsInTargetCondition(this.pickerTargetUpdateExpression.get());
|
||
814 | params.setInsertIfNotExistsTargetActive(this.chkTargetInsertIfNotExistsInTarget.isSelected());
|
||
815 | params.setUpdateIfExistsTargetActive(this.chkTargetUpdateIfExistsInTarget.isSelected());
|
||
816 | params.setDeleteIfNotExiststInSourceActive(this.chkTargetDeleteIfNotExiststInSource.isSelected());
|
||
817 | |||
818 | fetch_fields(params); |
||
819 | fetch_options(params); |
||
820 | |||
821 | return params;
|
||
822 | 46427 | jjdelcerro | } |
823 | |||
824 | 46615 | jjdelcerro | private void fetch_fields(CopyTable2ProcessParameters params) { |
825 | 46427 | jjdelcerro | MyTableModel model = (MyTableModel) this.tableFields.getModel();
|
826 | for (MyTableModel.Row row : model) {
|
||
827 | 46615 | jjdelcerro | Expression exp = null; |
828 | if( org.apache.commons.lang.StringUtils.isNotBlank(row.expression)) {
|
||
829 | exp = ExpressionUtils.createExpression(row.expression); |
||
830 | 46427 | jjdelcerro | } |
831 | 46615 | jjdelcerro | params.add(row.attrname, row.update, exp); |
832 | } |
||
833 | } |
||
834 | |||
835 | private void fetch_options(CopyTable2ProcessParameters params) { |
||
836 | if( this.rdoOptionsFulledit.isSelected() ) { |
||
837 | params.setEditMode(FeatureStore.MODE_FULLEDIT); |
||
838 | } else {
|
||
839 | params.setEditMode(FeatureStore.MODE_PASS_THROUGH); |
||
840 | 46427 | jjdelcerro | } |
841 | 46615 | jjdelcerro | params.setBeginEditIfNeed(this.chkOptionsBeginEditIfNeed.isSelected());
|
842 | params.setFinishAndRestarEdit(this.chkOptionsFinishAndRestarEditEach.isSelected());
|
||
843 | params.setNotifyUserIfNeedBeginEditing(this.chkOptionsNotifyUserIfNeedBeginEditing.isSelected());
|
||
844 | params.setFinishEditAfterTerminate(this.chkOptionsFinishEditAfterTerminate.isSelected());
|
||
845 | params.setFinishAndRestarEditEach(IntegerDocumentFilter.getValue(txtOptionsFinishAndRestarEditEach)); |
||
846 | 46403 | jjdelcerro | } |
847 | 46621 | fdiaz | |
848 | void message(String msg) { |
||
849 | this.lblStatusMessage.setText(msg);
|
||
850 | // if(this.taskStatus.getCompleted() >= 100){
|
||
851 | // this.pbStatus.setVisible(false);
|
||
852 | // }
|
||
853 | |||
854 | } |
||
855 | |||
856 | 46629 | fdiaz | void addHistory(CopyTable2ProcessParameters params) {
|
857 | this.history.add(params);
|
||
858 | } |
||
859 | |||
860 | 46698 | jjdelcerro | @Override
|
861 | public ImageIcon loadImage(String imageName) { |
||
862 | String name = FilenameUtils.getBaseName(imageName);
|
||
863 | IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
||
864 | if (theme.exists(name)) {
|
||
865 | return theme.get(name);
|
||
866 | } |
||
867 | URL url = CopyTable2Panel.class.getResource("images/"+name + ".png"); |
||
868 | if (url == null) { |
||
869 | return null; |
||
870 | } |
||
871 | return new ImageIcon(url); |
||
872 | } |
||
873 | 46621 | fdiaz | |
874 | 46403 | jjdelcerro | } |