/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
- *
+ *
* This file is part of Jalview.
- *
+ *
* Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
+ * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
- *
- * Jalview 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
+ *
+ * Jalview 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 Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
import jalview.ws.params.ParamDatastoreI;
import jalview.ws.params.WsParamSetI;
import jalview.ws.seqfetcher.DbSourceProxy;
-import jalview.ws.slivkaws.SlivkaWSDiscoverer;
+import jalview.ws2.WebServiceDiscoverer;
+import jalview.ws2.WebServiceI;
+import jalview.ws2.operations.Operation;
+import jalview.ws2.slivka.SlivkaWSDiscoverer;
+
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import java.util.Deque;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
import javax.swing.ButtonGroup;
/**
* DOCUMENT ME!
- *
+ *
* @author $author$
* @version $Revision$
*/
@SuppressWarnings("serial")
public class AlignFrame extends GAlignFrame
implements DropTargetListener, IProgressIndicator,
- AlignViewControllerGuiI, ColourChangeListener, ServiceChangeListener
+ AlignViewControllerGuiI, ColourChangeListener, ServiceChangeListener,
+ WebServiceDiscoverer.ServiceChangeListener
{
public static int frameCount;
/**
* Creates a new AlignFrame object with specific width and height.
- *
+ *
* @param al
* @param width
* @param height
/**
* Creates a new AlignFrame object with specific width, height and
* sequenceSetId
- *
+ *
* @param al
* @param width
* @param height
/**
* Creates a new AlignFrame object with specific width, height and
* sequenceSetId
- *
+ *
* @param al
* @param width
* @param height
/**
* new alignment window with hidden columns
- *
+ *
* @param al
* AlignmentI
* @param hiddenColumns
/**
* Create alignment frame for al with hiddenColumns, a specific width and
* height, and specific sequenceId
- *
+ *
* @param al
* @param hiddenColumns
* @param width
/**
* Create alignment frame for al with hiddenColumns, a specific width and
* height, and specific sequenceId
- *
+ *
* @param al
* @param hiddenColumns
* @param width
/**
* Make a new AlignFrame from existing alignmentPanels
- *
+ *
* @param ap
* AlignmentPanel
* @param av
/**
* Change the filename and format for the alignment, and enable the 'reload'
* button functionality.
- *
+ *
* @param file
* valid filename
* @param format
}
/**
- *
+ *
* @param fileName
* @param file from SwingJS; may contain bytes -- for reload
* @param protocol from SwingJS; may be RELATIVE_URL
/**
* JavaScript will have this, maybe others. More dependable than a file name
* and maintains a reference to the actual bytes loaded.
- *
+ *
* @param file
*/
buildWebServicesMenu();
}
+ @Override
+ public void operationsChanged(WebServiceDiscoverer discoverer,
+ List<Operation> list)
+ {
+ buildWebServicesMenu();
+ }
+
/* Set up intrinsic listeners for dynamically generated GUI bits. */
private void addServiceListeners()
{
if (Cache.getDefault("SHOW_SLIVKA_SERVICES", true))
{
- WSDiscovererI discoverer = SlivkaWSDiscoverer.getInstance();
- discoverer.addServiceChangeListener(this);
+ WebServiceDiscoverer discoverer = SlivkaWSDiscoverer.getInstance();
+ discoverer.addServiceChangeListener((disc, srvcs) -> buildWebServicesMenu());
}
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
buildWebServicesMenu();
};
Desktop.getInstance().addJalviewPropertyChangeListener("services",legacyListener);
-
+
addInternalFrameListener(new InternalFrameAdapter() {
@Override
public void internalFrameClosed(InternalFrameEvent e) {
System.out.println("deregistering discoverer listener");
- SlivkaWSDiscoverer.getInstance().removeServiceChangeListener(AlignFrame.this);
+// SlivkaWSDiscoverer.getInstance().removeServiceChangeListener(AlignFrame.this);
Jws2Discoverer.getInstance().removeServiceChangeListener(AlignFrame.this);
Desktop.getInstance().removeJalviewPropertyChangeListener("services", legacyListener);
closeMenuItem_actionPerformed(true);
/**
* Need to call this method when tabs are selected for multiple views, or when
* loading from Jalview2XML.java
- *
+ *
* @param av
* AlignViewport
*/
/**
* Set the enabled state of the 'Run Groovy' option in the Calculate menu
- *
+ *
* @param b
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
{
progressBar.setProgressBar(message, id);
}
-
+
@Override
public void removeProgressBar(long id)
{
}
/**
- *
+ *
* @return true if any progress bars are still active
*/
}
/*
- * get default parameters, and (if requested) show
+ * get default parameters, and (if requested) show
* dialog to allow modification
*/
ParamDatastoreI store = HMMERParamStore.forSearch(viewport);
{
/*
- * get default parameters, and (if requested) show
+ * get default parameters, and (if requested) show
* dialog to allow modification
*/
/**
* Checks if the alignment has at least one hidden Markov model, if not shows
* a dialog advising to run hmmbuild or load an HMM profile
- *
+ *
* @return
*/
private boolean checkForHMM()
/**
* Checks if the alignment contains the required number of sequences.
- *
+ *
* @param required
* @return
*/
* Opens a file chooser, optionally restricted to selecting folders
* (directories) only. Answers the path to the selected file or folder, or
* null if none is chosen.
- *
+ *
* @param
* @return
*/
* alignment has hidden regions, or the format is one capable of including
* non-sequence data (features, annotations, groups), then the user may be
* prompted to specify what to include in the output.
- *
+ *
* @param file
* @param format
*/
* Outputs the alignment to textbox in the requested format, if necessary
* first prompting the user for whether to include hidden regions or
* non-sequence data
- *
+ *
* @param fileFormatName
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Creates a PNG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* Creates an EPS image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* Creates an SVG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Close the current view or all views in the alignment frame. If the frame
* only contains one view then the alignment will be removed from memory.
- *
+ *
* @param closeAllTabs
*/
/**
* Close the specified panel and close up tabs appropriately.
- *
+ *
* @param panelToClose
*/
}
/**
- *
+ *
* @return alignment objects for all views
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param up
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
* @throws InterruptedException
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
* @throws InterruptedException
/**
* Paste contents of Jalview clipboard
- *
+ *
* @param newAlignment
* true to paste to a new alignment, otherwise add to this.
* @throws InterruptedException
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Creates and shows a new view of the current alignment.
- *
+ *
* @param viewTitle
* title of newly created view; if null, one will be generated
* @param copyAnnotation
* Make a new name for the view, ensuring it is unique within the current
* sequenceSetId. (This used to be essential for Jalview Project archives, but
* these now use viewId. Unique view names are still desirable for usability.)
- *
+ *
* @param viewTitle
* @return
*/
/**
* Returns a list of distinct view names found in the given list of
* components. View names are held on the viewport of an AlignmentPanel.
- *
+ *
* @param comps
* @return
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* called by key handler and the hide all/show all menu items
- *
+ *
* @param toggleSeqs
* @param toggleCols
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
* event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
* .ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
* ActionEvent)
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Set or clear 'Show Sequence Features'
- *
+ *
* @param evt
* DOCUMENT ME!
*/
/**
* Action on toggle of the 'Show annotations' menu item. This shows or hides
* the annotations panel as a whole.
- *
+ *
* The options to show/hide all annotations should be enabled when the panel
* is shown, and disabled when the panel is hidden.
- *
+ *
* @param e
*/
{
alignPanel.updateScrollBarsFromRanges();
}
-
+
});
}
else
/**
* Java only
- *
+ *
* @j2sIgnore
*/
{
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
* Action on the user checking or unchecking the option to apply the selected
* colour scheme to all groups. If unchecked, groups may have their own
* independent colour schemes.
- *
+ *
* @param selected
*/
/**
* Action on user selecting a colour from the colour menu
- *
+ *
* @param name
* the name (not the menu item label!) of the colour scheme
*/
/**
* Actions on setting or changing the alignment colour scheme
- *
+ *
* @param cs
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Constructs a tree panel and adds it to the desktop
- *
+ *
* @param type
* tree type (NJ or AV)
* @param modelName
/**
* DOCUMENT ME!
- *
+ *
* @param title
* DOCUMENT ME!
* @param order
/**
* Add a new sort by annotation score menu item
- *
+ *
* @param sort
* the menu to add the option to
* @param scoreLabel
* search the alignment and rebuild the sort by annotation score submenu the
* last alignment annotation vector hash is stored to minimize cost of
* rebuilding in subsequence calls.
- *
+ *
*/
@Override
}
/**
- * Enable (or, if desired, make visible) the By Tree
+ * Enable (or, if desired, make visible) the By Tree
* submenu only if it has at least one element (or will have).
- *
+ *
*/
@Override
protected void enableSortMenuOptions()
List<TreePanel> treePanels = getTreePanels();
sortByTreeMenu.setEnabled(!treePanels.isEmpty());
}
-
+
/**
* Maintain the Order by->Displayed Tree menu. Creates a new menu item for a
* TreePanel with an appropriate <code>jalview.analysis.AlignmentSorter</code>
/**
* Work out whether the whole set of sequences or just the selected set will
* be submitted for multiple alignment.
- *
+ *
*/
public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
/*
* SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new
* SequenceI[sz = seqs.getSize(false)];
- *
+ *
* for (int i = 0; i < sz; i++) { msa[i] = (SequenceI)
* seqs.getSequenceAt(i); }
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Add a treeviewer for the tree extracted from a Newick file object to the
* current alignment view
- *
+ *
* @param nf
* the tree
* @param title
buildWebServicesMenu(jws2servs, submenu);
webService.add(submenu);
}
+ build_fetchdbmenu(webService);
});
}
private void buildLegacyWebServicesMenu(JMenu menu)
{
JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
- if (Discoverer.getServices() != null && Discoverer.getServices().size() > 0)
+ if (Discoverer.getServices() != null && Discoverer.getServices().size() > 0)
{
var secstrpred = Discoverer.getServices().get("SecStrPred");
- if (secstrpred != null)
+ if (secstrpred != null)
{
- for (ext.vamsas.ServiceHandle sh : secstrpred)
+ for (ext.vamsas.ServiceHandle sh : secstrpred)
{
var menuProvider = Discoverer.getServiceClient(sh);
menuProvider.attachWSMenuEntry(secstrmenu, this);
/**
* Constructs the web services menu for the given discoverer under the
* specified menu. This method must be called on the EDT
- *
+ *
* @param discoverer
* the discoverer used to build the menu
* @param menu
}
}
+ private void buildWebServicesMenu(WebServiceDiscoverer discoverer, final JMenu menu)
+ {
+ if (discoverer.hasServices())
+ {
+ var builder = new WebServicesMenuBuilder();
+ builder.addAllOperations(discoverer.getOperations());
+ builder.addSelectedHostChangeListener((name, op) -> {
+ menu.removeAll();
+ builder.buildMenu(menu, this);
+ });
+ builder.buildMenu(menu, this);
+ }
+ if (discoverer.isRunning())
+ {
+ JMenuItem item = new JMenuItem("Service discovery in progress.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
+ else if (!discoverer.hasServices())
+ {
+ JMenuItem item = new JMenuItem("No services available.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
+ }
+
/**
* construct any groupURL type service menu entries.
- *
+ *
* @param webService
*/
/*
* JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
* AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
- *
+ *
* public void actionPerformed(ActionEvent e) {
* jalview.datamodel.AlignmentView
* .testSelectionViews(af.viewport.getAlignment(),
* af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
- *
+ *
* }); webService.add(testAlView);
*/
// TODO: refactor to RestClient discoverer and merge menu entries for
* Cross-References menu (formerly called Show Products), with database
* sources for which cross-references are found (protein sources for a
* nucleotide alignment and vice versa)
- *
+ *
* @return true if Show Cross-references menu should be enabled
*/
/**
* Finds and displays cross-references for the selected sequences (protein
* products for nucleotide sequences, dna coding sequences for peptides).
- *
+ *
* @param sel
* the sequences to show cross-references for
* @param dna
/**
* Set the file format
- *
+ *
* @param format
*/
/**
* Try to load a features file onto the alignment.
- *
+ *
* @param file
* contents or path to retrieve file or a File object
* @param sourceType
* <li>a features file</li>
* <li>else try to interpret as an alignment file</li>
* </ul>
- *
+ *
* @param file
* either a filename or a URL string.
* @throws InterruptedException
/**
* Change the display state for the given feature groups -- Added by BH from
* JalviewLite
- *
+ *
* @param groups
* list of group strings
* @param state
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
* )
/*
* (non-Javadoc)
- *
+ *
* @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
* ActionEvent)
*/
/**
* find the viewport amongst the tabs in this alignment frame and close that
* tab
- *
+ *
* @param av
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
* awt.event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
* .ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
* .event.ActionEvent)
/**
* make the given alignmentPanel the currently selected tab
- *
+ *
* @param alignmentPanel
*/
/**
* Action on selection of menu options to Show or Hide annotations.
- *
+ *
* @param visible
* @param forSequences
* update sequence-related annotations
}
/**
- *
+ *
* @return alignment panels in this alignment frame
*/
/**
* Set visibility of dna/protein complement view (available when shown in a
* split frame).
- *
+ *
* @param show
*/
/**
* Hides columns containing (or not containing) a specified feature, provided
* that would not leave all columns hidden
- *
+ *
* @param featureType
* @param columnsContaining
* @return
/**
* BH 2019 from JalviewLite
- *
+ *
* get sequence feature groups that are hidden or shown
- *
+ *
* @param visible
* true is visible
* @return list
}
/**
- *
+ *
* @return list of feature groups on the view
*/
}
}
}
+
}