/** * Listens to property fired by the <code>StatusLabel</code>. * * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (StatusLabel.FILES_SET_PROPERTY.equals(name)) { if (isCancelled()) { statusLabel.setText(CANCEL_TEXT); busyLabel.setBusy(false); busyLabel.setVisible(false); return; } Map<File, StatusLabel> files = (Map<File, StatusLabel>) evt.getNewValue(); insertFiles((Map<File, StatusLabel>) evt.getNewValue()); firePropertyChange(IMPORT_FILES_NUMBER_PROPERTY, null, files.size()); } else if (StatusLabel.FILE_IMPORT_STARTED_PROPERTY.equals(name)) { StatusLabel sl = (StatusLabel) evt.getNewValue(); if (sl == statusLabel && busyLabel != null) { busyLabel.setBusy(true); busyLabel.setVisible(true); cancelButton.setVisible(sl.isCancellable()); } } else if (StatusLabel.CANCELLABLE_IMPORT_PROPERTY.equals(name)) { StatusLabel sl = (StatusLabel) evt.getNewValue(); cancelButton.setVisible(sl.isCancellable()); } else if (StatusLabel.FILE_IMPORTED_PROPERTY.equals(name)) { Object[] results = (Object[]) evt.getNewValue(); File f = (File) results[0]; if (f.getAbsolutePath().equals(file.getAbsolutePath())) { setStatus(false, results[1]); if (f.isFile()) { if (hasImportFailed()) firePropertyChange(IMPORT_STATUS_CHANGE_PROPERTY, null, FAILURE); else if (isCancelled()) firePropertyChange(IMPORT_STATUS_CHANGE_PROPERTY, null, PARTIAL); else firePropertyChange(IMPORT_STATUS_CHANGE_PROPERTY, null, SUCCESS); } } } else if (StatusLabel.FILE_RESET_PROPERTY.equals(name)) { file = (File) evt.getNewValue(); fileNameLabel.setText(file.getName()); } else if (ThumbnailLabel.BROWSE_PLATE_PROPERTY.equals(name)) { firePropertyChange(BROWSE_PROPERTY, evt.getOldValue(), evt.getNewValue()); } else if (StatusLabel.CONTAINER_FROM_FOLDER_PROPERTY.equals(name)) { containerFromFolder = (DataObject) evt.getNewValue(); if (containerFromFolder instanceof DatasetData) { containerLabel.setText(TEXT_IMPORTED); browseButton.setText(((DatasetData) containerFromFolder).getName()); containerObject = containerFromFolder; } else if (containerFromFolder instanceof ScreenData) { containerLabel.setText(TEXT_IMPORTED); browseButton.setText(((ScreenData) containerFromFolder).getName()); containerObject = containerFromFolder; } } else if (StatusLabel.NO_CONTAINER_PROPERTY.equals(name)) { containerLabel.setText(""); noContainer = true; } else if (StatusLabel.DEBUG_TEXT_PROPERTY.equals(name)) { firePropertyChange(name, evt.getOldValue(), evt.getNewValue()); } }
/** * Indicates that the file will not be imported. * * @param fire Pass <code>true</code> to fire a property, <code>false</code> otherwise. */ private void cancel(boolean fire) { if (busyLabel.isBusy() && !statusLabel.isCancellable()) return; String s = CANCEL_TEXT; if (file.isDirectory()) { busyLabel.setBusy(true); busyLabel.setVisible(true); s += " waiting on scanning to finish"; } else { busyLabel.setBusy(false); busyLabel.setVisible(false); } statusLabel.setText(s); statusLabel.markedAsCancel(); cancelButton.setEnabled(false); cancelButton.setVisible(false); if (image == null && file.isFile()) firePropertyChange(IMPORT_STATUS_CHANGE_PROPERTY, null, PARTIAL); if (fire) firePropertyChange(CANCEL_IMPORT_PROPERTY, null, this); }