Skip to content

Commit

Permalink
Remove radio dialog box and include all links in the start page
Browse files Browse the repository at this point in the history
  • Loading branch information
sumanthreddy542 committed Jul 27, 2021
1 parent 1736c79 commit 0197845
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 66 deletions.
122 changes: 62 additions & 60 deletions src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ public class MetaOmGraph implements ActionListener {
private static StatisticalResultsFrame DCResultsFrame;
private static JButton plbbutton;
private static JPanel playbackForMac;


private enum DownloadSampleProject{
Metabolomics,
MicroArray,
HumanCancerRNASeq
}

public static StatisticalResultsFrame getDEAResultsFrame() {
return DEAResultsFrame;
Expand Down Expand Up @@ -521,8 +526,12 @@ public static String getVersion() {

public static final String OPEN_COMMAND = "Open a project";

public static final String DOWNLOAD_PROJ_COMMAND = "Download and open sample project";
public static final String DOWNLOAD_METABOLOMICS_PROJ_COMMAND = "Sample MOG project- A. thaliana Metabolomics (0.8 MB) Try me";

public static final String DOWNLOAD_MICROARRAY_PROJ_COMMAND = "Sample MOG project- A. thaliana Microarray (29.5 MB) Try me";

public static final String DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND = "Sample MOG project- Human Cancer RNA-Seq (247 MB) Try me";

public static final String SAVE_COMMAND = "Save the current project";

public static final String SAVE_AS_COMMAND = "Save as";
Expand Down Expand Up @@ -2640,8 +2649,16 @@ public void actionPerformed(ActionEvent e) {

}

if(DOWNLOAD_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject();
if(DOWNLOAD_METABOLOMICS_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.Metabolomics);
}

if(DOWNLOAD_MICROARRAY_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.MicroArray);
}

if(DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.HumanCancerRNASeq);
}

// Save the active project to a new file
Expand Down Expand Up @@ -4083,71 +4100,56 @@ public static void openAnotherProject() {
}


private static String downloadProjSelectionPanel(File projDirectory) {
JPanel sampleProjsPanel = new JPanel(new GridLayout(3,1));
JRadioButton r1 = new JRadioButton("A. thaliana Metabolomics project (0.8 MB)");
JRadioButton r2 = new JRadioButton("A. thaliana Microarray project (29.5 MB)");
JRadioButton r3 = new JRadioButton("Human Cancer RNA-Seq project (247 MB)");

ButtonGroup group = new ButtonGroup();
group.add(r1);
r1.setSelected(true);
group.add(r2);
group.add(r3);

sampleProjsPanel.add(r1);
sampleProjsPanel.add(r2);
sampleProjsPanel.add(r3);

int selectedButton = JOptionPane.showConfirmDialog(null, sampleProjsPanel, "Select a project to download and open",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
private static String downloadProjSelectionPanel(File projDirectory, DownloadSampleProject project) {
String destPath = "";
if(selectedButton == 0) {
URL projURL = null;
if(r1.isSelected()) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_Athaliana_metabolomics.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_Metabolomics";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
URL projURL = null;
if(project == DownloadSampleProject.Metabolomics) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_Athaliana_metabolomics.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_Metabolomics";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
} else if (project == DownloadSampleProject.MicroArray) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_AthalianaMAProj.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_MicroArray";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
if(r2.isSelected()) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_AthalianaMAProj.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_MicroArray";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
} else {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_HumanCancerRNASeqProject.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
if(r3.isSelected()) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_HumanCancerRNASeqProject.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_HumanCancerRNASeq";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_HumanCancerRNASeq";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
}
return destPath;
}

private static void downloadAndOpenProject() {
private static void downloadAndOpenProject(DownloadSampleProject project) {
File currDir = Utils.getLastDir();
File projSelDir = CustomFileSaveDialog.showDirectoryDialog(currDir);
String projDir = downloadProjSelectionPanel(projSelDir);
File projSelDir = CustomFileSaveDialog.showDirectoryDialog(currDir);
if(projSelDir == null) {
return;
}
String projDir = downloadProjSelectionPanel(projSelDir, project);
if(projDir.isEmpty()) {
return;
}
File projDirFile = new File(projDir);
File[] mogFiles = projDirFile.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename)
Expand Down
12 changes: 11 additions & 1 deletion src/edu/iastate/metnet/metaomgraph/ui/ClickableLabel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.iastate.metnet.metaomgraph.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
Expand All @@ -19,6 +20,7 @@ public class ClickableLabel extends JLabel implements java.awt.event.MouseListen
private String text;
private String htmlText;
private String pressedText;
private String textColor = "blue";
private javax.swing.border.Border pressedBorder;

public static void main(String[] args) {
Expand Down Expand Up @@ -64,11 +66,19 @@ public ClickableLabel(String text, Icon icon) {
super(text, icon, 2);
init();
}

public ClickableLabel(String text, String textColor, Icon icon) {
super(text, icon, 2);
this.textColor = textColor;
init();
this.text = htmlText;
setText(this.text);
}

private void init() {
text = getText();
htmlText =
("<html><u><font color=#0000ff>" + text + "</font></u></html>");
("<html><u><font color="+ textColor + ">" + text + "</font></u></html>");

pressedText =
("<html><u><font color=#ff0000>" + text + "</font></u></html>");
Expand Down
24 changes: 19 additions & 5 deletions src/edu/iastate/metnet/metaomgraph/ui/WelcomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,27 @@ public WelcomePanel() throws IOException {
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(openOtherLabel, c2);
ClickableLabel downloadSampleProjLabel = new ClickableLabel(
"Download and open sample project", openIcon);
downloadSampleProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_PROJ_COMMAND);
downloadSampleProjLabel.addActionListener(MetaOmGraph.getInstance());
ClickableLabel downloadMetabolomicsProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_METABOLOMICS_PROJ_COMMAND, "red", openIcon);
downloadMetabolomicsProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_METABOLOMICS_PROJ_COMMAND);
downloadMetabolomicsProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadSampleProjLabel, c2);
openPanel.add(downloadMetabolomicsProjLabel, c2);
ClickableLabel downloadMicroarrayProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_MICROARRAY_PROJ_COMMAND, "red", openIcon);
downloadMicroarrayProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_MICROARRAY_PROJ_COMMAND);
downloadMicroarrayProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadMicroarrayProjLabel, c2);
ClickableLabel downloadRNASeqProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND, "red", openIcon);
downloadRNASeqProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND);
downloadRNASeqProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadRNASeqProjLabel, c2);
openPanel.setBorder(BorderFactory.createEtchedBorder());
c.gridy = 0;
c.gridx = 1;
Expand Down

0 comments on commit 0197845

Please sign in to comment.