public class SwtHtmlContext extends AbstractHTMLContext
GUIContext encapsulates the HTML of this context in
a browser widget in SWT. Therefore when setting the initial content,
a browser widget will be created and the URL will be set appropriately. The
widget will also be closed again when closing this context.HTMLContext.Attachment, HTMLContext.HTTPReply, HTMLContext.Response| Modifier and Type | Field and Description |
|---|---|
protected Browser |
browser
Browser widget for displaying HTML content in the template
|
protected ClientService |
clientService
The client service to retrieve a session token from to access the HTTP
service.
|
protected SWTContext |
parentSwtContext
The parent SWT-context containing the Eclipse-Editor.
|
baseURL, DEFAULT_FINAL_RESPONSE, finalResponse, initialContent, logger, replies, replyHandlerTerminated, responses, thread| Constructor and Description |
|---|
SwtHtmlContext(java.lang.Thread thread,
SWTContext parentSwtContext,
HTTPService httpService,
ClientService clientService,
java.lang.String sessionId)
Creates a new HTML context based on the Eclipse-Browser-widget.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this
HTMLContext. |
void |
setInitialContent(java.lang.String html)
Sets the initial (HTML-)content of this context, that is the designated
content is sent as response to the first to the client for visualising the
executed application.
|
checkForValidExecutorThread, getResponse, getURL, getURL, setBaseURL, setFinalResponse, setFinalResponse, setResponse, waitForHTTPReplyprotected final SWTContext parentSwtContext
protected final ClientService clientService
protected Browser browser
public SwtHtmlContext(java.lang.Thread thread,
SWTContext parentSwtContext,
HTTPService httpService,
ClientService clientService,
java.lang.String sessionId)
thread - The thread which executes the application using this context.parentSwtContext - The parent SWT-context containing the
Eclipse-Editor.httpService - The HTTP service for deregistering this reply handler.clientService - The client service to retrieve a session token from to
access the HTTP service.sessionId - The ID of the session in which the GUI context is needed
(required for deregistering this reply handler).public void close()
HTMLContextHTMLContext. Implementations have to clean up
which usually involves deregistering the HTML-context from the
corresponding HTTP-server, for instance
de.aristaflow.adept2.ui.htmlgui.httpservice.HTTPService#deregisterReplyHandler(de.aristaflow.adept2.base.sessionmanagement.SessionToken, String)
. Additionally, a final response should be set here in case it has not been
set before. This will unblock threads currently waiting for a response that
will not come any more.public void setInitialContent(java.lang.String html)
URL and by HTMLContext.waitForHTTPReply(long). HTMLContext.setResponse(HTTPReply, Response) has to be used for sending HTML
to the user. If you want to set the initial content, be sure to set it
before the first request arrives! However, you need not set it here, you
can also provide it to a received
empty request. InvalidExecutorThreadException will be thrown if the method
is not called by the main thread of the corresponding component.
Besides setting the initial content, this method also creates a new browser
(in Eclipse) having the parent provided in the constructor and a
parameterless URL provided by the superclass of this HTMLContext.setInitialContent in interface HTMLContextsetInitialContent in class AbstractHTMLContexthtml - The content of this HTML-context, that is the
user-interface in HTML for the executed application.