diff --git a/uk/ac/sanger/artemis/components/genebuilder/ortholog/AbstractMatchTable.java b/uk/ac/sanger/artemis/components/genebuilder/ortholog/AbstractMatchTable.java index c766c346d7aae625795da11c736365e4065b76bf..63645b5c225ed61ef7125bba343eb1bbbd9c6446 100644 --- a/uk/ac/sanger/artemis/components/genebuilder/ortholog/AbstractMatchTable.java +++ b/uk/ac/sanger/artemis/components/genebuilder/ortholog/AbstractMatchTable.java @@ -240,6 +240,66 @@ abstract class AbstractMatchTable return db_entry; } + protected void openArtemis(final DatabaseDocument doc, final int selectedRow) + { + int columnIndex = getColumnIndex(OrthoParalogTable.ORTHO_COL); + + String geneRef = (String)getTable().getValueAt(selectedRow, columnIndex); + final String gene[] = geneRef.split(":"); + + final org.gmod.schema.sequence.Feature geneFeature = doc.getFeatureByUniquename(gene[1]); + + Collection featureLocs = geneFeature.getFeatureLocsForFeatureId(); + Iterator it = featureLocs.iterator(); + final FeatureLoc featureLoc = (FeatureLoc)it.next(); + + final JFrame progressFrame = progressReading(); + + SwingWorker readWorker = new SwingWorker() + { + public Object construct() + { + try + { + int start = featureLoc.getFmin().intValue()-10000; + if(start <= 1) + start = 2; + Range range = new Range(start,featureLoc.getFmax().intValue()+10000); + final DatabaseDocument newDoc = new DatabaseDocument( + doc, gene[0], geneFeature, range, + stream_progress_listener); + + 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(); + } + /** * 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 @@ -391,70 +451,8 @@ abstract class AbstractMatchTable 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(":"); - - final org.gmod.schema.sequence.Feature geneFeature = doc.getFeatureByUniquename(gene[1]); - - Collection featureLocs = geneFeature.getFeatureLocsForFeatureId(); - Iterator it = featureLocs.iterator(); - final FeatureLoc featureLoc = (FeatureLoc)it.next(); - - final JFrame progressFrame = progressReading(); - - SwingWorker readWorker = new SwingWorker() - { - public Object construct() - { - try - { - int start = featureLoc.getFmin().intValue()-10000; - if(start <= 1) - start = 2; - Range range = new Range(start,featureLoc.getFmax().intValue()+10000); - final DatabaseDocument newDoc = new DatabaseDocument( - doc, gene[0], geneFeature, range, - stream_progress_listener); - - 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; + openArtemis(doc, selectedRow); + //return null; } isPushed = false; return text; diff --git a/uk/ac/sanger/artemis/components/genebuilder/ortholog/OrthoParalogTable.java b/uk/ac/sanger/artemis/components/genebuilder/ortholog/OrthoParalogTable.java index d93a0b34fae974c8689a00a7951c021372ff4db7..1aa0ae05c931d0bed904612dcbac235f6e6becf7 100644 --- a/uk/ac/sanger/artemis/components/genebuilder/ortholog/OrthoParalogTable.java +++ b/uk/ac/sanger/artemis/components/genebuilder/ortholog/OrthoParalogTable.java @@ -447,6 +447,30 @@ public class OrthoParalogTable extends AbstractMatchTable table.setCursor(orginalCursor); } }); + + JMenuItem openMenu = new JMenuItem("Open selected in Artemis"); + popupMenu.add(openMenu); + openMenu.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + Cursor orginalCursor = table.getCursor(); + table.setCursor(new Cursor(Cursor.WAIT_CURSOR)); + int selectedRows[] = getTable().getSelectedRows(); + + if(selectedRows.length > 1) + { + int select = JOptionPane.showConfirmDialog(null, + "Open all selected sequences in seperate Artemis windows?", + "Open Artemis x"+selectedRows.length, JOptionPane.OK_CANCEL_OPTION); + if(select == JOptionPane.CANCEL_OPTION) + return; + } + for(int i=0; i<selectedRows.length; i++) + openArtemis(doc,selectedRows[i]); + table.setCursor(orginalCursor); + } + }); } /**