From dd31808c17e9882806a200438d319cb1374f203c Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Tue, 21 Nov 2017 13:09:35 +0000 Subject: [PATCH] JAL-281 added string label for loading from database --- resources/lang/Messages.properties | 7 +- src/jalview/ext/archaeopteryx/AptxInit.java | 3 +- src/jalview/gui/AlignFrame.java | 111 +++++++++++++-------------- src/jalview/jbgui/GAlignFrame.java | 2 +- 4 files changed, 58 insertions(+), 65 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index bf87e5e..290066b 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -299,7 +299,7 @@ label.show_distances = Show distances label.mark_unassociated_leaves = Mark Unassociated Leaves label.fit_to_window = Fit To Window label.newick_format = Newick Format -label.select_newick_like_tree_file = Select a newick-like tree file +label.select_tree_file = Select a tree file label.colours = Colours label.view_mapping = View Mapping label.wireframe = Wireframe @@ -389,6 +389,7 @@ label.sequences_selection_not_aligned = Sequences in selection are not aligned label.problem_reading_tree_file = Problem reading tree file label.possible_problem_with_tree_file = Possible problem with tree file label.tree_url_example = Please enter a complete URL, \"for example http://purl.org/phylo/treebase/phylows/study/TB2:S15480?format=nexus\" +label.from_database = From Database... label.load_tree_url = Tree from URL label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation = Please select at least three bases in at least one sequence in order to perform a cDNA translation. label.translation_failed = Translation Failed @@ -561,10 +562,10 @@ label.select_copy_raw_html = Select this if you want to copy raw html label.share_data_vamsas_applications = Share data with other vamsas applications label.connect_to = Connect to label.join_existing_vamsas_session = Join an existing vamsas session -label.from_url = from URL +label.from_url = From URL label.any_trees_calculated_or_loaded_alignment_automatically_sort = When selected, any trees calculated or loaded onto the alignment will automatically sort the alignment label.sort_with_new_tree = Sort With New Tree -label.from_textbox = from Textbox +label.from_textbox = From Textbox label.window = Window label.preferences = Preferences label.tools = Tools diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java index f6d9fd6..4a49734 100644 --- a/src/jalview/ext/archaeopteryx/AptxInit.java +++ b/src/jalview/ext/archaeopteryx/AptxInit.java @@ -130,7 +130,7 @@ public final class AptxInit public static MainFrame createInstanceFromUrl(URL treeUrl, AlignmentViewport viewport) - throws FileNotFoundException, IOException + throws FileNotFoundException, IOException, RuntimeException { Phylogeny[] trees = AptxUtil.readPhylogeniesFromUrl(treeUrl, @@ -154,7 +154,6 @@ public final class AptxInit return bindFrameToJalview(aptxApp); - } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index f5e8521..8408bcb 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3878,27 +3878,53 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } return seqs; } -public void chooseTreeFile() { - // Pick the tree file - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY")); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle( - MessageManager.getString("label.select_newick_like_tree_file")); // modify - chooser.setToolTipText( - MessageManager.getString("label.load_tree_for_sequence_set")); - for (SupportedTreeFileFilter treeFormat : SupportedTreeFileFilter - .values()) + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void loadTreeMenuItem_actionPerformed(ActionEvent e) + { + chooseTreeFile(); + } + + @Override + protected void loadTreeUrlItem_actionPerformed(ActionEvent e) { - chooser.setFileFilter(treeFormat.getTreeFilter()); + chooseTreeUrl(); } - int value = chooser.showOpenDialog(null); + @Override + protected void loadTreeDbItem_actionPerformed(ActionEvent e) + { + chooseTreeDb(); + } - if (value == JalviewFileChooser.APPROVE_OPTION) + public void chooseTreeFile() { - String filePath = chooser.getSelectedFile().getPath(); - Cache.setProperty("LAST_DIRECTORY", filePath); + // Pick the tree file + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle( + MessageManager.getString("label.select_tree_file")); // modify + chooser.setToolTipText( + MessageManager.getString("label.load_tree_for_sequence_set")); + for (SupportedTreeFileFilter treeFormat : SupportedTreeFileFilter + .values()) + { + chooser.setFileFilter(treeFormat.getTreeFilter()); + } + + int value = chooser.showOpenDialog(null); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String filePath = chooser.getSelectedFile().getPath(); + Cache.setProperty("LAST_DIRECTORY", filePath); TreeParser treeParser = new TreeParser(filePath); treeParser.loadTree(viewport); @@ -3907,7 +3933,7 @@ public void chooseTreeFile() { } /** - * Move to TreeParser? + * Break up and move to TreeParser? */ public void chooseTreeUrl() { @@ -3930,14 +3956,14 @@ public void chooseTreeFile() { StringTokenizer st; if (historyItems != null) - { + { st = new StringTokenizer(historyItems, "\t"); while (st.hasMoreTokens()) { history.addItem(st.nextToken()); } - } + } int reply = JvOptionPane.showInternalConfirmDialog(this, panel, MessageManager.getString("label.load_tree_url"), @@ -3958,15 +3984,13 @@ public void chooseTreeFile() { treeUrl = new URL(urlString); AptxInit.createInstanceFromUrl(treeUrl, viewport); - } catch (IOException e) + } catch (IOException | RuntimeException e) { - JvOptionPane.showMessageDialog(this, - MessageManager.formatMessage( - "exception.failed_to_read_data_from_source", - new String[] - { urlString }), - MessageManager.getString("label.url_not_found") - , JvOptionPane.ERROR_MESSAGE); + JvOptionPane.showMessageDialog(this, MessageManager.formatMessage( + "exception.failed_to_read_data_from_source", new String[] + { urlString }), + MessageManager.getString("label.url_not_found"), + JvOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } @@ -3974,42 +3998,11 @@ public void chooseTreeFile() { { } - - - - - // final String url_string = JOptionPane - // .showInputDialog( this, - // message, - // "Use URL/webservice to obtain a phylogeny", - // JOptionPane.QUESTION_MESSAGE ); - // boolean nhx_or_nexus = false; - // if ( ( url_string != null ) && ( url_string.length() > 0 ) ) { - // try { - // url = new URL( url_string ); } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void loadTreeMenuItem_actionPerformed(ActionEvent e) + public void chooseTreeDb() { - chooseTreeFile(); - } - @Override - protected void loadTreeUrlItem_actionPerformed(ActionEvent e) - { - chooseTreeUrl(); - } - - @Override - protected void loadTreeDbItem_actionPerformed(ActionEvent e) - { } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 954721e..0672136 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -1101,7 +1101,7 @@ public class GAlignFrame extends JInternalFrame }); JMenuItem loadTreeDb = new JMenuItem( - MessageManager.getString("FIX ME")); + MessageManager.getString("label.from_database")); loadTreeDb.addActionListener(new ActionListener() { @Override -- 1.7.10.2