| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | package org.pathvisio.plugins.gex; |
|---|
| 18 | |
|---|
| 19 | import java.awt.event.ActionEvent; |
|---|
| 20 | |
|---|
| 21 | import javax.swing.AbstractAction; |
|---|
| 22 | import javax.swing.JOptionPane; |
|---|
| 23 | |
|---|
| 24 | import org.bridgedb.rdb.construct.DBConnector; |
|---|
| 25 | import org.pathvisio.data.DBConnectorSwing; |
|---|
| 26 | import org.pathvisio.debug.Logger; |
|---|
| 27 | import org.pathvisio.gui.swing.PvDesktop; |
|---|
| 28 | import org.pathvisio.plugin.Plugin; |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | public class GexPlugin implements Plugin { |
|---|
| 36 | |
|---|
| 37 | public void init(PvDesktop desktop) |
|---|
| 38 | { |
|---|
| 39 | ImportGexDataAction importAction = new ImportGexDataAction(desktop); |
|---|
| 40 | SelectGexAction selectAction = new SelectGexAction(desktop); |
|---|
| 41 | |
|---|
| 42 | desktop.registerMenuAction ("Data", importAction); |
|---|
| 43 | desktop.registerMenuAction ("Data", selectAction); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | public void done() {}; |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | public static class ImportGexDataAction extends AbstractAction |
|---|
| 52 | { |
|---|
| 53 | private static final long serialVersionUID = 1L; |
|---|
| 54 | |
|---|
| 55 | private final PvDesktop sae; |
|---|
| 56 | |
|---|
| 57 | public ImportGexDataAction(PvDesktop sae) |
|---|
| 58 | { |
|---|
| 59 | super(); |
|---|
| 60 | this.sae = sae; |
|---|
| 61 | putValue (NAME, "Import expression data"); |
|---|
| 62 | putValue (SHORT_DESCRIPTION, "Import data from a tab delimited text file, for example experimental data from a high-throughput experiment"); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | public void actionPerformed (ActionEvent e) |
|---|
| 66 | { |
|---|
| 67 | GexImportWizard wizard = new GexImportWizard(sae); |
|---|
| 68 | wizard.showModalDialog(sae.getSwingEngine().getFrame()); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | public static class SelectGexAction extends AbstractAction |
|---|
| 77 | { |
|---|
| 78 | private static final long serialVersionUID = 1L; |
|---|
| 79 | private final PvDesktop se; |
|---|
| 80 | |
|---|
| 81 | public SelectGexAction(PvDesktop standaloneEngine) { |
|---|
| 82 | se = standaloneEngine; |
|---|
| 83 | putValue(NAME, "Select expression dataset"); |
|---|
| 84 | putValue(SHORT_DESCRIPTION, "Select expression dataset"); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | public void actionPerformed(ActionEvent e) { |
|---|
| 88 | try |
|---|
| 89 | { |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | DBConnectorSwing dbcon; |
|---|
| 96 | DBConnector dbc = se.getGexManager().getDBConnector(); |
|---|
| 97 | if(dbc instanceof DBConnectorSwing) |
|---|
| 98 | { |
|---|
| 99 | dbcon = (DBConnectorSwing)dbc; |
|---|
| 100 | } |
|---|
| 101 | else |
|---|
| 102 | { |
|---|
| 103 | |
|---|
| 104 | throw new IllegalArgumentException("Not a Swing database connector"); |
|---|
| 105 | } |
|---|
| 106 | String dbName = dbcon.openChooseDbDialog(null); |
|---|
| 107 | |
|---|
| 108 | if(dbName == null) return; |
|---|
| 109 | |
|---|
| 110 | se.getGexManager().setCurrentGex(dbName, false); |
|---|
| 111 | se.loadGexCache(); |
|---|
| 112 | } |
|---|
| 113 | catch(Exception ex) |
|---|
| 114 | { |
|---|
| 115 | String msg = "Failed to open expression dataset; " + ex.getMessage(); |
|---|
| 116 | JOptionPane.showMessageDialog(null, |
|---|
| 117 | "Error: " + msg + "\n\n" + "See the error log for details.", |
|---|
| 118 | "Error", |
|---|
| 119 | JOptionPane.ERROR_MESSAGE); |
|---|
| 120 | Logger.log.error(msg, ex); |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | } |
|---|