X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAPopupMenu.java;h=0226349aef00c59cbbf260bd5a96cfec91c765c6;hb=a3a196ed2104760ffeeebbca65fc03c361d29b17;hp=ff1c3c884e6b72e22af47aedf9fbaa801ad422ff;hpb=c35461ed2a5a258cab842e8ccb89b7a973722799;p=jalview.git diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index ff1c3c8..0226349 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -28,62 +27,100 @@ import jalview.analysis.*; import jalview.commands.*; import jalview.datamodel.*; import jalview.schemes.*; +import jalview.util.UrlLink; import jalview.io.AppletFormatAdapter; -public class APopupMenu - extends java.awt.PopupMenu implements ActionListener, ItemListener +public class APopupMenu extends java.awt.PopupMenu implements + ActionListener, ItemListener { Menu groupMenu = new Menu(); + MenuItem editGroupName = new MenuItem(); + protected MenuItem clustalColour = new MenuItem(); + protected MenuItem zappoColour = new MenuItem(); + protected MenuItem taylorColour = new MenuItem(); + protected MenuItem hydrophobicityColour = new MenuItem(); + protected MenuItem helixColour = new MenuItem(); + protected MenuItem strandColour = new MenuItem(); + protected MenuItem turnColour = new MenuItem(); + protected MenuItem buriedColour = new MenuItem(); + protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem(); + protected MenuItem userDefinedColour = new MenuItem(); + protected MenuItem PIDColour = new MenuItem(); + protected MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem noColourmenuItem = new MenuItem(); + protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); final AlignmentPanel ap; + MenuItem unGroupMenuItem = new MenuItem(); + MenuItem nucleotideMenuItem = new MenuItem(); + Menu colourMenu = new Menu(); + CheckboxMenuItem showBoxes = new CheckboxMenuItem(); + CheckboxMenuItem showText = new CheckboxMenuItem(); + CheckboxMenuItem showColourText = new CheckboxMenuItem(); + Menu editMenu = new Menu("Edit"); + MenuItem copy = new MenuItem("Copy (Jalview Only)"); + MenuItem cut = new MenuItem("Cut (Jalview Only)"); + MenuItem toUpper = new MenuItem("To Upper Case"); + MenuItem toLower = new MenuItem("To Lower Case"); + MenuItem toggleCase = new MenuItem("Toggle Case"); + Menu outputmenu = new Menu(); + Menu seqMenu = new Menu(); + MenuItem pdb = new MenuItem(); + MenuItem hideSeqs = new MenuItem(); + MenuItem repGroup = new MenuItem(); + MenuItem sequenceName = new MenuItem("Edit Name/Description"); + MenuItem sequenceFeature = new MenuItem("Create Sequence Feature"); + MenuItem editSequence = new MenuItem("Edit Sequence"); Sequence seq; + MenuItem revealAll = new MenuItem(); + Menu menu1 = new Menu(); public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links) { - /////////////////////////////////////////////////////////// + // ///////////////////////////////////////////////////////// // If this is activated from the sequence panel, the user may want to // edit or annotate a particular residue. Therefore display the residue menu // // If from the IDPanel, we must display the sequence menu - ////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////// this.ap = apanel; this.seq = seq; @@ -91,17 +128,15 @@ public class APopupMenu try { jbInit(); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; - i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { - MenuItem item = new MenuItem(jalview.io.AppletFormatAdapter. - WRITEABLE_FORMATS[i]); + MenuItem item = new MenuItem( + jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); item.addActionListener(this); outputmenu.add(item); @@ -127,56 +162,95 @@ public class APopupMenu remove(groupMenu); } - if (links != null && links.size()>0) + if (links != null && links.size() > 0) { Menu linkMenu = new Menu("Link"); String link; for (int i = 0; i < links.size(); i++) { link = links.elementAt(i).toString(); - final String target = link.substring(0, link.indexOf("|")); - - final String url; - - if (link.indexOf("$SEQUENCE_ID$") > -1) + UrlLink urlLink = new UrlLink(link); + if (!urlLink.isValid()) + { + System.err.println(urlLink.getInvalidMessage()); + continue; + } + final String target = urlLink.getTarget(); // link.substring(0, + // link.indexOf("|")); + final String label = urlLink.getLabel(); + if (urlLink.isDynamic()) { - // Substitute SEQUENCE_ID string and any matching database reference accessions - String url_pref = link.substring(link.indexOf("|") + 1, - link.indexOf("$SEQUENCE_ID$")); - - String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13); // collect matching db-refs - DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target}); + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq + .getDBRef(), new String[] + { target }); // collect id string too String id = seq.getName(); - if (id.indexOf("|") > -1) + if (dbr != null) { - id = id.substring(id.lastIndexOf("|") + 1); - } - if (dbr!=null) - { - for (int r=0;r -1) { // Substitute SEQUENCE_ID + * string and any matching database reference accessions String url_pref = + * link.substring(link.indexOf("|") + 1, link.indexOf("$SEQUENCE_ID$")); + * + * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13); + * // collect matching db-refs DBRefEntry[] dbr = + * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new + * String[]{target}); // collect id string too String id = + * seq.getName(); if (id.indexOf("|") > -1) { id = + * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int + * r=0;r