From d52261d786e016d66515c001ef30f5728f05af54 Mon Sep 17 00:00:00 2001 From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04> Date: Wed, 20 Jul 2005 09:29:56 +0000 Subject: [PATCH] automatic hook-up to chado db with -Dchado option git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3232 ee4ac58c-ac51-4696-9907-e4b3aa274f04 --- .../artemis/components/ArtemisMain.java | 44 ++++++++++++++----- .../components/DatabaseEntrySource.java | 12 ++++- .../artemis/io/SimpleDocumentEntry.java | 11 +---- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/uk/ac/sanger/artemis/components/ArtemisMain.java b/uk/ac/sanger/artemis/components/ArtemisMain.java index 74a5564d2..95acf23b8 100644 --- a/uk/ac/sanger/artemis/components/ArtemisMain.java +++ b/uk/ac/sanger/artemis/components/ArtemisMain.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ArtemisMain.java,v 1.15 2005-06-22 19:39:41 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ArtemisMain.java,v 1.16 2005-07-20 09:29:56 tjc Exp $ */ package uk.ac.sanger.artemis.components; @@ -45,7 +45,7 @@ import java.io.*; * The main window for the Artemis sequence editor. * * @author Kim Rutherford <kmr@sanger.ac.uk> - * @version $Id: ArtemisMain.java,v 1.15 2005-06-22 19:39:41 tjc Exp $ + * @version $Id: ArtemisMain.java,v 1.16 2005-07-20 09:29:56 tjc Exp $ **/ public class ArtemisMain extends Splash @@ -107,13 +107,7 @@ public class ArtemisMain extends Splash { public void actionPerformed(ActionEvent event) { - DatabaseEntrySource entry_source = new DatabaseEntrySource(); - if(!entry_source.setLocation()) - return; - - final DatabaseJFrame frame = new DatabaseJFrame(entry_source, - ArtemisMain.this); - frame.setVisible(true); + launchDatabaseJFrame(true); } }; @@ -121,8 +115,12 @@ public class ArtemisMain extends Splash Options.getOptions().getPropertyTruthValue("sanger_options"); if(sanger_options) + { makeMenuItem(file_menu, "Database Entry ...", menu_listener); - + if(System.getProperty("chado") != null) + launchDatabaseJFrame(false); + } + menu_listener = new ActionListener() { public void actionPerformed(ActionEvent event) @@ -169,6 +167,32 @@ public class ArtemisMain extends Splash // } // } + /** + * + * Launch database manager window + * + */ + private void launchDatabaseJFrame(final boolean prompt_user) + { + SwingWorker entryWorker = new SwingWorker() + { + public Object construct() + { + getStatusLabel().setText("Connecting ..."); + DatabaseEntrySource entry_source = new DatabaseEntrySource(); + if(!entry_source.setLocation(prompt_user)) + return null; + + final DatabaseJFrame frame = new DatabaseJFrame(entry_source, + ArtemisMain.this); + frame.setVisible(true); + getStatusLabel().setText(""); + return null; + } + }; + entryWorker.start(); + } + /** * Read the entries named in args and in the diana.ini file. **/ diff --git a/uk/ac/sanger/artemis/components/DatabaseEntrySource.java b/uk/ac/sanger/artemis/components/DatabaseEntrySource.java index 050c5f48b..03974a70a 100644 --- a/uk/ac/sanger/artemis/components/DatabaseEntrySource.java +++ b/uk/ac/sanger/artemis/components/DatabaseEntrySource.java @@ -123,7 +123,7 @@ public class DatabaseEntrySource implements EntrySource * jdbc:postgresql://localhost:13001/chadoCVS?user=es2 * */ - protected boolean setLocation() + protected boolean setLocation(final boolean prompt_user) { Container bacross = new Container(); bacross.setLayout(new GridLayout(5,2,5,5)); @@ -165,6 +165,16 @@ public class DatabaseEntrySource implements EntrySource { inDB.setText(db_url.substring(index2+1,index3)); inUser.setText(db_url.substring(index3+1)); + + if(!prompt_user) + { + location = "jdbc:postgresql://" + +inServer.getText().trim()+ ":" + +inPort.getText().trim()+ "/" + +inDB.getText().trim()+ "?user=" + +inUser.getText().trim(); + return true; + } } } } diff --git a/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java b/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java index 0eff47ed9..ec44d1455 100644 --- a/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java +++ b/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java,v 1.12 2005-06-03 16:04:18 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java,v 1.13 2005-07-20 09:29:56 tjc Exp $ */ package uk.ac.sanger.artemis.io; @@ -37,7 +37,7 @@ import java.util.Enumeration; * This class contains the methods common to all DocumentEntry objects. * * @author Kim Rutherford <kmr@sanger.ac.uk> - * @version $Id: SimpleDocumentEntry.java,v 1.12 2005-06-03 16:04:18 tjc Exp $ + * @version $Id: SimpleDocumentEntry.java,v 1.13 2005-07-20 09:29:56 tjc Exp $ **/ abstract public class SimpleDocumentEntry @@ -123,13 +123,6 @@ abstract public class SimpleDocumentEntry while((new_line_group = LineGroup.readNextLineGroup(pushback_reader)) != null) { -// if(document instanceof DatabaseDocument) -// { -// addLineGroup(new_line_group); -// System.out.println("SimpleDocumentEntry DatabaseDocument ******************************"); -// if(new_line_group instanceof StreamSequence) -// System.out.println("SimpleDocumentEntry StreamSequence ******************************"); -// } if(new_line_group instanceof SimpleDocumentFeature) { final SimpleDocumentFeature new_feature = -- GitLab