Skip to content
Snippets Groups Projects
Commit 3ded15d9 authored by tjc's avatar tjc
Browse files

read only option

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@7314 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent d5dc9354
No related branches found
No related tags found
No related merge requests found
......@@ -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 =
......
......@@ -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,6 +163,8 @@ public class EntryEdit extends JFrame
getEntryGroup().getBases().addSequenceChangeListener(ctm, 0);
ctm.setEntryGroup(getEntryGroup());
if(!getEntryGroup().getDefaultEntry().getEMBLEntry().isReadOnly())
{
commitButton = new CommitButton();
getEntryGroup().addFeatureChangeListener(commitButton);
getEntryGroup().addEntryChangeListener(commitButton);
......@@ -170,6 +172,7 @@ public class EntryEdit extends JFrame
xBox.add(commitButton);
}
}
}
//final int font_height;
//final int font_base_line;
......@@ -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()
......
......@@ -63,6 +63,8 @@ public class DatabaseEntrySource implements EntrySource, Serializable
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,12 +212,15 @@ public class DatabaseEntrySource implements EntrySource, Serializable
}
}
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;
}
location = "jdbc:postgresql://" +
inServer.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,11 +272,6 @@ 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);
......@@ -282,7 +279,8 @@ public class DatabaseEntrySource implements EntrySource, Serializable
if(range != null)
doc.setRange(range);
db_entry = new DatabaseDocumentEntry(doc, null);
}
db_entry.setReadOnly(isReadOnly());
final Bases real_bases;
......@@ -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;
}
}
......@@ -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...");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment