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

Trigger customization notifications on ide, stacking multiple notifications vertically and refactor/add support for more methods in PluginStore #48

Merged
merged 13 commits into from
Oct 4, 2024

Conversation

pras0131
Copy link
Contributor

@pras0131 pras0131 commented Oct 2, 2024

Reference ticket: https://issues.amazon.com/issues/ECLIPSE-297

  • Trigger IDE notifications on customization updates or selection of default foundation.
  • The PR also includes changes to stack multiple notifications vertically and the logic to reposition notifications once any of the notification is closed. The CRUX of the implementation is AbstractNotificationPopup initializeBounds() method, which has been overriden according to our requirements and repositioning of notifications once the older ones starts to flash out.
  • Support for two new methods - putObject and getObject in the PluginStore to ease set/get for more complex objects other than just plain strings.
  • Refactored the customizations preference storage code to let it store the entire customization object, rather than storing each of the individual fields.
Screenshot 2024-10-03 at 10 48 38

@pras0131 pras0131 changed the base branch from main to paras/fetchCustomizations October 2, 2024 13:45
@pras0131 pras0131 changed the title Trigger customization notifications on ide Trigger customization notifications on ide and stacking multiple notifications vertically Oct 3, 2024
@pras0131 pras0131 changed the title Trigger customization notifications on ide and stacking multiple notifications vertically Trigger customization notifications on ide, stacking multiple notifications vertically and refactor/add support for more methods in PluginStore Oct 3, 2024
@pras0131 pras0131 requested a review from breedloj October 3, 2024 12:45
PluginStore.put(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY, this.selectedCustomisationArn);
Display.getCurrent().asyncExec(() -> showNotification(Constants.DEFAULT_Q_FOUNDATION_DISPLAY_NAME));
} else if (Objects.nonNull(this.getSelectedCustomization()) && StringUtils.isNotBlank(this.getSelectedCustomization().getName())) {
PluginStore.putObject(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY, this.getSelectedCustomization());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not just store the ARN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Earlier I was just storing ARN only but I need to have name (or maybe description as well later) for showing notifications. So instead of creating 3 different getter/setter for all of these, I changed the implementation to just have a single setter/getter.

Comment on lines 84 to 86
synchronized (lock) {
activeNotifications.add(this);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Having a synchronized block here adds no value since the underlying call to add is thread safe since you're using a CopyOnWriteArrayList. It would make sense if you are trying to perform several operations together in an atomic unit of work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, I can actually remove the synchronized block. Thanks for this.

Comment on lines +38 to +40
String jsonValue = GSON.toJson(value);
byte[] byteValue = jsonValue.getBytes(StandardCharsets.UTF_8);
PREFERENCES.putByteArray(key, byteValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

While this technically can be done serializing entire objects does present additional risks. In general I would like to be convinced that use cases require it, vs. binding relational configuration under a common key namespace, e.g.:

notifications.foo: 123
notifications.bar: 456

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the same reason which I described here https://github.com/aws/amazon-q-eclipse/pull/48/files#r1787324480

Also, currently when LSP server requests for aws.q, we only return customization object but maybe in near future - we might be returning more than just one single row item. Then in those kindof cases, it would be better to just do a single lookup and return it.

@pras0131 pras0131 force-pushed the paras/triggerCustomizationNotificationsOnIDE branch from 6b587c6 to 013f639 Compare October 4, 2024 13:41
Base automatically changed from paras/fetchCustomizations to main October 4, 2024 22:25
@pras0131 pras0131 merged commit 7e8933a into main Oct 4, 2024
1 check passed
@pras0131 pras0131 deleted the paras/triggerCustomizationNotificationsOnIDE branch October 4, 2024 22:42
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.

2 participants