From: gmungoc Date: Mon, 8 May 2017 16:01:31 +0000 (+0100) Subject: Merge branch 'develop' into features/JAL-2446NCList X-Git-Tag: Release_2_10_3b1~295 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a42904684c75b2729d763af933e5a991a3424f67;p=jalview.git Merge branch 'develop' into features/JAL-2446NCList Conflicts: src/jalview/appletgui/IdPanel.java src/jalview/gui/FeatureRenderer.java --- a42904684c75b2729d763af933e5a991a3424f67 diff --cc src/jalview/appletgui/IdPanel.java index 80f03a1,4cc4a3a..39a15b8 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@@ -55,11 -57,11 +56,11 @@@ public class IdPanel extends Panel impl UrlProviderI urlProvider = null; -- public IdPanel(AlignViewport av, AlignmentPanel parent) ++ public IdPanel(AlignViewport viewport, AlignmentPanel parent) { -- this.av = av; ++ this.av = viewport; alignPanel = parent; -- idCanvas = new IdCanvas(av); ++ idCanvas = new IdCanvas(viewport); setLayout(new BorderLayout()); add(idCanvas, BorderLayout.CENTER); idCanvas.addMouseListener(this); @@@ -70,12 -72,12 +71,12 @@@ // make a list of label,url pairs HashMap urlList = new HashMap(); -- if (av.applet != null) ++ if (viewport.applet != null) { for (int i = 1; i < 10; i++) { -- label = av.applet.getParameter("linkLabel_" + i); -- url = av.applet.getParameter("linkURL_" + i); ++ label = viewport.applet.getParameter("linkLabel_" + i); ++ url = viewport.applet.getParameter("linkURL_" + i); // only add non-null parameters if (label != null) @@@ -87,7 -89,7 +88,7 @@@ if (!urlList.isEmpty()) { // set default as first entry in list -- String defaultUrl = av.applet.getParameter("linkLabel_1"); ++ String defaultUrl = viewport.applet.getParameter("linkLabel_1"); UrlProviderFactoryI factory = new AppletUrlProviderFactory( defaultUrl, urlList); urlProvider = factory.createUrlProvider(); @@@ -275,21 -288,30 +280,29 @@@ if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq); + SequenceI sq = av.getAlignment().getSequenceAt(seq); - // build a new links menu based on the current links + any non-positional - // features + /* + * build a new links menu based on the current links + * and any non-positional features + */ - List nlinks = urlProvider.getLinksForMenu(); + List nlinks; + if (urlProvider != null) + { + nlinks = urlProvider.getLinksForMenu(); + } + else + { + nlinks = new ArrayList(); + } - SequenceFeature sf[] = sq == null ? null : sq.getSequenceFeatures(); - for (int sl = 0; sf != null && sl < sf.length; sl++) + + for (SequenceFeature sf : sq.getFeatures().getNonPositionalFeatures()) { - if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) + if (sf.links != null) { - if (sf[sl].links != null && sf[sl].links.size() > 0) + for (String link : sf.links) { - for (int l = 0, lSize = sf[sl].links.size(); l < lSize; l++) - { - nlinks.add(sf[sl].links.elementAt(l)); - } + nlinks.add(link); } } } @@@ -402,9 -424,9 +415,9 @@@ boolean up = true; -- public ScrollThread(boolean up) ++ public ScrollThread(boolean isUp) { -- this.up = up; ++ this.up = isUp; start(); } diff --cc src/jalview/gui/FeatureRenderer.java index 56da67c,50a8689..b33ada2 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@@ -42,7 -43,7 +43,8 @@@ import java.awt.event.MouseAdapter import java.awt.event.MouseEvent; import java.util.Arrays; import java.util.Comparator; +import java.util.HashMap; + import java.util.List; import javax.swing.JColorChooser; import javax.swing.JComboBox; @@@ -358,47 -402,30 +403,56 @@@ public class FeatureRenderer extend } else if (reply == JvOptionPane.YES_OPTION) { + /* + * YES_OPTION corresponds to the Amend button + */ + boolean typeChanged = !lastFeatureAdded.equals(sf.type); - sf.type = lastFeatureAdded; - sf.featureGroup = lastFeatureGroupAdded; - sf.description = lastDescriptionAdded; - - setColour(sf.type, fcol); - getFeaturesDisplayed().setVisible(sf.type); - + String newType = lastFeatureAdded; + String newFeatureGroup = lastFeatureGroupAdded; + String newDescription = lastDescriptionAdded; + + setColour(newType, fcol); + getFeaturesDisplayed().setVisible(newType); + int newBegin = sf.begin; + int newEnd = sf.end; try { - sf.begin = ((Integer) start.getValue()).intValue(); - sf.end = ((Integer) end.getValue()).intValue(); + newBegin = ((Integer) start.getValue()).intValue(); + newEnd = ((Integer) end.getValue()).intValue(); } catch (NumberFormatException ex) { + // JSpinner doesn't accept invalid format data :-) + } + + /* + * replace the feature by deleting it and adding a new one + * (to ensure integrity of SequenceFeatures data store) + */ - sequences[0].deleteFeature(sf); ++ sequences.get(0).deleteFeature(sf); + SequenceFeature newSf = new SequenceFeature(newType, + newDescription, newBegin, newEnd, sf.getScore(), + newFeatureGroup); + // ensure any additional properties are copied + if (sf.otherDetails != null) + { + newSf.otherDetails = new HashMap(sf.otherDetails); + } + ffile.parseDescriptionHTML(newSf, false); + // add any additional links not parsed from description + if (sf.links != null) + { + for (String link : sf.links) + { + newSf.addLink(link); + } } + // amend features only gets one sequence to act on - sequences[0].addSequenceFeature(newSf); ++ sequences.get(0).addSequenceFeature(newSf); + - ffile.parseDescriptionHTML(sf, false); + if (typeChanged) + { + findAllFeatures(); + } } } else