Skip to content
Snippets Groups Projects
Commit 36375bb1 authored by tjc's avatar tjc
Browse files

updates

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@1841 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent b44d4c28
Branches
Tags
No related merge requests found
......@@ -20,14 +20,14 @@
* 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/FeatureEdit.java,v 1.3 2004-08-13 13:59:20 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/FeatureEdit.java,v 1.4 2004-08-26 12:51:56 tjc Exp $
**/
package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.util.*;
import uk.ac.sanger.artemis.*;
import uk.ac.sanger.artemis.sequence.*;
import uk.ac.sanger.artemis.sequence.MarkerRange;
import uk.ac.sanger.artemis.io.OutOfDateException;
import uk.ac.sanger.artemis.io.LocationParseException;
......@@ -44,19 +44,21 @@ import uk.ac.sanger.artemis.io.EntryInformation;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.StreamQualifier;
import uk.ac.sanger.artemis.io.QualifierInfo;
import uk.ac.sanger.artemis.io.EmblStreamFeature;
import uk.ac.sanger.artemis.components.ProgressThread;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Date;
import java.util.Vector;
import javax.swing.*;
/**
* FeatureEdit class
*
* @author Kim Rutherford
* @version $Id: FeatureEdit.java,v 1.3 2004-08-13 13:59:20 tjc Exp $
* @version $Id: FeatureEdit.java,v 1.4 2004-08-26 12:51:56 tjc Exp $
**/
public class FeatureEdit extends JFrame
......@@ -147,7 +149,6 @@ public class FeatureEdit extends JFrame
this.goto_event_source = goto_event_source;
createComponents();
updateFromFeature();
orig_qualifier_text = qualifier_text_area.getText();
......@@ -288,7 +289,6 @@ public class FeatureEdit extends JFrame
new KeyChoice(getEntryInformation(),getFeature().getKey());
final JPanel key_and_qualifier_panel = new JPanel();
location_text.setBackground(Color.white);
final JPanel key_panel = new JPanel();
......@@ -299,8 +299,7 @@ public class FeatureEdit extends JFrame
key_and_qualifier_panel.add(key_panel, "West");
qualifier_choice = new QualifierChoice(getEntryInformation(),
key_choice.getSelectedItem(),
null);
key_choice.getSelectedItem(),null);
final JPanel qualifier_panel = new JPanel();
final JButton qualifier_add_button = new JButton("Add Qualifier:");
......@@ -329,11 +328,9 @@ public class FeatureEdit extends JFrame
getEntryInformation().getQualifierInfo(qualifier_name);
if(qualifier_info == null)
{
qualifier_info = new QualifierInfo(qualifier_name,
QualifierInfo.OPTIONAL_QUOTED_TEXT,
null, null, false);
}
qualifier_text_area.append("/" + qualifier_name);
......@@ -346,8 +343,7 @@ public class FeatureEdit extends JFrame
final java.util.Calendar calendar =
java.util.Calendar.getInstance();
final java.util.Date current_time =
calendar.getTime();
final Date current_time = calendar.getTime();
final java.text.SimpleDateFormat date_format =
new java.text.SimpleDateFormat("yyyyMMdd");
......@@ -357,15 +353,13 @@ public class FeatureEdit extends JFrame
date_format.format(current_time, result_buffer,
new java.text.FieldPosition(java.text.DateFormat.DATE_FIELD));
final String go_string =
"aspect=; term=; GOid=GO:; "+
final String go_string = "aspect=; term=; GOid=GO:; "+
"evidence=ISS; db_xref=GOC:unpublished; " +
"with=UNIPROT:; date=" + result_buffer;
qualifier_text_area.append("=\"" + go_string + "\"");
}
else
qualifier_text_area.append ("=\"\"");
break;
case QualifierInfo.NO_VALUE:
......@@ -448,10 +442,7 @@ public class FeatureEdit extends JFrame
}
});
final boolean sanger_options =
Options.getOptions().getPropertyTruthValue("sanger_options");
if(sanger_options)
if(Options.getOptions().getPropertyTruthValue("sanger_options"))
{
// a PSU only hack
final JButton tidy_button = new JButton("Tidy");
......@@ -500,32 +491,19 @@ public class FeatureEdit extends JFrame
else
max_fasta_hits = max_fasta_hits_from_options;
externalEdit(new String[]
{
"-fasta",
"-maxhits",
max_fasta_hits,
"-euk"
});
externalEdit(new String[] { "-fasta", "-maxhits",
max_fasta_hits, "-euk" });
}
else
{
if(max_fasta_hits_from_options == null)
{
externalEdit(new String[]
{
"-fasta"
});
externalEdit(new String[] { "-fasta" });
}
else
{
externalEdit(new String[]
{
"-fasta",
"-maxhits",
max_fasta_hits_from_options
});
externalEdit(new String[] { "-fasta", "-maxhits",
max_fasta_hits_from_options });
}
}
return;
......@@ -560,22 +538,13 @@ public class FeatureEdit extends JFrame
if(Options.getOptions().isEukaryoticMode())
{
externalEdit(new String[]
{
"-blastp",
"-maxhits",
max_blastp_hits,
"-euk"
});
externalEdit(new String[] { "-blastp", "-maxhits",
max_blastp_hits, "-euk" });
}
else
{
externalEdit(new String[]
{
"-blastp",
"-maxhits",
max_blastp_hits
});
externalEdit(new String[] { "-blastp", "-maxhits",
max_blastp_hits });
}
return;
}
......@@ -609,22 +578,13 @@ public class FeatureEdit extends JFrame
if(Options.getOptions().isEukaryoticMode())
{
externalEdit(new String[]
{
"-blastp+go",
"-maxhits",
max_go_blast_hits,
"-euk"
});
externalEdit(new String[] { "-blastp+go", "-maxhits",
max_go_blast_hits, "-euk" });
}
else
{
externalEdit(new String[]
{
"-blastp+go",
"-maxhits",
max_go_blast_hits
});
externalEdit(new String[] { "-blastp+go", "-maxhits",
max_go_blast_hits });
}
return;
}
......@@ -636,8 +596,67 @@ public class FeatureEdit extends JFrame
});
}
middle_panel.add(location_panel, "North");
if(Options.isUnixHost())
{
JButton oo_edit_button = new JButton("ObjectEdit");
location_button_panel.add(oo_edit_button);
oo_edit_button.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
String qualifier_txt = qualifier_text_area.getText();
StringReader strRead = new StringReader(qualifier_txt);
BufferedReader buff = new BufferedReader(strRead);
String line;
final Vector dataFile = new Vector();
try
{
while((line = buff.readLine()) != null)
{
if(line.startsWith("/fasta_file="))
{
int ind = line.lastIndexOf("\"");
if(ind > -1)
dataFile.add(line.substring(13,ind));
}
else if(line.startsWith("/blastp_file="))
{
int ind = line.lastIndexOf("\"");
if(ind > -1)
dataFile.add(line.substring(14,ind));
}
else if(line.startsWith("/blastp+go_file="))
{
int ind = line.lastIndexOf("\"");
if(ind > -1)
dataFile.add(line.substring(17,ind));
}
}
}
catch(IOException ioe){}
FeatureEdit.this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
final ProgressThread progress = new ProgressThread(null,
"Loading Data....");
progress.start();
SwingWorker ooEd = new SwingWorker()
{
public Object construct()
{
new uk.ac.sanger.artemis.editor.BigPane(dataFile.toArray(),
qualifier_text_area);
progress.finished();
FeatureEdit.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
return null;
}
};
ooEd.start();
}
});
}
middle_panel.add(location_panel, "North");
getContentPane().add(key_and_qualifier_panel, "North");
cancel_button.addActionListener(new ActionListener()
......@@ -860,8 +879,7 @@ public class FeatureEdit extends JFrame
if(!rationalizeLocation())
{
location_text.setText (old_location_text);
new MessageDialog (this,
"grab failed - location cannot be parsed after " +
new MessageDialog(this, "grab failed - location cannot be parsed after " +
"grabbing");
}
}
......@@ -1037,7 +1055,7 @@ public class FeatureEdit extends JFrame
final String pre_edit_text = qualifier_text_area.getText();
// write to a temporary file
final java.util.Date current_time = calendar.getTime();
final Date current_time = calendar.getTime();
final String temp_file_name =
"/tmp/artemis_temp." + current_time.getTime();
......@@ -1086,7 +1104,6 @@ public class FeatureEdit extends JFrame
new ProcessWatcher(process, "editor", false);
final Thread watcher_thread = new Thread(process_watcher);
watcher_thread.start();
final ProcessWatcherListener listener = new ProcessWatcherListener()
......@@ -1096,21 +1113,17 @@ public class FeatureEdit extends JFrame
try
{
final FileReader file_reader = new FileReader(temp_file);
final BufferedReader buffered_reader =
new BufferedReader(file_reader);
final StringBuffer buffer = new StringBuffer();
String line;
while((line = buffered_reader.readLine()) != null)
buffer.append(line + "\n");
final String current_qualifier_text =
qualifier_text_area.getText();
if(!current_qualifier_text.equals(pre_edit_text))
//ensure current qualifier text has not changed
if(!qualifier_text_area.getText().equals(pre_edit_text))
{
final String message =
"the qualifiers have changed - apply changes from the " +
......@@ -1164,7 +1177,6 @@ public class FeatureEdit extends JFrame
private String getQualifierString()
{
final StringBuffer buffer = new StringBuffer();
final QualifierVector qualifiers = getFeature().getQualifiers();
for(int qualifier_index = 0; qualifier_index < qualifiers.size();
......@@ -1199,7 +1211,6 @@ public class FeatureEdit extends JFrame
private boolean setFeature()
{
final Key key = key_choice.getSelectedItem();
final KeyVector possible_keys = getEntryInformation().getValidKeys();
if(possible_keys != null && !possible_keys.contains(key))
......@@ -1214,7 +1225,6 @@ public class FeatureEdit extends JFrame
}
final Location location;
try
{
location = new Location(location_text.getText());
......@@ -1223,10 +1233,8 @@ public class FeatureEdit extends JFrame
{
final String error_string = exception.getMessage ();
System.out.println(error_string);
new MessageDialog(this,
"Cannot apply changes because of location error: " +
new MessageDialog(this, "Cannot apply changes because of location error: " +
error_string);
return false;
}
......@@ -1242,8 +1250,7 @@ public class FeatureEdit extends JFrame
{
final String error_string = exception.getMessage();
System.out.println(error_string);
new MessageDialog(this,
"Cannot apply changes because of a qualifier " +
new MessageDialog(this, "Cannot apply changes because of a qualifier " +
"error: " + error_string);
return false;
}
......@@ -1259,8 +1266,7 @@ public class FeatureEdit extends JFrame
catch(OutOfDateException e)
{
final YesNoDialog dialog =
new YesNoDialog(this,
"the feature has changed since the edit " +
new YesNoDialog(this, "the feature has changed since the edit " +
"window was opened, continue?");
if(dialog.getResult()) // yes - ignore the datestamp
......@@ -1278,15 +1284,13 @@ public class FeatureEdit extends JFrame
}
catch(OutOfRangeException e)
{
new MessageDialog(this,
"Cannot apply changes - the location is out of " +
new MessageDialog(this, "Cannot apply changes - the location is out of " +
"range for this sequence");
return false;
}
catch(ReadOnlyException e)
{
new MessageDialog(this,
"Cannot apply changes - the feature is " +
new MessageDialog(this, "Cannot apply changes - the feature is " +
"read only");
return false;
}
......
......@@ -35,6 +35,7 @@ public class ProgressThread extends Thread
private String msg;
private JProgressBar progressBar = new JProgressBar();
public ProgressThread(JFrame frame, String msg)
{
this.frame = frame;
......@@ -45,7 +46,7 @@ public class ProgressThread extends Thread
{
try
{
progress_frame = new JFrame("Loading...");
progress_frame = new JFrame(msg);
Dimension d = progress_frame.getToolkit().getScreenSize();
progressBar.setIndeterminate(true);
progressBar.setBackground(Color.white);
......
......@@ -120,7 +120,7 @@ public class Annotation extends JEditorPane
text = getDatabaseHTML(text,"SWALL:");
text = getDatabaseHTML(text,"UNIPROT:");
text = getDatabaseHTML(text,"EMBL:");
setText("<html><body>"+text+"</html></body>");
setText("<html><body><font size=3>"+text+"</font></html></body>");
startRange = getDocument().getLength();
}
......
......@@ -28,10 +28,14 @@ import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Font;
import java.awt.Component;
import java.awt.Insets;
import java.awt.Toolkit;
import java.util.Vector;
import javax.swing.*;
......@@ -75,7 +79,7 @@ public class BigPane extends JFrame
addWindowListener(new winExit());
// data set
int hgt = getHeight()-60;
int hgt = getHeight()-85;
int wid = getWidth()-100;
dataView = new DataViewInternalFrame(dataFile,desktop,
wid,qualifier_txt);
......@@ -87,9 +91,43 @@ public class BigPane extends JFrame
JMenuBar menuBar = createMenuBar(desktop);
setJMenuBar(menuBar);
// toolbar
JToolBar toolBar = createToolbar();
getContentPane().add(toolBar,BorderLayout.NORTH);
setVisible(true);
}
/**
*
* Create a toolbar
* @return toolbar.
*
*/
private JToolBar createToolbar()
{
JToolBar toolBar = new JToolBar();
JButton applyButt = new JButton("APPLY");
applyButt.setToolTipText("Apply annotation changed to feature editor");
applyButt.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
qualifier.setText(dataView.getFeatureText());
}
});
applyButt.setBackground(new Color(0,0,81));
applyButt.setForeground(Color.white);
applyButt.setBorderPainted(false);
applyButt.setMargin(new Insets(0,0,0,0));
applyButt.setFont(font);
toolBar.add(applyButt);
return toolBar;
}
/**
*
* Create a menu bar.
......@@ -133,6 +171,16 @@ public class BigPane extends JFrame
if(qualifier == null)
System.exit(0);
int ok = JOptionPane.showConfirmDialog(BigPane.this,
"Apply changes now?",
"Apply Changes",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(ok == JOptionPane.CANCEL_OPTION)
return;
if(ok == JOptionPane.OK_OPTION)
qualifier.setText(dataView.getFeatureText());
BigPane.srsFrame = null;
dispose();
......
......@@ -118,11 +118,11 @@ public class DataViewInternalFrame extends JInternalFrame
// add annotator text pane
ann.setAnnotation(annFormat.toString().trim());
JScrollPane annotationScroll = new JScrollPane(ann);
annotationScroll.setPreferredSize(new Dimension(500,300));
annotationScroll.setPreferredSize(new Dimension(500,150));
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
annotationScroll,tabPane);
split.setDividerLocation(250);
split.setDividerLocation(150);
getContentPane().add(split);
setVisible(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment