Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,35 @@ protected boolean dropFiles(List<File> files, TransferSupport support) {
}
}

// Separate zip files from regular files
List<File> zipFiles = new ArrayList<>();
List<File> regularFiles = new ArrayList<>();
for (File file : files) {
if (!file.isDirectory() && file.getName().toLowerCase().endsWith(".zip")) { // NON-NLS
zipFiles.add(file);
} else {
regularFiles.add(file);
}
}

// Process zip files using DicomSeriesHandler if available
if (!zipFiles.isEmpty()) {

try {
Class<?> dicomSeriesHandlerClass = Class.forName("org.weasis.dicom.explorer.DicomSeriesHandler"); // NON-NLS
java.lang.reflect.Method dropDicomFilesMethod = dicomSeriesHandlerClass.getMethod("dropDicomFiles", List.class);
Boolean result = (Boolean) dropDicomFilesMethod.invoke(null, zipFiles);
if (Boolean.TRUE.equals(result)) {
// Zip files processed successfully
}
} catch (Exception e) {
LOGGER.warn("Cannot process DICOM zip files via DicomSeriesHandler", e);
}
}

final List<File> dirs = new ArrayList<>();
Map<Codec, List<File>> codecs = new HashMap<>();
for (File file : files) {
for (File file : regularFiles) {
if (file.isDirectory()) {
dirs.add(file);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.weasis.dicom.codec.DicomSeries;
import org.weasis.dicom.explorer.HangingProtocols.OpeningViewer;


public class DicomSeriesHandler extends SequenceHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(DicomSeriesHandler.class);
protected final ViewCanvas<DicomImageElement> viewCanvas;
Expand Down Expand Up @@ -164,8 +165,28 @@ public static boolean dropDicomFiles(List<File> files) {
DicomModel model = (DicomModel) dicomView.getDataExplorerModel();
OpeningViewer openingViewer =
OpeningViewer.getOpeningViewerByLocalKey(LocalImport.LAST_OPEN_VIEWER_MODE);
DicomModel.LOADING_EXECUTOR.execute(
new LoadLocalDicom(files.toArray(File[]::new), true, model, openingViewer));

// Drag and Drop to open zip files
List<File> zipFiles = new ArrayList<>();
List<File> regularFiles = new ArrayList<>();

for (File file : files) {
if (file.getName().toLowerCase().endsWith(".zip")) { // NON-NLS
zipFiles.add(file);
} else {
regularFiles.add(file);
}
}

for (File zipFile : zipFiles) {
DicomZipImport.loadDicomZip(
zipFile, model, openingViewer, GuiUtils.getUICore().getApplicationWindow());
}

if (!regularFiles.isEmpty()) {
DicomModel.LOADING_EXECUTOR.execute(
new LoadLocalDicom(regularFiles.toArray(File[]::new), true, model, openingViewer));
}
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@

public interface ImportDicom extends PageItem {


void importDICOM(DicomModel dicomModel, JProgressBar info);
}