From 14c503a4aead168cef90f37558824d52c25b223a Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Mon, 20 Nov 2023 07:34:20 -0500 Subject: [PATCH 1/6] Opt Into Memory The user now has to opt into opening the image in memory. --- pom.xml | 7 ------- src/main/java/org/vcell/vcellfiji/N5ImageHandler.java | 8 ++++---- src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form | 4 ++-- src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index f496153..852be82 100644 --- a/pom.xml +++ b/pom.xml @@ -181,13 +181,6 @@ - - - - - - - org.jsoup jsoup diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index 0d2be9f..93711ce 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -189,13 +189,13 @@ public ImagePlus getImgPlusFromN5File(String selectedDataset, N5Reader n5Reader) private void displayN5Dataset(ImagePlus imagePlus){ - if (this.vGui.openVirtualCheckBox.isSelected()){ - imagePlus.show(); - } - else{ + if (this.vGui.openMemoryCheckBox.isSelected()){ ImagePlus memoryImagePlus = new Duplicator().run(imagePlus); memoryImagePlus.show(); } + else{ + imagePlus.show(); + } } public N5AmazonS3Reader getN5AmazonS3Reader(){ diff --git a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form index 9a21987..b64f312 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form +++ b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form @@ -62,13 +62,13 @@ - + - + diff --git a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java index ac40072..a1cfea6 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java +++ b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java @@ -15,7 +15,7 @@ public class VCellGUI extends JFrame { private JScrollPane resultsScrollPane; public JButton remoteFiles; public JButton okayButton; - public JCheckBox openVirtualCheckBox; + public JCheckBox openMemoryCheckBox; public RemoteFileSelection remoteFileSelection; From a51c1afdb296926c96f8563a9f3c6dff093c0cea Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Mon, 20 Nov 2023 12:18:16 -0500 Subject: [PATCH 2/6] Log Exceptions Exceptions now get handled gracefully and put into ImageJ's default logger. --- .../org/vcell/vcellfiji/N5ImageHandler.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index 93711ce..702c55e 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -18,6 +18,8 @@ import org.janelia.saalfeldlab.n5.imglib2.N5Utils; import org.janelia.saalfeldlab.n5.s3.N5AmazonS3Reader; import org.scijava.command.Command; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.janelia.saalfeldlab.n5.*; import org.vcell.vcellfiji.UI.VCellGUI; @@ -48,6 +50,8 @@ public class N5ImageHandler implements Command, ActionListener { private AmazonS3 s3Client; private String bucketName; private String s3ObjectKey; + @Parameter + private LogService logService; private SwingWorker, ArrayList> n5DatasetListUpdater; @Override public void actionPerformed(ActionEvent e) { @@ -66,6 +70,12 @@ protected ArrayList doInBackground() throws Exception { @Override protected void done() { enableCriticalButtons(true); + try{ + get(); + } + catch (Exception exception){ + logService.error(exception); + } } @Override @@ -80,18 +90,19 @@ else if (e.getSource() == vGui.okayButton) { SwingWorker swingWorker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { - try{ - loadN5Dataset(vGui.datasetList.getSelectedValue()); - return null; - } - catch (IOException ex){ - return null; - } + loadN5Dataset(vGui.datasetList.getSelectedValue()); + return null; } @Override protected void done() { enableCriticalButtons(true); + try{ + get(); + } + catch (Exception exception){ + logService.error(exception); + } } }; swingWorker.execute(); @@ -112,6 +123,12 @@ protected ArrayList doInBackground() throws Exception { @Override protected void done() { enableCriticalButtons(true); + try{ + get(); + } + catch (Exception exception){ + logService.error(exception); + } } @Override @@ -120,6 +137,7 @@ protected void process(List> chunks) { } }; n5DatasetListUpdater.execute(); + n5DatasetListUpdater.getState(); } } From 76b5c6f28067556321fe89ef93daacd92ac719a5 Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Wed, 22 Nov 2023 16:25:40 -0500 Subject: [PATCH 3/6] Rewrite GUI Rewrote the GUI for ImageJ plugin. --- .../org/vcell/vcellfiji/N5ImageHandler.java | 8 +- .../org/vcell/vcellfiji/UI/N5ViewerGUI.java | 134 ++++++++++++++++++ .../java/org/vcell/vcellfiji/UI/VCellGUI.form | 76 ---------- .../java/org/vcell/vcellfiji/UI/VCellGUI.java | 68 --------- 4 files changed, 138 insertions(+), 148 deletions(-) create mode 100644 src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java delete mode 100644 src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form delete mode 100644 src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index 702c55e..38e2314 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -22,7 +22,7 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.janelia.saalfeldlab.n5.*; -import org.vcell.vcellfiji.UI.VCellGUI; +import org.vcell.vcellfiji.UI.N5ViewerGUI; import javax.swing.*; import java.awt.event.ActionEvent; @@ -45,7 +45,7 @@ @Plugin(type = Command.class, menuPath = "Plugins>VCell>N5 Dataset Viewer") public class N5ImageHandler implements Command, ActionListener { - private VCellGUI vGui; + private N5ViewerGUI vGui; private File selectedLocalFile; private AmazonS3 s3Client; private String bucketName; @@ -144,13 +144,13 @@ protected void process(List> chunks) { private void enableCriticalButtons(boolean enable) { vGui.remoteFileSelection.submitS3Info.setEnabled(enable); vGui.okayButton.setEnabled(enable); - vGui.LocalFiles.setEnabled(enable); + vGui.localFiles.setEnabled(enable); vGui.remoteFiles.setEnabled(enable); } @Override public void run() { - this.vGui = new VCellGUI(); + this.vGui = new N5ViewerGUI(); this.vGui.localFileDialog.addActionListener(this); this.vGui.okayButton.addActionListener(this); diff --git a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java new file mode 100644 index 0000000..0ae0bc0 --- /dev/null +++ b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java @@ -0,0 +1,134 @@ +package org.vcell.vcellfiji.UI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class N5ViewerGUI extends JFrame { + public JButton localFiles; + public JPanel mainPanel; + private JFrame thisJFrame; + public JFileChooser localFileDialog; + private JToolBar menuBar; + public JList datasetList; + private JScrollPane resultsScrollPane; + public JButton remoteFiles; + public JButton okayButton; + public JCheckBox openMemoryCheckBox; + private JPanel datasetListPanel; + private JLabel datasetLabel; + private JLabel openInMemory; + + public RemoteFileSelection remoteFileSelection; + + public N5ViewerGUI() { + thisJFrame = this; + localFileDialog = new JFileChooser(); + mainPanel = new JPanel(); + datasetListPanel = new JPanel(); + mainPanel.setLayout(new GridBagLayout()); + datasetListPanel.setLayout(new GridBagLayout()); + datasetList = new JList<>(); + datasetList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + GridBagConstraints mainPanelConstraints = new GridBagConstraints(); + mainPanelConstraints.gridx = 0; + mainPanelConstraints.gridy = 0; + localFiles = new JButton(); + localFiles.setText("Local Files"); + mainPanel.add(localFiles, mainPanelConstraints); + + mainPanelConstraints.gridy = 0; + mainPanelConstraints.gridx = 1; + remoteFiles = new JButton(); + remoteFiles.setText("Remote Files"); + mainPanel.add(remoteFiles, mainPanelConstraints); + + mainPanelConstraints.gridy = 0; + mainPanelConstraints.gridx = 3; + openInMemory = new JLabel(); + openInMemory.setText("Open Image in Memory"); + mainPanel.add(openInMemory, mainPanelConstraints); + + mainPanelConstraints.gridy = 0; + mainPanelConstraints.gridx = 4; + openMemoryCheckBox = new JCheckBox(); + mainPanel.add(openMemoryCheckBox, mainPanelConstraints); + + + GridBagConstraints datasetConstraints = new GridBagConstraints(); + datasetConstraints.gridx = 0; + datasetConstraints.gridy = 0; + datasetLabel = new JLabel(); + datasetLabel.setText("Dataset List"); + datasetListPanel.add(datasetLabel, datasetConstraints); + + datasetConstraints.gridx = 0; + datasetConstraints.gridy = 1; + datasetConstraints.gridwidth = 1; + datasetConstraints.ipady = 70; + datasetConstraints.ipadx = 100; + resultsScrollPane = new JScrollPane(datasetList); + datasetListPanel.add(resultsScrollPane, datasetConstraints); + + mainPanelConstraints.gridwidth = 4; + mainPanelConstraints.gridy = 1; + mainPanelConstraints.ipady = 40; + mainPanelConstraints.gridx = 0; + mainPanelConstraints.fill = GridBagConstraints.BOTH; + mainPanelConstraints.anchor = GridBagConstraints.CENTER; + mainPanel.add(datasetListPanel, mainPanelConstraints); + + + mainPanelConstraints = new GridBagConstraints(); + mainPanelConstraints.gridy = 2; + mainPanelConstraints.gridx = 0; + mainPanelConstraints.gridwidth = 4; + okayButton = new JButton(); + okayButton.setText("Open Dataset"); + mainPanel.add(okayButton, mainPanelConstraints); + + + localFiles.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + localFileDialog.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + localFileDialog.showOpenDialog(thisJFrame); +// System.out.print(localFileDialog.getSelectedFile()); + } + }); + + remoteFiles.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + remoteFileSelection.setVisible(true); + } + }); + + // listener for if credentials or endpoint is used + + this.setTitle("VCell Manager"); + this.setContentPane(this.mainPanel); + this.setSize(500, 400); + this.setVisible(true); + this.remoteFileSelection = new RemoteFileSelection(); + + + } + + public void updateDatasetList(ArrayList arrayList){ + DefaultListModel listModel = new DefaultListModel<>(); + for (String s: arrayList){ + listModel.addElement(s); + } + this.datasetList.setModel(listModel); + this.datasetList.updateUI(); + } + + private void createUIComponents() { + // TODO: place custom component creation code here + } +} + diff --git a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form deleted file mode 100644 index b64f312..0000000 --- a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form +++ /dev/null @@ -1,76 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java b/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java deleted file mode 100644 index a1cfea6..0000000 --- a/src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.vcell.vcellfiji.UI; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; - -public class VCellGUI extends JFrame { - public JButton LocalFiles; - public JPanel mainPanel; - private final JFrame jFrame; - public JFileChooser localFileDialog; - private JToolBar menuBar; - public JList datasetList; - private JScrollPane resultsScrollPane; - public JButton remoteFiles; - public JButton okayButton; - public JCheckBox openMemoryCheckBox; - - public RemoteFileSelection remoteFileSelection; - - public VCellGUI() { - jFrame = this; - localFileDialog = new JFileChooser(); - - - this.setTitle("VCell Manager"); - this.setContentPane(this.mainPanel); - this.setSize(500, 400); - this.setVisible(true); - this.remoteFileSelection = new RemoteFileSelection(); - - - LocalFiles.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - localFileDialog.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - localFileDialog.showOpenDialog(jFrame); -// System.out.print(localFileDialog.getSelectedFile()); - } - }); - - remoteFiles.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - remoteFileSelection.setVisible(true); - } - }); - - // listener for if credentials or endpoint is used - - - - } - - public void updateDatasetList(ArrayList arrayList){ - DefaultListModel listModel = new DefaultListModel<>(); - for (String s: arrayList){ - listModel.addElement(s); - } - this.datasetList.setModel(listModel); - this.datasetList.updateUI(); - } - - private void createUIComponents() { - // TODO: place custom component creation code here - } -} From 6fe7e7d0fb710a42292d2904a78f5a353ddaffb1 Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Tue, 5 Dec 2023 10:12:45 -0500 Subject: [PATCH 4/6] Remote file window child of main JFrame Before the two where separate JFrame's which could spell trouble when more instances are had and other things. So this fixes that issue by making it a JDialog. --- src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java | 2 +- .../java/org/vcell/vcellfiji/UI/RemoteFileSelection.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java index 0ae0bc0..5b2e4c8 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java +++ b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java @@ -113,7 +113,7 @@ public void actionPerformed(ActionEvent e) { this.setContentPane(this.mainPanel); this.setSize(500, 400); this.setVisible(true); - this.remoteFileSelection = new RemoteFileSelection(); + this.remoteFileSelection = new RemoteFileSelection(thisJFrame); } diff --git a/src/main/java/org/vcell/vcellfiji/UI/RemoteFileSelection.java b/src/main/java/org/vcell/vcellfiji/UI/RemoteFileSelection.java index bcd6db0..d60b309 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/RemoteFileSelection.java +++ b/src/main/java/org/vcell/vcellfiji/UI/RemoteFileSelection.java @@ -5,7 +5,7 @@ import java.awt.event.ActionListener; import java.util.HashMap; -public class RemoteFileSelection extends JFrame{ +public class RemoteFileSelection extends JDialog{ private JPanel mainPanel; private JTextField linkTextField; private JTextField s3AccessKeyTextField; @@ -19,7 +19,8 @@ public class RemoteFileSelection extends JFrame{ private JPanel credentialsPanel; private JPanel endpointPanel; - public RemoteFileSelection(){ + public RemoteFileSelection(JFrame parentFrame){ + super(parentFrame, true); this.setTitle("Remote File Selection"); this.setContentPane(this.mainPanel); this.setSize(500, 350); From fb5cc805352af2609ccf62d901d84b2944971d5e Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Wed, 13 Dec 2023 18:13:07 -0500 Subject: [PATCH 5/6] Fix Export Bug and Automatically Close JDialog Fix the bug that raised a null error whenever an export did not go through, and made the JDialog automatically close whenever the user opens a remote file making for a smoother experience. --- src/main/java/org/vcell/vcellfiji/N5ImageHandler.java | 5 ++++- src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index 38e2314..c3a49fe 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -71,7 +71,9 @@ protected ArrayList doInBackground() throws Exception { protected void done() { enableCriticalButtons(true); try{ - get(); + if(vGui.jFileChooserResult == JFileChooser.APPROVE_OPTION){ + get(); + } } catch (Exception exception){ logService.error(exception); @@ -125,6 +127,7 @@ protected void done() { enableCriticalButtons(true); try{ get(); + vGui.remoteFileSelection.dispose(); } catch (Exception exception){ logService.error(exception); diff --git a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java index 5b2e4c8..5bedce4 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java +++ b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java @@ -20,6 +20,7 @@ public class N5ViewerGUI extends JFrame { private JPanel datasetListPanel; private JLabel datasetLabel; private JLabel openInMemory; + public int jFileChooserResult; public RemoteFileSelection remoteFileSelection; @@ -95,7 +96,7 @@ public N5ViewerGUI() { @Override public void actionPerformed(ActionEvent e) { localFileDialog.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - localFileDialog.showOpenDialog(thisJFrame); + jFileChooserResult = localFileDialog.showOpenDialog(thisJFrame); // System.out.print(localFileDialog.getSelectedFile()); } }); From 5c4b4393b1cd4338367f02cec01323ada9bb0d5a Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Thu, 14 Dec 2023 15:47:29 -0500 Subject: [PATCH 6/6] Open Most Recent Add the ability to open the most recent N5 file that gets exported. --- .../org/vcell/vcellfiji/N5ImageHandler.java | 79 ++++++++++++++++++- .../org/vcell/vcellfiji/UI/N5ViewerGUI.java | 38 +++++---- 2 files changed, 97 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index c3a49fe..2ed0d44 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -8,6 +8,10 @@ import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.AmazonS3URI; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.internal.LinkedTreeMap; +import com.google.gson.reflect.TypeToken; import ij.ImagePlus; import ij.plugin.Duplicator; import net.imglib2.cache.img.CachedCellImg; @@ -28,12 +32,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.io.FileReader; import java.io.IOException; +import java.lang.reflect.Type; import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; +import java.util.*; /* @@ -141,6 +144,49 @@ protected void process(List> chunks) { }; n5DatasetListUpdater.execute(); n5DatasetListUpdater.getState(); + } else if (e.getSource() == vGui.mostRecentExport) { + n5DatasetListUpdater= new SwingWorker, ArrayList>() { + @Override + protected ArrayList doInBackground(){ + HashMap jsonData = getJsonData(); + if (jsonData != null){ + List set = (ArrayList) jsonData.get("jobIDs"); + LinkedTreeMap lastElement = null; + for(int i = set.size() - 1; i > -1; i--){ + lastElement = (LinkedTreeMap) jsonData.get(set.get(i)); + if(lastElement != null && lastElement.get("format").equalsIgnoreCase("n5")){ + break; + } + lastElement = null; + } + if(lastElement != null){ + String url = lastElement.get("uri"); + createS3Client(url); + ArrayList list = getS3N5DatasetList(); + publish(list); + } + } + return null; + } + + @Override + protected void done() { + enableCriticalButtons(true); + try{ + get(); + } + catch (Exception exception){ + logService.error(exception); + } + } + + @Override + protected void process(List> chunks) { + displayN5Results(chunks.get(0)); + } + }; + n5DatasetListUpdater.execute(); + n5DatasetListUpdater.getState(); } } @@ -149,6 +195,7 @@ private void enableCriticalButtons(boolean enable) { vGui.okayButton.setEnabled(enable); vGui.localFiles.setEnabled(enable); vGui.remoteFiles.setEnabled(enable); + vGui.mostRecentExport.setEnabled(enable); } @Override @@ -159,6 +206,7 @@ public void run() { this.vGui.okayButton.addActionListener(this); this.vGui.remoteFileSelection.submitS3Info.addActionListener(this); + this.vGui.mostRecentExport.addActionListener(this); } public ArrayList getN5DatasetList(){ @@ -248,6 +296,11 @@ public void loadN5Dataset(String selectedDataset) throws IOException { } //When creating client's try to make one for an Amazon link, otherwise use our custom url scheme + + public void createS3Client(String url){ + createS3Client(url, null, null); + } + public void createS3Client(String url, HashMap credentials, HashMap endpoint){ AmazonS3ClientBuilder s3ClientBuilder = AmazonS3ClientBuilder.standard(); URI uri = URI.create(url); @@ -317,4 +370,22 @@ public static void main(String[] args) { N5ImageHandler n5ImageHandler = new N5ImageHandler(); n5ImageHandler.run(); } + + public HashMap getJsonData(){ + try{ + File jsonFile = new File(System.getProperty("user.home") + "/.vcell", "exportMetaData.json"); + if (jsonFile.exists() && jsonFile.length() != 0){ + HashMap jsonHashMap; + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + Type type = new TypeToken>() {}.getType(); + jsonHashMap = gson.fromJson(new FileReader(jsonFile.getAbsolutePath()), type); + return jsonHashMap; + } + return null; + } + catch (Exception e){ + logService.error("Failed to read export metadata JSON:", e); + return null; + } + } } diff --git a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java index 5bedce4..fbfab52 100644 --- a/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java +++ b/src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java @@ -6,7 +6,7 @@ import java.awt.event.ActionListener; import java.util.ArrayList; -public class N5ViewerGUI extends JFrame { +public class N5ViewerGUI extends JFrame implements ActionListener { public JButton localFiles; public JPanel mainPanel; private JFrame thisJFrame; @@ -22,6 +22,8 @@ public class N5ViewerGUI extends JFrame { private JLabel openInMemory; public int jFileChooserResult; + public JButton mostRecentExport; + public RemoteFileSelection remoteFileSelection; public N5ViewerGUI() { @@ -47,6 +49,12 @@ public N5ViewerGUI() { remoteFiles.setText("Remote Files"); mainPanel.add(remoteFiles, mainPanelConstraints); + mainPanelConstraints.gridy = 0; + mainPanelConstraints.gridx = 2; + mostRecentExport = new JButton(); + mostRecentExport.setText("Recent Export"); + mainPanel.add(mostRecentExport, mainPanelConstraints); + mainPanelConstraints.gridy = 0; mainPanelConstraints.gridx = 3; openInMemory = new JLabel(); @@ -92,27 +100,15 @@ public N5ViewerGUI() { mainPanel.add(okayButton, mainPanelConstraints); - localFiles.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - localFileDialog.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - jFileChooserResult = localFileDialog.showOpenDialog(thisJFrame); -// System.out.print(localFileDialog.getSelectedFile()); - } - }); + localFiles.addActionListener(this); - remoteFiles.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - remoteFileSelection.setVisible(true); - } - }); + remoteFiles.addActionListener(this); // listener for if credentials or endpoint is used this.setTitle("VCell Manager"); this.setContentPane(this.mainPanel); - this.setSize(500, 400); + this.setSize(600, 400); this.setVisible(true); this.remoteFileSelection = new RemoteFileSelection(thisJFrame); @@ -131,5 +127,15 @@ public void updateDatasetList(ArrayList arrayList){ private void createUIComponents() { // TODO: place custom component creation code here } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == localFiles){ + localFileDialog.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + jFileChooserResult = localFileDialog.showOpenDialog(thisJFrame); + } else if (e.getSource() == remoteFiles) { + remoteFileSelection.setVisible(true); + } + } }