diff --git a/src/main/java/org/broad/igv/ui/IGVMenuBar.java b/src/main/java/org/broad/igv/ui/IGVMenuBar.java index 8f72951c9..67dae72c5 100644 --- a/src/main/java/org/broad/igv/ui/IGVMenuBar.java +++ b/src/main/java/org/broad/igv/ui/IGVMenuBar.java @@ -431,7 +431,7 @@ private JMenu createGenomesMenu() { JMenu menu = new JMenu("Genomes"); - loadGenomeFromServerMenuItem = new JMenuItem("Select Hosted Genome..."); + loadGenomeFromServerMenuItem = new JMenuItem("Download Hosted Genome..."); loadGenomeFromServerMenuItem.addActionListener(e -> GenomeComboBox.loadGenomeFromServer()); loadGenomeFromServerMenuItem.setToolTipText(LOAD_GENOME_SERVER_TOOLTIP); menu.add(loadGenomeFromServerMenuItem); diff --git a/src/main/java/org/broad/igv/ui/commandbar/GenomeComboBox.java b/src/main/java/org/broad/igv/ui/commandbar/GenomeComboBox.java index 96302500c..b7fca4cca 100644 --- a/src/main/java/org/broad/igv/ui/commandbar/GenomeComboBox.java +++ b/src/main/java/org/broad/igv/ui/commandbar/GenomeComboBox.java @@ -6,11 +6,9 @@ import org.broad.igv.event.IGVEventBus; import org.broad.igv.feature.genome.GenomeListItem; import org.broad.igv.feature.genome.GenomeManager; -import org.broad.igv.feature.genome.GenomeServerException; import org.broad.igv.ui.IGV; import org.broad.igv.ui.UIConstants; import org.broad.igv.ui.util.MessageUtils; -import org.broad.igv.ui.util.ProgressBar; import org.broad.igv.ui.util.UIUtilities; import org.broad.igv.util.LongRunningTask; @@ -97,27 +95,16 @@ private void loadGenomeListItem(final GenomeListItem genomeListItem) { return; } - final Runnable runnable = new Runnable() { + final Runnable runnable = () -> { - public void run() { + if (genomeListItem != null && genomeListItem.getPath() != null) { - if (genomeListItem != null && genomeListItem.getPath() != null) { - - //log.warn("Loading " + genomeListItem.getId()); - - //User selected "more", pull up dialog and revert combo box - if (genomeListItem == GenomeListItem.DOWNLOAD_ITEM) { - loadGenomeFromServer(); - return; - } + if (genomeListItem == GenomeListItem.DOWNLOAD_ITEM) { + loadGenomeFromServer(); + } else { try { - GenomeManager.getInstance().loadGenomeById(genomeListItem.getId()); - } catch (GenomeServerException e) { - log.error("Error loading genome: " + genomeListItem.getId() + " " + genomeListItem.getPath(), e); - JOptionPane.showMessageDialog( - IGV.getInstance().getMainFrame(), - "Error loading genome: " + genomeListItem.getDisplayableName()); + GenomeManager.getInstance().loadGenomeById(genomeListItem.getId()); } catch (Exception e) { log.error(e); int choice = JOptionPane.showConfirmDialog( @@ -130,10 +117,7 @@ public void run() { refreshGenomeListComboBox(); log.error("Error initializing genome", e); } - } finally { - } - } } }; @@ -223,21 +207,20 @@ public static void loadGenomeFromServer() { Collection inputListItems = GenomeListManager.getInstance().getServerGenomeList(); if (inputListItems == null) { - //Could not reach genome server. Not necessary to display a message, getServerGenomeArchiveList does it already return; } GenomeSelectionDialog dialog = new GenomeSelectionDialog(IGV.getInstance().getMainFrame(), inputListItems); UIUtilities.invokeAndWaitOnEventThread(() -> dialog.setVisible(true)); if (dialog.isCanceled()) { - // Clear the "More..." selection in pulldown IGVEventBus.getInstance().post(new GenomeResetEvent()); } else { List selectedValueList = dialog.getSelectedValues(); GenomeListItem firstItem = null; for (GenomeListItem selectedValue : selectedValueList) { if (selectedValue != null) { - boolean success = GenomeManager.getInstance().downloadGenome(selectedValue, dialog.downloadSequence()); + boolean downloadSequence = false; + boolean success = GenomeManager.getInstance().downloadGenome(selectedValue, downloadSequence); if (success) { GenomeListManager.getInstance().addServerGenomeItem(selectedValue); firstItem = selectedValue; @@ -252,7 +235,7 @@ public static void loadGenomeFromServer() { GenomeListManager.getInstance().removeUserDefinedGenome(firstItem.getId()); // If this is a .json genome, attempt to remove existing .genome files - if(firstItem.getPath().endsWith(".json")) { + if (firstItem.getPath().endsWith(".json")) { removeDotGenomeFile(firstItem.getId()); } @@ -276,7 +259,7 @@ public static void loadGenomeFromServer() { public static void removeDotGenomeFile(String id) { try { File dotGenomeFile = new File(DirectoryManager.getGenomeCacheDirectory(), id + ".genome"); - if(dotGenomeFile.exists()) { + if (dotGenomeFile.exists()) { dotGenomeFile.delete(); } } catch (Exception e) { diff --git a/src/main/java/org/broad/igv/ui/commandbar/GenomeSelectionDialog.java b/src/main/java/org/broad/igv/ui/commandbar/GenomeSelectionDialog.java index baa3cc6bf..096566b4d 100644 --- a/src/main/java/org/broad/igv/ui/commandbar/GenomeSelectionDialog.java +++ b/src/main/java/org/broad/igv/ui/commandbar/GenomeSelectionDialog.java @@ -47,7 +47,7 @@ * Dialog box for selecting genomes. User can choose from a list, * which is filtered according to text box input */ -public class GenomeSelectionDialog extends org.broad.igv.ui.IGVDialog { +public class GenomeSelectionDialog extends org.broad.igv.ui.IGVDialog { private JPanel dialogPane; private JPanel contentPanel; @@ -57,7 +57,6 @@ public class GenomeSelectionDialog extends org.broad.igv.ui.IGVDialog { private JTextField genomeFilter; private JScrollPane scrollPane1; private JList genomeList; - private JCheckBox downloadSequenceCB; private JPanel buttonBar; private JButton okButton; private JButton cancelButton; @@ -74,7 +73,6 @@ public GenomeSelectionDialog(java.awt.Frame parent, Collection i super(parent); initComponents(); initData(inputListItems); - downloadSequenceCB.setVisible(true); } private void initData(Collection inputListItems) { @@ -84,18 +82,12 @@ private void initData(Collection inputListItems) { } /** - * Filter the list of displayed genomes so we only show this - * with the text the user entered. + * Filter the list of displayed genomes with the text the user entered. */ private void rebuildGenomeList(String filterText) { if (genomeListModel == null) { genomeListModel = new DefaultListModel(); - UIUtilities.invokeOnEventThread(new Runnable() { - @Override - public void run() { - genomeList.setModel(genomeListModel); - } - }); + UIUtilities.invokeOnEventThread(() -> genomeList.setModel(genomeListModel)); } genomeListModel.clear(); filterText = filterText.toLowerCase().trim(); @@ -117,11 +109,9 @@ private void genomeListMouseClicked(MouseEvent e) { switch (e.getClickCount()) { case 1: List selValues = genomeList.getSelectedValuesList(); - downloadSequenceCB.setEnabled(selValues != null && selValues.size() == 1); break; case 2: - okButtonActionPerformed(null); - break; + okButtonActionPerformed(null); } } @@ -133,10 +123,6 @@ public List getSelectedValues() { return selectedValues; } - public boolean downloadSequence(){ - return !isCanceled() && downloadSequenceCB.isEnabled() && downloadSequenceCB.isSelected(); - } - public boolean isCanceled() { return isCanceled; } @@ -165,7 +151,6 @@ private void initComponents() { genomeFilter = new JTextField(); scrollPane1 = new JScrollPane(); genomeList = new JList(); - downloadSequenceCB = new JCheckBox(); buttonBar = new JPanel(); okButton = new JButton(); cancelButton = new JButton(); @@ -201,10 +186,10 @@ private void initComponents() { { filterPanel.setMaximumSize(new Dimension(2147483647, 28)); filterPanel.setLayout(new GridBagLayout()); - ((GridBagLayout)filterPanel.getLayout()).columnWidths = new int[] {0, 0, 0}; - ((GridBagLayout)filterPanel.getLayout()).rowHeights = new int[] {0, 0}; - ((GridBagLayout)filterPanel.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0E-4}; - ((GridBagLayout)filterPanel.getLayout()).rowWeights = new double[] {1.0, 1.0E-4}; + ((GridBagLayout) filterPanel.getLayout()).columnWidths = new int[]{0, 0, 0}; + ((GridBagLayout) filterPanel.getLayout()).rowHeights = new int[]{0, 0}; + ((GridBagLayout) filterPanel.getLayout()).columnWeights = new double[]{1.0, 1.0, 1.0E-4}; + ((GridBagLayout) filterPanel.getLayout()).rowWeights = new double[]{1.0, 1.0E-4}; //---- label1 ---- label1.setText("Filter:"); @@ -246,14 +231,6 @@ public void igvMouseClicked(MouseEvent e) { } contentPanel.add(scrollPane1); - //---- downloadSequenceCB ---- - downloadSequenceCB.setText("Download Sequence"); - downloadSequenceCB.setAlignmentX(1.0F); - downloadSequenceCB.setToolTipText("Download the full sequence for this organism. Note that these files can be very large (human is about 3 gigabytes)"); - downloadSequenceCB.setMaximumSize(new Dimension(1000, 23)); - downloadSequenceCB.setPreferredSize(new Dimension(300, 23)); - downloadSequenceCB.setMinimumSize(new Dimension(300, 23)); - contentPanel.add(downloadSequenceCB); } dialogPane.add(contentPanel, BorderLayout.CENTER); @@ -261,29 +238,19 @@ public void igvMouseClicked(MouseEvent e) { { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); - ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; - ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; + ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[]{0, 85, 80}; + ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[]{1.0, 0.0, 0.0}; //---- okButton ---- okButton.setText("OK"); - okButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - okButtonActionPerformed(e); - } - }); + okButton.addActionListener(e -> okButtonActionPerformed(e)); buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- cancelButton ---- cancelButton.setText("Cancel"); - cancelButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cancelButtonActionPerformed(e); - } - }); + cancelButton.addActionListener(e -> cancelButtonActionPerformed(e)); buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));