Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Paras committed Sep 30, 2024
1 parent cc0e02d commit f5a8163
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public final CompletableFuture<ConnectionMetadata> getConnectionMetadata() {
}

@Override
public CompletableFuture<List<Object>> configuration(ConfigurationParams configurationParams) {
if (configurationParams.getItems().size() == 0) return CompletableFuture.completedFuture(null);
public final CompletableFuture<List<Object>> configuration(final ConfigurationParams configurationParams) {
if (configurationParams.getItems().size() == 0) {
return CompletableFuture.completedFuture(null);
}
List<Object> output = new ArrayList<>();
configurationParams.getItems().forEach(item -> {
if (item.getSection().equals(Constants.LSP_CONFIGURATION_KEY)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package software.aws.toolkits.eclipse.amazonq.util;

public final class Constants {
private Constants() {
// to avoid initiation
}

private Constants() {
// to avoid initiation
}

public static final String CUSTOMIZATION_STORAGE_INTERNAL_KEY = "aws.q.customization.eclipse";
public static final String LSP_CUSTOMIZATION_CONFIGURATION_KEY = "customization";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ protected void createButtonsForButtonBar(final Composite parent) {
protected void okPressed() {
PluginLogger.info(String.format("Select pressed with responseSelection:%s and selectedArn:%s", this.responseSelection, this.selectedCustomisationArn));
if (this.responseSelection.equals(ResponseSelection.AMAZON_Q_FOUNDATION_DEFAULT)) {
PluginStore.remove(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY);
PluginStore.remove(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY);
} else {
PluginStore.put(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY, this.selectedCustomisationArn);
Map<String, Object> updatedSettings = new HashMap<>();
Map<String, String> internalMap = new HashMap<>();
internalMap.put(Constants.LSP_CUSTOMIZATION_CONFIGURATION_KEY, this.selectedCustomisationArn);
updatedSettings.put(Constants.LSP_CONFIGURATION_KEY, internalMap);
ThreadingUtils.executeAsyncTask( () -> CustomizationUtil.triggerChangeConfigurationNotification(updatedSettings));
PluginStore.put(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY, this.selectedCustomisationArn);
Map<String, Object> updatedSettings = new HashMap<>();
Map<String, String> internalMap = new HashMap<>();
internalMap.put(Constants.LSP_CUSTOMIZATION_CONFIGURATION_KEY, this.selectedCustomisationArn);
updatedSettings.put(Constants.LSP_CONFIGURATION_KEY, internalMap);
ThreadingUtils.executeAsyncTask(() -> CustomizationUtil.triggerChangeConfigurationNotification(updatedSettings));
}
super.okPressed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public void fill(final Menu menu, final int index) {
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
CustomizationDialog dialog = new CustomizationDialog(shell);
// TODO: This mock will be replaced by an actual call to LSP
dialog.setCustomisationResponse(getCustomizations());
String storedCustomizationArn = PluginStore.get(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY);
if (StringUtils.isBlank(storedCustomizationArn)) {
dialog.setResponseSelection(ResponseSelection.AMAZON_Q_FOUNDATION_DEFAULT);
dialog.setSelectedCustomizationArn(null);
} else {
dialog.setResponseSelection(ResponseSelection.CUSTOMIZATION);
dialog.setSelectedCustomizationArn(storedCustomizationArn);
}
CustomizationDialog dialog = new CustomizationDialog(shell);
// TODO: This mock will be replaced by an actual call to LSP
dialog.setCustomisationResponse(getCustomizations());
String storedCustomizationArn = PluginStore.get(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY);
if (StringUtils.isBlank(storedCustomizationArn)) {
dialog.setResponseSelection(ResponseSelection.AMAZON_Q_FOUNDATION_DEFAULT);
dialog.setSelectedCustomizationArn(null);
} else {
dialog.setResponseSelection(ResponseSelection.CUSTOMIZATION);
dialog.setSelectedCustomizationArn(storedCustomizationArn);
}
dialog.open();
}
});
Expand Down

0 comments on commit f5a8163

Please sign in to comment.