Skip to content

Commit

Permalink
Update Main Panel GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
AvocadoMoon committed Nov 1, 2024
1 parent 06af568 commit 58487a4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import java.awt.*;

public class AdvancedFeatures extends JPanel {
public final JCheckBox inMemory;
public final JCheckBox dataReduction;
public final JButton openInMemory;
public final JButton copyLink;
public final JButton useN5Link;

Expand All @@ -16,21 +15,21 @@ public AdvancedFeatures(){
Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);


inMemory = new JCheckBox("Open In Memory");
dataReduction = new JCheckBox("Run Measurement Script");
openInMemory = new JButton("Open In Memory");
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.add(dataReduction);
// checkBoxPanel.add(openInMemory);

JPanel buttonPanel = new JPanel();
copyLink = new JButton("Copy Link");
useN5Link = new JButton("Use N5 Link");
buttonPanel.add(copyLink);
buttonPanel.add(useN5Link);
buttonPanel.add(openInMemory);

setLayout(new BorderLayout());
add(buttonPanel, BorderLayout.NORTH);
add(checkBoxPanel, BorderLayout.SOUTH);
// setLayout(new BorderLayout());
// add(buttonPanel, BorderLayout.NORTH);
// add(checkBoxPanel, BorderLayout.SOUTH);
add(buttonPanel);
this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Advanced Features "));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class ControlButtonsPanel extends JPanel implements ActionListener {

private static JButton openOrCancel;
private JButton openInMemory;
private final JButton dataReduction;
// private final JButton openLocal = new JButton("Open N5 Local");
private final JButton questionMark;

Expand All @@ -31,7 +31,7 @@ public ControlButtonsPanel(){
displayAdvancedFeatures = new JCheckBox("Advanced Features");

openOrCancel = new JButton("Open Virtually");
openInMemory = new JButton("Open In Memory");
dataReduction = new JButton("Run Measurement Script");
questionMark = new JButton("?");
questionMark.setPreferredSize(new Dimension(20, 20));

Expand All @@ -43,16 +43,16 @@ public ControlButtonsPanel(){
topRow.add(openOrCancel, gridBagConstraints);

gridBagConstraints.gridx = 1;
topRow.add(openInMemory, gridBagConstraints);
topRow.add(dataReduction, gridBagConstraints);


gridBagConstraints.gridx = 2;
topRow.add(questionMark);

JPanel bottomRow = new JPanel(new GridBagLayout());
bottomRow.add(includeExampleExports);
gridBagConstraints.gridx = 1;
bottomRow.add(displayAdvancedFeatures, gridBagConstraints);

gridBagConstraints.gridx = 2;
bottomRow.add(questionMark);

JPanel userButtonsPanel = new JPanel(new GridBagLayout());
gridBagConstraints.gridx = 0;
Expand Down Expand Up @@ -86,11 +86,12 @@ public ControlButtonsPanel(){
// openLocal.addActionListener(this);
includeExampleExports.addActionListener(this);
displayAdvancedFeatures.addActionListener(this);
openInMemory.addActionListener(this);
dataReduction.addActionListener(this);
advancedFeatures.openInMemory.addActionListener(this);


openOrCancel.setEnabled(false);
openInMemory.setEnabled(false);
dataReduction.setEnabled(false);
advancedFeatures.copyLink.setEnabled(false);
}

Expand All @@ -101,11 +102,13 @@ public void initialize(N5ExportTable n5ExportTable, RemoteFileSelection remoteFi

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(openOrCancel) || e.getSource().equals(openInMemory)){
boolean inMemory = e.getSource().equals(advancedFeatures.openInMemory);
boolean performDataReduction = e.getSource().equals(dataReduction);
if(e.getSource().equals(openOrCancel) || inMemory || performDataReduction){
if (openOrCancel.getText().equals("Cancel")){
n5ExportTable.removeFromLoadingRows();
} else {
n5ExportTable.openSelectedRows(e.getSource().equals(openInMemory));
n5ExportTable.openSelectedRows(inMemory, performDataReduction);
}
} else if (e.getSource().equals(advancedFeatures.copyLink)) {
n5ExportTable.copySelectedRowLink();
Expand All @@ -126,7 +129,8 @@ public void allowCancel(boolean allow){
advancedFeatures.copyLink.setEnabled(true);
advancedFeatures.useN5Link.setEnabled(true);
remoteFileSelection.submitS3Info.setEnabled(true);
openInMemory.setEnabled(!allow);
dataReduction.setEnabled(!allow);
advancedFeatures.openInMemory.setEnabled(!allow);
if (allow){
openOrCancel.setText("Cancel");
} else {
Expand All @@ -139,7 +143,8 @@ public void enableRowContextDependentButtons(boolean enable){
if (allowButtons){
openOrCancel.setEnabled(enable);
advancedFeatures.copyLink.setEnabled(enable);
openInMemory.setEnabled(enable);
dataReduction.setEnabled(enable);
advancedFeatures.openInMemory.setEnabled(enable);
}
}

Expand All @@ -148,7 +153,8 @@ public void enableCriticalButtons(boolean enable){
openOrCancel.setEnabled(enable);
advancedFeatures.copyLink.setEnabled(enable);
remoteFileSelection.submitS3Info.setEnabled(enable);
openInMemory.setEnabled(enable);
dataReduction.setEnabled(enable);
advancedFeatures.openInMemory.setEnabled(enable);
allowButtons = enable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.util.Enumeration;

public class MainPanel {
private static JDialog exportTableDialog;
private final int paneWidth = 800;
private static JFrame exportTableDialog;

public final static ControlButtonsPanel controlButtonsPanel = new ControlButtonsPanel();
public final static N5ExportTable n5ExportTable = new N5ExportTable();
Expand All @@ -23,32 +23,30 @@ public class MainPanel {
public final static SearchBar searchBar = new SearchBar();

public MainPanel(){
JPanel parentPanel = new JPanel();


n5ExportTable.initialize(controlButtonsPanel, exportDetailsPanel, timeFilter);
controlButtonsPanel.initialize(n5ExportTable, remoteFileSelection);

JPanel contentPanel = new JPanel(new BorderLayout());
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.add(controlButtonsPanel, BorderLayout.SOUTH);

parentPanel.setLayout(new BorderLayout());
parentPanel.add(northPanel, BorderLayout.NORTH);
JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, n5ExportTable, exportDetailsPanel);
jSplitPane.setContinuousLayout(true);
parentPanel.add(jSplitPane, BorderLayout.CENTER);

JPanel filters = new JPanel(new BorderLayout());
Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
filters.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Filters "));
filters.add(timeFilter, BorderLayout.NORTH);
filters.add(searchBar, BorderLayout.SOUTH);
parentPanel.add(filters, BorderLayout.SOUTH);

parentPanel.setPreferredSize(new Dimension(paneWidth, 750));
JOptionPane pane = new JOptionPane(parentPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[]{"Close"});
exportTableDialog = pane.createDialog("VCell Exports");
exportTableDialog.setModal(false);
contentPanel.add(northPanel, BorderLayout.NORTH);
contentPanel.add(jSplitPane, BorderLayout.CENTER);
contentPanel.add(filters, BorderLayout.SOUTH);
contentPanel.setBorder(new EmptyBorder(15, 12, 15, 12));

exportTableDialog = new JFrame("VCell Exports");
exportTableDialog.add(contentPanel);
exportTableDialog.pack();
exportTableDialog.setResizable(true);
exportTableDialog.setVisible(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,16 @@ private void automaticRefresh(){
refreshTableThread.start();
}

public void openSelectedRows(boolean openInMemory){
public void openSelectedRows(boolean openInMemory, boolean performDataReduction){
ArrayList<SimResultsLoader> filesToOpen = new ArrayList<>();
for(int row: exportListTable.getSelectedRows()){
String uri = n5ExportTableModel.getRowData(row).uri;
ExportDataRepresentation.SimulationExportDataRepresentation rowData = n5ExportTableModel.getRowData(row);
SimResultsLoader simResultsLoader = new SimResultsLoader(uri, rowData.savedFileName, row, rowData.jobID);
filesToOpen.add(simResultsLoader);
}
AdvancedFeatures advancedFeatures = MainPanel.controlButtonsPanel.advancedFeatures;
N5ImageHandler.loadingManager.openN5FileDataset(filesToOpen, openInMemory,
advancedFeatures.dataReduction.isSelected());
performDataReduction);
}

public void copySelectedRowLink(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ public String getS3URL(){
@Override
public void actionPerformed(ActionEvent e) {
SimResultsLoader simResultsLoader = new SimResultsLoader(getS3URL(), "", -1, "");
AdvancedFeatures advancedFeatures = MainPanel.controlButtonsPanel.advancedFeatures;
N5ImageHandler.loadingManager.openN5FileDataset(new ArrayList<SimResultsLoader>(){{add(simResultsLoader);}},
advancedFeatures.inMemory.isSelected(),
advancedFeatures.dataReduction.isSelected());
false,
false);
this.setVisible(false);
}
}

0 comments on commit 58487a4

Please sign in to comment.