equal
deleted
inserted
replaced
1298 String prop = e.getPropertyName(); |
1298 String prop = e.getPropertyName(); |
1299 if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { |
1299 if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { |
1300 filters = (FileFilter[]) e.getNewValue(); |
1300 filters = (FileFilter[]) e.getNewValue(); |
1301 fireContentsChanged(this, -1, -1); |
1301 fireContentsChanged(this, -1, -1); |
1302 } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { |
1302 } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { |
1303 fireContentsChanged(this, -1, -1); |
1303 setSelectedItem(e.getNewValue()); |
1304 } |
1304 } |
1305 } |
1305 } |
1306 |
1306 |
1307 public void setSelectedItem(Object filter) { |
1307 public void setSelectedItem(Object filter) { |
1308 if(filter != null) { |
1308 if (filter != null && !containsFileFilter(filter)) { |
1309 getFileChooser().setFileFilter((FileFilter) filter); |
1309 getFileChooser().setFileFilter((FileFilter) filter); |
1310 fireContentsChanged(this, -1, -1); |
1310 fireContentsChanged(this, -1, -1); |
1311 } |
1311 } |
1312 } |
1312 } |
1313 |
1313 |
1351 return null; |
1351 return null; |
1352 } |
1352 } |
1353 } |
1353 } |
1354 } |
1354 } |
1355 |
1355 |
|
1356 private boolean containsFileFilter(Object fileFilter) { |
|
1357 return Objects.equals(fileFilter, getFileChooser().getFileFilter()); |
|
1358 } |
|
1359 |
1356 /** |
1360 /** |
1357 * Acts when FilterComboBox has changed the selected item. |
1361 * Acts when FilterComboBox has changed the selected item. |
1358 */ |
1362 */ |
1359 @SuppressWarnings("serial") // Superclass is not serializable across versions |
1363 @SuppressWarnings("serial") // Superclass is not serializable across versions |
1360 protected class FilterComboBoxAction extends AbstractAction { |
1364 protected class FilterComboBoxAction extends AbstractAction { |
1361 protected FilterComboBoxAction() { |
1365 protected FilterComboBoxAction() { |
1362 super("FilterComboBoxAction"); |
1366 super("FilterComboBoxAction"); |
1363 } |
1367 } |
1364 |
1368 |
1365 public void actionPerformed(final ActionEvent e) { |
1369 public void actionPerformed(final ActionEvent e) { |
1366 getFileChooser().setFileFilter((FileFilter) filterComboBox.getSelectedItem()); |
1370 Object selectedFilter = filterComboBox.getSelectedItem(); |
|
1371 if (!containsFileFilter(selectedFilter)) { |
|
1372 getFileChooser().setFileFilter((FileFilter) selectedFilter); |
|
1373 } |
1367 } |
1374 } |
1368 } |
1375 } |
1369 |
1376 |
1370 /** |
1377 /** |
1371 * Acts when DirectoryComboBox has changed the selected item. |
1378 * Acts when DirectoryComboBox has changed the selected item. |