Skip to content

Commit

Permalink
Quick Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AvocadoMoon committed Sep 10, 2024
1 parent 0b0fc24 commit 34964d6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,38 @@ private void setUnits(N5Reader n5Reader, ImagePlus imagePlus){
}
}

public static void openLocalN5FS(ArrayList<SimResultsLoader> filesToOpen){
N5ExportTable.enableCriticalButtons(false);
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setAcceptAllFileFilterUsed(false);
int result = fileChooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION){
File file = fileChooser.getCurrentDirectory();
N5ExportTable.exportTableDialog.setCursor(new Cursor(Cursor.WAIT_CURSOR));
Thread openN5FileDataset = new Thread(() -> {
try{
for(SimResultsLoader simResultsLoader: filesToOpen){
simResultsLoader.setSelectedLocalFile(file);
ImagePlus imagePlus = simResultsLoader.getImgPlusFromLocalN5File();
imagePlus.show();
}
} catch (IOException ex) {
throw new RuntimeException(ex);
} finally {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
N5ExportTable.exportTableDialog.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
N5ExportTable.enableCriticalButtons(true);
}
});
}
});
openN5FileDataset.start();
}
}


public static void openN5FileDataset(ArrayList<SimResultsLoader> filesToOpen, boolean openInMemory){
N5ExportTable.enableCriticalButtons(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.vcell.N5.UI;

import ij.ImagePlus;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.numeric.real.DoubleType;
import org.janelia.saalfeldlab.n5.N5FSReader;
import org.scijava.log.Logger;
import org.vcell.N5.ExportDataRepresentation;
import org.vcell.N5.N5ImageHandler;
import org.vcell.N5.SimCacheLoader;
import org.vcell.N5.SimResultsLoader;

import javax.swing.*;
Expand All @@ -18,6 +24,7 @@
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
Expand All @@ -35,6 +42,7 @@ public class N5ExportTable implements ActionListener, ListSelectionListener {
private JSplitPane exportDetails;

private static JButton open;
private static JButton openLocal = new JButton("Open N5 Local");
private static JButton copyLink;
private static JButton refreshButton;
private static JButton useN5Link;
Expand Down Expand Up @@ -256,8 +264,6 @@ private JPanel topPanel(){
gridBagConstraints.gridy = 1;
userButtonsPanel.add(bottomRow, gridBagConstraints);



// buttonsPanel.add(questionMark);


Expand All @@ -283,12 +289,15 @@ private JPanel topPanel(){
JPanel topBar = new JPanel();
topBar.setPreferredSize(new Dimension(paneWidth, 100));
topBar.setLayout(new BorderLayout());
topBar.add(openLocal);
topBar.add(userButtonsPanel, BorderLayout.EAST);
topBar.add(timeFilter, BorderLayout.WEST);
topBar.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " User Options "));


refreshButton.addActionListener(this);
open.addActionListener(this);
openLocal.addActionListener(this);
copyLink.addActionListener(this);
questionMark.addActionListener(this);
useN5Link.addActionListener(this);
Expand Down Expand Up @@ -356,7 +365,29 @@ public void actionPerformed(ActionEvent e) {
new HelpExplanation().displayHelpMenu();
} else if (e.getSource().equals(useN5Link)) {
remoteFileSelection.setVisible(true);
} else if (e.getSource().equals(includeExampleExports)){
} else if (e.getSource().equals(openLocal)){
ArrayList<SimResultsLoader> filesToOpen = new ArrayList<>();
for(int row: exportListTable.getSelectedRows()){
String uri = n5ExportTableModel.getRowData(row).uri;
SimResultsLoader simResultsLoader = new SimResultsLoader(uri, n5ExportTableModel.getRowData(row).savedFileName);
filesToOpen.add(simResultsLoader);
}
SimResultsLoader.openLocalN5FS(filesToOpen);
// JFileChooser fileChooser = new JFileChooser();
// int r = fileChooser.showDialog(null, "Open");
// if (r == JFileChooser.APPROVE_OPTION){
// File file = fileChooser.getSelectedFile();
// N5FSReader n5FSReader = new N5FSReader(file.getPath());
// n5FSReader.list("/");
//
//
// SimCacheLoader<DoubleType, ?> simCacheLoader = SimCacheLoader.factoryDefault(n5FSReader, dataSetChosen);
// CachedCellImg<DoubleType, ?> cachedCellImg = simCacheLoader.createCachedCellImage();
// ImagePlus imagePlus = ImageJFunctions.wrap(cachedCellImg, dataSetChosen);
// imagePlus.show();
// }
}
else if (e.getSource().equals(includeExampleExports)){
if(includeExampleExports.isSelected()){
updateExampleExportsToTable();
return;
Expand Down

0 comments on commit 34964d6

Please sign in to comment.