Skip to content

Commit

Permalink
Fix broken webview (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
pras0131 authored Sep 18, 2024
1 parent b74d7cf commit 69a9b10
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ public class AmazonQChatWebview extends AmazonQView {
private final ViewActionHandler actionHandler;

public AmazonQChatWebview() {
browser = getBrowser();
amazonQCommonActions = getAmazonQCommonActions();

this.commandParser = new LoginViewCommandParser();
this.actionHandler = new AmazonQChatViewActionHandler();
}

@Override
public final void createPartControl(final Composite parent) {
setupAmazonQView(parent, true);
browser = getBrowser();
amazonQCommonActions = getAmazonQCommonActions();

AuthUtils.isLoggedIn().thenAcceptAsync(isLoggedIn -> {
handleAuthStatusChange(isLoggedIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public final AmazonQCommonActions getAmazonQCommonActions() {

protected final void setupAmazonQView(final Composite parent, final boolean isLoggedIn) {
setupBrowser(parent);
setupActions(isLoggedIn);
setupActions(browser, isLoggedIn);
setupAuthStatusListeners();
setupSelectionListener();
}
Expand All @@ -89,8 +89,8 @@ private void setupBrowser(final Composite parent) {
parent.setBackground(black);
}

private void setupActions(final boolean isLoggedIn) {
amazonQCommonActions = new AmazonQCommonActions(isLoggedIn, getViewSite());
private void setupActions(final Browser browser, final boolean isLoggedIn) {
amazonQCommonActions = new AmazonQCommonActions(browser, isLoggedIn, getViewSite());
}

private void setupAuthStatusListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public final class ToolkitLoginWebview extends AmazonQView {
private final ViewActionHandler actionHandler;

public ToolkitLoginWebview() {
browser = getBrowser();
amazonQCommonActions = getAmazonQCommonActions();
this.commandParser = new LoginViewCommandParser();
this.actionHandler = new LoginViewActionHandler();
}

@Override
public void createPartControl(final Composite parent) {
setupAmazonQView(parent, true);
browser = getBrowser();
amazonQCommonActions = getAmazonQCommonActions();

AuthUtils.isLoggedIn().thenAcceptAsync(isLoggedIn -> {
handleAuthStatusChange(isLoggedIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewSite;
import org.eclipse.swt.browser.Browser;

public final class AmazonQCommonActions {

private ChangeThemeAction changeThemeAction;
private SignoutAction signoutAction;
private FeedbackDialogContributionItem feedbackDialogContributionItem;

public AmazonQCommonActions(final boolean isLoggedIn, final IViewSite viewSite) {
createActions(isLoggedIn, viewSite);
public AmazonQCommonActions(final Browser browser, final boolean isLoggedIn, final IViewSite viewSite) {
createActions(browser, isLoggedIn, viewSite);
contributeToActionBars(viewSite);
updateActionVisibility(isLoggedIn, viewSite);
}
Expand All @@ -31,8 +32,8 @@ public FeedbackDialogContributionItem getFeedbackDialogContributionAction() {
return feedbackDialogContributionItem;
}

private void createActions(final boolean isLoggedIn, final IViewSite viewSite) {
changeThemeAction = new ChangeThemeAction();
private void createActions(final Browser browser, final boolean isLoggedIn, final IViewSite viewSite) {
changeThemeAction = new ChangeThemeAction(browser);
signoutAction = new SignoutAction();
feedbackDialogContributionItem = new FeedbackDialogContributionItem(viewSite);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public final class ChangeThemeAction extends Action {
private Browser browser;
private boolean darkMode = Display.isSystemDarkTheme();

public ChangeThemeAction() {
public ChangeThemeAction(final Browser browser) {
this.browser = browser;
setText("Change Color");
setToolTipText("Change the color");
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
Expand Down

0 comments on commit 69a9b10

Please sign in to comment.