Skip to content
Snippets Groups Projects
Commit 5b40d267 authored by tjc's avatar tjc
Browse files

updates

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@6322 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 1d68f817
No related branches found
No related tags found
No related merge requests found
......@@ -37,11 +37,14 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
......@@ -55,6 +58,13 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.text.JTextComponent;
import org.gmod.schema.sequence.FeatureLoc;
import uk.ac.sanger.artemis.Entry;
import uk.ac.sanger.artemis.components.ArtemisMain;
import uk.ac.sanger.artemis.components.EntryEdit;
import uk.ac.sanger.artemis.components.SwingWorker;
import uk.ac.sanger.artemis.components.Utilities;
import uk.ac.sanger.artemis.components.genebuilder.GeneEdit;
import uk.ac.sanger.artemis.editor.BrowserControl;
import uk.ac.sanger.artemis.editor.DataCollectionPane;
......@@ -62,7 +72,11 @@ import uk.ac.sanger.artemis.io.DatabaseDocumentEntry;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.Qualifier;
import uk.ac.sanger.artemis.io.QualifierVector;
import uk.ac.sanger.artemis.sequence.Bases;
import uk.ac.sanger.artemis.util.DatabaseDocument;
import uk.ac.sanger.artemis.util.InputStreamProgressEvent;
import uk.ac.sanger.artemis.util.InputStreamProgressListener;
import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.util.StringVector;
abstract class AbstractMatchTable
......@@ -70,6 +84,7 @@ abstract class AbstractMatchTable
protected boolean isChanged = false;
protected JTable table;
protected QualifierVector origQualifiers;
private JLabel status_line;
protected abstract String updateQualifierString(int row);
/**
......@@ -188,6 +203,42 @@ abstract class AbstractMatchTable
return field;
}
/**
*
* @param schema
* @param uniquename
* @return
*/
private DatabaseDocumentEntry makeEntry(final String schema,
final String uniquename,
final DatabaseDocument doc,
final boolean isGeneEditor)
{
DatabaseDocumentEntry db_entry = null;
DatabaseDocument newdoc = new DatabaseDocument(doc,
uniquename, schema, isGeneEditor, stream_progress_listener);
try
{
db_entry = new DatabaseDocumentEntry(newdoc, null);
}
catch(EntryInformationException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(NullPointerException npe)
{
JOptionPane.showMessageDialog(null, schema+":"+uniquename+
" not found!", "Warning", JOptionPane.WARNING_MESSAGE);
}
return db_entry;
}
/**
* Sets the preferred, min & max width of the column specified by columnIndex.
* The column will be just wide enough to show the column head and the widest
......@@ -279,18 +330,22 @@ abstract class AbstractMatchTable
private int selectedRow;
private Color fgColor = new Color(139,35,35);
private DefaultTableModel tableModel;
private String text;
private DatabaseDocument doc;
public ButtonEditor(JCheckBox checkBox, final DefaultTableModel tableModel)
public ButtonEditor(JCheckBox checkBox, final DefaultTableModel tableModel,
final String text, final DatabaseDocument doc)
{
super(checkBox);
this.tableModel = tableModel;
this.text = text;
this.doc = doc;
buttRemove = new JButton("X");
buttRemove = new JButton(text);
buttRemove.setBorderPainted(false);
buttRemove.setOpaque(false);
Font font = buttRemove.getFont().deriveFont(Font.BOLD);
buttRemove.setFont(font);
buttRemove.setToolTipText("REMOVE");
buttRemove.setForeground(fgColor);
Dimension size = new Dimension(20,20);
......@@ -328,13 +383,77 @@ abstract class AbstractMatchTable
public Object getCellEditorValue()
{
if(isPushed)
{
if(text.equals("X"))
{
tableModel.removeRow(selectedRow);
isChanged = true;
}
else
{
int columnIndex = 0;
for(int i=0;i<tableModel.getColumnCount(); i++)
{
if(tableModel.getColumnName(i).equals(OrthoParalogTable.ORTHO_COL))
columnIndex = i;
}
String geneRef = (String)tableModel.getValueAt(selectedRow, columnIndex);
final String gene[] = geneRef.split(":");
org.gmod.schema.sequence.Feature feature = doc.getFeatureByUniquename(gene[1]);
Collection featureLocs = feature.getFeatureLocsForFeatureId();
Iterator it = featureLocs.iterator();
final FeatureLoc featureLoc = (FeatureLoc)it.next();
final JFrame progressFrame = progressReading();
final String srcFeatureId = Integer.toString(featureLoc.getFeatureBySrcFeatureId().getFeatureId());
SwingWorker readWorker = new SwingWorker()
{
public Object construct()
{
final DatabaseDocument newDoc = new DatabaseDocument(
doc, srcFeatureId,
gene[0], false,
stream_progress_listener);
newDoc.setName(featureLoc.getFeatureBySrcFeatureId().getUniqueName());
try
{
DatabaseDocumentEntry db_entry = new DatabaseDocumentEntry(newDoc, null);
Bases bases = new Bases(db_entry.getSequence());
Entry entry = new Entry(bases, db_entry);
final EntryEdit new_entry_edit = ArtemisMain.makeEntryEdit(entry);
new_entry_edit.getGotoEventSource().gotoBase(featureLoc.getFmin().intValue());
new_entry_edit.setVisible(true);
}
catch(EntryInformationException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(OutOfRangeException e)
{
e.printStackTrace();
}
return null;
}
public void finished()
{
progressFrame.dispose();
}
};
readWorker.start();
}
return null;
}
isPushed = false;
return new String("X") ;
return text;
}
public boolean stopCellEditing()
......@@ -353,6 +472,23 @@ abstract class AbstractMatchTable
}
}
/**
* Let the user know the progress of reading from the database
*/
private JFrame progressReading()
{
final JFrame fread = new JFrame();
fread.setUndecorated(true);
status_line = new JLabel("Loading ... ");
status_line.setBackground(Color.white);
status_line.setOpaque(true);
fread.getContentPane().add(status_line);
fread.pack();
Utilities.centreFrame(fread);
fread.setVisible(true);
return fread;
}
/**
*
......@@ -405,50 +541,6 @@ abstract class AbstractMatchTable
{
}
});
/*
linkButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
fireEditingStopped();
}
});
*/
}
/**
*
* @param schema
* @param uniquename
* @return
*/
private DatabaseDocumentEntry makeEntry(final String schema,
final String uniquename)
{
DatabaseDocumentEntry db_entry = null;
DatabaseDocument newdoc = new DatabaseDocument(doc,
uniquename, schema, true);
try
{
db_entry = new DatabaseDocumentEntry(newdoc, null);
}
catch(EntryInformationException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(NullPointerException npe)
{
JOptionPane.showMessageDialog(null, schema+":"+uniquename+
" not found!", "Warning", JOptionPane.WARNING_MESSAGE);
}
return db_entry;
}
public Component getTableCellEditorComponent(JTable table, Object value,
......@@ -502,7 +594,7 @@ abstract class AbstractMatchTable
// open gene editor for this gene link
linkButton.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
final String reference[] = linkButton.getActionCommand().split(":");
DatabaseDocumentEntry entry = makeEntry(reference[0], reference[1]);
DatabaseDocumentEntry entry = makeEntry(reference[0], reference[1], doc, true);
if(entry != null)
{
......@@ -681,5 +773,26 @@ abstract class AbstractMatchTable
}
}
/**
* An InputStreamProgressListener used to update the error label with the
* current number of chars read.
**/
protected final InputStreamProgressListener stream_progress_listener =
new InputStreamProgressListener()
{
public void progressMade(final InputStreamProgressEvent event)
{
final int char_count = event.getCharCount();
if(char_count == -1)
status_line.setText("");
else
status_line.setText("chars read so far: " + char_count);
}
public void progressMade(String progress)
{
status_line.setText(progress);
}
};
}
\ No newline at end of file
......@@ -17,7 +17,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/genebuilder/ortholog/MatchPanel.java,v 1.18 2007-08-15 15:50:41 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/genebuilder/ortholog/MatchPanel.java,v 1.19 2007-08-23 12:13:46 tjc Exp $
*/
package uk.ac.sanger.artemis.components.genebuilder.ortholog;
......@@ -358,7 +358,7 @@ public class MatchPanel extends JPanel
if(simQualifier instanceof QualifierLazyLoading)
((QualifierLazyLoading)simQualifier).setForceLoad(true);
similarityTable = new SimilarityTable(simQualifier);
similarityTable = new SimilarityTable(simQualifier,doc);
if(hide_show_sim == null)
hide_show_sim = new JButton("-");
addHideShowButton(similarityTable.getTable(), hide_show_sim);
......
......@@ -69,7 +69,7 @@ import uk.ac.sanger.artemis.util.StringVector;
public class OrthoParalogTable extends AbstractMatchTable
{
private static int NUMBER_COLUMNS = 9;
private static int NUMBER_COLUMNS = 10;
private Vector rowData = new Vector();
private Vector tableData = new Vector(NUMBER_COLUMNS);
private JTable table;
......@@ -79,15 +79,16 @@ public class OrthoParalogTable extends AbstractMatchTable
//
// column headings
final static String CLUSTER_NAME_COL = "Cluster";
final static String MATCH_NAME_COL = "Match";
final static String ROW_TYPE_HIDE_COL = "Term";
final static String ROW_TYPE_COL = "Type";
final static String ORGANISM_COL = "Organism";
final static String ORTHO_COL = "Gene";
final static String LINK_COL = "Link";
final static String DESCRIPTION_COL = "Description";
final static String REMOVE_BUTTON_COL = "";
protected final static String CLUSTER_NAME_COL = "Cluster";
protected final static String MATCH_NAME_COL = "Match";
protected final static String ROW_TYPE_HIDE_COL = "Term";
protected final static String ROW_TYPE_COL = "Type";
protected final static String ORGANISM_COL = "Organism";
protected final static String ORTHO_COL = "Gene";
protected final static String LINK_COL = "Link";
protected final static String DESCRIPTION_COL = "Description";
protected final static String VIEW_BUTTON_COL = "View";
protected final static String REMOVE_BUTTON_COL = "";
/**
......@@ -125,7 +126,8 @@ public class OrthoParalogTable extends AbstractMatchTable
tableData.setElementAt(ORTHO_COL,5);
tableData.setElementAt(LINK_COL,6);
tableData.setElementAt(DESCRIPTION_COL,7);
tableData.setElementAt(REMOVE_BUTTON_COL,8);
tableData.setElementAt(VIEW_BUTTON_COL,8);
tableData.setElementAt(REMOVE_BUTTON_COL,9);
// add row data
......@@ -234,13 +236,19 @@ public class OrthoParalogTable extends AbstractMatchTable
packColumn(table, getColumnIndex(ORTHO_COL), 4);
packColumn(table, getColumnIndex(LINK_COL), 4);
packColumn(table, getColumnIndex(ORGANISM_COL), 4);
packColumn(table, getColumnIndex(VIEW_BUTTON_COL), 4);
if(showCluster)
packColumn(table, getColumnIndex(CLUSTER_NAME_COL), 4);
// remove JButton column
col = table.getColumn(REMOVE_BUTTON_COL);
col.setCellEditor(new ButtonEditor(new JCheckBox(),
(DefaultTableModel)table.getModel()));
(DefaultTableModel)table.getModel(), "X", doc));
// remove JButton column
col = table.getColumn(VIEW_BUTTON_COL);
col.setCellEditor(new ButtonEditor(new JCheckBox(),
(DefaultTableModel)table.getModel(), "VIEW", doc));
// orthologue link
col = table.getColumn(ORTHO_COL);
......@@ -483,7 +491,7 @@ public class OrthoParalogTable extends AbstractMatchTable
String ortho = (String)table.getValueAt(rows[i], orthoColumn);
final String reference[] = ortho.split(":");
DatabaseDocument newdoc = new DatabaseDocument(doc,
reference[0], reference[1], true);
reference[0], reference[1], true, stream_progress_listener);
try
{
......@@ -725,6 +733,7 @@ public class OrthoParalogTable extends AbstractMatchTable
private final JLabel clusterName = new JLabel();
private final JLabel matchName = new JLabel();
private final JLabel buttRemove = new JLabel("X");
private final JLabel buttView = new JLabel("VIEW");
private Color fgColor = new Color(139,35,35);
private Color fgLinkColor = Color.BLUE;
......@@ -748,6 +757,10 @@ public class OrthoParalogTable extends AbstractMatchTable
buttRemove.setToolTipText("REMOVE");
buttRemove.setHorizontalAlignment(SwingConstants.CENTER);
buttView.setOpaque(true);
buttView.setFont(font);
buttView.setHorizontalAlignment(SwingConstants.CENTER);
symbol.setOpaque(true);
symbol.setFont(font);
symbol.setHorizontalAlignment(SwingConstants.CENTER);
......@@ -847,6 +860,20 @@ public class OrthoParalogTable extends AbstractMatchTable
minHeight = Math.max(minHeight, dim.height);
c = symbol;
}
else if(column == getColumnIndex(VIEW_BUTTON_COL))
{
if(isSelected)
{
buttView.setForeground(fgColor);
buttView.setBackground(table.getSelectionBackground());
}
else
{
buttView.setForeground(fgColor);
buttView.setBackground(UIManager.getColor("Button.background"));
}
c = buttView;
}
else if(column == getColumnIndex(REMOVE_BUTTON_COL))
{
if(isSelected)
......
......@@ -47,6 +47,7 @@ import javax.swing.table.TableModel;
import uk.ac.sanger.artemis.io.Qualifier;
import uk.ac.sanger.artemis.io.QualifierVector;
import uk.ac.sanger.artemis.util.DatabaseDocument;
import uk.ac.sanger.artemis.util.StringVector;
public class SimilarityTable extends AbstractMatchTable
......@@ -80,7 +81,8 @@ public class SimilarityTable extends AbstractMatchTable
* @param similarity
* @param similarityString
*/
protected SimilarityTable(final Qualifier simQualifier)
protected SimilarityTable(final Qualifier simQualifier,
final DatabaseDocument doc)
{
this.origQualifiers = new QualifierVector();
this.origQualifiers.add(simQualifier);
......@@ -207,7 +209,7 @@ public class SimilarityTable extends AbstractMatchTable
// remove JButton column
col = getTable().getColumn(REMOVE_BUTTON_COL);
col.setCellEditor(new ButtonEditor(new JCheckBox(),
(DefaultTableModel)getTable().getModel()));
(DefaultTableModel)getTable().getModel(), "X", doc));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment