(discoverer, null);
+ new Thread(f).start();
+ tasks.add(f);
}
- if (ignore_SHOW_JWS2_SERVICES_preference || Cache.getDefault("SHOW_JWS2_SERVICES", true)) {
- t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(changeSupport);
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ 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) {
- try {
- Thread.sleep(15);
- } catch (Exception e) {
+ if (blocking)
+ {
+ for (Future> task : tasks) {
+ try
+ {
+ // 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());
}
}
}
@@ -2267,50 +2763,72 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param evt
*/
- protected void JalviewServicesChanged(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector) {
- final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().getErrorMessages();
- if (ermsg != null) {
- if (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true)) {
- if (serviceChangedDialog == null) {
+ protected void JalviewServicesChanged(PropertyChangeEvent evt)
+ {
+ if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
+ {
+ 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))
+ {
+ if (serviceChangedDialog == null)
+ {
// only run if we aren't already displaying one of these.
- addDialogThread(serviceChangedDialog = new Runnable() {
+ addDialogThread(serviceChangedDialog = new Runnable()
+ {
@Override
- public void run() {
+ public void run()
+ {
/*
* 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 +
+ * } }; 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. |
"
+ * ), true, true, "Web Service Configuration Problem", 450,
+ * 400);
*
* jd.waitForInput();
*/
- JvOptionPane.showConfirmDialog(Desktop.desktop,
- new JLabel(""
- + "It may be that you have invalid JABA URLs
in your web service preferences,"
- + "
or as a command-line argument, or mis-configured HTTP proxy settings.
"
- + "Check the Connections and Web services tab
of the"
- + " Tools->Preferences dialog box to change them.
"),
- "Web Service Configuration Problem", JvOptionPane.DEFAULT_OPTION, JvOptionPane.ERROR_MESSAGE);
+ JvOptionPane.showConfirmDialog(desktopPane,
+ new JLabel(""
+ + "It may be that you have invalid JABA URLs
in your web service preferences,"
+ + "
or as a command-line argument, or mis-configured HTTP proxy settings.
"
+ + "Check the Connections and Web services tab
of the"
+ + " Tools->Preferences dialog box to change them.
"),
+ "Web Service Configuration Problem",
+ JvOptionPane.DEFAULT_OPTION,
+ JvOptionPane.ERROR_MESSAGE);
serviceChangedDialog = null;
}
});
}
- } else {
- jalview.bin.Console.error("Errors reported by JABA discovery service. Check web services preferences.\n" + ermsg);
+ }
+ else
+ {
+ jalview.bin.Console.error(
+ "Errors reported by JABA discovery service. Check web services preferences.\n"
+ + ermsg);
}
}
}
@@ -2325,34 +2843,47 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param url
*/
- public static void showUrl(final String url) {
- showUrl(url, Desktop.instance);
+ public static void showUrl(final String url)
+ {
+ showUrl(url, getInstance());
}
/**
* Like showUrl but allows progress handler to be specified
*
* @param url
- * @param progress (null) or object implementing IProgressIndicator
+ * @param progress
+ * (null) or object implementing IProgressIndicator
*/
- public static void showUrl(final String url, final IProgressIndicator progress) {
- new Thread(new Runnable() {
+ public static void showUrl(final String url,
+ final IProgressIndicator progress)
+ {
+ new Thread(new Runnable()
+ {
@Override
- public void run() {
- try {
- if (progress != null) {
- progress.setProgressBar(MessageManager.formatMessage("status.opening_params", new Object[] { url }),
- this.hashCode());
+ public void run()
+ {
+ try
+ {
+ if (progress != null)
+ {
+ progress.setProgressBar(MessageManager
+ .formatMessage("status.opening_params", new Object[]
+ { url }), this.hashCode());
}
jalview.util.BrowserLauncher.openURL(url);
- } catch (Exception ex) {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString("label.web_browser_not_found_unix"),
- MessageManager.getString("label.web_browser_not_found"), JvOptionPane.WARNING_MESSAGE);
+ } catch (Exception ex)
+ {
+ JvOptionPane.showInternalMessageDialog(getDesktopPane(),
+ MessageManager
+ .getString("label.web_browser_not_found_unix"),
+ MessageManager.getString("label.web_browser_not_found"),
+ JvOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
- if (progress != null) {
+ if (progress != null)
+ {
progress.setProgressBar(null, this.hashCode());
}
}
@@ -2361,8 +2892,10 @@ public class Desktop extends jalview.jbgui.GDesktop
public static WsParamSetManager wsparamManager = null;
- public static ParamManager getUserParameterStore() {
- if (wsparamManager == null) {
+ public static ParamManager getUserParameterStore()
+ {
+ if (wsparamManager == null)
+ {
wsparamManager = new WsParamSetManager();
}
return wsparamManager;
@@ -2373,14 +2906,20 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param e
*/
- public static void hyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == EventType.ACTIVATED) {
+ public static void hyperlinkUpdate(HyperlinkEvent e)
+ {
+ if (e.getEventType() == EventType.ACTIVATED)
+ {
String url = null;
- try {
+ try
+ {
url = e.getURL().toString();
- Desktop.showUrl(url);
- } catch (Exception x) {
- if (url != null) {
+ showUrl(url);
+ } catch (Exception x)
+ {
+ if (url != null)
+ {
+ // 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.
@@ -2411,29 +2950,39 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param prompter
*/
- public void addDialogThread(final Runnable prompter) {
- dialogExecutor.submit(new Runnable() {
+ public void addDialogThread(final Runnable prompter)
+ {
+ dialogExecutor.submit(new Runnable()
+ {
@Override
- public void run() {
- if (dialogPause) {
- try {
+ public void run()
+ {
+ if (dialogPause)
+ {
+ try
+ {
block.acquire();
- } catch (InterruptedException x) {
+ } catch (InterruptedException x)
+ {
}
}
- if (instance == null) {
+ if (Jalview.isHeadlessMode())
+ {
return;
}
- try {
+ try
+ {
SwingUtilities.invokeAndWait(prompter);
- } catch (Exception q) {
+ } catch (Exception q)
+ {
jalview.bin.Console.warn("Unexpected Exception in dialog thread.", q);
}
}
});
}
- public void startDialogQueue() {
+ public void startDialogQueue()
+ {
// set the flag so we don't pause waiting for another permit and semaphore
// the current task to begin
dialogPause = false;
@@ -2450,53 +2999,65 @@ public class Desktop extends jalview.jbgui.GDesktop
*
*/
@Override
- protected void snapShotWindow_actionPerformed(ActionEvent e) {
+ protected void snapShotWindow_actionPerformed(ActionEvent e)
+ {
// currently the menu option to do this is not shown
invalidate();
int width = getWidth();
int height = getHeight();
- File of = new File("Jalview_snapshot_" + System.currentTimeMillis() + ".eps");
- ImageWriterI writer = new ImageWriterI() {
+ File of = new File(
+ "Jalview_snapshot_" + System.currentTimeMillis() + ".eps");
+ ImageWriterI writer = new ImageWriterI()
+ {
@Override
- public void exportImage(Graphics g) throws Exception {
+ public void exportImage(Graphics g) throws Exception
+ {
paintAll(g);
- jalview.bin.Console.info("Successfully written snapshot to file " + of.getAbsolutePath());
+ jalview.bin.Console.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
}
};
String title = "View of desktop";
- ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS, title);
+ ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
+ title);
exporter.doExport(of, this, width, height, title);
}
/**
* Explode the views in the given SplitFrame into separate SplitFrame windows.
- * This respects (remembers) any previous 'exploded geometry' i.e. the size and
- * location last time the view was expanded (if any). However it does not
+ * This respects (remembers) any previous 'exploded geometry' i.e. the size
+ * and location last time the view was expanded (if any). However it does not
* remember the split pane divider location - this is set to match the
* 'exploding' frame.
*
* @param sf
*/
- public void explodeViews(SplitFrame sf) {
+ public void explodeViews(SplitFrame sf)
+ {
AlignFrame oldTopFrame = (AlignFrame) sf.getTopFrame();
AlignFrame oldBottomFrame = (AlignFrame) sf.getBottomFrame();
- List extends AlignmentViewPanel> topPanels = oldTopFrame.getAlignPanels();
- List extends AlignmentViewPanel> bottomPanels = oldBottomFrame.getAlignPanels();
+ List extends AlignmentViewPanel> topPanels = oldTopFrame
+ .getAlignPanels();
+ List extends AlignmentViewPanel> bottomPanels = oldBottomFrame
+ .getAlignPanels();
int viewCount = topPanels.size();
- if (viewCount < 2) {
+ if (viewCount < 2)
+ {
return;
}
/*
- * 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--) {
+ 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
@@ -2505,8 +3066,10 @@ public class Desktop extends jalview.jbgui.GDesktop
AlignFrame newTopFrame = new AlignFrame(topPanel);
newTopFrame.setSize(oldTopFrame.getSize());
newTopFrame.setVisible(true);
- Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport()).getExplodedGeometry();
- if (geometry != null) {
+ Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
newTopFrame.setSize(geometry.getSize());
}
@@ -2514,23 +3077,27 @@ public class Desktop extends jalview.jbgui.GDesktop
AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
newBottomFrame.setSize(oldBottomFrame.getSize());
newBottomFrame.setVisible(true);
- geometry = ((AlignViewport) bottomPanel.getAlignViewport()).getExplodedGeometry();
- if (geometry != null) {
+ geometry = ((AlignViewport) bottomPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
newBottomFrame.setSize(geometry.getSize());
}
topPanel.av.setGatherViewsHere(false);
bottomPanel.av.setGatherViewsHere(false);
- JInternalFrame splitFrame = new SplitFrame(newTopFrame, newBottomFrame);
- if (geometry != null) {
+ JInternalFrame splitFrame = new SplitFrame(newTopFrame,
+ newBottomFrame);
+ if (geometry != null)
+ {
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();
@@ -2544,7 +3111,8 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param source
*/
- public void gatherViews(GSplitFrame source) {
+ public void gatherViews(GSplitFrame source)
+ {
/*
* special handling of explodedGeometry for a view within a SplitFrame: - it
* holds the (x, y) position of the enclosing SplitFrame, and the (width,
@@ -2552,38 +3120,46 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
- myTopFrame.viewport.setExplodedGeometry(
- new Rectangle(source.getX(), source.getY(), myTopFrame.getWidth(), myTopFrame.getHeight()));
- myBottomFrame.viewport.setExplodedGeometry(
- new Rectangle(source.getX(), source.getY(), myBottomFrame.getWidth(), myBottomFrame.getHeight()));
+ myTopFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(),
+ source.getY(), myTopFrame.getWidth(), myTopFrame.getHeight()));
+ myBottomFrame.viewport
+ .setExplodedGeometry(new Rectangle(source.getX(), source.getY(),
+ myBottomFrame.getWidth(), myBottomFrame.getHeight()));
myTopFrame.viewport.setGatherViewsHere(true);
myBottomFrame.viewport.setGatherViewsHere(true);
String topViewId = myTopFrame.viewport.getSequenceSetId();
String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
- JInternalFrame[] frames = desktop.getAllFrames();
- for (JInternalFrame frame : frames) {
- if (frame instanceof SplitFrame && frame != source) {
+ JInternalFrame[] frames = desktopPane.getAllFrames();
+ for (JInternalFrame frame : frames)
+ {
+ if (frame instanceof SplitFrame && frame != source)
+ {
SplitFrame sf = (SplitFrame) frame;
AlignFrame topFrame = (AlignFrame) sf.getTopFrame();
AlignFrame bottomFrame = (AlignFrame) sf.getBottomFrame();
boolean gatherThis = false;
- for (int a = 0; a < topFrame.alignPanels.size(); a++) {
+ for (int a = 0; a < topFrame.alignPanels.size(); a++)
+ {
AlignmentPanel topPanel = topFrame.alignPanels.get(a);
AlignmentPanel bottomPanel = bottomFrame.alignPanels.get(a);
if (topViewId.equals(topPanel.av.getSequenceSetId())
- && bottomViewId.equals(bottomPanel.av.getSequenceSetId())) {
+ && bottomViewId.equals(bottomPanel.av.getSequenceSetId()))
+ {
gatherThis = true;
topPanel.av.setGatherViewsHere(false);
bottomPanel.av.setGatherViewsHere(false);
- topPanel.av.setExplodedGeometry(new Rectangle(sf.getLocation(), topFrame.getSize()));
- bottomPanel.av.setExplodedGeometry(new Rectangle(sf.getLocation(), bottomFrame.getSize()));
+ topPanel.av.setExplodedGeometry(
+ new Rectangle(sf.getLocation(), topFrame.getSize()));
+ bottomPanel.av.setExplodedGeometry(
+ new Rectangle(sf.getLocation(), bottomFrame.getSize()));
myTopFrame.addAlignmentPanel(topPanel, false);
myBottomFrame.addAlignmentPanel(bottomPanel, false);
}
}
- if (gatherThis) {
+ if (gatherThis)
+ {
topFrame.getAlignPanels().clear();
bottomFrame.getAlignPanels().clear();
sf.close();
@@ -2597,7 +3173,8 @@ public class Desktop extends jalview.jbgui.GDesktop
myTopFrame.setDisplayedView(myTopFrame.alignPanel);
}
- public static groovy.ui.Console getGroovyConsole() {
+ public static groovy.ui.Console getGroovyConsole()
+ {
return groovyConsole;
}
@@ -2606,88 +3183,150 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* TODO refactor to desktop utilities class
*
- * @param files - Data source strings extracted from the drop event
- * @param protocols - protocol for each data source extracted from the drop
- * event
- * @param evt - the drop event
- * @param t - the payload from the drop event
+ * @param files
+ * - Data source strings extracted from the drop event
+ * @param protocols
+ * - protocol for each data source extracted from the drop event
+ * @param evt
+ * - the drop event
+ * @param t
+ * - the payload from the drop event
* @throws Exception
*/
- public static void transferFromDropTarget(List