").append("Built: ")
+ .append(Cache.getDefault("BUILD_DATE", "unknown")).append(" from ")
+ .append(Cache.getBuildDetailsForSplash()).append("");
String latestVersion = Cache.getDefault("LATEST_VERSION", "Checking");
- if (latestVersion.equals("Checking"))
- {
+ if (latestVersion.equals("Checking")) {
// JBP removed this message for 2.11: May be reinstated in future version
// message.append(" ...Checking latest version...");
- }
- else if (!latestVersion.equals(Cache.getProperty("VERSION")))
- {
+ } else if (!latestVersion.equals(Cache.getProperty("VERSION"))) {
boolean red = false;
- if (Cache.getProperty("VERSION").toLowerCase(Locale.ROOT)
- .indexOf("automated build") == -1)
- {
+ if (Cache.getProperty("VERSION").toLowerCase(Locale.ROOT).indexOf("automated build") == -1) {
red = true;
// Displayed when code version and jnlp version do not match and code
// version is not a development build
message.append("
");
}
- message.append(" !! Version ")
- .append(Cache.getDefault("LATEST_VERSION", "..Checking.."))
- .append(" is available for download from ")
- .append(Cache.getDefault("www.jalview.org",
- "https://www.jalview.org"))
- .append(" !!");
- if (red)
- {
+ message.append(" !! Version ").append(Cache.getDefault("LATEST_VERSION", "..Checking.."))
+ .append(" is available for download from ")
+ .append(Cache.getDefault("www.jalview.org", "https://www.jalview.org")).append(" !!");
+ if (red) {
message.append("
");
}
}
@@ -1497,15 +1469,11 @@ public class Desktop extends jalview.jbgui.GDesktop
* Action on requesting Help documentation
*/
@Override
- public void documentationMenuItem_actionPerformed()
- {
- try
- {
- if (Platform.isJS())
- {
+ public void documentationMenuItem_actionPerformed() {
+ try {
+ if (Platform.isJS()) {
BrowserLauncher.openURL("https://www.jalview.org/help.html");
- }
- else
+ } else
/**
* Java only
*
@@ -1514,8 +1482,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
Help.showHelpWindow();
}
- } catch (Exception ex)
- {
+ } catch (Exception ex) {
System.err.println("Error opening help: " + ex.getMessage());
}
}
@@ -1524,7 +1491,7 @@ public class Desktop extends jalview.jbgui.GDesktop
public void closeAll_actionPerformed(ActionEvent e)
{
// TODO show a progress bar while closing?
- JInternalFrame[] frames = desktop.getAllFrames();
+ JInternalFrame[] frames = desktopPane.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
try
@@ -1584,13 +1551,14 @@ public class Desktop extends jalview.jbgui.GDesktop
/*
* (non-Javadoc)
*
- * @see jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.
- * ActionEvent )
+ * @see
+ * jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.ActionEvent
+ * )
*/
@Override
protected void showMemusage_actionPerformed(ActionEvent e)
{
- desktop.showMemoryUsage(showMemusage.isSelected());
+ desktopPane.showMemoryUsage(showMemusage.isSelected());
}
/*
@@ -1627,13 +1595,14 @@ public class Desktop extends jalview.jbgui.GDesktop
void reorderAssociatedWindows(boolean minimize, boolean close)
{
- JInternalFrame[] frames = desktop.getAllFrames();
+ JInternalFrame[] frames = desktopPane.getAllFrames();
if (frames == null || frames.length < 1)
{
return;
}
- AlignmentViewport source = null, target = null;
+ AlignViewportI source = null;
+ AlignViewportI target = null;
if (frames[0] instanceof AlignFrame)
{
source = ((AlignFrame) frames[0]).getCurrentView();
@@ -1709,8 +1678,7 @@ public class Desktop extends jalview.jbgui.GDesktop
* DOCUMENT ME!
*/
@Override
- protected void preferences_actionPerformed(ActionEvent e)
- {
+ protected void preferences_actionPerformed(ActionEvent e) {
Preferences.openPreferences();
}
@@ -1754,8 +1722,7 @@ public class Desktop extends jalview.jbgui.GDesktop
}
}
- if (approveSave || autoSave)
- {
+ if (approveSave || autoSave) {
final Desktop me = this;
final java.io.File chosenFile = projectFile;
new Thread(new Runnable()
@@ -1864,7 +1831,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
jalview.bin.Console.error(
"Problems whilst loading project from " + choice, ex);
- JvOptionPane.showMessageDialog(Desktop.desktop,
+ JvOptionPane.showMessageDialog(getDesktopPane(),
MessageManager.formatMessage(
"label.error_whilst_loading_project_from",
new Object[]
@@ -1908,7 +1875,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
progressPanel = new JPanel(new GridLayout(1, 1));
totalProgressCount = 0;
- instance.getContentPane().add(progressPanel, BorderLayout.SOUTH);
+ getContentPane().add(progressPanel, BorderLayout.SOUTH);
}
JPanel thisprogress = new JPanel(new BorderLayout(10, 5));
JProgressBar progressBar = new JProgressBar();
@@ -1921,7 +1888,7 @@ public class Desktop extends jalview.jbgui.GDesktop
((GridLayout) progressPanel.getLayout()).setRows(
((GridLayout) progressPanel.getLayout()).getRows() + 1);
++totalProgressCount;
- instance.validate();
+ validate();
return thisprogress;
}
@@ -1975,7 +1942,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
{
- if (Desktop.desktop == null)
+ if (getDesktopPane() == null)
{
// no frames created and in headless mode
// TODO: verify that frames are recoverable when in headless mode
@@ -2017,9 +1984,9 @@ public class Desktop extends jalview.jbgui.GDesktop
public static AlignmentViewport[] getViewports(String sequenceSetId)
{
List viewp = new ArrayList<>();
- if (desktop != null)
+ if (getDesktopPane() != null)
{
- AlignFrame[] frames = Desktop.getAlignFrames();
+ AlignFrame[] frames = getAlignFrames();
for (AlignFrame afr : frames)
{
@@ -2085,8 +2052,9 @@ public class Desktop extends jalview.jbgui.GDesktop
}
/*
- * Restore the view's last exploded frame geometry if known. Multiple views from
- * one exploded frame share and restore the same (frame) position and size.
+ * Restore the view's last exploded frame geometry if known. Multiple
+ * views from one exploded frame share and restore the same (frame)
+ * position and size.
*/
Rectangle geometry = ap.av.getExplodedGeometry();
if (geometry != null)
@@ -2127,7 +2095,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
source.viewport.setGatherViewsHere(true);
source.viewport.setExplodedGeometry(source.getBounds());
- JInternalFrame[] frames = desktop.getAllFrames();
+ JInternalFrame[] frames = desktopPane.getAllFrames();
String viewId = source.viewport.getSequenceSetId();
for (int t = 0; t < frames.length; t++)
{
@@ -2180,7 +2148,7 @@ public class Desktop extends jalview.jbgui.GDesktop
public JInternalFrame[] getAllFrames()
{
- return desktop.getAllFrames();
+ return desktopPane.getAllFrames();
}
/**
@@ -2266,7 +2234,7 @@ public class Desktop extends jalview.jbgui.GDesktop
});
msgPanel.add(jcb);
- JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
+ JvOptionPane.showMessageDialog(desktopPane, msgPanel,
MessageManager
.getString("label.SEQUENCE_ID_no_longer_used"),
JvOptionPane.WARNING_MESSAGE);
@@ -2371,7 +2339,7 @@ public class Desktop extends jalview.jbgui.GDesktop
}
// output debug scale message. Important for jalview.bin.HiDPISettingTest2
- Desktop.debugScaleMessage(Desktop.getDesktop().getGraphics());
+ Desktop.debugScaleMessage(Desktop.getDesktopPane().getGraphics());
}
}
@@ -2384,11 +2352,10 @@ public class Desktop extends jalview.jbgui.GDesktop
{
if (Jalview.isHeadlessMode())
{
- // Desktop.desktop is null in headless mode
- return new AlignFrame[] { Jalview.currentAlignFrame };
+ return new AlignFrame[] { Jalview.getInstance().currentAlignFrame };
}
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = getDesktopPane().getAllFrames();
if (frames == null)
{
@@ -2433,7 +2400,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public GStructureViewer[] getJmols()
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = desktopPane.getAllFrames();
if (frames == null)
{
@@ -2469,7 +2436,7 @@ public class Desktop extends jalview.jbgui.GDesktop
} catch (Exception ex)
{
jalview.bin.Console.error("Groovy Shell Creation failed.", ex);
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(desktopPane,
MessageManager.getString("label.couldnt_create_groovy_shell"),
MessageManager.getString("label.groovy_support_failed"),
@@ -2490,9 +2457,9 @@ public class Desktop extends jalview.jbgui.GDesktop
/*
* We allow only one console at a time, so that AlignFrame menu option
- * 'Calculate | Run Groovy script' is unambiguous. Disable 'Groovy Console', and
- * enable 'Run script', when the console is opened, and the reverse when it is
- * closed
+ * 'Calculate | Run Groovy script' is unambiguous.
+ * Disable 'Groovy Console', and enable 'Run script', when the console is
+ * opened, and the reverse when it is closed
*/
Window window = (Window) groovyConsole.getFrame();
window.addWindowListener(new WindowAdapter()
@@ -2515,8 +2482,8 @@ public class Desktop extends jalview.jbgui.GDesktop
((Window) groovyConsole.getFrame()).setVisible(true);
/*
- * if we got this far, enable 'Run Groovy' in AlignFrame menus and disable
- * opening a second console
+ * if we got this far, enable 'Run Groovy' in AlignFrame menus
+ * and disable opening a second console
*/
enableExecuteGroovy(true);
}
@@ -2527,12 +2494,10 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
protected void addQuitHandler()
{
- getRootPane()
- .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
- KeyStroke
- .getKeyStroke(KeyEvent.VK_Q,
- jalview.util.ShortcutKeyMaskExWrapper
- .getMenuShortcutKeyMaskEx()),
+
+ getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
+ .put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
+ Platform.SHORTCUT_KEY_MASK),
"Quit");
getRootPane().getActionMap().put("Quit", new AbstractAction()
{
@@ -2553,8 +2518,8 @@ public class Desktop extends jalview.jbgui.GDesktop
public void enableExecuteGroovy(boolean enabled)
{
/*
- * disable opening a second Groovy console (or re-enable when the console is
- * closed)
+ * disable opening a second Groovy console
+ * (or re-enable when the console is closed)
*/
groovyShell.setEnabled(!enabled);
@@ -2583,6 +2548,8 @@ public class Desktop extends jalview.jbgui.GDesktop
@Override
public void setProgressBar(String message, long id)
{
+ // Platform.timeCheck("Desktop " + message, Platform.TIME_MARK);
+
if (progressBars == null)
{
progressBars = new Hashtable<>();
@@ -2603,6 +2570,20 @@ public class Desktop extends jalview.jbgui.GDesktop
progressBars.put(Long.valueOf(id), addProgressPanel(message));
}
}
+
+ @Override
+ public void addProgressBar(long id, String message)
+ {
+ // TODO
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ @Override
+ public void removeProgressBar(long id)
+ {
+ //TODO
+ throw new UnsupportedOperationException("not implemented");
+ }
/*
* (non-Javadoc)
@@ -2668,7 +2649,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
{
- if (desktop != null)
+ if (getDesktopPane() != null)
{
AlignmentPanel[] aps = getAlignmentPanels(
viewport.getSequenceSetId());
@@ -2730,61 +2711,49 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public void startServiceDiscovery(boolean blocking)
{
- startServiceDiscovery(blocking, false);
- }
+ jalview.bin.Console.debug("Starting service discovery");
- /**
- * start service discovery threads
- *
- * @param blocking
- * - false means call returns immediately
- * @param ignore_SHOW_JWS2_SERVICES_preference
- * - when true JABA services are discovered regardless of user's JWS2
- * discovery preference setting
- */
- public void startServiceDiscovery(boolean blocking,
- boolean ignore_SHOW_JWS2_SERVICES_preference)
- {
- boolean alive = true;
- Thread t0 = null, t1 = null, t2 = null;
+ var tasks = new ArrayList>();
// JAL-940 - JALVIEW 1 services are now being EOLed as of JABA 2.1 release
- if (true)
+
+ System.out.println("loading services");
+
+ /** @j2sIgnore */
{
// todo: changesupport handlers need to be transferred
if (discoverer == null)
{
- discoverer = new jalview.ws.jws1.Discoverer();
+ discoverer = jalview.ws.jws1.Discoverer.getInstance();
// register PCS handler for desktop.
discoverer.addPropertyChangeListener(changeSupport);
}
// JAL-940 - disabled JWS1 service configuration - always start discoverer
// until we phase out completely
- (t0 = new Thread(discoverer)).start();
+ var f = new FutureTask(discoverer, null);
+ new Thread(f).start();
+ tasks.add(f);
}
- if (ignore_SHOW_JWS2_SERVICES_preference
- || Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
- .startDiscoverer(changeSupport);
+ tasks.add(jalview.ws.jws2.Jws2Discoverer.getInstance().startDiscoverer());
}
- Thread t3 = null;
+ if (Cache.getDefault("SHOW_SLIVKA_SERVICES", true))
{
- // TODO: do rest service discovery
+ tasks.add(jalview.ws2.client.slivka.SlivkaWSDiscoverer
+ .getInstance().startDiscoverer());
}
if (blocking)
{
- while (alive)
- {
+ for (Future> task : tasks) {
try
{
- Thread.sleep(15);
+ // block until all discovery tasks are done
+ task.get();
} catch (Exception e)
{
+ e.printStackTrace();
}
- alive = (t1 != null && t1.isAlive()) || (t2 != null && t2.isAlive())
- || (t3 != null && t3.isAlive())
- || (t0 != null && t0.isAlive());
}
}
}
@@ -2798,8 +2767,10 @@ public class Desktop extends jalview.jbgui.GDesktop
{
if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
{
- final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
- .getErrorMessages();
+ final WSDiscovererI discoverer = jalview.ws.jws2.Jws2Discoverer
+ .getInstance();
+ final String ermsg = discoverer.getErrorMessages();
+ // CONFLICT:ALT:? final String ermsg = jalview.ws.jws2.Jws2Discoverer.getInstance()
if (ermsg != null)
{
if (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true))
@@ -2816,23 +2787,28 @@ public class Desktop extends jalview.jbgui.GDesktop
/*
* JalviewDialog jd =new JalviewDialog() {
*
- * @Override protected void cancelPressed() { // TODO Auto-generated method stub
+ * @Override protected void cancelPressed() { // TODO
+ * Auto-generated method stub
*
- * }@Override protected void okPressed() { // TODO Auto-generated method stub
+ * }@Override protected void okPressed() { // TODO
+ * Auto-generated method stub
*
- * }@Override protected void raiseClosed() { // TODO Auto-generated method stub
+ * }@Override protected void raiseClosed() { // TODO
+ * Auto-generated method stub
*
- * } }; jd.initDialogFrame(new JLabel("
" + ermsg +
* " It may be that you have invalid JABA URLs in your web service preferences,"
* + " or mis-configured HTTP proxy settings. " +
- * "Check the Connections and Web services tab of the" +
- * " Tools->Preferences dialog box to change them.
" ),
- * true, true, "Web Service Configuration Problem", 450, 400);
+ * "Check the Connections and Web services tab of the"
+ * +
+ * " Tools->Preferences dialog box to change them.
It may be that you have invalid JABA URLs in your web service preferences,"
@@ -2869,7 +2845,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public static void showUrl(final String url)
{
- showUrl(url, Desktop.instance);
+ showUrl(url, getInstance());
}
/**
@@ -2898,7 +2874,7 @@ public class Desktop extends jalview.jbgui.GDesktop
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(getDesktopPane(),
MessageManager
.getString("label.web_browser_not_found_unix"),
MessageManager.getString("label.web_browser_not_found"),
@@ -2938,13 +2914,13 @@ public class Desktop extends jalview.jbgui.GDesktop
try
{
url = e.getURL().toString();
- Desktop.showUrl(url);
+ showUrl(url);
} catch (Exception x)
{
if (url != null)
{
- jalview.bin.Console
- .error("Couldn't handle string " + url + " as a URL.");
+ // TODO does error send to stderr if no log exists ?
+ jalview.bin.Console.error("Couldn't handle string " + url + " as a URL.");
}
// ignore any exceptions due to dud links.
}
@@ -2990,7 +2966,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
}
}
- if (instance == null)
+ if (Jalview.isHeadlessMode())
{
return;
}
@@ -2999,8 +2975,7 @@ public class Desktop extends jalview.jbgui.GDesktop
SwingUtilities.invokeAndWait(prompter);
} catch (Exception q)
{
- jalview.bin.Console.warn("Unexpected Exception in dialog thread.",
- q);
+ jalview.bin.Console.warn("Unexpected Exception in dialog thread.", q);
}
}
});
@@ -3073,15 +3048,16 @@ public class Desktop extends jalview.jbgui.GDesktop
}
/*
- * Processing in reverse order works, forwards order leaves the first panels not
- * visible. I don't know why!
+ * Processing in reverse order works, forwards order leaves the first panels
+ * not visible. I don't know why!
*/
for (int i = viewCount - 1; i >= 0; i--)
{
/*
- * Make new top and bottom frames. These take over the respective AlignmentPanel
- * objects, including their AlignmentViewports, so the cdna/protein
- * relationships between the viewports is carried over to the new split frames.
+ * Make new top and bottom frames. These take over the respective
+ * AlignmentPanel objects, including their AlignmentViewports, so the
+ * cdna/protein relationships between the viewports is carried over to the
+ * new split frames.
*
* explodedGeometry holds the (x, y) position of the previously exploded
* SplitFrame, and the (width, height) of the AlignFrame component
@@ -3116,12 +3092,12 @@ public class Desktop extends jalview.jbgui.GDesktop
{
splitFrame.setLocation(geometry.getLocation());
}
- Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
+ addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
}
/*
- * Clear references to the panels (now relocated in the new SplitFrames) before
- * closing the old SplitFrame.
+ * Clear references to the panels (now relocated in the new SplitFrames)
+ * before closing the old SplitFrame.
*/
topPanels.clear();
bottomPanels.clear();
@@ -3154,7 +3130,7 @@ public class Desktop extends jalview.jbgui.GDesktop
String topViewId = myTopFrame.viewport.getSequenceSetId();
String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
- JInternalFrame[] frames = desktop.getAllFrames();
+ JInternalFrame[] frames = desktopPane.getAllFrames();
for (JInternalFrame frame : frames)
{
if (frame instanceof SplitFrame && frame != source)
@@ -3217,11 +3193,34 @@ public class Desktop extends jalview.jbgui.GDesktop
* - the payload from the drop event
* @throws Exception
*/
+ @SuppressWarnings("unchecked")
public static void transferFromDropTarget(List