viewp = new ArrayList<>();
- if (desktop != null)
+ if (getDesktopPane() != null)
{
AlignFrame[] frames = Desktop.getAlignFrames();
@@ -2012,11 +2008,29 @@ public class Desktop extends jalview.jbgui.GDesktop
return;
}
+ // BH! not in applet branch
+ // FIXME: ideally should use UI interface API
+ FeatureSettings viewFeatureSettings = (af.featureSettings != null
+ && af.featureSettings.isOpen())
+ ? af.featureSettings
+ : null;
+ Rectangle fsBounds = af.getFeatureSettingsGeometry();
for (int i = 0; i < size; i++)
{
AlignmentPanel ap = af.alignPanels.get(i);
AlignFrame newaf = new AlignFrame(ap);
+ // BH! not in applet branch
+ // transfer reference for existing feature settings to new alignFrame
+ if (ap == af.alignPanel)
+ {
+ if (viewFeatureSettings != null && viewFeatureSettings.fr.ap == ap)
+ {
+ newaf.featureSettings = viewFeatureSettings;
+ }
+ newaf.setFeatureSettingsGeometry(fsBounds);
+ }
+
/*
* Restore the view's last exploded frame geometry if known. Multiple
* views from one exploded frame share and restore the same (frame)
@@ -2032,8 +2046,19 @@ public class Desktop extends jalview.jbgui.GDesktop
addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
+ // BH! not in applet branch
+ // and materialise a new feature settings dialog instance for the new alignframe
+ // (closes the old as if 'OK' was pressed)
+ if (ap == af.alignPanel && newaf.featureSettings != null
+ && newaf.featureSettings.isOpen()
+ && af.alignPanel.getAlignViewport().isShowSequenceFeatures())
+ {
+ newaf.showFeatureSettingsUI();
+ }
}
+ // BH! not in applet branch
+ af.featureSettings = null;
af.alignPanels.clear();
af.closeMenuItem_actionPerformed(true);
@@ -2051,7 +2076,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
source.viewport.setGatherViewsHere(true);
source.viewport.setExplodedGeometry(source.getBounds());
- JInternalFrame[] frames = desktop.getAllFrames();
+ JInternalFrame[] frames = getAllFrames();
String viewId = source.viewport.getSequenceSetId();
for (int t = 0; t < frames.length; t++)
@@ -2074,379 +2099,37 @@ public class Desktop extends jalview.jbgui.GDesktop
if (gatherThis)
{
- af.alignPanels.clear();
- af.closeMenuItem_actionPerformed(true);
- }
- }
- }
-
- }
-
- jalview.gui.VamsasApplication v_client = null;
-
- @Override
- public void vamsasImport_actionPerformed(ActionEvent e)
- {
- // TODO: JAL-3048 not needed for Jalview-JS
-
- if (v_client == null)
- {
- // Load and try to start a session.
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(
- MessageManager.getString("label.open_saved_vamsas_session"));
- chooser.setToolTipText(MessageManager.getString(
- "label.select_vamsas_session_opened_as_new_vamsas_session"));
-
- int value = chooser.showOpenDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- String fle = chooser.getSelectedFile().toString();
- if (!vamsasImport(chooser.getSelectedFile()))
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.couldnt_import_as_vamsas_session",
- new Object[]
- { fle }),
- MessageManager
- .getString("label.vamsas_document_import_failed"),
- JvOptionPane.ERROR_MESSAGE);
- }
- }
- }
- else
- {
- jalview.bin.Cache.log.error(
- "Implementation error - load session from a running session is not supported.");
- }
- }
-
- /**
- * import file into a new vamsas session (uses jalview.gui.VamsasApplication)
- *
- * @param file
- * @return true if import was a success and a session was started.
- */
- public boolean vamsasImport(URL url)
- {
- // TODO: create progress bar
- if (v_client != null)
- {
-
- jalview.bin.Cache.log.error(
- "Implementation error - load session from a running session is not supported.");
- return false;
- }
-
- try
- {
- // copy the URL content to a temporary local file
- // TODO: be a bit cleverer here with nio (?!)
- File file = File.createTempFile("vdocfromurl", ".vdj");
- FileOutputStream fos = new FileOutputStream(file);
- BufferedInputStream bis = new BufferedInputStream(url.openStream());
- byte[] buffer = new byte[2048];
- int ln;
- while ((ln = bis.read(buffer)) > -1)
- {
- fos.write(buffer, 0, ln);
- }
- bis.close();
- fos.close();
- v_client = new jalview.gui.VamsasApplication(this, file,
- url.toExternalForm());
- } catch (Exception ex)
- {
- jalview.bin.Cache.log.error(
- "Failed to create new vamsas session from contents of URL "
- + url,
- ex);
- return false;
- }
- setupVamsasConnectedGui();
- v_client.initial_update(); // TODO: thread ?
- return v_client.inSession();
- }
-
- /**
- * import file into a new vamsas session (uses jalview.gui.VamsasApplication)
- *
- * @param file
- * @return true if import was a success and a session was started.
- */
- public boolean vamsasImport(File file)
- {
- if (v_client != null)
- {
-
- jalview.bin.Cache.log.error(
- "Implementation error - load session from a running session is not supported.");
- return false;
- }
-
- setProgressBar(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
- try
- {
- v_client = new jalview.gui.VamsasApplication(this, file, null);
- } catch (Exception ex)
- {
- setProgressBar(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
- jalview.bin.Cache.log.error(
- "New vamsas session from existing session file failed:", ex);
- return false;
- }
- setupVamsasConnectedGui();
- v_client.initial_update(); // TODO: thread ?
- setProgressBar(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
- return v_client.inSession();
- }
-
- public boolean joinVamsasSession(String mysesid)
- {
- if (v_client != null)
- {
- throw new Error(MessageManager
- .getString("error.try_join_vamsas_session_another"));
- }
- if (mysesid == null)
- {
- throw new Error(
- MessageManager.getString("error.invalid_vamsas_session_id"));
- }
- v_client = new VamsasApplication(this, mysesid);
- setupVamsasConnectedGui();
- v_client.initial_update();
- return (v_client.inSession());
- }
-
- @Override
- public void vamsasStart_actionPerformed(ActionEvent e)
- {
- if (v_client == null)
- {
- // Start a session.
- // we just start a default session for moment.
- /*
- * JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
- * getProperty("LAST_DIRECTORY"));
- *
- * chooser.setFileView(new JalviewFileView());
- * chooser.setDialogTitle("Load Vamsas file");
- * chooser.setToolTipText("Import");
- *
- * int value = chooser.showOpenDialog(this);
- *
- * if (value == JalviewFileChooser.APPROVE_OPTION) { v_client = new
- * jalview.gui.VamsasApplication(this, chooser.getSelectedFile());
- */
- v_client = new VamsasApplication(this);
- setupVamsasConnectedGui();
- v_client.initial_update(); // TODO: thread ?
- }
- else
- {
- // store current data in session.
- v_client.push_update(); // TODO: thread
- }
- }
-
- protected void setupVamsasConnectedGui()
- {
- vamsasStart.setText(MessageManager.getString("label.session_update"));
- vamsasSave.setVisible(true);
- vamsasStop.setVisible(true);
- vamsasImport.setVisible(false); // Document import to existing session is
- // not possible for vamsas-client-1.0.
- }
-
- protected void setupVamsasDisconnectedGui()
- {
- vamsasSave.setVisible(false);
- vamsasStop.setVisible(false);
- vamsasImport.setVisible(true);
- vamsasStart
- .setText(MessageManager.getString("label.new_vamsas_session"));
- }
-
- @Override
- public void vamsasStop_actionPerformed(ActionEvent e)
- {
- if (v_client != null)
- {
- v_client.end_session();
- v_client = null;
- setupVamsasDisconnectedGui();
- }
- }
-
- protected void buildVamsasStMenu()
- {
- if (v_client == null)
- {
- String[] sess = null;
- try
- {
- sess = VamsasApplication.getSessionList();
- } catch (Exception e)
- {
- jalview.bin.Cache.log.warn("Problem getting current sessions list.",
- e);
- sess = null;
- }
- if (sess != null)
- {
- jalview.bin.Cache.log.debug(
- "Got current sessions list: " + sess.length + " entries.");
- VamsasStMenu.removeAll();
- for (int i = 0; i < sess.length; i++)
- {
- JMenuItem sessit = new JMenuItem();
- sessit.setText(sess[i]);
- sessit.setToolTipText(MessageManager
- .formatMessage("label.connect_to_session", new Object[]
- { sess[i] }));
- final Desktop dsktp = this;
- final String mysesid = sess[i];
- sessit.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
+ if (af.featureSettings != null && af.featureSettings.isOpen())
{
- if (dsktp.v_client == null)
+ if (source.featureSettings == null)
{
- Thread rthr = new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- dsktp.v_client = new VamsasApplication(dsktp, mysesid);
- dsktp.setupVamsasConnectedGui();
- dsktp.v_client.initial_update();
- }
-
- });
- rthr.start();
+ // preserve the feature settings geometry for this frame
+ source.featureSettings = af.featureSettings;
+ source.setFeatureSettingsGeometry(
+ af.getFeatureSettingsGeometry());
}
- };
- });
- VamsasStMenu.add(sessit);
- }
- // don't show an empty menu.
- VamsasStMenu.setVisible(sess.length > 0);
-
- }
- else
- {
- jalview.bin.Cache.log.debug("No current vamsas sessions.");
- VamsasStMenu.removeAll();
- VamsasStMenu.setVisible(false);
- }
- }
- else
- {
- // Not interested in the content. Just hide ourselves.
- VamsasStMenu.setVisible(false);
- }
- }
-
- @Override
- public void vamsasSave_actionPerformed(ActionEvent e)
- {
- // TODO: JAL-3048 not needed for Jalview-JS
-
- if (v_client != null)
- {
- // TODO: VAMSAS DOCUMENT EXTENSION is VDJ
- JalviewFileChooser chooser = new JalviewFileChooser("vdj",
- "Vamsas Document");
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(MessageManager
- .getString("label.save_vamsas_document_archive"));
-
- int value = chooser.showSaveDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- java.io.File choice = chooser.getSelectedFile();
- JPanel progpanel = addProgressPanel(MessageManager
- .formatMessage("label.saving_vamsas_doc", new Object[]
- { choice.getName() }));
- Cache.setProperty("LAST_DIRECTORY", choice.getParent());
- String warnmsg = null;
- String warnttl = null;
- try
- {
- v_client.vclient.storeDocument(choice);
- } catch (Error ex)
- {
- warnttl = "Serious Problem saving Vamsas Document";
- warnmsg = ex.toString();
- jalview.bin.Cache.log
- .error("Error Whilst saving document to " + choice, ex);
-
- } catch (Exception ex)
- {
- warnttl = "Problem saving Vamsas Document.";
- warnmsg = ex.toString();
- jalview.bin.Cache.log.warn(
- "Exception Whilst saving document to " + choice, ex);
-
- }
- removeProgressPanel(progpanel);
- if (warnmsg != null)
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
-
- warnmsg, warnttl, JvOptionPane.ERROR_MESSAGE);
+ else
+ {
+ // close it and forget
+ af.featureSettings.close();
+ }
+ }
+ af.alignPanels.clear();
+ af.closeMenuItem_actionPerformed(true);
+ }
}
}
- }
- }
-
- JPanel vamUpdate = null;
-
- /**
- * hide vamsas user gui bits when a vamsas document event is being handled.
- *
- * @param b
- * true to hide gui, false to reveal gui
- */
- public void setVamsasUpdate(boolean b)
- {
- Cache.log.debug("Setting gui for Vamsas update "
- + (b ? "in progress" : "finished"));
-
- if (vamUpdate != null)
- {
- this.removeProgressPanel(vamUpdate);
- }
- if (b)
+ // refresh the feature setting UI for the source frame if it exists
+ if (source.featureSettings != null
+ && source.featureSettings.isOpen())
{
- vamUpdate = this.addProgressPanel(
- MessageManager.getString("label.updating_vamsas_session"));
+ source.showFeatureSettingsUI();
}
- vamsasStart.setVisible(!b);
- vamsasStop.setVisible(!b);
- vamsasSave.setVisible(!b);
}
public JInternalFrame[] getAllFrames()
{
- return desktop.getAllFrames();
+ return desktopPane.getAllFrames();
}
/**
@@ -2485,7 +2168,7 @@ public class Desktop extends jalview.jbgui.GDesktop
while (li.hasNext())
{
String link = li.next();
- if (link.contains(SEQUENCE_ID)
+ if (link.contains(UrlConstants.SEQUENCE_ID)
&& !UrlConstants.isDefaultString(link))
{
check = true;
@@ -2532,7 +2215,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);
@@ -2647,11 +2330,11 @@ public class Desktop extends jalview.jbgui.GDesktop
{
if (Jalview.isHeadlessMode())
{
- // Desktop.desktop is null in headless mode
- return new AlignFrame[] { Jalview.currentAlignFrame };
+ // Desktop.getDesktopPane() is null in headless mode
+ return new AlignFrame[] { Jalview.getCurrentAlignFrame() };
}
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
if (frames == null)
{
@@ -2696,7 +2379,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public GStructureViewer[] getJmols()
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
if (frames == null)
{
@@ -2731,8 +2414,8 @@ public class Desktop extends jalview.jbgui.GDesktop
openGroovyConsole();
} catch (Exception ex)
{
- jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ Cache.log.error("Groovy Shell Creation failed.", ex);
+ JvOptionPane.showInternalMessageDialog(desktopPane,
MessageManager.getString("label.couldnt_create_groovy_shell"),
MessageManager.getString("label.groovy_support_failed"),
@@ -2743,7 +2426,7 @@ public class Desktop extends jalview.jbgui.GDesktop
/**
* Open the Groovy console
*/
- void openGroovyConsole()
+ private void openGroovyConsole()
{
if (groovyConsole == null)
{
@@ -2792,7 +2475,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
+ ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()),
"Quit");
getRootPane().getActionMap().put("Quit", new AbstractAction()
{
@@ -2843,7 +2526,7 @@ public class Desktop extends jalview.jbgui.GDesktop
@Override
public void setProgressBar(String message, long id)
{
- Platform.timeCheck("Desktop " + message, Platform.TIME_MARK);
+ // Platform.timeCheck("Desktop " + message, Platform.TIME_MARK);
if (progressBars == null)
{
@@ -2851,18 +2534,18 @@ public class Desktop extends jalview.jbgui.GDesktop
progressBarHandlers = new Hashtable<>();
}
- if (progressBars.get(new Long(id)) != null)
+ if (progressBars.get(Long.valueOf(id)) != null)
{
- JPanel panel = progressBars.remove(new Long(id));
- if (progressBarHandlers.contains(new Long(id)))
+ JPanel panel = progressBars.remove(Long.valueOf(id));
+ if (progressBarHandlers.contains(Long.valueOf(id)))
{
- progressBarHandlers.remove(new Long(id));
+ progressBarHandlers.remove(Long.valueOf(id));
}
removeProgressPanel(panel);
}
else
{
- progressBars.put(new Long(id), addProgressPanel(message));
+ progressBars.put(Long.valueOf(id), addProgressPanel(message));
}
}
@@ -2877,13 +2560,13 @@ public class Desktop extends jalview.jbgui.GDesktop
final IProgressIndicatorHandler handler)
{
if (progressBarHandlers == null
- || !progressBars.containsKey(new Long(id)))
+ || !progressBars.containsKey(Long.valueOf(id)))
{
throw new Error(MessageManager.getString(
"error.call_setprogressbar_before_registering_handler"));
}
- progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = progressBars.get(new Long(id));
+ progressBarHandlers.put(Long.valueOf(id), handler);
+ final JPanel progressPanel = progressBars.get(Long.valueOf(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
@@ -2929,7 +2612,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());
@@ -2944,12 +2627,6 @@ public class Desktop extends jalview.jbgui.GDesktop
return null;
}
- public VamsasApplication getVamsasApplication()
- {
- return v_client;
-
- }
-
/**
* flag set if jalview GUI is being operated programmatically
*/
@@ -2990,8 +2667,8 @@ public class Desktop extends jalview.jbgui.GDesktop
// todo: changesupport handlers need to be transferred
if (discoverer == null)
{
- discoverer = new jalview.ws.jws1.Discoverer();
- // register PCS handler for desktop.
+ discoverer = jalview.ws.jws1.Discoverer.getInstance();
+ // register PCS handler for getDesktopPane().
discoverer.addPropertyChangeListener(changeSupport);
}
// JAL-940 - disabled JWS1 service configuration - always start discoverer
@@ -3001,7 +2678,7 @@ public class Desktop extends jalview.jbgui.GDesktop
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ t2 = jalview.ws.jws2.Jws2Discoverer.getInstance()
.startDiscoverer(changeSupport);
}
Thread t3 = null;
@@ -3034,7 +2711,7 @@ public class Desktop extends jalview.jbgui.GDesktop
{
if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
{
- final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ final String ermsg = jalview.ws.jws2.Jws2Discoverer.getInstance()
.getErrorMessages();
if (ermsg != null)
{
@@ -3073,7 +2750,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* jd.waitForInput();
*/
- JvOptionPane.showConfirmDialog(Desktop.desktop,
+ JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
new JLabel(""
+ "It may be that you have invalid JABA URLs
in your web service preferences,"
@@ -3099,7 +2776,7 @@ public class Desktop extends jalview.jbgui.GDesktop
}
}
- private Runnable serviceChangedDialog = null;
+ Runnable serviceChangedDialog = null;
/**
* start a thread to open a URL in the configured browser. Pops up a warning
@@ -3110,7 +2787,7 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
public static void showUrl(final String url)
{
- showUrl(url, Desktop.instance);
+ showUrl(url, Desktop.getInstance());
}
/**
@@ -3130,16 +2807,16 @@ public class Desktop extends jalview.jbgui.GDesktop
{
try
{
- if (progress != null)
+ if (progress != null && !Platform.isJS())
{
progress.setProgressBar(MessageManager
.formatMessage("status.opening_params", new Object[]
{ url }), this.hashCode());
}
- jalview.util.BrowserLauncher.openURL(url);
+ Platform.openURL(url);
} catch (Exception ex)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
MessageManager
.getString("label.web_browser_not_found_unix"),
MessageManager.getString("label.web_browser_not_found"),
@@ -3147,7 +2824,7 @@ public class Desktop extends jalview.jbgui.GDesktop
ex.printStackTrace();
}
- if (progress != null)
+ if (progress != null && !Platform.isJS())
{
progress.setProgressBar(null, this.hashCode());
}
@@ -3155,15 +2832,16 @@ public class Desktop extends jalview.jbgui.GDesktop
}).start();
}
- public static WsParamSetManager wsparamManager = null;
+ private WsParamSetManager wsparamManager = null;
public static ParamManager getUserParameterStore()
{
- if (wsparamManager == null)
+ Desktop d = Desktop.getInstance();
+ if (d.wsparamManager == null)
{
- wsparamManager = new WsParamSetManager();
+ d.wsparamManager = new WsParamSetManager();
}
- return wsparamManager;
+ return d.wsparamManager;
}
/**
@@ -3215,7 +2893,10 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
private java.util.concurrent.Semaphore block = new Semaphore(0);
- private static groovy.ui.Console groovyConsole;
+ // BH was static
+ private groovy.ui.Console groovyConsole;
+
+ public StructureViewer lastTargetedView;
/**
* add another dialog thread to the queue
@@ -3237,9 +2918,9 @@ public class Desktop extends jalview.jbgui.GDesktop
} catch (InterruptedException x)
{
}
- ;
}
- if (instance == null)
+ // BH! Q: do we mean System.headless ? or "nogui/nodisplay" headless?
+ if (Jalview.isHeadlessMode())
{
return;
}
@@ -3403,7 +3084,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)
@@ -3448,7 +3129,8 @@ public class Desktop extends jalview.jbgui.GDesktop
public static groovy.ui.Console getGroovyConsole()
{
- return groovyConsole;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.groovyConsole;
}
/**
@@ -3466,6 +3148,7 @@ public class Desktop extends jalview.jbgui.GDesktop
* - the payload from the drop event
* @throws Exception
*/
+ @SuppressWarnings("unchecked")
public static void transferFromDropTarget(List