Skip to content

Commit

Permalink
Rewrite GUI
Browse files Browse the repository at this point in the history
Rewrote the GUI for ImageJ plugin.
  • Loading branch information
AvocadoMoon committed Nov 22, 2023
1 parent a51c1af commit 76b5c6f
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 148 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/vcell/vcellfiji/N5ImageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -144,13 +144,13 @@ protected void process(List<ArrayList<String>> 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);
Expand Down
134 changes: 134 additions & 0 deletions src/main/java/org/vcell/vcellfiji/UI/N5ViewerGUI.java
Original file line number Diff line number Diff line change
@@ -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<String> 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<String> arrayList){
DefaultListModel<String> 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
}
}

76 changes: 0 additions & 76 deletions src/main/java/org/vcell/vcellfiji/UI/VCellGUI.form

This file was deleted.

68 changes: 0 additions & 68 deletions src/main/java/org/vcell/vcellfiji/UI/VCellGUI.java

This file was deleted.

0 comments on commit 76b5c6f

Please sign in to comment.