Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce View Container and base view components #338

Merged
merged 14 commits into from
Feb 6, 2025

Conversation

nborges-aws
Copy link
Contributor

Issue #336

Description of changes:
This PR introduces the view container component and a updated base view as part of a larger refactor of the view handling in the plugin. Changes include refactoring browser-less views to implement the new base view, and creating logic to display all content using a singular view. The code here is dependent on previous PR #309 and PR #337.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nborges-aws nborges-aws changed the base branch from main to taldekar/ViewRouter January 29, 2025 14:22
Base automatically changed from taldekar/ViewRouter to feature/viewRefactor February 4, 2025 21:27
parent.setLayout(gridLayout);

setupStaticMenuActions();
updateChildView(activeView, ViewId.RE_AUTHENTICATE_VIEW);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both the active view and the view ID to be passed in?

}

if (views.containsKey(newViewId)) {
BaseAmazonQView newView = views.get(newViewId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we track the active view ID here for when the parent composite is disposed?

private Disposable viewChangeEventSubscription;

public AmazonQViewContainer() {
viewChangeEventSubscription = Activator.getEventBroker().subscribe(ViewId.class, this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would need to subscribe to these events in the createPartControl every time if you dispose the subscription in the dispose call. I think Jonathan prefers not disposing the subscription.


package software.aws.toolkits.eclipse.amazonq.views.router;

public enum ViewId {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this class was renamed in the ViewRouter PR so it might have gotten added accidentally.


//default view passed in from router
//possible we'll use chatView as default?
activeView = views.get(currentActiveViewId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This view might get disposed before being created if createPartControl calls updateChildView the first time. Not sure if that causes any issues.

new AmazonQStaticActions(getViewSite());
}

private void updateChildView() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be race condition if both the createPartControl and onEvent call these methods simultaneously.

* 2. viewContainer.init(currentView)
*/

public void initializeViews(final AmazonQViewType currentActiveViewId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this to the constructor?

@nborges-aws nborges-aws merged commit 68ee9c5 into feature/viewRefactor Feb 6, 2025
@nborges-aws nborges-aws deleted the nickdb/viewContainerSetup branch February 6, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants