Revision 337 org.gvsig.toolbox/trunk/org.gvsig.toolbox/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/DefaultParametersPanel.java
DefaultParametersPanel.java | ||
---|---|---|
97 | 97 |
import javax.swing.ImageIcon; |
98 | 98 |
import javax.swing.JComponent; |
99 | 99 |
import org.apache.commons.lang3.tuple.Pair; |
100 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
100 | 101 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
101 | 102 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
102 | 103 |
import org.gvsig.temporarystorage.TemporaryStorageGroup; |
... | ... | |
124 | 125 |
protected JPanel jPanelParameters; |
125 | 126 |
protected ArrayList m_ParameterContainer = new ArrayList(); |
126 | 127 |
protected ArrayList m_ComboBox = new ArrayList(); |
127 |
protected ArrayList m_FilterComboBox = new ArrayList(); |
|
128 | 128 |
protected GeoAlgorithm m_Algorithm; |
129 | 129 |
protected ArrayList m_OutputParameterContainer = new ArrayList(); |
130 | 130 |
protected HashMap m_HelpElements; |
... | ... | |
167 | 167 |
protected void initGUI() { |
168 | 168 |
|
169 | 169 |
m_ComboBox = new ArrayList(); |
170 |
m_FilterComboBox = new ArrayList(); |
|
171 | 170 |
|
172 | 171 |
{ |
173 | 172 |
jScrollPanelParameters = new JScrollPane(); |
... | ... | |
417 | 416 |
int i, j; |
418 | 417 |
String sParameterName; |
419 | 418 |
final ArrayList childComboBoxIndex = new ArrayList(); |
419 |
|
|
420 | 420 |
Parameter parameter; |
421 | 421 |
Parameter subParameter; |
422 | 422 |
final ParametersSet parameters = m_Algorithm.getParameters(); |
... | ... | |
427 | 427 |
|
428 | 428 |
|
429 | 429 |
for (i = 0; i < m_Algorithm.getNumberOfParameters(); i++) { |
430 |
int tableFiltersApplied = 0; |
|
430 |
//int tableFiltersApplied = 0;
|
|
431 | 431 |
parameter = parameters.getParameter(i); |
432 | 432 |
if (parameter instanceof ParameterVectorLayer) { |
433 | 433 |
try { |
... | ... | |
435 | 435 |
//check for table fields that depend on this vector layer |
436 | 436 |
sParameterName = parameter.getParameterName(); |
437 | 437 |
childComboBoxIndex.clear(); |
438 |
|
|
438 | 439 |
for (j = 0; j < m_Algorithm.getNumberOfParameters(); j++) { |
439 | 440 |
subParameter = parameters.getParameter(j); |
440 | 441 |
if (subParameter instanceof ParameterTableField) { |
... | ... | |
456 | 457 |
} else if (subParameter instanceof ParameterTableFilter) { |
457 | 458 |
if (((AdditionalInfoTableFilter) subParameter.getParameterAdditionalInfo()).getParentParameterName().equals( |
458 | 459 |
sParameterName)) { |
459 |
addTableFilter(pane, (ParameterVectorLayer) parameter, (ParameterTableFilter) subParameter, shapeTypes); |
|
460 |
tableFiltersApplied++; |
|
460 |
addTableFilter(pane, (ParameterVectorLayer) parameter, (ParameterTableFilter) subParameter, shapeTypes, childComboBoxIndex);
|
|
461 |
//tableFiltersApplied++;
|
|
461 | 462 |
} |
462 | 463 |
} |
463 | 464 |
} |
... | ... | |
473 | 474 |
|
474 | 475 |
if (((AdditionalInfoVectorLayer) parameter.getParameterAdditionalInfo()).getIsMandatory()) { |
475 | 476 |
bAddNotSetField = false; |
476 |
addTitleLabel(pane, parameter.getParameterDescription(), m_iCurrentRow - childComboBoxIndex.size()- tableFiltersApplied, false);
|
|
477 |
addTitleLabel(pane, parameter.getParameterDescription(), m_iCurrentRow - childComboBoxIndex.size(), false); //- tableFiltersApplied
|
|
477 | 478 |
} |
478 | 479 |
else { |
479 | 480 |
bAddNotSetField = true; |
... | ... | |
484 | 485 |
if (bAddNotSetField) { |
485 | 486 |
comboBox.setSelectedIndex(0); |
486 | 487 |
} |
487 |
pane.add(comboBox, getStringTableCoords(2, m_iCurrentRow - childComboBoxIndex.size() - tableFiltersApplied));
|
|
488 |
pane.add(comboBox, getStringTableCoords(2, m_iCurrentRow - childComboBoxIndex.size())); // -tableFilerApplied
|
|
488 | 489 |
m_iCurrentRow++; |
489 | 490 |
m_ParameterContainer.add(new ParameterContainer(parameter, comboBox)); |
490 | 491 |
} |
... | ... | |
529 | 530 |
parameter = parameters.getParameter(i); |
530 | 531 |
if (parameter instanceof ParameterTable) { |
531 | 532 |
//check for table fields that depend on this table |
533 |
//int[] tableTypes = ((AdditionalInfoTable) parameter.getParameterAdditionalInfo()); //.getShapeTypes(); |
|
534 |
|
|
532 | 535 |
sParameterName = parameter.getParameterName(); |
533 | 536 |
childComboBoxIndex.clear(); |
534 | 537 |
for (j = 0; j < m_Algorithm.getNumberOfParameters(); j++) { |
... | ... | |
549 | 552 |
catch (final NullParameterAdditionalInfoException e) { |
550 | 553 |
Sextante.addErrorToLog(e); |
551 | 554 |
} |
552 |
} |
|
555 |
} else if (subParameter instanceof ParameterTableFilter) { |
|
556 |
try { |
|
557 |
if (((AdditionalInfoTableFilter) subParameter.getParameterAdditionalInfo()).getParentParameterName().equals( |
|
558 |
sParameterName)) { |
|
559 |
Object shapeTypes = null; |
|
560 |
addTableFilter(pane, (ParameterTable) parameter, (ParameterTableFilter) subParameter, childComboBoxIndex); |
|
561 |
//tableFiltersApplied++; |
|
562 |
} |
|
563 |
} catch (NullParameterAdditionalInfoException ex) { |
|
564 |
Sextante.addErrorToLog(ex); |
|
565 |
} |
|
566 |
} |
|
553 | 567 |
} |
554 | 568 |
// add table |
555 | 569 |
try { |
... | ... | |
758 | 772 |
} |
759 | 773 |
|
760 | 774 |
} |
775 |
protected void addTableFilter(final JPanel pane, |
|
776 |
final ParameterTable parameter, |
|
777 |
final ParameterTableFilter subParameter, |
|
778 |
ArrayList childComboBoxIndex) { |
|
761 | 779 |
|
780 |
try { |
|
781 |
final AdditionalInfoTable additionalInfo = (AdditionalInfoTable) parameter.getParameterAdditionalInfo(); |
|
782 |
m_iCurrentRow++; |
|
783 |
addTitleLabel(pane, " " + subParameter.getParameterDescription(), m_iCurrentRow, false); |
|
784 |
} catch (final NullParameterAdditionalInfoException e) { |
|
785 |
Sextante.addErrorToLog(e); |
|
786 |
} |
|
787 |
TableFilterPanel tableFilterPanel; |
|
788 |
// IVectorLayer ivlayer = parameter.getParameterValueAsVectorLayer(); |
|
789 |
List<ITable> layers = getTables(); |
|
790 |
if (layers.size() > 0) { |
|
791 |
ITable ivlayer = layers.get(0); |
|
792 |
TableDocument layer = (TableDocument) ivlayer.getBaseDataObject(); |
|
793 |
FeatureStore store = layer.getFeatureStore(); |
|
794 |
tableFilterPanel = new TableFilterPanel(store); |
|
795 |
} else { |
|
796 |
tableFilterPanel = new TableFilterPanel(); |
|
797 |
} |
|
798 |
childComboBoxIndex.add(new Integer(m_ComboBox.size())); |
|
799 |
pane.add(tableFilterPanel, getStringTableCoords(2, m_iCurrentRow)); |
|
800 |
m_ComboBox.add(tableFilterPanel); |
|
801 |
m_ParameterContainer.add(new ParameterContainer(subParameter, tableFilterPanel)); |
|
802 |
|
|
803 |
} |
|
804 |
|
|
762 | 805 |
protected void addTableFilter(final JPanel pane, |
763 | 806 |
final ParameterVectorLayer parameter, |
764 | 807 |
final ParameterTableFilter subParameter, |
765 |
int[] shapeTypes) { |
|
808 |
int[] shapeTypes, |
|
809 |
ArrayList childComboBoxIndex) { |
|
766 | 810 |
|
767 | 811 |
try { |
768 | 812 |
final AdditionalInfoVectorLayer additionalInfo = (AdditionalInfoVectorLayer) parameter.getParameterAdditionalInfo(); |
... | ... | |
782 | 826 |
} else { |
783 | 827 |
tableFilterPanel = new TableFilterPanel(); |
784 | 828 |
} |
785 |
|
|
829 |
childComboBoxIndex.add(new Integer(m_ComboBox.size())); |
|
786 | 830 |
pane.add(tableFilterPanel, getStringTableCoords(2, m_iCurrentRow)); |
787 |
m_FilterComboBox.add(tableFilterPanel);
|
|
831 |
m_ComboBox.add(tableFilterPanel); |
|
788 | 832 |
m_ParameterContainer.add(new ParameterContainer(subParameter, tableFilterPanel)); |
789 | 833 |
|
790 |
|
|
791 | 834 |
} |
792 | 835 |
|
793 | 836 |
protected void addPoint(final JPanel pane, |
... | ... | |
1269 | 1312 |
final ObjectAndDescription ob = (ObjectAndDescription) cb.getSelectedItem(); |
1270 | 1313 |
final IVectorLayer layer = (IVectorLayer) ob.getObject(); |
1271 | 1314 |
if (layer != null) { |
1272 |
FieldDescriptionComboBox[] sNames = getVectorLayerFieldRendererComboBox(layer); |
|
1273 |
if (sNames != null) { |
|
1274 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1275 |
JComboBox cmb = (JComboBox) m_ComboBox.get(iIndex); |
|
1276 |
cmb.setModel(defaultModel); |
|
1315 |
Object item = m_ComboBox.get(iIndex); |
|
1316 |
if (item instanceof JComboBox) { |
|
1317 |
FieldDescriptionComboBox[] sNames = getVectorLayerFieldRendererComboBox(layer); |
|
1318 |
if (sNames != null) { |
|
1319 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1320 |
JComboBox cmb = (JComboBox) item; |
|
1321 |
cmb.setModel(defaultModel); |
|
1322 |
} |
|
1277 | 1323 |
} |
1278 |
TableFilterPanel pane = (TableFilterPanel) m_FilterComboBox.get(iIndex); |
|
1279 |
VectorLayer ivector = (VectorLayer) layer.getBaseDataObject(); |
|
1280 |
pane.setStore(ivector.getFeatureStore()); |
|
1324 |
if (item instanceof TableFilterPanel) { |
|
1325 |
TableFilterPanel pane = (TableFilterPanel) item; |
|
1326 |
VectorLayer ivector = (VectorLayer) layer.getBaseDataObject(); |
|
1327 |
pane.setStore(ivector.getFeatureStore()); |
|
1328 |
} |
|
1281 | 1329 |
} |
1282 | 1330 |
} |
1283 | 1331 |
} |
... | ... | |
1319 | 1367 |
final ObjectAndDescription ob = (ObjectAndDescription) cb.getSelectedItem(); |
1320 | 1368 |
final IVectorLayer layer = (IVectorLayer) ob.getObject(); |
1321 | 1369 |
if (layer != null) { |
1322 |
FieldDescriptionComboBox[] sNames = getVectorLayerFieldRendererComboBox(layer); |
|
1323 |
if (sNames != null) { |
|
1324 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1325 |
//FieldComboBoxRenderer renderer = new FieldComboBoxRenderer(); |
|
1326 |
JComboBox cmb = (JComboBox) m_ComboBox.get(iIndex); |
|
1327 |
//cmb.setRenderer(renderer); |
|
1328 |
cmb.setModel(defaultModel); |
|
1370 |
Object item = m_ComboBox.get(iIndex); |
|
1371 |
if (item instanceof JComboBox) { |
|
1372 |
FieldDescriptionComboBox[] sNames = getVectorLayerFieldRendererComboBox(layer); |
|
1373 |
if (sNames != null) { |
|
1374 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1375 |
JComboBox cmb = (JComboBox) item; |
|
1376 |
cmb.setModel(defaultModel); |
|
1377 |
} |
|
1329 | 1378 |
} |
1330 |
TableFilterPanel pane = (TableFilterPanel) m_FilterComboBox.get(iIndex); |
|
1331 |
VectorLayer ivector = (VectorLayer) layer.getBaseDataObject(); |
|
1332 |
pane.setStore(ivector.getFeatureStore()); |
|
1379 |
if (item instanceof TableFilterPanel) { |
|
1380 |
TableFilterPanel pane = (TableFilterPanel) item; |
|
1381 |
VectorLayer ivector = (VectorLayer) layer.getBaseDataObject(); |
|
1382 |
pane.setStore(ivector.getFeatureStore()); |
|
1383 |
} |
|
1333 | 1384 |
} |
1334 | 1385 |
} |
1335 | 1386 |
} |
... | ... | |
1339 | 1390 |
|
1340 | 1391 |
} |
1341 | 1392 |
|
1393 |
/** |
|
1394 |
* @param shapeTypes |
|
1395 |
* @return |
|
1396 |
*/ |
|
1397 |
private List<ITable> getTables() { |
|
1398 |
List<ITable> tables = new ArrayList<ITable>(); |
|
1399 |
ITable[] allTables = SextanteGUI.getInputFactory().getTables(); |
|
1400 |
for (int k = 0; k < allTables.length; k++) { |
|
1401 |
tables.add(allTables[k]); |
|
1402 |
}; |
|
1342 | 1403 |
|
1404 |
return tables; |
|
1405 |
} |
|
1406 |
|
|
1343 | 1407 |
/** |
1344 | 1408 |
* @param shapeTypes |
1345 | 1409 |
* @return |
... | ... | |
1388 | 1452 |
iIndex = (childsArray[i]).intValue(); |
1389 | 1453 |
final ObjectAndDescription ob = (ObjectAndDescription) comboBox.getSelectedItem(); |
1390 | 1454 |
final ITable table = (ITable) ob.getObject(); |
1391 |
if (table != null) { |
|
1392 |
sNames = getTableFieldNames(table); |
|
1393 |
if (sNames != null) { |
|
1394 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1395 |
((JComboBox) m_ComboBox.get(iIndex)).setModel(defaultModel); |
|
1396 |
} |
|
1397 |
} |
|
1398 |
} |
|
1455 |
if (table != null) { |
|
1456 |
Object item = m_ComboBox.get(iIndex); |
|
1457 |
if (item instanceof JComboBox) { |
|
1458 |
sNames = getTableFieldNames(table); |
|
1459 |
if (sNames != null) { |
|
1460 |
defaultModel = new DefaultComboBoxModel(sNames); |
|
1461 |
((JComboBox) item).setModel(defaultModel); |
|
1462 |
} |
|
1463 |
} |
|
1464 |
if (item instanceof TableFilterPanel) { |
|
1465 |
TableFilterPanel pane = (TableFilterPanel) item; |
|
1466 |
TableDocument ivector = (TableDocument) table.getBaseDataObject(); |
|
1467 |
pane.setStore(ivector.getFeatureStore()); |
|
1468 |
|
|
1469 |
} |
|
1470 |
} |
|
1471 |
} |
|
1399 | 1472 |
} |
1400 | 1473 |
}); |
1401 | 1474 |
|
Also available in: Unified diff