* <li>Start the Chimera process</li>
* <li>Start the REST service on Chimera, get the port number it is listening on
* </li>
- * <li>Start the ChimeraListener, get the port number it is listening on</li>
+ * <li>Start the ChimeraListener, get the URL it is listening on</li>
+ * <li>The first listener started will start the singleton HttpServer</li>
* <li>Send a 'listen' command to Chimera with the URL of the listener</li>
+ * <li>When Jalview's Chimera window is closed, shut down the ChimeraListener</li>
+ * <li>Multiple linked Chimera instances will each have a separate listener (but
+ * share one Http server)</li>
* </ul>
*
* @author gmcarstairs
public class ChimeraListener extends AbstractRequestHandler implements
SelectionSource
{
+ private static final String CHIMERA_NOTIFICATION = "chimeraNotification";
+
+ private static final String MODEL_CHANGED = "ModelChanged: ";
+
+ private static final String SELECTION_CHANGED = "SelectionChanged: selection changed\n";
+
/*
* A static counter so each listener can be associated with a distinct context
* root (/chimera0,1,2,3...). This is needed so we can fetch selections from
HttpServletResponse response)
{
// dumpRequest(request);
- String message = request.getParameter("chimeraNotification");
- if ("selection changed".equals(message))
+ String message = request.getParameter(CHIMERA_NOTIFICATION);
+ if (SELECTION_CHANGED.equals(message))
{
this.chimeraBinding.highlightChimeraSelection();
}
+ else if (message != null && message.startsWith(MODEL_CHANGED))
+ {
+ processModelChanged(message.substring(MODEL_CHANGED.length()));
+ }
else
{
System.err.println("Unexpected chimeraNotification: " + message);
- // do it anyway for now!
- this.chimeraBinding.highlightChimeraSelection();
}
}
/**
+ * Handler a ModelChanged notification from Chimera
+ *
+ * @param substring
+ */
+ protected void processModelChanged(String message)
+ {
+ System.out.println(message + " (not implemented in Jalview)");
+ }
+
+ /**
* Deregister this listener and close it down
*
* @throws Exception