diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java index 9eb0579..5e51007 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java @@ -19,12 +19,6 @@ public class ControlButtonsPanel extends JPanel implements ActionListener { private final JButton useN5Link; private final JButton questionMark; private final JButton openInMemory; - private final JCheckBox includeExampleExports; - private final JCheckBox todayInterval; - private final JCheckBox monthInterval; - private final JCheckBox yearlyInterval; - private final JCheckBox anyInterval; - private final JPanel timeFilter; private N5ExportTable n5ExportTable; private RemoteFileSelection remoteFileSelection; @@ -37,8 +31,6 @@ public ControlButtonsPanel(){ questionMark.setPreferredSize(new Dimension(20, 20)); openInMemory = new JButton("Open In Memory"); openInMemory.setSelected(false); - includeExampleExports = new JCheckBox("Show Example Exports"); - includeExampleExports.setSelected(!N5ImageHandler.exportedDataExists()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); @@ -72,38 +64,15 @@ public ControlButtonsPanel(){ // buttonsPanel.add(questionMark); - todayInterval = new JCheckBox("Past 24 Hours"); - monthInterval = new JCheckBox("Past Month"); - yearlyInterval = new JCheckBox("Past Year"); - anyInterval = new JCheckBox("Any Time"); - anyInterval.setSelected(true); - - ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(todayInterval); - buttonGroup.add(monthInterval); - buttonGroup.add(yearlyInterval); - buttonGroup.add(anyInterval); - - JPanel filters = new JPanel(); - filters.setLayout(new BorderLayout()); - timeFilter = new JPanel(new GridBagLayout()); - timeFilter.add(anyInterval); - timeFilter.add(todayInterval); - timeFilter.add(monthInterval); - timeFilter.add(yearlyInterval); -// timeFilter.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Time ")); - filters.add(timeFilter, BorderLayout.NORTH); - filters.add(includeExampleExports, BorderLayout.SOUTH); - Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); - filters.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Filters ")); + int paneWidth = 800; this.setPreferredSize(new Dimension(paneWidth, 100)); this.setLayout(new BorderLayout()); // topBar.add(openLocal); + Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); this.add(userButtonsPanel, BorderLayout.EAST); - this.add(filters, BorderLayout.WEST); this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " User Options ")); @@ -111,14 +80,10 @@ public ControlButtonsPanel(){ copyLink.addActionListener(this); questionMark.addActionListener(this); useN5Link.addActionListener(this); - includeExampleExports.addActionListener(this); // openLocal.addActionListener(this); openInMemory.addActionListener(this); - Enumeration b = buttonGroup.getElements(); - while (b.hasMoreElements()){ - b.nextElement().addActionListener(this); - } + openOrCancel.setEnabled(false); copyLink.setEnabled(false); @@ -144,34 +109,7 @@ public void actionPerformed(ActionEvent e) { new HelpExplanation().displayHelpMenu(); } else if (e.getSource().equals(useN5Link)) { remoteFileSelection.setVisible(true); - } else if (e.getSource().equals(includeExampleExports)){ - if(includeExampleExports.isSelected()){ - n5ExportTable.updateExampleExportsToTable(); - return; - } - n5ExportTable.updateTableData(); - } else if (e.getSource().equals(anyInterval) || e.getSource().equals(todayInterval) - || e.getSource().equals(monthInterval) || e.getSource().equals(yearlyInterval)) { - if(includeExampleExports.isSelected()){ - n5ExportTable.updateExampleExportsToTable(); - return; - } - n5ExportTable.updateTableData(); - } - } - - public LocalDateTime oldestTimeAllowed(){ - LocalDateTime pastTime = LocalDateTime.now(); - if (todayInterval.isSelected()){ - pastTime = pastTime.minusDays(1); - } else if (monthInterval.isSelected()) { - pastTime = pastTime.minusMonths(1); - } else if (yearlyInterval.isSelected()) { - pastTime = pastTime.minusYears(1); - } else { - pastTime = pastTime.minusYears(10); //Max date back is 10 years } - return pastTime; } public void allowCancel(boolean allow){ diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java new file mode 100644 index 0000000..bf2e7c5 --- /dev/null +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java @@ -0,0 +1,95 @@ +package org.vcell.N5.UI.Filters; + +import org.vcell.N5.N5ImageHandler; +import org.vcell.N5.UI.MainPanel; +import org.vcell.N5.UI.N5ExportTable; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EtchedBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.time.LocalDateTime; +import java.util.Enumeration; + + +public class TimeFilter extends JPanel implements ActionListener { + private final JCheckBox todayInterval; + private final JCheckBox monthInterval; + private final JCheckBox yearlyInterval; + private final JCheckBox anyInterval; + private final JPanel timeFilter; + private final JCheckBox includeExampleExports; + + private final N5ExportTable n5ExportTable; + + + public TimeFilter(){ + includeExampleExports = new JCheckBox("Show Example Exports"); + includeExampleExports.setSelected(!N5ImageHandler.exportedDataExists()); + n5ExportTable = MainPanel.n5ExportTable; + + todayInterval = new JCheckBox("Past 24 Hours"); + monthInterval = new JCheckBox("Past Month"); + yearlyInterval = new JCheckBox("Past Year"); + anyInterval = new JCheckBox("Any Time"); + anyInterval.setSelected(true); + + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(todayInterval); + buttonGroup.add(monthInterval); + buttonGroup.add(yearlyInterval); + buttonGroup.add(anyInterval); + + this.setLayout(new BorderLayout()); + timeFilter = new JPanel(new GridBagLayout()); + timeFilter.add(anyInterval); + timeFilter.add(todayInterval); + timeFilter.add(monthInterval); + timeFilter.add(yearlyInterval); +// timeFilter.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Time ")); + this.add(timeFilter, BorderLayout.NORTH); + this.add(includeExampleExports, BorderLayout.SOUTH); + Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); + this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Filters ")); + + Enumeration b = buttonGroup.getElements(); + while (b.hasMoreElements()){ + b.nextElement().addActionListener(this); + } + includeExampleExports.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(anyInterval) || e.getSource().equals(todayInterval) + || e.getSource().equals(monthInterval) || e.getSource().equals(yearlyInterval)) { + if(includeExampleExports.isSelected()){ + n5ExportTable.updateExampleExportsToTable(); + return; + } + n5ExportTable.updateTableData(); + } else if (e.getSource().equals(includeExampleExports)){ + if(includeExampleExports.isSelected()){ + n5ExportTable.updateExampleExportsToTable(); + return; + } + n5ExportTable.updateTableData(); + } + } + + public LocalDateTime oldestTimeAllowed(){ + LocalDateTime pastTime = LocalDateTime.now(); + if (todayInterval.isSelected()){ + pastTime = pastTime.minusDays(1); + } else if (monthInterval.isSelected()) { + pastTime = pastTime.minusMonths(1); + } else if (yearlyInterval.isSelected()) { + pastTime = pastTime.minusYears(1); + } else { + pastTime = pastTime.minusYears(10); //Max date back is 10 years + } + return pastTime; + } +} diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/MainPanel.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/MainPanel.java index a49f5b7..efeba55 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/MainPanel.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/MainPanel.java @@ -1,5 +1,7 @@ package org.vcell.N5.UI; +import org.vcell.N5.UI.Filters.TimeFilter; + import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; @@ -11,21 +13,26 @@ public class MainPanel { private final int paneWidth = 800; public final static ControlButtonsPanel controlButtonsPanel = new ControlButtonsPanel(); - public final N5ExportTable n5ExportTable = new N5ExportTable(); + public final static N5ExportTable n5ExportTable = new N5ExportTable(); public final ExportDetailsPanel exportDetailsPanel = new ExportDetailsPanel(); public final RemoteFileSelection remoteFileSelection = new RemoteFileSelection(); + public final TimeFilter timeFilter = new TimeFilter(); public MainPanel(){ JPanel parentPanel = new JPanel(); - n5ExportTable.initialize(controlButtonsPanel, exportDetailsPanel); + n5ExportTable.initialize(controlButtonsPanel, exportDetailsPanel, timeFilter); controlButtonsPanel.initialize(n5ExportTable, remoteFileSelection); + JPanel bottomPortion = new JPanel(new BorderLayout()); + bottomPortion.add(timeFilter, BorderLayout.NORTH); + bottomPortion.add(exportDetailsPanel, BorderLayout.SOUTH); + parentPanel.setLayout(new BorderLayout()); parentPanel.add(controlButtonsPanel, BorderLayout.NORTH); - JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, n5ExportTable, exportDetailsPanel); + JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, n5ExportTable, bottomPortion); jSplitPane.setContinuousLayout(true); parentPanel.add(jSplitPane, BorderLayout.CENTER); diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java index b75cf70..2b2c6b7 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java @@ -4,6 +4,7 @@ import org.scijava.log.Logger; import org.vcell.N5.ExportDataRepresentation; import org.vcell.N5.N5ImageHandler; +import org.vcell.N5.UI.Filters.TimeFilter; import org.vcell.N5.retrieving.SimLoadingListener; import org.vcell.N5.retrieving.SimResultsLoader; @@ -33,15 +34,18 @@ public class N5ExportTable extends JScrollPane implements ListSelectionListener, private ControlButtonsPanel controlPanel; private ExportDetailsPanel exportDetailsPanel; + private TimeFilter timeFilter; private final Logger logger = N5ImageHandler.getLogger(N5ExportTable.class); public N5ExportTable(){} - public void initialize(ControlButtonsPanel controlButtonsPanel, ExportDetailsPanel exportDetailsPanel){ + public void initialize(ControlButtonsPanel controlButtonsPanel, ExportDetailsPanel exportDetailsPanel, + TimeFilter timeFilter){ this.controlPanel = controlButtonsPanel; this.exportDetailsPanel = exportDetailsPanel; + this.timeFilter = timeFilter; N5ImageHandler.loadingManager.addSimLoadingListener(this); n5ExportTableModel = new N5ExportTableModel(); exportListTable = new JTable(n5ExportTableModel); @@ -81,12 +85,12 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole automaticRefresh(); } - void updateTableData(){ + public void updateTableData(){ // when initializing it is null if (controlPanel == null){ updateTableData(LocalDateTime.now().minusYears(10)); } else { - updateTableData(controlPanel.oldestTimeAllowed()); + updateTableData(timeFilter.oldestTimeAllowed()); } } @@ -111,12 +115,12 @@ void updateTableData(LocalDateTime oldestTimeAllowed){ } } - void updateExampleExportsToTable(){ + public void updateExampleExportsToTable(){ // when initializing it is null if (controlPanel == null){ updateExampleExportsToTable(LocalDateTime.now().minusYears(10)); } else { - updateExampleExportsToTable(controlPanel.oldestTimeAllowed()); + updateExampleExportsToTable(timeFilter.oldestTimeAllowed()); } } @@ -155,7 +159,7 @@ private void automaticRefresh(){ || !formatExportData.simulationDataMap.containsKey(mostRecentTableEntry.jobID))){ break; } - isUpdated = n5ExportTableModel.prependRowData(formatExportData.simulationDataMap.get(currentJob), controlPanel.oldestTimeAllowed()); + isUpdated = n5ExportTableModel.prependRowData(formatExportData.simulationDataMap.get(currentJob), timeFilter.oldestTimeAllowed()); } if(isUpdated){ n5ExportTableModel.fireTableDataChanged();