Package de.aristaflow.adept2.ui.swtgui
Class SwtHtmlContext
java.lang.Object
de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
de.aristaflow.adept2.ui.swtgui.SwtHtmlContext
- All Implemented Interfaces:
GUIContext,HTMLContext,HTTPReplyHandler,Closeable,AutoCloseable
This
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classThe clean-up task for closing the browser.Nested classes/interfaces inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
AbstractHTMLContext.HtmlContextCleanupTaskNested classes/interfaces inherited from interface de.aristaflow.adept2.ui.htmlgui.HTMLContext
HTMLContext.Attachment, HTMLContext.CloseIgnoringAttachment, HTMLContext.HTTPReply, HTMLContext.Response -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.lang3.mutable.Mutable<org.eclipse.swt.browser.Browser>Browser widget for displaying HTML content in the templateprotected final ClientServiceThe client service to retrieve a session token from to access the HTTP service.protected final Cleanup<RuntimeException>The clean-up for closing the context and all related resources.protected final org.apache.commons.lang3.mutable.Mutable<SWTContext>The parent SWT-context containing the Eclipse-Editor.Fields inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
baseURL, cleanup, DEFAULT_FINAL_RESPONSE, finalResponse, httpService, initialContentString, logger, relRes, replies, replyHandlerTerminated, responses, sessionID, thread -
Constructor Summary
ConstructorsConstructorDescriptionSwtHtmlContext(Thread thread, SWTContext parentSwtContext, HTTPService httpService, ClientService clientService, String sessionId) Creates a new HTML context based on the Eclipse-Browser-widget. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisHTMLContext.voidsetInitialContent(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.Methods inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
checkForValidExecutorThread, close, getRelativeLink, getRelativeLink, getResponse, setBaseURL, setFinalResponse, setFinalResponse, setResponse, waitForHTTPReply
-
Field Details
-
parentSwtContext
The parent SWT-context containing the Eclipse-Editor. -
clientService
The client service to retrieve a session token from to access the HTTP service. -
browser
protected final org.apache.commons.lang3.mutable.Mutable<org.eclipse.swt.browser.Browser> browserBrowser widget for displaying HTML content in the template -
contextCleanup
The clean-up for closing the context and all related resources.
-
-
Constructor Details
-
SwtHtmlContext
public SwtHtmlContext(Thread thread, SWTContext parentSwtContext, HTTPService httpService, ClientService clientService, String sessionId) Creates a new HTML context based on the Eclipse-Browser-widget.- Parameters:
thread- The thread which executes the application using this context.
We must not keep a strong reference to this thread! Otherwise memory leaks may occur.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).
-
-
Method Details
-
close
public void close()Description copied from interface:HTMLContextCloses thisHTMLContext. Implementations have to clean up which usually involves deregistering the HTML-context from the corresponding HTTP-server, for instanceHTTPService.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. -
setInitialContent
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. Feedback/data can be retrieved via the usage of the providedURLand byHTMLContext.waitForHTTPReply(long).
The content is only provided once. Afterwards,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.
AnInvalidExecutorThreadExceptionwill 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.- Specified by:
setInitialContentin interfaceHTMLContext- Overrides:
setInitialContentin classAbstractHTMLContext- Parameters:
html- The content of this HTML-context, that is the user-interface in HTML for the executed application.
-