Skip to content

Commit

Permalink
Merge pull request #47 from virtualcell/ann-quick-fix
Browse files Browse the repository at this point in the history
Ann quick fix
  • Loading branch information
AvocadoMoon authored Sep 16, 2024
2 parents 0b0fc24 + 2b07e1e commit d583d2f
Show file tree
Hide file tree
Showing 2 changed files with 51 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(true);
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.getSelectedFile();
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 final 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 Down Expand Up @@ -287,6 +293,7 @@ private JPanel topPanel(){
topBar.add(timeFilter, BorderLayout.WEST);
topBar.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " User Options "));


refreshButton.addActionListener(this);
open.addActionListener(this);
copyLink.addActionListener(this);
Expand Down Expand Up @@ -356,7 +363,16 @@ 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)){ // This button is not displayed to the end user
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);
}
else if (e.getSource().equals(includeExampleExports)){
if(includeExampleExports.isSelected()){
updateExampleExportsToTable();
return;
Expand Down

0 comments on commit d583d2f

Please sign in to comment.