Skip to content
Snippets Groups Projects
Commit 0b55e078 authored by tcarver's avatar tcarver
Browse files

allow user to open database entry using gene or sequence ID

parent 70715460
Branches
Tags
No related merge requests found
......@@ -72,6 +72,8 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import uk.ac.sanger.artemis.Options;
import uk.ac.sanger.artemis.components.database.DatabaseEntrySource;
import uk.ac.sanger.artemis.components.database.DatabaseJPanel;
import uk.ac.sanger.artemis.util.Document;
import uk.ac.sanger.artemis.util.FileDocument;
......@@ -89,6 +91,7 @@ public class ProjectProperty extends JFrame
private static HashMap<String, HashMap<String, String>> centralProjects;
private static HashMap<String, HashMap<String, String>> userProjects;
private Splash splash;
private DatabaseEntrySource entry_source;
private final static int REFERENCE = 1;
private final static int ANNOTATION = 2;
......@@ -690,6 +693,36 @@ public class ProjectProperty extends JFrame
}
}
/**
* Open a database entry
* @param splash
* @param featureName gene or sequence ID
*/
private void openDatabase(final Splash splash, final String featureName)
{
String loc = System.getProperty("chado");
int idx;
if((idx = loc.indexOf("?")) > -1 && loc.indexOf("?user=") == -1)
loc = loc.substring(0, idx+1) + "user=" + loc.substring(idx+1);
if( entry_source == null ||
!entry_source.getLocation().endsWith(loc) )
{
entry_source = new DatabaseEntrySource();
boolean promptUser = true;
if(System.getProperty("read_only") != null)
{
promptUser = false;
entry_source.setReadOnly(true);
}
if(!entry_source.setLocation(promptUser))
return;
}
DatabaseJPanel.getEntryEditFromDatabase(
entry_source, splash, ProjectProperty.this, featureName);
}
/**
* Escape the spaces with a double backslash (i.e. '\\ ').
* @param s
......@@ -799,10 +832,19 @@ public class ProjectProperty extends JFrame
{
public void run()
{
final String[] args = getArgs();
if(System.getProperty("chado") != null &&
args != null &&
args.length == 1 &&
args[0].indexOf(":") == -1)
{
openDatabase(splash, args[0]);
return;
}
setCursor(new Cursor(Cursor.WAIT_CURSOR));
try
{
String[] args = getArgs();
final ArtemisMain main_window;
if (splash == null)
{
......
......@@ -65,6 +65,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Cursor;
......@@ -79,8 +80,8 @@ public class DatabaseJPanel extends JPanel
{
/** */
private static final long serialVersionUID = 1L;
private JLabel status_line = new JLabel("");
private boolean splitGFFEntry = false;
private static JLabel status_line = new JLabel("");
private static boolean splitGFFEntry = false;
private JTree tree;
private DatabaseDocument doc;
private static Vector<String> opening = new Vector<String>();
......@@ -140,7 +141,7 @@ public class DatabaseJPanel extends JPanel
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ENTER)
getEntryEditFromDatabase(entry_source, splash_main,
getEntryEditFromDatabase(entry_source, splash_main, DatabaseJPanel.this,
openGeneText.getText().trim());
}
});
......@@ -150,7 +151,7 @@ public class DatabaseJPanel extends JPanel
{
public void actionPerformed(ActionEvent e)
{
getEntryEditFromDatabase(entry_source, splash_main,
getEntryEditFromDatabase(entry_source, splash_main, DatabaseJPanel.this,
openGeneText.getText().trim());
}
});
......@@ -238,7 +239,7 @@ public class DatabaseJPanel extends JPanel
* @throws Exception
*/
private static EntryEdit show(final DatabaseEntrySource entry_source,
final JComponent srcComponent,
final Component srcComponent,
final JLabel status_line,
final Splash splash_main,
final InputStreamProgressListener stream_progress_listener,
......@@ -393,8 +394,9 @@ public class DatabaseJPanel extends JPanel
* @param splash_main
* @param featureName
*/
private void getEntryEditFromDatabase(final DatabaseEntrySource entry_source,
public static void getEntryEditFromDatabase(final DatabaseEntrySource entry_source,
final Splash splash_main,
final Component comp,
final String featureName)
{
SwingWorker entryWorker = new SwingWorker()
......@@ -405,10 +407,10 @@ public class DatabaseJPanel extends JPanel
Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR);
try
{
DatabaseJPanel.this.setCursor(cbusy);
comp.setCursor(cbusy);
EntryEdit ee = show(entry_source,
DatabaseJPanel.this, status_line, splash_main,
comp, status_line, splash_main,
stream_progress_listener, ":" + featureName,
true, splitGFFEntry);
goTo(ee, featureName);
......@@ -416,14 +418,14 @@ public class DatabaseJPanel extends JPanel
catch (Exception npe)
{
//npe.printStackTrace();
JOptionPane.showMessageDialog(DatabaseJPanel.this,
JOptionPane.showMessageDialog(comp,
featureName + " not opened/found!",
"Failed to Open", JOptionPane.WARNING_MESSAGE);
logger4j.debug(featureName + " not found!");
}
finally
{
DatabaseJPanel.this.setCursor(cdone);
comp.setCursor(cdone);
}
return null;
}
......@@ -448,7 +450,7 @@ public class DatabaseJPanel extends JPanel
private static EntryEdit openEntry(
final String srcfeatureId,
final DatabaseEntrySource entry_source,
final JComponent srcComponent,
final Component srcComponent,
final JLabel status_line,
final InputStreamProgressListener stream_progress_listener,
final boolean splitGFFEntry,
......@@ -596,7 +598,7 @@ public class DatabaseJPanel extends JPanel
* An InputStreamProgressListener used to update the error label with the
* current number of chars read.
*/
private final InputStreamProgressListener stream_progress_listener =
private static final InputStreamProgressListener stream_progress_listener =
new InputStreamProgressListener()
{
public void progressMade(final InputStreamProgressEvent event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment