/** * Sets the result of the import. * * @param status Flag indicating the status of the import. * @param image The image. */ public void setStatus(boolean status, Object image) { this.image = image; busyLabel.setBusy(false); busyLabel.setVisible(false); cancelButton.setVisible(false); importCount++; if (parent != null) parent.increaseNumberOfImport(); if (image instanceof ImageData) { ImageData img = (ImageData) image; Exception error = null; try { img.getDefaultPixels(); } catch (Exception e) { error = e; toReImport = true; } if (error != null) { exception = error; fileNameLabel.setForeground(ERROR_COLOR); resultLabel.setVisible(false); errorButton.setToolTipText(UIUtilities.formatExceptionForToolTip(error)); errorButton.setVisible(true); errorBox.setVisible(true); errorBox.addChangeListener(this); deleteButton.setVisible(true); deleteButton.addActionListener(this); } else { imageLabel.setData(img); resultLabel.setText(VIEW_TEXT); resultLabel.setForeground(UIUtilities.HYPERLINK_COLOR); if (browsable) resultLabel.setToolTipText(ThumbnailLabel.IMAGE_LABEL_TOOLTIP); else imageLabel.setToolTipText(""); resultLabel.setVisible(true); fileNameLabel.addMouseListener(adapter); resultLabel.addMouseListener(adapter); addMouseListener(adapter); showContainerLabel = (dataset != null || containerFromFolder != null); if (noContainer) { browseButton.setVisible(false); containerLabel.setVisible(false); } else { browseButton.setVisible(showContainerLabel); containerLabel.setVisible(showContainerLabel); } groupLabel.setVisible(!singleGroup); } } else if (image instanceof ThumbnailData) { ThumbnailData thumbnail = (ThumbnailData) image; groupLabel.setVisible(!singleGroup); if (thumbnail.isValidImage()) { imageLabel.setData(thumbnail); statusLabel.setVisible(false); fileNameLabel.addMouseListener(adapter); addMouseListener(adapter); resultLabel.setText(VIEW_TEXT); resultLabel.setForeground(UIUtilities.HYPERLINK_COLOR); if (browsable) resultLabel.setToolTipText(ThumbnailLabel.IMAGE_LABEL_TOOLTIP); else imageLabel.setToolTipText(""); resultLabel.setVisible(false); if (thumbnail.requirePyramid() != null && thumbnail.requirePyramid().booleanValue()) { imageLabel.setToolTipText(PYRAMID_TEXT); resultLabel.setVisible(true); resultLabel.addMouseListener(adapter); } showContainerLabel = (dataset != null || containerFromFolder != null); if (noContainer) { browseButton.setVisible(false); containerLabel.setVisible(false); } else { browseButton.setVisible(showContainerLabel); containerLabel.setVisible(showContainerLabel); } } else { statusLabel.setVisible(false); fileNameLabel.setForeground(ERROR_COLOR); resultLabel.setText(IMAGE_CREATION_ERROR_TEXT); resultLabel.setToolTipText(UIUtilities.formatExceptionForToolTip(thumbnail.getError())); resultLabel.setVisible(true); errorButton.setVisible(false); errorBox.setVisible(false); groupLabel.setVisible(!singleGroup); } } else if (image instanceof PlateData) { imageLabel.setData((PlateData) image); statusLabel.setVisible(false); groupLabel.setVisible(!singleGroup); if (browsable) { resultLabel.setText(BROWSE_TEXT); resultLabel.setForeground(UIUtilities.HYPERLINK_COLOR); resultLabel.setToolTipText(ThumbnailLabel.PLATE_LABEL_TOOLTIP); resultLabel.setVisible(true); } fileNameLabel.addMouseListener(adapter); resultLabel.addMouseListener(adapter); showContainerLabel = containerObject instanceof ScreenData; if (noContainer || !browsable) { browseButton.setVisible(false); containerLabel.setVisible(false); } else { browseButton.setVisible(showContainerLabel); containerLabel.setVisible(showContainerLabel); } } else if (image instanceof List) { statusLabel.setVisible(false); groupLabel.setVisible(!singleGroup); List list = (List) image; int m = list.size(); imageLabel.setData(list.get(0)); list.remove(0); ThumbnailLabel label = imageLabels.get(0); label.setVisible(true); label.setData(list.get(0)); list.remove(0); if (list.size() > 0) { label = imageLabels.get(1); label.setVisible(true); label.setData(list.get(0)); list.remove(0); int n = statusLabel.getSeriesCount() - m; if (n > 0) { label = imageLabels.get(2); Font f = label.getFont(); label.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2)); label.setVisible(true); String value = "... " + n + " more"; label.setText(value); } } resultLabel.setVisible(true); showContainerLabel = true; if (noContainer) { browseButton.setVisible(false); containerLabel.setVisible(false); } else { browseButton.setVisible(showContainerLabel); containerLabel.setVisible(showContainerLabel); } // control = resultLabel; } else if (image instanceof Boolean) { if (!statusLabel.isMarkedAsCancel()) { cancelButton.setVisible(false); if (statusLabel.isMarkedAsDuplicate()) { statusLabel.setVisible(false); setStatusText(StatusLabel.DUPLICATE); } else { statusLabel.setVisible(false); setStatusText(FILE_NOT_VALID_TEXT); } } else resultLabel.setText(""); } else { if (!status) { statusLabel.setVisible(false); resultLabel.setToolTipText(""); resultLabel.setEnabled(false); if (image == null) setStatusText(null); else if (image instanceof String) { setStatusText((String) image); } else if (image instanceof ImportException) { ImportException ie = (ImportException) image; fileNameLabel.setForeground(ERROR_COLOR); resultLabel.setVisible(false); toReImport = true; errorButton.setToolTipText(UIUtilities.formatExceptionForToolTip(ie)); exception = ie; errorButton.setVisible(false); int s = ie.getStatus(); if (s == ImportException.COMPRESSION) { resultLabel.setVisible(true); resultLabel.setText(COMPRESSION_ERROR_TEXT); resultLabel.setToolTipText(UIUtilities.formatExceptionForToolTip(ie)); } else if (s == ImportException.MISSING_LIBRARY) { resultLabel.setVisible(true); resultLabel.setText(MISSING_LIB_ERROR_TEXT); resultLabel.setToolTipText(UIUtilities.formatExceptionForToolTip(ie)); } else if (s == ImportException.FILE_ON_TAPE) { resultLabel.setVisible(true); resultLabel.setText(FILE_ON_TAPE_ERROR_TEXT); resultLabel.setToolTipText(UIUtilities.formatExceptionForToolTip(ie)); } else if (s == ImportException.NO_SPACE) { resultLabel.setVisible(true); resultLabel.setText(NO_SPACE_ERROR_TEXT); resultLabel.setToolTipText(UIUtilities.formatExceptionForToolTip(ie)); } else { errorButton.setVisible(true); errorBox.setVisible(true); errorBox.addChangeListener(this); } cancelButton.setVisible(false); } } } repaint(); }