import java.util.Arrays;
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 java.util.concurrent.CompletableFuture;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
// modifyPID.setEnabled(false);
}
- String sortby = Cache.getDefault("SORT_ALIGNMENT",
- "No sort");
+ String sortby = Cache.getDefault("SORT_ALIGNMENT", "No sort");
if (sortby.equals("Id"))
{
});
if (Cache.getDefault("VERSION", "DEVELOPMENT").toLowerCase(Locale.ROOT)
.indexOf("devel") > -1
- || Cache.getDefault("VERSION", "DEVELOPMENT").toLowerCase(Locale.ROOT)
- .indexOf("test") > -1)
+ || Cache.getDefault("VERSION", "DEVELOPMENT")
+ .toLowerCase(Locale.ROOT).indexOf("test") > -1)
{
formatMenu.add(vsel);
}
}
if (viewport.cursorMode)
{
- alignPanel.getSeqPanel().moveCursor(0, -1,evt.isShiftDown());
+ alignPanel.getSeqPanel().moveCursor(0, -1, evt.isShiftDown());
}
break;
webService.add(me.webServiceNoServices);
}
// TODO: move into separate menu builder class.
- boolean new_sspred = false;
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
+ // logic for 2.11.1.4 is
+ // always look to see if there is a discover. if there isn't
+ // we can't show any Jws2 services
+ // if there are services available, show them - regardless of
+ // the 'show JWS2 preference'
+ // if the discoverer is running then say so
+ // otherwise offer to trigger discovery if 'show JWS2' is not
+ // enabled
Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
if (jws2servs != null)
{
jws2servs.attachWSMenuEntry(webService, me);
for (Jws2Instance sv : jws2servs.getServices())
{
- if (sv.description.toLowerCase(Locale.ROOT).contains("jpred"))
+ if (sv.description.toLowerCase(Locale.ROOT)
+ .contains("jpred"))
{
for (JMenuItem jmi : legacyItems)
{
}
}
}
-
}
+
if (jws2servs.isRunning())
{
JMenuItem tm = new JMenuItem(
tm.setEnabled(false);
webService.add(tm);
}
+ else if (!Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ JMenuItem enableJws2 = new JMenuItem(
+ "Discover Web Services");
+ enableJws2.setToolTipText(
+ "Select to start JABA Web Service discovery (or enable option in Web Service preferences)");
+ enableJws2.setEnabled(true);
+ enableJws2.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ // start service discoverer, but ignore preference
+ Desktop.instance.startServiceDiscovery(false,
+ true);
+ }
+ });
+ webService.add(enableJws2);
+ }
}
}
build_urlServiceMenu(me.webService);
return showp;
}
+ public List<String> getProducts()
+ {
+ SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
+ AlignmentI dataset = viewport.getAlignment().getDataset();
+
+ boolean dna = viewport.getAlignment().isNucleotide();
+
+ if (seqs == null || seqs.length == 0)
+ {
+ // nothing to see here.
+ return null;
+ }
+
+ return new CrossRef(seqs, dataset).findXrefSourcesForSequences(dna);
+ }
+
/**
* Finds and displays cross-references for the selected sequences (protein
* products for nucleotide sequences, dna coding sequences for peptides).
* @param source
* the database to show cross-references for
*/
+ /*
protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
final String source)
{
new Thread(CrossRefAction.getHandlerFor(sel, _odna, source, this))
.start();
}
+ */
+ protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
+ final String source)
+ {
+ showProductsFor(sel, _odna, source, false, null);
+ }
+
+ public CompletableFuture<Void> showProductsFor(final SequenceI[] sel,
+ final boolean _odna, final String source, boolean returnFuture,
+ String id)
+ {
+ CompletableFuture<Void> cf = CompletableFuture
+ .runAsync(() -> runCrossRefActionAndCacheAlignFrame(sel, _odna,
+ source, returnFuture, id));
+ return returnFuture ? cf : null;
+ }
+
+ private void runCrossRefActionAndCacheAlignFrame(SequenceI[] sel,
+ boolean _odna, String source, boolean cacheAlignFrame, String id)
+ {
+ final AlignFrame af = this;
+ CrossRefAction.getHandlerFor(sel, _odna, source, af).run();
+ af.cacheAlignFrameFromRestId(id);
+ }
/**
* Construct and display a new frame containing the translation of this
al = dna.translateCdna(codeTable);
} catch (Exception ex)
{
- Console.error(
- "Exception during translation. Please report this !", ex);
+ Console.error("Exception during translation. Please report this !",
+ ex);
final String msg = MessageManager.getString(
"label.error_when_translating_sequences_submit_bug_report");
final String errorTitle = MessageManager
}
}
}
+
});
}
}).start();
{
return lastFeatureSettingsBounds;
}
+
+ /*
+ * Caching hashmaps for jalview.rest.API
+ */
+ private static Map<String, AlignFrame> alignFrameMap = null;
+
+ public static AlignFrame getAlignFrameFromRestId(String id)
+ {
+ if (id == null || alignFrameMap == null)
+ return null;
+ return alignFrameMap.get(id);
+ }
+
+ public void cacheAlignFrameFromRestId(String id)
+ {
+ if (id == null)
+ return;
+ if (alignFrameMap == null)
+ alignFrameMap = new HashMap<>();
+ alignFrameMap.put(id, this);
+ }
}
class PrintThread extends Thread