Newer
Older
/* MultiComparator.java
*
* created: Tue Sep 11 2001
*
* This file is part of Artemis
*
* Copyright(C) 2001,2002 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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/MultiComparator.java,v 1.22 2008-09-03 10:58:33 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.*;
import uk.ac.sanger.artemis.components.alignment.BamView;
import uk.ac.sanger.artemis.components.alignment.FileSelectionDialog;
import uk.ac.sanger.artemis.util.RemoteFileDocument;
import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.util.InputStreamProgressListener;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.DocumentEntryFactory;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.io.File;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
/**
* This JFrame component contains an arbitrary number of AlignmentViewer
* components and FeatureDisplay components along with ComparatorGlue objects
* to keep them synchronized.
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* An array of EntryGroup objects to display(set by the constructor). The
* array will contain at least one EntryGroup and will be exactly one
* element longer than comparison_data_array.
**/
private EntryGroup[] entry_group_array = null;
/**
* An array of ComparisonData objects to display(set by the constructor).
* The array will be exactly one element shorter than entry_group_array.
**/
private ComparisonData[] comparison_data_array = null;
/**
* An array of Selection objects - one per EntryGroup. Created by
* makeSelectionArray()
**/
private Selection[] selection_array = null;
/**
* An array of GotoEventSource objects - one per EntryGroup. Created by
* makeGotoEventSourceArray()
**/
private GotoEventSource[] goto_event_source_array = null;
/**
* An array of FeatureDisplay objects - one per EntryGroup. Created in the
* constructor.
**/
private FeatureDisplay[] feature_display_array = null;
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* An array of AlignmentViewer objects - one per ComparisonData. Created
* in the constructor.
**/
private AlignmentViewer[] alignment_viewer_array = null;
/**
* An array of AlignmentViewer objects - one per ComparisonData. Created
* in the constructor.
**/
private ComparatorGlue[] comparator_glue_array = null;
/**
* An array of BasePlotGroup objects - one per FeatureDisplay/EntryGroup.
* Created in the constructor.
**/
private BasePlotGroup[] base_plot_group_array = null;
/** This menu is populated by makeFileMenu(). */
private final JMenu file_menu = new JMenu("File");
/**
* The EntrySourceVector reference that is created in the constructor.
**/
private EntrySourceVector entry_sources;
/** Used to show the progress of loading file. */
private InputStreamProgressListener progress_listener;
private GridBagLayout layout = new GridBagLayout();
/**
* Initialise entry_group_array and comparison_data_array and create all
* the FeatureDisplay and AlignmentViewer components.
* @param entry_group_array The EntryGroup components to display.
* @param comparison_data_array The ComparisonData to display. This array
* must have one element less than entry_group_array.
* @param progress_listener The object to which InputStreamProgressEvents
* will be send while reading. Currently unused.
**/
public MultiComparator(final EntryGroup[] entry_group_array,
final ComparisonData[] comparison_data_array,
final InputStreamProgressListener
progress_listener)
{
super();
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
if(entry_group_array.length != comparison_data_array.length + 1)
throw new Error("internal error - " +
"MultiComparator got illegal arguments");
this.entry_group_array = entry_group_array;
this.comparison_data_array = comparison_data_array;
this.progress_listener = progress_listener;
this.entry_sources = Utilities.getEntrySources(this, null);
title_buffer.append(
entry_group_array[i].getDefaultEntry().getName()).append(" vs ");
final EntryGroup last_entry_group =
entry_group_array[entry_group_array.length - 1];
title_buffer.append(last_entry_group.getDefaultEntry().getName());
setTitle(title_buffer.toString());
makeSelectionArray();
makeGotoEventSourceArray();
feature_display_array =
new FeatureDisplay[entry_group_array.length];
base_plot_group_array =
new BasePlotGroup[entry_group_array.length];
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
alignment_viewer_array =
new AlignmentViewer[comparison_data_array.length];
comparator_glue_array =
new ComparatorGlue[comparison_data_array.length];
for(int i = 0; i < getEntryGroupArray().length; ++i)
{
final EntryGroup this_entry_group = getEntryGroupArray()[i];
final BasePlotGroup base_plot_group =
new BasePlotGroup(this_entry_group, this,
getSelectionArray()[i],
getGotoEventSourceArray()[i]);
final int scroll_bar_position;
if(i == getEntryGroupArray().length - 1 &&
getEntryGroupArray().length == 2)
{
// put scrollbar at the top normally, but at the bottom of the lower
// sequence if there's two entries on display
scroll_bar_position = FeatureDisplay.SCROLLBAR_AT_BOTTOM;
}
else
scroll_bar_position = FeatureDisplay.SCROLLBAR_AT_TOP;
feature_display_array[i] =
new FeatureDisplay(this_entry_group,
getSelectionArray()[i],
getGotoEventSourceArray()[i],
base_plot_group,
scroll_bar_position);
feature_display_array[i].setShowLabels(false);
feature_display_array[i].setHardLeftEdge(false);
if(getEntryGroupArray().length > 2)
{
feature_display_array[i].setShowForwardFrameLines(false);
feature_display_array[i].setShowReverseFrameLines(false);
}
feature_display_array[i].addDisplayAdjustmentListener(base_plot_group);
base_plot_group_array[i] = base_plot_group;
this_entry_group.ref();
}
for(int i = 0 ; i < getComparisonDataArray().length ; ++i)
{
alignment_viewer_array[i] =
new AlignmentViewer(getFeatureDisplayArray()[i] ,
getFeatureDisplayArray()[i + 1],
getComparisonDataArray()[i]);
comparator_glue_array[i] =
new ComparatorGlue(this,
getFeatureDisplayArray()[i],
getFeatureDisplayArray()[i + 1],
getAlignmentViewerArray()[i]);
}
getContentPane().setLayout(layout);
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.NORTH;
c.gridheight = 1;
c.weightx = 1;
c.weighty = 0;
for(int i = 0; i < getFeatureDisplayArray().length; ++i)
{
if(!(i == getEntryGroupArray().length - 1 &&
getEntryGroupArray().length == 2))
{
// put graph above the sequence in this case
getContentPane().add(base_plot_group_array[i], c);
c.weighty = 1;
bamPanel[i].setVisible(false);
if(i == getEntryGroupArray().length - 1 &&
getEntryGroupArray().length == 2)
{
// put graph below the sequence in this case
getContentPane().add(base_plot_group_array[i], c);
c.weighty = 1;
bamPanel[i].setVisible(false);
}
if(i < getAlignmentViewerArray().length)
{
c.fill = GridBagConstraints.BOTH;
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
}
}
for(int i = 0 ; i < getEntryGroupArray().length ; ++i)
{
final EntryGroupChangeListener change_listener =
new EntryGroupChangeListener()
{
public void entryGroupChanged(final EntryGroupChangeEvent event)
{
switch(event.getType())
{
case EntryGroupChangeEvent.ENTRY_ADDED:
case EntryGroupChangeEvent.ENTRY_DELETED:
makeFileMenu();
break;
}
}
};
getEntryGroupArray()[i].addEntryGroupChangeListener(change_listener);
final EntryChangeListener entry_change_listener =
new EntryChangeListener()
{
public void entryChanged(final EntryChangeEvent event)
{
switch(event.getType())
{
case EntryChangeEvent.NAME_CHANGED:
makeFileMenu();
break;
}
}
};
getEntryGroupArray()[i].addEntryChangeListener(entry_change_listener);
}
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent event)
{
closeComparator();
}
});
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
if(icon_url != null)
{
Toolkit toolkit = Toolkit.getDefaultToolkit();
final Image icon_image = toolkit.getImage(icon_url);
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(icon_image, 0);
try
{
tracker.waitForAll();
setIconImage(icon_image);
}
catch(InterruptedException e)
{
// ignore and continue
}
}
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int screen_height = screen.height;
int screen_width = screen.width;
if(getAlignmentViewerArray().length > 0)
{
if(screen_width <= 900 || screen_height <= 700)
setSize(screen_width * 9 / 10, screen_height * 9 / 10);
else
setSize(900, 700);
}
setLocation(new Point((screen.width - getSize().width) / 2,
(screen.height - getSize().height) / 2));
for(int i=0; i<getEntryGroupArray().length; i++)
loadFromProperty(i);
}
/**
* Load BAM/VCF files using the system properties flag -Dbam1, -Dbam2
* for sequences 1, 2...
* @param index the feature display to associate the files with
*/
private void loadFromProperty(final int index)
{
final String bamProperty = "bam"+(index+1);
if(System.getProperty(bamProperty) != null)
{
SwingWorker worker = new SwingWorker()
{
public Object construct()
{
MultiComparator.this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
String ngs[] = System.getProperty(bamProperty).split("[\\s,]");
FileSelectionDialog fileChooser = new FileSelectionDialog(ngs);
List<String> listBams = fileChooser.getFiles(".*\\.bam$");
List<String> vcfFiles = fileChooser.getFiles(VCFview.VCFFILE_SUFFIX);
loadBamAndVcf(listBams, vcfFiles, index);
MultiComparator.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
return null;
}
};
worker.start();
}
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
}
/**
* Move all the sequences(and comparisons) up one place. The first and
* last EntryGroups should be the same(reference).
**/
private void rotateSequences()
{
final EntryGroup[] new_entry_groups =
new EntryGroup[getEntryGroupArray().length];
final ComparisonData[] new_comparison_data =
new ComparisonData[getComparisonDataArray().length];
for(int i = 1 ; i < new_entry_groups.length ; ++i)
new_entry_groups[i - 1] = getEntryGroupArray()[i];
new_entry_groups[new_entry_groups.length - 1] = new_entry_groups[0];
for(int i = 1; i < new_comparison_data.length; ++i)
new_comparison_data[i - 1] = getComparisonDataArray()[i];
new_comparison_data[new_comparison_data.length - 1] =
getComparisonDataArray()[0];
final MultiComparator new_comparator =
new MultiComparator(new_entry_groups, new_comparison_data,
progress_listener);
setVisible(false);
new_comparator.setVisible(true);
closeComparator();
}
/**
* If there are no unsaved changes, close this EntryEdit. Otherwise ask
* the user first.
**/
private void closeComparator()
{
for(int i = 0 ; i < getEntryGroupArray().length ; ++i)
{
final EntryGroup entry_group = getEntryGroupArray()[i];
if(entry_group.hasUnsavedChanges() &&
entry_group.refCount() == 1)
{
final YesNoDialog yes_no_dialog =
new YesNoDialog(this,
"there are unsaved changes - really close?");
if(!yes_no_dialog.getResult())
return;
}
}
for(int i = 0 ; i < getEntryGroupArray().length ; ++i)
{
final EntryGroup entry_group = getEntryGroupArray()[i];
if(!GeneUtils.isDatabaseEntry(entry_group))
entry_group.unref();
}
dispose();
}
/**
* Make one Selection object each EntryGroup.
**/
private void makeSelectionArray()
{
final int length = getEntryGroupArray().length;
selection_array = new Selection[length];
for(int i = 0 ; i < length ; ++i)
selection_array[i] = new Selection(null);
}
/**
* Make subject_goto_event_source and query_goto_event_source and wire them
* togeather so that goto events do the right thing.
**/
private void makeGotoEventSourceArray()
{
final int length = getEntryGroupArray().length;
goto_event_source_array = new GotoEventSource[length];
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
{
goto_event_source_array[i] =
new SimpleGotoEventSource(getEntryGroupArray()[i])
{
/**
* Send the given event to all the GotoListeners.
**/
public void sendGotoEvent(final GotoEvent goto_event)
{
// temporarily disable moving so that the other FeatureDisplay
// doesn't start moving(because of the listeners set up in
// addDisplayListeners()
super.sendGotoEvent(goto_event);
}
};
}
}
/**
* Save the given entry, prompting for a file name if necessary.
**/
private void saveEntry(final Entry entry)
{
if(entry.getName() == null)
{
final EntryFileDialog file_dialog = new EntryFileDialog(this, true);
file_dialog.saveEntry(entry, true, true,
}
else
{
try
{
entry.save(DocumentEntryFactory.ANY_FORMAT);
// save it back to ssh server
if(((DocumentEntry)entry.getEMBLEntry()).getDocument()
instanceof RemoteFileDocument)
{
RemoteFileDocument node =
(RemoteFileDocument)(((DocumentEntry)entry.getEMBLEntry()).getDocument());
File file = new File( ((DocumentEntry)entry.getEMBLEntry()).getDocument().getLocation().toString() );
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
}
catch(IOException e)
{
new MessageDialog(this, "error while saving: " + e);
return;
}
catch(EntryInformationException e)
{
new MessageDialog(this, "error while saving: " + e);
return;
}
}
}
/**
* Return the name to use for the sub JMenu for the given EntryGroup.
**/
private String makeNewSubMenuName(final EntryGroup entry_group)
{
final Entry sequence_entry = entry_group.getSequenceEntry();
if(sequence_entry == null)
return "(no name)";
else
{
final String sequence_name = sequence_entry.getName();
if(sequence_name == null)
return "(no name)";
else
return sequence_name;
}
}
/**
* Make and add the menus for this component.
**/
private void makeMenus()
{
setJMenuBar(menu_bar);
makeFileMenu();
menu_bar.add(file_menu);
final JMenu entries_menu = new JMenu("Entries");
menu_bar.add(entries_menu);
final JMenu select_menu = new JMenu("Select");
menu_bar.add(select_menu);
final JMenu view_menu = new JMenu("View");
menu_bar.add(view_menu);
final JMenu goto_menu = new JMenu("Goto");
menu_bar.add(goto_menu);
final JMenu edit_menu = new JMenu("Edit");
menu_bar.add(edit_menu);
final JMenu create_menu = new JMenu("Create");
JMenu run_menu = new JMenu("Run");
run_menu.setMnemonic(KeyEvent.VK_R);
menu_bar.add(run_menu);
menu_bar.add(graph_menu);
for(int i = 0 ; i < getEntryGroupArray().length ; ++i)
{
final EntryGroup entry_group = getEntryGroupArray()[i];
final String sub_menu_name = makeNewSubMenuName(entry_group);
AlignmentViewer alignQueryViewer;
if(i==0)
alignQueryViewer = null;
else
alignQueryViewer = getAlignmentViewerArray()[i-1];
AlignmentViewer alignSubjectViewer;
if(i == getEntryGroupArray().length-1)
alignSubjectViewer = null;
else
alignSubjectViewer = getAlignmentViewerArray()[i];
final EntryGroupMenu this_entries_menu =
new EntryGroupMenu(this,
getEntryGroupArray()[i],
sub_menu_name);
entries_menu.add(this_entries_menu);
final SelectMenu this_select_menu =
new SelectMenu(this,
getSelectionArray()[i],
getGotoEventSourceArray()[i],
getEntryGroupArray()[i],
getBasePlotGroupArray()[i],
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
sub_menu_name);
select_menu.add(this_select_menu);
final ViewMenu this_view_menu =
new ViewMenu(this,
getSelectionArray()[i],
getGotoEventSourceArray()[i],
getEntryGroupArray()[i],
getBasePlotGroupArray()[i],
sub_menu_name);
view_menu.add(this_view_menu);
final GotoMenu this_goto_menu =
new GotoMenu(this,
getSelectionArray()[i],
getGotoEventSourceArray()[i],
getEntryGroupArray()[i],
sub_menu_name);
goto_menu.add(this_goto_menu);
AddMenu this_create_menu = null;
if(Options.readWritePossible())
{
final EditMenu this_edit_menu =
new EditMenu(this,
getSelectionArray()[i],
getGotoEventSourceArray()[i],
getEntryGroupArray()[i],
getBasePlotGroupArray()[i],
new AddMenu(this, getSelectionArray()[i],
getEntryGroupArray()[i],
getGotoEventSourceArray()[i],
getBasePlotGroupArray()[i],
final RunMenu this_run_menu =
new RunMenu(this, getSelectionArray()[i],
}
final GraphMenu this_graph_menu =
new GraphMenu(this,
getEntryGroupArray()[i],
getBasePlotGroupArray()[i],
getFeatureDisplayArray()[i],
sub_menu_name, null, i+1);
final JMenuItem resize = new JMenuItem("Adjust panel heights ...");
resize.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
new ActPanelResizer(MultiComparator.this, layout);
}
});
view_menu.add(resize);
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
final JMenuItem hide_on_frame_lines_item =
new JMenuItem("Hide Frame Lines");
hide_on_frame_lines_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
for(int i = 0 ; i < getFeatureDisplayArray().length ; ++i)
{
getFeatureDisplayArray()[i].setShowForwardFrameLines(false);
getFeatureDisplayArray()[i].setShowReverseFrameLines(false);
}
}
});
display_menu.add(hide_on_frame_lines_item);
final JMenuItem show_on_frame_lines_item =
new JMenuItem("Show Frame Lines");
show_on_frame_lines_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
for(int i = 0 ; i < getFeatureDisplayArray().length ; ++i)
{
getFeatureDisplayArray()[i].setShowForwardFrameLines(true);
getFeatureDisplayArray()[i].setShowReverseFrameLines(true);
}
}
});
display_menu.add(show_on_frame_lines_item);
menu_bar.add(display_menu);
}
JMenuItem printImage = new JMenuItem("Save As Image Files (png/svg)...");
printImage.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
PrintACT pact = new PrintACT(MultiComparator.this);
pact.print();
}
});
file_menu.add(printImage);
JMenuItem printPS = new JMenuItem("Print...");
printPS.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
PrintACT pact = new PrintACT(MultiComparator.this);
pact.doPrintActions();
}
});
file_menu.add(printPS);
// print preview
JMenuItem printPreview = new JMenuItem("Print Preview");
file_menu.add(printPreview);
printPreview.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
PrintACT pact = new PrintACT(MultiComparator.this);
pact.printPreview();
}
});
}
/**
* Make a new File menu replacing the current one(if any).
**/
private void makeFileMenu()
{
file_menu.removeAll();
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
final EntryGroup[] entry_group_array = getEntryGroupArray();
JMenuItem popFileManager = new JMenuItem("Show File Manager ...");
popFileManager.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(ActMain.filemanager == null)
ActMain.filemanager = new FileManager(MultiComparator.this,null);
else
ActMain.filemanager.setVisible(true);
}
});
file_menu.add(popFileManager);
if(entry_group_array[0] ==
entry_group_array[entry_group_array.length - 1])
{
final JMenuItem rotate_button = new JMenuItem("Rotate Sequences");
rotate_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
rotateSequences();
}
});
file_menu.add(rotate_button);
file_menu.addSeparator();
}
for(int i = 0; i < getEntryGroupArray().length; ++i)
{
final EntryGroup entry_group = getEntryGroupArray()[i];
final String new_menu_name = makeNewSubMenuName(entry_group);
final JMenu entry_group_menu = new JMenu(new_menu_name);
file_menu.add(entry_group_menu);
for(int source_index = 0; source_index < entry_sources.size();
++source_index)
{
final EntrySource this_source =
entry_sources.elementAt(source_index);
if(this_source.isFullEntrySource())
continue;
String entry_source_name = this_source.getSourceName();
String menu_item_name = null;
if(entry_source_name.equals("Filesystem"))
menu_item_name = "Read An Entry ...";
else
menu_item_name = "Read An Entry From " + entry_source_name + " ...";
final JMenuItem read_entry = new JMenuItem(menu_item_name);
read_entry.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
readAnEntry(this_source,entry_group);
}
});
entry_group_menu.add(read_entry);
}
entry_group_menu.addSeparator();
if(entry_group == null || entry_group.size() == 0)
{
// don't create a menu
}
else
{
final JMenu save_entry_menu = new JMenu("Save Entry");
for(int entry_index = 0; entry_index < entry_group.size();
++entry_index)
{
final Entry this_entry = entry_group.elementAt(entry_index);
String entry_name = this_entry.getName();
if(entry_name == null)
entry_name = "no name";
final ActionListener save_entry_listener =
new ActionListener()
{
public void actionPerformed(final ActionEvent event)
{
MultiComparator.this.saveEntry(this_entry);
}
};
final JMenuItem save_entry_item = new JMenuItem(entry_name);
save_entry_item.addActionListener(save_entry_listener);
save_entry_menu.add(save_entry_item);
}
entry_group_menu.add(save_entry_menu);
if(GeneUtils.isDatabaseEntry(entry_group))
{
final ChadoTransactionManager ctm = new ChadoTransactionManager();
entry_group.addFeatureChangeListener(ctm);
entry_group.addEntryChangeListener(ctm);
entry_group.getBases().addSequenceChangeListener(ctm, 0);
ctm.setEntryGroup(entry_group);
final Selection selection = getSelectionArray()[i];
final GotoEventSource goto_event_source = getGotoEventSourceArray()[i];
final BasePlotGroup base_plot_group = getBasePlotGroupArray()[i];
final JMenuItem commit_entry_item = new JMenuItem("Commit ...");
commit_entry_item.addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent event)
{
EntryEdit.commitToDatabase(entry_group, ctm, MultiComparator.this,
selection, goto_event_source,base_plot_group);
}
});
entry_group_menu.add(commit_entry_item);
}
final JMenuItem save_all_menu = new JMenuItem("Save All");
save_all_menu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
for(int entry_index = 0; entry_index < entry_group.size();
++entry_index)
{
final Entry this_entry = entry_group.elementAt(entry_index);
MultiComparator.this.saveEntry(this_entry);
}
}
});
entry_group_menu.add(save_all_menu);
entry_group_menu.addSeparator();
final WriteMenu this_write_menu =
new WriteMenu(this,
getSelectionArray()[i],
getEntryGroupArray()[i]);
entry_group_menu.add(this_write_menu);
entry_group_menu.addSeparator();
read_bam_file.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
FileSelectionDialog fileChooser = new FileSelectionDialog(
List<String> listBams = fileChooser.getFiles(".*\\.bam$");
List<String> vcfFiles = fileChooser.getFiles(VCFview.VCFFILE_SUFFIX);
loadBamAndVcf(listBams, vcfFiles, index);
final JMenuItem edit_subject = new JMenuItem("Edit In Artemis");
edit_subject.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
final EntryEdit entry_edit = new EntryEdit(entry_group);
entry_edit.setVisible(true);
}
});
entry_group_menu.add(edit_subject);
}