diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java index 1d54d6b5..69561b33 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java @@ -4,7 +4,6 @@ package software.aws.toolkits.eclipse.amazonq.views; import java.nio.file.Path; - import org.eclipse.jetty.server.Server; import org.eclipse.swt.browser.BrowserFunction; import org.eclipse.swt.widgets.Composite; @@ -58,12 +57,12 @@ public Object function(final Object[] arguments) { } private String getContent() { - String jsFile = PluginUtils.getAwsDirectory(LspConstants.LSP_SUBDIRECTORY).resolve("amazonq-ui.js").toString(); + String jsFile = PluginUtils.getAwsDirectory(LspConstants.LSP_SUBDIRECTORY).resolve("amazonq-ui.js").toString(); var jsParent = Path.of(jsFile).getParent(); var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString(); server = setupVirtualServer(jsDirectoryPath); - if(server == null) { + if (server == null) { return "Failed to load JS"; } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java index 6f2d6314..5caaf388 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java @@ -104,70 +104,70 @@ private void setupActions(final Browser browser, final boolean isLoggedIn) { amazonQCommonActions = new AmazonQCommonActions(browser, isLoggedIn, getViewSite()); } - private void setupAuthStatusListeners() { - authStatusChangedListener = this::handleAuthStatusChange; - AuthUtils.addAuthStatusChangeListener(amazonQCommonActions.getSignoutAction()); - AuthUtils.addAuthStatusChangeListener(amazonQCommonActions.getFeedbackDialogContributionAction()); - } - - /** - * Sets up virtual host mapping for the given path using jetty server - * - * @param jsPath - * @return server launched - */ - protected Server setupVirtualServer(String jsPath) { - Server server = null; - try { - server = new Server(0); - var servletContext = new ContextHandler(); - servletContext.setContextPath("/"); - servletContext.addVirtualHosts(new String[] { "localhost" }); - - var handler = new ResourceHandler(); - - ResourceFactory resourceFactory = ResourceFactory.of(server); - handler.setBaseResource(resourceFactory.newResource(jsPath)); - handler.setDirAllowed(true); - servletContext.setHandler(handler); - - server.setHandler(servletContext); - server.start(); - - return server; - - } catch (Exception e) { - stopVirtualServer(server); - PluginLogger.error("Error occurred while attempting to start a virtual server for " + jsPath, e); - return null; - } - } - - protected void stopVirtualServer(Server server) { - if (server != null) { - try { - server.stop(); - } catch (Exception e) { - PluginLogger.error("Error occurred when attempting to stop the virtual server", e); - } - } - } - - @Override - public final void setFocus() { - browser.setFocus(); - } - - /** - * Disposes of the resources associated with this view. - * - * This method is called when the view is closed. It removes the authentication - * status change listener and the selection listener from the page. - */ - @Override - public void dispose() { - AuthUtils.removeAuthStatusChangeListener(authStatusChangedListener); - super.dispose(); - } + private void setupAuthStatusListeners() { + authStatusChangedListener = this::handleAuthStatusChange; + AuthUtils.addAuthStatusChangeListener(amazonQCommonActions.getSignoutAction()); + AuthUtils.addAuthStatusChangeListener(amazonQCommonActions.getFeedbackDialogContributionAction()); + } + + /** + * Sets up virtual host mapping for the given path using jetty server + * + * @param jsPath + * @return server launched + */ + protected Server setupVirtualServer(String jsPath) { + Server server = null; + try { + server = new Server(0); + var servletContext = new ContextHandler(); + servletContext.setContextPath("/"); + servletContext.addVirtualHosts(new String[] { "localhost" }); + + var handler = new ResourceHandler(); + + ResourceFactory resourceFactory = ResourceFactory.of(server); + handler.setBaseResource(resourceFactory.newResource(jsPath)); + handler.setDirAllowed(true); + servletContext.setHandler(handler); + + server.setHandler(servletContext); + server.start(); + + return server; + + } catch (Exception e) { + stopVirtualServer(server); + PluginLogger.error("Error occurred while attempting to start a virtual server for " + jsPath, e); + return null; + } + } + + protected void stopVirtualServer(Server server) { + if (server != null) { + try { + server.stop(); + } catch (Exception e) { + PluginLogger.error("Error occurred when attempting to stop the virtual server", e); + } + } + } + + @Override + public final void setFocus() { + browser.setFocus(); + } + + /** + * Disposes of the resources associated with this view. + * + * This method is called when the view is closed. It removes the authentication + * status change listener and the selection listener from the page. + */ + @Override + public void dispose() { + AuthUtils.removeAuthStatusChangeListener(authStatusChangedListener); + super.dispose(); + } }