Skip to content

Commit

Permalink
Merge pull request #1226 from virtualcell/dan-export-monitor2
Browse files Browse the repository at this point in the history
Dan export monitor2
  • Loading branch information
danv61 committed Apr 23, 2024
2 parents 3fc47b2 + f9cdb71 commit c328651
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2522,9 +2522,9 @@ public static void downloadExportedData(final Component requester, final UserPre
if (exportsRecord.contains(evt.getJobID() + "")) {
return;
}
// if (evt.getLocation().toLowerCase().endsWith("." + N5Specs.n5Suffix)){
// return;
// }
if (evt.getLocation().toLowerCase().endsWith("." + N5Specs.n5Suffix)){
return;
}
AsynchClientTask task1 = new AsynchClientTask("Retrieving data from '" + evt.getLocation() + "'",
AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ protected ArrayList<TableData> computeData() {
}
}

if(tableDataRow.link != null && tableDataRow.link.contains(prefix)) {
String dataSetName = tableDataRow.link.substring(tableDataRow.link.lastIndexOf(prefix) + prefix.length());
if (dataSetName.toLowerCase().contains(lowerCaseSearchText)) {
if (!newData.contains(tableDataRow)) {
newData.add(tableDataRow);
// continue;
}
if(tableDataRow.link != null && tableDataRow.link.toLowerCase().contains(lowerCaseSearchText)) {
if (!newData.contains(tableDataRow)) {
newData.add(tableDataRow);
// continue;
}
}
if(tableDataRow.name != null && tableDataRow.name.toLowerCase().contains(lowerCaseSearchText)) {
if(!newData.contains(tableDataRow)) {
newData.add(tableDataRow);
continue;
}
}
// TODO: we could also iterate through the list of parameters
Expand Down Expand Up @@ -175,6 +178,7 @@ public static class TableData {
public String dateExported = null;
public String format = null;
public String link = null;
public String name = null; // user given name for the saved dataset
public String bioModelName = null;
public String timeSlice = null;
public String appName = null;
Expand All @@ -184,14 +188,15 @@ public static class TableData {
public boolean nonSpatial;
public String applicationType = null;

public TableData(String jobID, String simID, String dateExported, String format, String link,
public TableData(String jobID, String simID, String dateExported, String format, String link, String name,
String bioModelName, String timeSlice, String appName, String simName, String variables,
ArrayList<String> differentParameterValues, boolean nonSpatial, String applicationType){
this.jobID = jobID;
this.simID = simID;
this.dateExported = dateExported;
this.format = format;
this.link = link;
this.name = name;
this.bioModelName = bioModelName;
this.timeSlice = timeSlice;
this.appName = appName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ExportedDataViewer extends DocumentEditorSubPanel implements Action

private final static Logger lg = LogManager.getLogger(ExportedDataViewer.class);

public ExportedDataViewer() {
public ExportedDataViewer() { // =============== middle panel ( with the table, Search sub-panel and Copy / Delete )
int tableHeight = 300;
int tableWidth = 400;

Expand Down Expand Up @@ -102,7 +102,6 @@ public Component getTableCellRendererComponent(JTable table, Object value,
setIcon(VCellIcons.appRbmNonspIcon);
break;
}
//setText("");
// setToolTipText(application.getDescription());
setHorizontalTextPosition(SwingConstants.RIGHT);
}
Expand All @@ -116,8 +115,9 @@ public Component getTableCellRendererComponent(JTable table, Object value,
JPanel searchPane = new JPanel();
searchPane.setLayout(new GridBagLayout());

copyButton = new JButton("Copy Export URI");
copyButton = new JButton("Copy Link");
copyButton.setEnabled(false);
copyButton.setToolTipText("Select a table row and press this button to copy the file location to Clipboard");
copyButton.addActionListener(this);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
Expand All @@ -128,6 +128,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,

deleteButton = new JButton("Delete Export");
deleteButton.setEnabled(false);
deleteButton.setToolTipText("Select a table row and press the this button to delete the exported file");
deleteButton.addActionListener(this);
gbc = new GridBagConstraints();
gbc.gridx = 1;
Expand Down Expand Up @@ -190,8 +191,6 @@ public Component getTableCellRendererComponent(JTable table, Object value,
this.setLayout(new BorderLayout());
this.add(userOptionsPane(), BorderLayout.NORTH);
add(splitPane);
// this.add(tableScrollPane, BorderLayout.CENTER);
// this.add(parameterScrollPane, BorderLayout.SOUTH);

todayInterval.addActionListener(this);
monthInterval.addActionListener(this);
Expand All @@ -201,7 +200,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
initalizeTableData();
}

private JSplitPane exportDetailsPane(){
private JSplitPane exportDetailsPane(){ // ========================== bottom panel ( Export Details panel )
int height = 200;
int width = 140;
exportVariableText = new JTextPane();
Expand All @@ -217,23 +216,22 @@ private JSplitPane exportDetailsPane(){
parameterScrollPane.setMaximumSize(new Dimension(width, height));
parameterScrollPane.setBorder(BorderFactory.createTitledBorder(loweredEtchedBorder, " Parameters "));


JScrollPane exportDetails = new JScrollPane(exportVariableText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
exportDetails.setPreferredSize(new Dimension(width, height));
exportDetails.setSize(new Dimension(width, height));
exportDetails.setBorder(BorderFactory.createTitledBorder(loweredEtchedBorder, " Properties "));

JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, exportDetails, parameterScrollPane);
splitPane.setContinuousLayout(true);
splitPane.setResizeWeight(0.5);
splitPane.setResizeWeight(0.65);
splitPane.setBorder(BorderFactory.createTitledBorder(loweredEtchedBorder, " Export Details "));
return splitPane;
}

private JPanel userOptionsPane(){
private JPanel userOptionsPane(){ // ========================== top panel (user options)
refreshButton = new JButton("Refresh");

JPanel timeIntervalSelector = new JPanel();
JPanel timeIntervalSelector = new JPanel(); // ---------- Time Interval sub-panel
timeIntervalSelector.setBorder(BorderFactory.createTitledBorder(loweredEtchedBorder, " Time Interval "));
timeIntervalSelector.setLayout(new BoxLayout(timeIntervalSelector, BoxLayout.X_AXIS));

Expand All @@ -248,7 +246,7 @@ private JPanel userOptionsPane(){
timeIntervalSelector.add(yearlyInterval);
timeIntervalSelector.add(anyInterval);

JPanel exportFormatFilterPanel = new JPanel();
JPanel exportFormatFilterPanel = new JPanel(); // ------------- Export Type sub-panel
GridBagConstraints gridBagConstraints = new GridBagConstraints();
exportFormatFilterPanel.setBorder(BorderFactory.createTitledBorder(loweredEtchedBorder, " Export Type "));
exportFormatFilterPanel.setLayout(new GridBagLayout());
Expand Down Expand Up @@ -278,21 +276,13 @@ private JPanel userOptionsPane(){
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
// gbc.weightx = 1;
// gbc.weighty = 1;
// gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = GridBagConstraints.VERTICAL;
gbc.insets = new Insets(1, 1, 5, 1);
topBar.add(exportFormatFilterPanel, gbc);

gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
// gbc.weightx = 1;
// gbc.weighty = 1;
// gbc.gridwidth = 2;
// gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(1, 1, 1, 1);
topBar.add(timeIntervalSelector, gbc);

Expand All @@ -308,8 +298,6 @@ private JPanel userOptionsPane(){
gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridy = 0;
// gbc.weightx = 1;
// gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(9, 1, 7, 4);
Expand Down Expand Up @@ -360,7 +348,7 @@ public void initalizeTableData(){
private void addRowFromJson(String jobID, String dataFormat, ExportDataRepresentation jsonData){
ExportDataRepresentation.SimulationExportDataRepresentation simData = jsonData.formatData.get(dataFormat).simulationDataMap.get(jobID);
ExportedDataTableModel.TableData newRow = new ExportedDataTableModel.TableData(
simData.jobID, simData.dataID, simData.exportDate, dataFormat, simData.uri,
simData.jobID, simData.dataID, simData.exportDate, dataFormat, simData.uri, simData.savedFileName,
simData.biomodelName, simData.startAndEndTime, simData.applicationName, simData.simulationName, simData.variables,
simData.differentParameterValues, simData.nonSpatial, simData.applicationType
);
Expand Down Expand Up @@ -395,6 +383,17 @@ public void actionPerformed(ActionEvent e) {
clipboard.setContents(new StringSelection(tableData.link), null);
} else if(e.getSource().equals(deleteButton)) {
// TODO: add delete code here
int row = editorScrollTable.getSelectedRow();
ExportedDataTableModel.TableData tableData = tableModel.getValueAt(row);

// load json file exportMetaData.json in C:\Users\MyName\.vcell (use Visual Studio Code to visualize)
// delete the globalJobIS
// delete the entry with that ID
// save the json back to file

// class with all the stuff is ExportDataRepresentation



} else if(e.getSource() instanceof JCheckBox && formatButtonGroup.contains(e.getSource())) {
initalizeTableData();
Expand Down Expand Up @@ -437,16 +436,16 @@ public void valueChanged(ListSelectionEvent e) {
StyledDocument doc = new DefaultStyledDocument();
addColoredText(doc, "\nVariables List: ", GraphConstants.darkgreen);
addColoredText(doc, rowData.variables, Color.BLACK);
addColoredText(doc, "\n\nSimulation ID: ", GraphConstants.darkgreen);
addColoredText(doc, "\n\nSimulation ID: ", GraphConstants.darkgreen);
addColoredText(doc, rowData.simID, Color.BLACK);

String dataSetName = rowData.link;
if(dataSetName != null && dataSetName.contains(ExportedDataTableModel.prefix)) {
dataSetName = dataSetName.substring(dataSetName.lastIndexOf(ExportedDataTableModel.prefix) + ExportedDataTableModel.prefix.length());
if(dataSetName != null && !dataSetName.isEmpty()) {
addColoredText(doc, "\nDataset Name: ", GraphConstants.darkgreen);
addColoredText(doc, dataSetName, Color.BLACK);
}
if(rowData.name != null && !rowData.name.isEmpty()) {
addColoredText(doc, "\nName: ", GraphConstants.darkgreen);
addColoredText(doc, rowData.name, Color.BLACK);
}
if(rowData.link != null && !rowData.link.isEmpty() && rowData.link.contains(ExportedDataTableModel.prefix)) {
addColoredText(doc, "\nLink: ", GraphConstants.darkgreen);
addColoredText(doc, rowData.link, Color.BLACK);
}

parameterScrollTableModel.resetData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.Optional;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
Expand All @@ -29,6 +34,10 @@
import cbit.vcell.client.data.ExportedDataTableModel;
import cbit.vcell.resource.PropertyLoader;
import org.apache.xalan.trace.SelectionEvent;
import org.vcell.client.logicalwindow.LWContainerHandle;
import org.vcell.client.logicalwindow.LWDialog;
import org.vcell.client.logicalwindow.LWNamespace;
import org.vcell.client.logicalwindow.LWTitledOptionPaneDialog;
import org.vcell.util.gui.DefaultScrollTableActionManager;
import org.vcell.util.gui.DialogUtils;
import org.vcell.util.gui.ScrollTable;
Expand Down Expand Up @@ -212,7 +221,7 @@ private ScrollTable getScrollPaneTable() {
ivjScrollPaneTable = new ScrollTable();
ivjScrollPaneTable.setName("ScrollPaneTable");
ivjScrollPaneTable.setModel(new ExportMonitorTableModel());
ivjScrollPaneTable.setToolTipText("Right Click to copy file location to Clipboard");
ivjScrollPaneTable.setToolTipText("Select a row and press the 'Copy Link' button to copy the file location to Clipboard");
ivjScrollPaneTable.setBounds(0, 0, 200, 200);
ivjScrollPaneTable.setScrollTableActionManager(new DefaultScrollTableActionManager(getScrollPaneTable()) {
@Override
Expand Down Expand Up @@ -400,6 +409,7 @@ private JButton getCopyButton() {
if(copyButton == null) {
copyButton = new JButton("Copy Link");
copyButton.setName("CopyButton");
copyButton.setToolTipText("Select a table row and press this button to copy the file location to Clipboard");
copyButton.addActionListener(ivjEventHandler);
copyButton.setEnabled(false);
}
Expand All @@ -409,6 +419,7 @@ private JButton getHelpButton() {
if(helpButton == null) {
helpButton = new JButton("Help");
helpButton.setName("HelpButton");
helpButton.setToolTipText("ImageJ N5 format export help");
helpButton.addActionListener(ivjEventHandler);
helpButton.setEnabled(true);
}
Expand Down Expand Up @@ -442,11 +453,67 @@ private void CopyButton_ActionPerformed() {
clipboard.setContents(stringSelection, null);
}
private void HelpButton_ActionPerformed() {
String message = "The simulation results of spatial applications may be exported to ImageJ for further ";
message += "processing using the compatible N5 format.\n";
message += "Use the 'Copy Link' button above to copy the exported data location to the clipboard.\n";
message += "Use the vcell macro in ImageJ to download the file within ImageJ for further processing.";
DialogUtils.showInfoDialog(ExportMonitorPanel.this, "ImageJ Export Help", message);
String strFiji = "The simulation results of spatial applications may be exported to ImageJ for further ";
strFiji += "processing using the compatible N5 format.<br>";
strFiji += "Use the 'Copy Link' button above to copy the exported data location to the clipboard.<br>";
strFiji += "The Fiji ImageJ application can be downloaded from the ";
strFiji += "<a href='https://imagej.net/software/fiji/'>Fiji ImageJ website</a>";
JEditorPane jepFiji = new JEditorPane("text/html", strFiji);
jepFiji.setEditable(false);
jepFiji.setOpaque(false);
jepFiji.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hle) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
URL url = hle.getURL();
System.out.println(url);
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(url.toURI());
} catch(IOException | URISyntaxException e) {
System.out.println(e.getMessage());
}
}
}
}
});
String strPlugin = "Use the VCell plugin in ImageJ to download the exported file for further processing.<br>";
strPlugin += "Click <a href='https://sites.imagej.net/VCell-Simulations-Result-Viewer/'>here</a> to copy the ";
strPlugin += "VCell plugin to the Clipboard";

JEditorPane jepPlugin = new JEditorPane("text/html", strPlugin);
jepPlugin.setEditable(false);
jepPlugin.setOpaque(false);
jepPlugin.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hle) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
URL url = hle.getURL();
System.out.println(url);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(url.toString());
clipboard.setContents(stringSelection, null);
}
}
});

JPanel p = new JPanel();
p.setLayout(new GridBagLayout());

GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(1, 1, 5, 1);
p.add(jepFiji, gbc);

gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(1, 1, 1, 1);
p.add(jepPlugin, gbc);

DialogUtils.showInfoDialog(ExportMonitorPanel.this, p, "ImageJ Export Help");

}
private void ImagejButton_ActionPerformed() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private javax.swing.JLabel getJLabelDatasetName() {
dataSetNameLabel = new javax.swing.JLabel();
dataSetNameLabel.setName("JLabelDatasetName");
dataSetNameLabel.setPreferredSize(new java.awt.Dimension(108, 27));
dataSetNameLabel.setText("N5 File Name:");
dataSetNameLabel.setText("N5 Dataset Name:");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
Expand Down
Loading

0 comments on commit c328651

Please sign in to comment.