From: gmungoc Date: Mon, 28 Sep 2015 11:20:42 +0000 (+0100) Subject: JAL-1499 MEGA format, JAL-1421 List url links X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4b2d869e1b0570a5a37339e8a787a7b40ded2209;p=jalview.git JAL-1499 MEGA format, JAL-1421 List url links --- diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 5dfe581..c86240f 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -35,8 +35,8 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -196,7 +196,7 @@ public class IdPanel extends JPanel implements MouseListener, return; } - Vector links = Preferences.sequenceURLLinks; + List links = Preferences.getSequenceURLLinks(); if (links == null || links.size() < 1) { return; @@ -210,7 +210,7 @@ public class IdPanel extends JPanel implements MouseListener, { // DEFAULT LINK IS FIRST IN THE LINK LIST // BUT IF ITS A REGEX AND DOES NOT MATCH THE NEXT ONE WILL BE TRIED - url = links.elementAt(i++).toString(); + url = links.get(i++).toString(); jalview.util.UrlLink urlLink = null; try { @@ -252,12 +252,6 @@ public class IdPanel extends JPanel implements MouseListener, } } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ @Override public void mouseEntered(MouseEvent e) { @@ -267,12 +261,6 @@ public class IdPanel extends JPanel implements MouseListener, } } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ @Override public void mouseExited(MouseEvent e) { @@ -321,7 +309,8 @@ public class IdPanel extends JPanel implements MouseListener, Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq); // build a new links menu based on the current links + any non-positional // features - Vector nlinks = new Vector(Preferences.sequenceURLLinks); + List nlinks = new ArrayList( + Preferences.getSequenceURLLinks()); SequenceFeature sf[] = sq == null ? null : sq.getSequenceFeatures(); for (int sl = 0; sf != null && sl < sf.length; sl++) { @@ -331,14 +320,14 @@ public class IdPanel extends JPanel implements MouseListener, { for (int l = 0, lSize = sf[sl].links.size(); l < lSize; l++) { - nlinks.addElement(sf[sl].links.elementAt(l)); + nlinks.add(sf[sl].links.elementAt(l)); } } } } - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, sq, - nlinks, new Vector(Preferences.getGroupURLLinks())); + PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks, + Preferences.getGroupURLLinks()); pop.show(this, e.getX(), e.getY()); return; diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index fee47e5..8953487 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -33,7 +33,6 @@ import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.DBRefEntry; import jalview.datamodel.PDBEntry; -import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -62,6 +61,7 @@ import jalview.util.UrlLink; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Hashtable; @@ -215,19 +215,6 @@ public class PopupMenu extends JPopupMenu JMenuItem hideInsertions = new JMenuItem(); /** - * Creates a new PopupMenu object. - * - * @param ap - * DOCUMENT ME! - * @param seq - * DOCUMENT ME! - */ - public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links) - { - this(ap, seq, links, null); - } - - /** * * @param ap * @param seq @@ -235,7 +222,7 @@ public class PopupMenu extends JPopupMenu * @param groupLinks */ public PopupMenu(final AlignmentPanel ap, final SequenceI seq, - Vector links, Vector groupLinks) + List links, List groupLinks) { // ///////////////////////////////////////////////////////// // If this is activated from the sequence panel, the user may want to @@ -616,10 +603,10 @@ public class PopupMenu extends JPopupMenu { JMenu linkMenu = new JMenu(MessageManager.getString("action.link")); - Vector linkset = new Vector(); + List linkset = new ArrayList(); for (int i = 0; i < links.size(); i++) { - String link = links.elementAt(i).toString(); + String link = links.get(i); UrlLink urlLink = null; try { @@ -670,7 +657,7 @@ public class PopupMenu extends JPopupMenu { if (!linkset.contains(urls[u] + "|" + urls[u + 1])) { - linkset.addElement(urls[u] + "|" + urls[u + 1]); + linkset.add(urls[u] + "|" + urls[u + 1]); addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]); } @@ -688,7 +675,7 @@ public class PopupMenu extends JPopupMenu { if (!linkset.contains(urls[u] + "|" + urls[u + 1])) { - linkset.addElement(urls[u] + "|" + urls[u + 1]); + linkset.add(urls[u] + "|" + urls[u + 1]); addshowLink(linkMenu, label, urls[u + 1]); } } @@ -706,7 +693,7 @@ public class PopupMenu extends JPopupMenu { if (!linkset.contains(urls[u] + "|" + urls[u + 1])) { - linkset.addElement(urls[u] + "|" + urls[u + 1]); + linkset.add(urls[u] + "|" + urls[u + 1]); addshowLink(linkMenu, label, urls[u + 1]); } } @@ -717,7 +704,7 @@ public class PopupMenu extends JPopupMenu { if (!linkset.contains(label + "|" + urlLink.getUrl_prefix())) { - linkset.addElement(label + "|" + urlLink.getUrl_prefix()); + linkset.add(label + "|" + urlLink.getUrl_prefix()); // Add a non-dynamic link addshowLink(linkMenu, label, urlLink.getUrl_prefix()); } @@ -861,7 +848,7 @@ public class PopupMenu extends JPopupMenu showOrHideMenu.add(item); } - private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks) + private void buildGroupURLMenu(SequenceGroup sg, List groupLinks) { // TODO: usability: thread off the generation of group url content so root @@ -929,7 +916,7 @@ public class PopupMenu extends JPopupMenu // to user for (int i = 0; i < groupLinks.size(); i++) { - String link = groupLinks.elementAt(i).toString(); + String link = groupLinks.get(i); GroupUrlLink urlLink = null; try { diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 5cb6512..33ed0ae 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -29,7 +29,9 @@ import jalview.io.JalviewFileView; import jalview.jbgui.GPreferences; import jalview.jbgui.GSequenceLink; import jalview.schemes.ColourSchemeProperty; +import jalview.util.BrowserLauncher; import jalview.util.MessageManager; +import jalview.util.Platform; import java.awt.BorderLayout; import java.awt.Color; @@ -39,10 +41,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.io.File; -import java.util.Collection; +import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import java.util.Vector; import javax.help.HelpSetException; import javax.swing.JColorChooser; @@ -95,7 +96,7 @@ public class Preferences extends GPreferences * Holds name and link separated with | character. Sequence ID must be * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$ */ - public static Vector sequenceURLLinks; + private static List sequenceURLLinks; /** * Holds name and link separated with | character. Sequence IDS and Sequences @@ -105,14 +106,25 @@ public class Preferences extends GPreferences * (TODO: proper escape for using | to separate ids or sequences */ - public static Vector groupURLLinks; + private static List groupURLLinks; + + List nameLinks; + + List urlLinks; + + JInternalFrame frame; + + DasSourceBrowser dasSource; + + private WsPreferences wsPrefs; + static { String string = Cache .getDefault( "SEQUENCE_LINKS", "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"); - sequenceURLLinks = new Vector(); + sequenceURLLinks = new ArrayList(); try { @@ -127,7 +139,7 @@ public class Preferences extends GPreferences { url = url + "|" + st.nextToken(); } - sequenceURLLinks.addElement(name + "|" + url); + sequenceURLLinks.add(name + "|" + url); } } catch (Exception ex) { @@ -140,9 +152,8 @@ public class Preferences extends GPreferences if (srsPos > -1) { sequenceURLLinks - .setElementAt( - "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$", - srsPos); + .set(srsPos, + "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"); } } @@ -151,17 +162,9 @@ public class Preferences extends GPreferences * .properties file as '|' separated strings */ - groupURLLinks = new Vector(); + groupURLLinks = new ArrayList(); } - Vector nameLinks, urlLinks; - - JInternalFrame frame; - - DasSourceBrowser dasSource; - - private WsPreferences wsPrefs; - /** * Creates a new Preferences object. */ @@ -175,7 +178,7 @@ public class Preferences extends GPreferences wsPrefs = new WsPreferences(); wsTab.add(wsPrefs, BorderLayout.CENTER); int width = 500, height = 450; - if (new jalview.util.Platform().isAMac()) + if (Platform.isAMac()) { width = 570; height = 480; @@ -316,13 +319,13 @@ public class Preferences extends GPreferences /* * Set Connections tab defaults */ - nameLinks = new Vector(); - urlLinks = new Vector(); + nameLinks = new ArrayList(); + urlLinks = new ArrayList(); for (int i = 0; i < sequenceURLLinks.size(); i++) { - String link = sequenceURLLinks.elementAt(i).toString(); - nameLinks.addElement(link.substring(0, link.indexOf("|"))); - urlLinks.addElement(link.substring(link.indexOf("|") + 1)); + String link = sequenceURLLinks.get(i).toString(); + nameLinks.add(link.substring(0, link.indexOf("|"))); + urlLinks.add(link.substring(link.indexOf("|") + 1)); } updateLinkData(); @@ -511,17 +514,17 @@ public class Preferences extends GPreferences */ Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText()); - jalview.util.BrowserLauncher.resetBrowser(); + BrowserLauncher.resetBrowser(); if (nameLinks.size() > 0) { StringBuffer links = new StringBuffer(); - sequenceURLLinks = new Vector(); + sequenceURLLinks = new ArrayList(); for (int i = 0; i < nameLinks.size(); i++) { - sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|" - + urlLinks.elementAt(i)); - links.append(sequenceURLLinks.elementAt(i).toString()); + sequenceURLLinks.add(nameLinks.get(i) + "|" + + urlLinks.get(i)); + links.append(sequenceURLLinks.get(i).toString()); links.append("|"); } // remove last "|" @@ -579,6 +582,8 @@ public class Preferences extends GPreferences Boolean.toString(clustaljv.isSelected())); Cache.applicationProperties.setProperty("FASTA_JVSUFFIX", Boolean.toString(fastajv.isSelected())); + Cache.applicationProperties.setProperty("MEGA_JVSUFFIX", + Boolean.toString(megajv.isSelected())); Cache.applicationProperties.setProperty("MSF_JVSUFFIX", Boolean.toString(msfjv.isSelected())); Cache.applicationProperties.setProperty("PFAM_JVSUFFIX", @@ -651,9 +656,9 @@ public class Preferences extends GPreferences { JalviewFileChooser chooser = new JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", - "PIR", "BLC", "Jalview" }, + "fa, fasta, fastq", "aln", "pfam", "meg", "msf", "pir", + "blc", "jar" }, new String[] { "Fasta", "Clustal", "PFAM", + "MEGA", "MSF", "PIR", "BLC", "Jalview" }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@ -720,8 +725,8 @@ public class Preferences extends GPreferences { if (link.checkValid()) { - nameLinks.addElement(link.getName()); - urlLinks.addElement(link.getURL()); + nameLinks.add(link.getName()); + urlLinks.add(link.getURL()); updateLinkData(); valid = true; } @@ -747,8 +752,8 @@ public class Preferences extends GPreferences return; } - link.setName(nameLinks.elementAt(index).toString()); - link.setURL(urlLinks.elementAt(index).toString()); + link.setName(nameLinks.get(index).toString()); + link.setURL(urlLinks.get(index).toString()); boolean valid = false; while (!valid) @@ -760,8 +765,8 @@ public class Preferences extends GPreferences { if (link.checkValid()) { - nameLinks.setElementAt(link.getName(), index); - urlLinks.setElementAt(link.getURL(), index); + nameLinks.set(index, link.getName()); + urlLinks.set(index, link.getURL()); updateLinkData(); valid = true; } @@ -785,15 +790,15 @@ public class Preferences extends GPreferences JOptionPane.WARNING_MESSAGE); return; } - nameLinks.removeElementAt(index); - urlLinks.removeElementAt(index); + nameLinks.remove(index); + urlLinks.remove(index); updateLinkData(); } void updateLinkData() { - linkNameList.setListData(nameLinks); - linkURLList.setListData(urlLinks); + linkNameList.setListData(nameLinks.toArray(new String[nameLinks.size()])); + linkURLList.setListData(urlLinks.toArray(new String[urlLinks.size()])); } public void defaultBrowser_mouseClicked(MouseEvent e) @@ -811,22 +816,14 @@ public class Preferences extends GPreferences } - /* - * (non-Javadoc) - * - * @see - * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event - * .ActionEvent) - */ - protected void showunconserved_actionPerformed(ActionEvent e) + public static List getGroupURLLinks() { - // TODO Auto-generated method stub - super.showunconserved_actionPerformed(e); + return groupURLLinks; } - public static Collection getGroupURLLinks() + public static List getSequenceURLLinks() { - return groupURLLinks; + return sequenceURLLinks; } @Override diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 4ee87fc..30d7d63 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -54,8 +54,8 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -1601,19 +1601,19 @@ public class SeqPanel extends JPanel implements MouseListener, List allFeatures = ap.getFeatureRenderer() .findFeaturesAtRes(sequence.getDatasetSequence(), sequence.findPosition(res)); - Vector links = new Vector(); + List links = new ArrayList(); for (SequenceFeature sf : allFeatures) { if (sf.links != null) { for (int j = 0; j < sf.links.size(); j++) { - links.addElement(sf.links.elementAt(j)); + links.add(sf.links.elementAt(j)); } } } - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null, links); + PopupMenu pop = new PopupMenu(ap, null, links, null); pop.show(this, evt.getX(), evt.getY()); return; } diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index b12355a..40c5173 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -170,7 +170,7 @@ public class GPreferences extends JPanel /* * Connections tab components */ - protected JList linkURLList = new JList(); + protected JList linkURLList = new JList(); protected JTextField proxyServerTB = new JTextField(); @@ -178,7 +178,7 @@ public class GPreferences extends JPanel protected JTextField defaultBrowser = new JTextField(); - protected JList linkNameList = new JList(); + protected JList linkNameList = new JList(); protected JCheckBox useProxy = new JCheckBox(); @@ -205,6 +205,8 @@ public class GPreferences extends JPanel protected JCheckBox clustaljv = new JCheckBox(); + protected JCheckBox megajv = new JCheckBox(); + protected JCheckBox msfjv = new JCheckBox(); protected JCheckBox fastajv = new JCheckBox(); diff --git a/test/jalview/gui/PopupMenuTest.java b/test/jalview/gui/PopupMenuTest.java index edf3202..400a9cb 100644 --- a/test/jalview/gui/PopupMenuTest.java +++ b/test/jalview/gui/PopupMenuTest.java @@ -69,7 +69,7 @@ public class PopupMenuTest AppletFormatAdapter.PASTE, "FASTA"); AlignFrame af = new AlignFrame(alignment, 700, 500); parentPanel = new AlignmentPanel(af, af.getViewport()); - testee = new PopupMenu(parentPanel, null, null); + testee = new PopupMenu(parentPanel, null, null, null); int i = 0; for (SequenceI seq : alignment.getSequences()) {