diff --git a/uk/ac/sanger/artemis/components/ArtemisMain.java b/uk/ac/sanger/artemis/components/ArtemisMain.java index ec3e0f5d6a031fcc65378f08dfc82a823dc6d569..216c19875026c3dedd975e9b3e108a2ab3804323 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.28 2008-01-21 16:15:39 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ArtemisMain.java,v 1.29 2008-04-25 09:58:29 tjc Exp $ */ package uk.ac.sanger.artemis.components; @@ -52,7 +52,7 @@ import javax.swing.JOptionPane; * The main window for the Artemis sequence editor. * * @author Kim Rutherford <kmr@sanger.ac.uk> - * @version $Id: ArtemisMain.java,v 1.28 2008-01-21 16:15:39 tjc Exp $ + * @version $Id: ArtemisMain.java,v 1.29 2008-04-25 09:58:29 tjc Exp $ **/ public class ArtemisMain extends Splash @@ -137,7 +137,7 @@ public class ArtemisMain extends Splash { public void actionPerformed(ActionEvent event) { - launchDatabaseJFrame(true); + launchDatabaseJFrame(); } }; @@ -256,7 +256,7 @@ public class ArtemisMain extends Splash * Launch database manager window * */ - private void launchDatabaseJFrame(final boolean prompt_user) + private void launchDatabaseJFrame() { SwingWorker entryWorker = new SwingWorker() { @@ -264,7 +264,11 @@ public class ArtemisMain extends Splash { getStatusLabel().setText("Connecting ..."); DatabaseEntrySource entry_source = new DatabaseEntrySource(); - if(!entry_source.setLocation(prompt_user)) + boolean promptUser = true; + if(System.getProperty("read_only") != null) + promptUser = false; + + if(!entry_source.setLocation(promptUser)) return null; JFrame frame = new JFrame("Organism List"); @@ -366,7 +370,12 @@ public class ArtemisMain extends Splash Splash.logger4j.info("OPEN ENTRY "+new_entry_name); getStatusLabel().setText("Connecting ..."); DatabaseEntrySource entry_source = new DatabaseEntrySource(); - if(!entry_source.setLocation(true)) + + boolean promptUser = true; + if(System.getProperty("read_only") != null) + promptUser = false; + + if(!entry_source.setLocation(promptUser)) return; last_entry_edit = diff --git a/uk/ac/sanger/artemis/components/EntryEdit.java b/uk/ac/sanger/artemis/components/EntryEdit.java index 82fc8cab798bbf82f5e4839dea7c646a6d43f238..3b4baf2e4f82e990f18a37fb57ef2a7aaa483915 100644 --- a/uk/ac/sanger/artemis/components/EntryEdit.java +++ b/uk/ac/sanger/artemis/components/EntryEdit.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/EntryEdit.java,v 1.60 2008-03-07 12:20:44 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/EntryEdit.java,v 1.61 2008-04-25 09:58:29 tjc Exp $ */ package uk.ac.sanger.artemis.components; @@ -67,7 +67,7 @@ import java.util.Vector; * Each object of this class is used to edit an EntryGroup object. * * @author Kim Rutherford - * @version $Id: EntryEdit.java,v 1.60 2008-03-07 12:20:44 tjc Exp $ + * @version $Id: EntryEdit.java,v 1.61 2008-04-25 09:58:29 tjc Exp $ * */ public class EntryEdit extends JFrame @@ -163,11 +163,14 @@ public class EntryEdit extends JFrame getEntryGroup().getBases().addSequenceChangeListener(ctm, 0); ctm.setEntryGroup(getEntryGroup()); - commitButton = new CommitButton(); - getEntryGroup().addFeatureChangeListener(commitButton); - getEntryGroup().addEntryChangeListener(commitButton); - getEntryGroup().getBases().addSequenceChangeListener(commitButton, 0); - xBox.add(commitButton); + if(!getEntryGroup().getDefaultEntry().getEMBLEntry().isReadOnly()) + { + commitButton = new CommitButton(); + getEntryGroup().addFeatureChangeListener(commitButton); + getEntryGroup().addEntryChangeListener(commitButton); + getEntryGroup().getBases().addSequenceChangeListener(commitButton, 0); + xBox.add(commitButton); + } } } @@ -1091,7 +1094,7 @@ public class EntryEdit extends JFrame db = true; } - if(db) + if(db && !getEntryGroup().getDefaultEntry().getEMBLEntry().isReadOnly()) { final JMenuItem commit = new JMenuItem("Commit to Database"); commit.addActionListener(new ActionListener() diff --git a/uk/ac/sanger/artemis/components/database/DatabaseEntrySource.java b/uk/ac/sanger/artemis/components/database/DatabaseEntrySource.java index 44eb1ca2087b6ea0d1f88ff96d91ac9cf07737c2..b1cb60405071ea45e490981d511126163370c36c 100644 --- a/uk/ac/sanger/artemis/components/database/DatabaseEntrySource.java +++ b/uk/ac/sanger/artemis/components/database/DatabaseEntrySource.java @@ -62,6 +62,8 @@ public class DatabaseEntrySource implements EntrySource, Serializable private JPasswordField pfield; private boolean splitGFFEntry; + + private boolean readOnly = false; /** * Create a new DatabaseEntrySource. @@ -110,14 +112,14 @@ public class DatabaseEntrySource implements EntrySource, Serializable InputStreamProgressListener progress_listener) throws OutOfRangeException, NoSequenceException, IOException { - return makeFromID(null, id, schema, false, progress_listener, null); + return makeFromID(null, id, schema, progress_listener, null); } public Entry getEntry(String id, String schema, InputStreamProgressListener progress_listener, Range range) throws OutOfRangeException, NoSequenceException, IOException { - return makeFromID(null, id, schema, false, progress_listener, range); + return makeFromID(null, id, schema, progress_listener, range); } /** @@ -143,7 +145,7 @@ public class DatabaseEntrySource implements EntrySource, Serializable * jdbc:postgresql://host:port/database?user=username * */ - public boolean setLocation(final boolean prompt_user) + public boolean setLocation(final boolean promptUser) { Container bacross = new Container(); bacross.setLayout(new GridLayout(6, 2, 5, 5)); @@ -210,13 +212,16 @@ public class DatabaseEntrySource implements EntrySource, Serializable } } - int n = JOptionPane.showConfirmDialog(null, bacross, + if(promptUser) + { + int n = JOptionPane.showConfirmDialog(null, bacross, "Enter Database Address", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if(n == JOptionPane.CANCEL_OPTION) - return false; - + if(n == JOptionPane.CANCEL_OPTION) + return false; + } + location = "jdbc:postgresql://" + inServer.getText().trim() + ":" + inPort.getText().trim() + "/" + @@ -253,15 +258,12 @@ public class DatabaseEntrySource implements EntrySource, Serializable * The id of the entry in the database * @param schema * The schema of the entry in the database - * @param read_only - * true if and only if a read-only Entry should be created (some are - * always read only). * @exception OutOfRangeException * Thrown if one of the features in the Entry is out of range of * the Bases object. */ private Entry makeFromID(final Bases bases, final String id, - final String schema, final boolean read_only, + final String schema, InputStreamProgressListener progress_listener, final Range range) throws OutOfRangeException, IOException @@ -270,20 +272,16 @@ public class DatabaseEntrySource implements EntrySource, Serializable { DatabaseDocumentEntry db_entry = null; - if(read_only) - { - } - else - { - DatabaseDocument doc = new DatabaseDocument(location, pfield, id, - schema, splitGFFEntry, - progress_listener); - doc.setLazyFeatureLoad(LocalAndRemoteFileManager.lazyLoad.isSelected()); - if(range != null) - doc.setRange(range); - db_entry = new DatabaseDocumentEntry(doc, null); - } - + DatabaseDocument doc = new DatabaseDocument(location, pfield, id, + schema, splitGFFEntry, + progress_listener); + doc.setLazyFeatureLoad(LocalAndRemoteFileManager.lazyLoad.isSelected()); + if(range != null) + doc.setRange(range); + db_entry = new DatabaseDocumentEntry(doc, null); + + db_entry.setReadOnly(isReadOnly()); + final Bases real_bases; if(bases == null) @@ -356,4 +354,14 @@ public class DatabaseEntrySource implements EntrySource, Serializable { return pfield; } + + public boolean isReadOnly() + { + return readOnly; + } + + public void setReadOnly(boolean readOnly) + { + this.readOnly = readOnly; + } } diff --git a/uk/ac/sanger/artemis/components/filetree/LocalAndRemoteFileManager.java b/uk/ac/sanger/artemis/components/filetree/LocalAndRemoteFileManager.java index 7636586c93a59004b5aaacb10ac2bf9804e75236..e3377f57a754e248cb8b5ac61507c13fb425a020 100644 --- a/uk/ac/sanger/artemis/components/filetree/LocalAndRemoteFileManager.java +++ b/uk/ac/sanger/artemis/components/filetree/LocalAndRemoteFileManager.java @@ -145,7 +145,15 @@ public class LocalAndRemoteFileManager extends JFrame { setTitle("Database and File Manager"); entry_source = new DatabaseEntrySource(); - if(!entry_source.setLocation(true)) + + boolean promptUser = true; + if(System.getProperty("read_only") != null) + { + promptUser = false; + entry_source.setReadOnly(true); + } + + if(!entry_source.setLocation(promptUser)) return; JLabel label = new JLabel(" Database Loading...");