From ceaa511662cf68fdbe47022dadcade66a234b730 Mon Sep 17 00:00:00 2001 From: Jonathan Breedlove Date: Fri, 13 Sep 2024 16:08:47 -0700 Subject: [PATCH 1/4] Pass client information to LSPs --- plugin/META-INF/MANIFEST.MF | 6 +-- plugin/plugin.xml | 4 +- .../amazonq/lsp/AmazonQLspServerBuilder.java | 17 ++++++ .../lsp/AuthLspConnectionProvider.java | 41 -------------- .../amazonq/lsp/LspConnectionProvider.java | 54 ------------------- .../AbstractLspConnectionProvider.java | 32 +++++++++++ .../connection/AuthLspConnectionProvider.java | 33 ++++++++++++ .../connection/QLspConnectionProvider.java | 34 ++++++++++++ .../amazonq/providers/LspManagerProvider.java | 39 ++++++++++++++ .../eclipse/amazonq/util/PluginUtils.java | 3 ++ 10 files changed, 163 insertions(+), 100 deletions(-) delete mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AuthLspConnectionProvider.java delete mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/LspConnectionProvider.java create mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AbstractLspConnectionProvider.java create mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java create mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java create mode 100644 plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java diff --git a/plugin/META-INF/MANIFEST.MF b/plugin/META-INF/MANIFEST.MF index bfc3c671..4167807c 100644 --- a/plugin/META-INF/MANIFEST.MF +++ b/plugin/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: aws-plugin-q +Bundle-Name: amazon-q-eclipse Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-SymbolicName: aws-plugin-q;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: amazon-q-eclipse;singleton:=true +Bundle-Version: 0.0.1.snapshot Automatic-Module-Name: aws.plugin.q Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;bundle-version="3.31.0", diff --git a/plugin/plugin.xml b/plugin/plugin.xml index e48a04b0..b70b918d 100644 --- a/plugin/plugin.xml +++ b/plugin/plugin.xml @@ -40,7 +40,7 @@ { @@ -18,4 +24,15 @@ public final Launcher create() { return launcher; } + @Override + protected MessageConsumer wrapMessageConsumer(MessageConsumer consumer) { + return super.wrapMessageConsumer((Message message) -> { + if (message instanceof RequestMessage && ((RequestMessage) message).getMethod().equals("initialize")) { + InitializeParams initParams = (InitializeParams) ((RequestMessage) message).getParams(); + initParams.setClientInfo(new ClientInfo(PluginUtils.PLUGIN_NAME, PluginUtils.PLUGIN_VERSION)); + } + consumer.consume(message); + }); + } + } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AuthLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AuthLspConnectionProvider.java deleted file mode 100644 index 24ab36f8..00000000 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AuthLspConnectionProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.eclipse.amazonq.lsp; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; -import org.eclipse.lsp4e.server.StreamConnectionProvider; - -import software.aws.toolkits.eclipse.amazonq.util.PluginUtils; - -public class AuthLspConnectionProvider extends ProcessStreamConnectionProvider implements StreamConnectionProvider { - - public AuthLspConnectionProvider() throws IOException { - setWorkingDirectory(System.getProperty("user.dir")); - var authJs = PluginUtils.getResource("auth/packages/server/dist/index.js"); - - List commands = new ArrayList<>(); - commands.add("/opt/homebrew/bin/node"); //TODO: don't hardcode - this should be bundled and platform specific - commands.add(authJs.getPath()); - commands.add("--nolazy"); - commands.add("--inspect=5599"); - commands.add("--stdio"); - setCommands(commands); - } - - @Override - protected final ProcessBuilder createProcessBuilder() { - final var builder = new ProcessBuilder(getCommands()); - if (getWorkingDirectory() != null) { - builder.directory(new File(getWorkingDirectory())); - } - builder.redirectError(ProcessBuilder.Redirect.INHERIT); - return builder; - } - -} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/LspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/LspConnectionProvider.java deleted file mode 100644 index fe2b292f..00000000 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/LspConnectionProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.eclipse.amazonq.lsp; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; -import org.eclipse.lsp4e.server.StreamConnectionProvider; - -import software.aws.toolkits.eclipse.amazonq.lsp.manager.DefaultLspManager; -import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspConstants; -import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspManager; -import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.RemoteManifestLspFetcher; - -public class LspConnectionProvider extends ProcessStreamConnectionProvider implements StreamConnectionProvider { - - public LspConnectionProvider() throws IOException { - setWorkingDirectory(System.getProperty("user.dir")); - - LspManager lspManager = DefaultLspManager.builder() - .withLspExecutablePrefix(LspConstants.CW_LSP_FILENAME) - .withFetcher(RemoteManifestLspFetcher.builder() - .withManifestUrl(LspConstants.CW_MANIFEST_URL) - .build()) - .build(); - - var cwLspInstallation = lspManager.getLspInstallation(); - List commands = new ArrayList<>(); - commands.add(cwLspInstallation.nodeExecutable().toString()); - commands.add(cwLspInstallation.lspJs().toString()); - commands.add("--nolazy"); - commands.add("--inspect=5599"); - commands.add("--stdio"); - setCommands(commands); - } - - @Override - protected final ProcessBuilder createProcessBuilder() { - final var builder = new ProcessBuilder(getCommands()); - if (getWorkingDirectory() != null) { - builder.directory(new File(getWorkingDirectory())); - } - builder.redirectError(ProcessBuilder.Redirect.INHERIT); - Map env = builder.environment(); - env.put("ENABLE_INLINE_COMPLETION", "true"); - env.put("ENABLE_TOKEN_PROVIDER", "true"); - return builder; - } -} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AbstractLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AbstractLspConnectionProvider.java new file mode 100644 index 00000000..a1126ee3 --- /dev/null +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AbstractLspConnectionProvider.java @@ -0,0 +1,32 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.eclipse.amazonq.lsp.connection; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; +import org.eclipse.lsp4e.server.StreamConnectionProvider; + +public abstract class AbstractLspConnectionProvider extends ProcessStreamConnectionProvider implements StreamConnectionProvider { + + protected AbstractLspConnectionProvider() throws IOException { + setWorkingDirectory(System.getProperty("user.dir")); + } + + @Override + protected final ProcessBuilder createProcessBuilder() { + final var builder = new ProcessBuilder(getCommands()); + if (getWorkingDirectory() != null) { + builder.directory(new File(getWorkingDirectory())); + } + builder.redirectError(ProcessBuilder.Redirect.INHERIT); + addEnvironmentVariables(builder.environment()); + return builder; + } + + protected abstract void addEnvironmentVariables(Map env); + +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java new file mode 100644 index 00000000..55cd1b2c --- /dev/null +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java @@ -0,0 +1,33 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.eclipse.amazonq.lsp.connection; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import software.aws.toolkits.eclipse.amazonq.providers.LspManagerProvider; +import software.aws.toolkits.eclipse.amazonq.util.PluginUtils; + +public class AuthLspConnectionProvider extends AbstractLspConnectionProvider { + + public AuthLspConnectionProvider() throws IOException { + super(); + var authJs = PluginUtils.getResource("auth/packages/server/dist/index.js"); + var lspManager = LspManagerProvider.getInstance(); + + List commands = new ArrayList<>(); + commands.add(lspManager.getLspInstallation().nodeExecutable().toString()); + commands.add(authJs.getPath()); + commands.add("--nolazy"); + commands.add("--inspect=5599"); + commands.add("--stdio"); + setCommands(commands); + } + + @Override + protected void addEnvironmentVariables(Map env) { } + +} \ No newline at end of file diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java new file mode 100644 index 00000000..dbaed921 --- /dev/null +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java @@ -0,0 +1,34 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.eclipse.amazonq.lsp.connection; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspManager; +import software.aws.toolkits.eclipse.amazonq.providers.LspManagerProvider; + +public class QLspConnectionProvider extends AbstractLspConnectionProvider { + + public QLspConnectionProvider() throws IOException { + super(); + LspManager lspManager = LspManagerProvider.getInstance(); + List commands = new ArrayList<>(); + commands.add(lspManager.getLspInstallation().nodeExecutable().toString()); + commands.add(lspManager.getLspInstallation().lspJs().toString()); + commands.add("--nolazy"); + commands.add("--inspect=5599"); + commands.add("--stdio"); + setCommands(commands); + } + + @Override + protected void addEnvironmentVariables(Map env) { + env.put("ENABLE_INLINE_COMPLETION", "true"); + env.put("ENABLE_TOKEN_PROVIDER", "true"); + } + +} \ No newline at end of file diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java new file mode 100644 index 00000000..e65c6f23 --- /dev/null +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java @@ -0,0 +1,39 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.eclipse.amazonq.providers; + +import software.aws.toolkits.eclipse.amazonq.lsp.manager.DefaultLspManager; +import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspConstants; +import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspManager; +import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.RemoteManifestLspFetcher; + +public class LspManagerProvider { + + private LspManagerProvider() { + // prevent instantiation + } + + private static LspManager instance; + + public static LspManager getInstance() { + if (instance == null) { + synchronized (LspManagerProvider.class) { + if (instance == null) { + instance = createLspManager(); + } + } + } + return instance; + } + + private static LspManager createLspManager() { + return DefaultLspManager.builder() + .withLspExecutablePrefix(LspConstants.CW_LSP_FILENAME) + .withFetcher(RemoteManifestLspFetcher.builder() + .withManifestUrl(LspConstants.CW_MANIFEST_URL) + .build()) + .build(); + } + +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java index c2a9a54d..424cbc3a 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java @@ -27,6 +27,9 @@ private PluginUtils() { private static Image qIcon = null; + public static final String PLUGIN_NAME = FrameworkUtil.getBundle(PluginUtils.class).getSymbolicName(); + public static final String PLUGIN_VERSION = FrameworkUtil.getBundle(PluginUtils.class).getVersion().toString(); + public static java.nio.file.Path getPluginDir(final String directoryName) { Bundle bundle = FrameworkUtil.getBundle(PluginUtils.class); File pluginDir = bundle.getDataFile(directoryName); From 9319332981df387cc423fd27ae5c04be1702cbe5 Mon Sep 17 00:00:00 2001 From: Jonathan Breedlove Date: Fri, 13 Sep 2024 17:02:40 -0700 Subject: [PATCH 2/4] Checkstyle fixes --- feature/feature.xml | 4 +- feature/pom.xml | 6 +- plugin/.checkstyle | 7 + plugin/META-INF/MANIFEST.MF | 6 +- plugin/pom.xml | 4 +- .../amazonq/lsp/AmazonQLspServerBuilder.java | 6 +- .../connection/AuthLspConnectionProvider.java | 4 +- .../connection/QLspConnectionProvider.java | 4 +- .../amazonq/providers/LspManagerProvider.java | 2 +- .../eclipse/amazonq/util/ClientMetadata.java | 37 +- .../amazonq/util/InlineCompletionUtils.java | 4 +- .../eclipse/amazonq/util/PluginUtils.java | 7 +- .../views/AmazonQChatViewActionHandler.java | 4 +- .../amazonq/views/AmazonQChatWebview.java | 5 +- .../amazonq/views/DialogContributionItem.java | 8 +- .../eclipse/amazonq/views/FeedbackDialog.java | 316 ++++++++---------- .../amazonq/views/ToolkitLoginWebview.java | 6 +- .../eclipse/amazonq/views/model/Command.java | 14 +- .../amazonq/views/model/CommandRequest.java | 11 +- .../amazonq/views/model/ParsedCommand.java | 22 +- pom.xml | 4 +- updatesite/category.xml | 2 +- updatesite/pom.xml | 6 +- 23 files changed, 239 insertions(+), 250 deletions(-) create mode 100644 plugin/.checkstyle diff --git a/feature/feature.xml b/feature/feature.xml index d342234e..8b6946be 100644 --- a/feature/feature.xml +++ b/feature/feature.xml @@ -1,6 +1,6 @@ @@ -13,7 +13,7 @@ software.aws.toolkits.eclipse - aws-plugin-q-group + amazon-q-eclipse-group 1.0.0-SNAPSHOT ../ software.aws.toolkits.eclipse - aws-plugin-q-feature + amazon-q-eclipse-feature 1.0.0-SNAPSHOT eclipse-feature - \ No newline at end of file + diff --git a/plugin/.checkstyle b/plugin/.checkstyle new file mode 100644 index 00000000..103805d6 --- /dev/null +++ b/plugin/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugin/META-INF/MANIFEST.MF b/plugin/META-INF/MANIFEST.MF index 4167807c..b615381c 100644 --- a/plugin/META-INF/MANIFEST.MF +++ b/plugin/META-INF/MANIFEST.MF @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: amazon-q-eclipse Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-SymbolicName: amazon-q-eclipse;singleton:=true -Bundle-Version: 0.0.1.snapshot -Automatic-Module-Name: aws.plugin.q +Bundle-Version: 1.0.0.qualifier +Automatic-Module-Name: amazon.q.eclipse Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;bundle-version="3.31.0", org.eclipse.ui;bundle-version="3.205.100", @@ -42,9 +42,7 @@ Bundle-Classpath: ., target/dependency/j2objc-annotations-3.0.0.jar, target/dependency/jackson-annotations-2.17.1.jar, target/dependency/jackson-core-2.17.1.jar, - target/dependency/jackson-core-2.17.2.jar, target/dependency/jackson-databind-2.17.1.jar, - target/dependency/jackson-databind-2.17.2.jar, target/dependency/jakarta.annotation-api-2.1.1.jar, target/dependency/jakarta.inject-api-2.0.1.jar, target/dependency/jna-5.14.0.jar, diff --git a/plugin/pom.xml b/plugin/pom.xml index 7262b1fa..f223ea18 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -5,13 +5,13 @@ 4.0.0 software.aws.toolkits.eclipse - aws-plugin-q-group + amazon-q-eclipse-group 1.0.0-SNAPSHOT ../ software.aws.toolkits.eclipse - aws-plugin-q + amazon-q-eclipse 1.0.0-SNAPSHOT eclipse-plugin diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AmazonQLspServerBuilder.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AmazonQLspServerBuilder.java index 48fefb92..bd2685df 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AmazonQLspServerBuilder.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AmazonQLspServerBuilder.java @@ -12,7 +12,7 @@ import org.eclipse.lsp4j.jsonrpc.messages.RequestMessage; import software.aws.toolkits.eclipse.amazonq.providers.LspProvider; -import software.aws.toolkits.eclipse.amazonq.util.PluginUtils; +import software.aws.toolkits.eclipse.amazonq.util.ClientMetadata; public class AmazonQLspServerBuilder extends Builder { @@ -25,11 +25,11 @@ public final Launcher create() { } @Override - protected MessageConsumer wrapMessageConsumer(MessageConsumer consumer) { + protected final MessageConsumer wrapMessageConsumer(final MessageConsumer consumer) { return super.wrapMessageConsumer((Message message) -> { if (message instanceof RequestMessage && ((RequestMessage) message).getMethod().equals("initialize")) { InitializeParams initParams = (InitializeParams) ((RequestMessage) message).getParams(); - initParams.setClientInfo(new ClientInfo(PluginUtils.PLUGIN_NAME, PluginUtils.PLUGIN_VERSION)); + initParams.setClientInfo(new ClientInfo(ClientMetadata.getPluginName(), ClientMetadata.getPluginVersion())); } consumer.consume(message); }); diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java index 55cd1b2c..da69f3ce 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/AuthLspConnectionProvider.java @@ -28,6 +28,6 @@ public AuthLspConnectionProvider() throws IOException { } @Override - protected void addEnvironmentVariables(Map env) { } + protected void addEnvironmentVariables(final Map env) { } -} \ No newline at end of file +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java index dbaed921..6bea5326 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/connection/QLspConnectionProvider.java @@ -26,9 +26,9 @@ public QLspConnectionProvider() throws IOException { } @Override - protected void addEnvironmentVariables(Map env) { + protected final void addEnvironmentVariables(final Map env) { env.put("ENABLE_INLINE_COMPLETION", "true"); env.put("ENABLE_TOKEN_PROVIDER", "true"); } -} \ No newline at end of file +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java index e65c6f23..11762011 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/providers/LspManagerProvider.java @@ -8,7 +8,7 @@ import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspManager; import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.RemoteManifestLspFetcher; -public class LspManagerProvider { +public final class LspManagerProvider { private LspManagerProvider() { // prevent instantiation diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/ClientMetadata.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/ClientMetadata.java index 75842af2..cd45db61 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/ClientMetadata.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/ClientMetadata.java @@ -4,30 +4,41 @@ package software.aws.toolkits.eclipse.amazonq.util; import org.eclipse.core.runtime.Platform; +import org.osgi.framework.FrameworkUtil; public final class ClientMetadata { private ClientMetadata() { // Prevent instantiation } - - private static final String osName = System.getProperty("os.name"); - private static final String osVersion = System.getProperty("os.version"); - private static final String ideName = Platform.getProduct().getName(); - private static final String ideVersion = Platform.getProduct().getDefiningBundle().getVersion().toString(); - + + private static final String OS_NAME = System.getProperty("os.name"); + private static final String OS_VERSION = System.getProperty("os.version"); + private static final String IDE_NAME = Platform.getProduct().getName(); + private static final String IDE_VERSION = Platform.getProduct().getDefiningBundle().getVersion().toString(); + public static final String PLUGIN_NAME = FrameworkUtil.getBundle(ClientMetadata.class).getSymbolicName(); + public static final String PLUGIN_VERSION = FrameworkUtil.getBundle(ClientMetadata.class).getVersion().toString(); + public static String getOSName() { - return osName; + return OS_NAME; } - + public static String getOSVersion() { - return osVersion; + return OS_VERSION; } - + public static String getIdeName() { - return ideName; + return IDE_NAME; } - + public static String getIdeVersion() { - return ideVersion; + return IDE_VERSION; + } + + public static String getPluginName() { + return PLUGIN_NAME; + } + + public static String getPluginVersion() { + return PLUGIN_VERSION; } } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/InlineCompletionUtils.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/InlineCompletionUtils.java index 0dcef4d6..f28d86e6 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/InlineCompletionUtils.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/InlineCompletionUtils.java @@ -47,8 +47,8 @@ public static InlineCompletionParams cwParamsFromContext(final ITextEditor edito params.setPosition(invocationPosition); return params; } - - private static String getOpenFilePath(IEditorInput editorInput) { + + private static String getOpenFilePath(final IEditorInput editorInput) { if (editorInput instanceof FileStoreEditorInput fileStoreEditorInput) { return fileStoreEditorInput.getURI().getPath(); } else if (editorInput instanceof IFileEditorInput fileEditorInput) { diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java index 424cbc3a..ce88142d 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/PluginUtils.java @@ -27,9 +27,6 @@ private PluginUtils() { private static Image qIcon = null; - public static final String PLUGIN_NAME = FrameworkUtil.getBundle(PluginUtils.class).getSymbolicName(); - public static final String PLUGIN_VERSION = FrameworkUtil.getBundle(PluginUtils.class).getVersion().toString(); - public static java.nio.file.Path getPluginDir(final String directoryName) { Bundle bundle = FrameworkUtil.getBundle(PluginUtils.class); File pluginDir = bundle.getDataFile(directoryName); @@ -93,8 +90,8 @@ public static PluginArchitecture getArchitecture() { throw new AmazonQPluginException("Detected unsupported architecture: " + osArch); } } - - public static void openWebpage(String url) { + + public static void openWebpage(final String url) { try { PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(url)); } catch (Exception ex) { diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatViewActionHandler.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatViewActionHandler.java index ce3dda31..9c31c98b 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatViewActionHandler.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatViewActionHandler.java @@ -11,7 +11,7 @@ public class AmazonQChatViewActionHandler implements ViewActionHandler { @Override - public final void handleCommand(ParsedCommand parsedCommand, final Browser browser) { + public final void handleCommand(final ParsedCommand parsedCommand, final Browser browser) { switch (parsedCommand.getCommand()) { case CHAT_READY: PluginLogger.info("Chat_ready command received"); @@ -20,7 +20,7 @@ public final void handleCommand(ParsedCommand parsedCommand, final Browser brows PluginLogger.info("Chat_tab_add command received with params " + parsedCommand.getParams().toString()); break; case TELEMETRY_EVENT: - PluginLogger.info("Telemetry command received with params " + parsedCommand.getParams().toString()); + PluginLogger.info("Telemetry command received with params " + parsedCommand.getParams().toString()); break; default: PluginLogger.info("Unhandled command: " + parsedCommand.getCommand()); 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 4e10ddbc..6347aff0 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java @@ -72,7 +72,6 @@ public Object function(final Object[] arguments) { return null; } }; - } private void contributeToActionBars(final IViewSite viewSite) { @@ -172,8 +171,8 @@ private String generateJS(final String jsEntrypoint) { + " amazonQChat.createChat({\n" + " postMessage: (message) => {\n" + " ideCommand(JSON.stringify(message));\n" - + " }\n" - + " });\n" + + " }\n" + + " });\n" + " }\n" + " ", jsEntrypoint); } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/DialogContributionItem.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/DialogContributionItem.java index c9c78687..8ae0f20b 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/DialogContributionItem.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/DialogContributionItem.java @@ -17,22 +17,22 @@ public class DialogContributionItem extends ContributionItem { private String menuItemName; private Image icon; - public DialogContributionItem(Dialog dialog, String menuItemName, Image icon) { + public DialogContributionItem(final Dialog dialog, final String menuItemName, final Image icon) { this.dialog = dialog; this.menuItemName = menuItemName; this.icon = icon; } @Override - public void fill(Menu menu, int index) { + public final void fill(final Menu menu, final int index) { MenuItem menuItem = new MenuItem(menu, SWT.NONE, index); menuItem.setText(this.menuItemName); menuItem.setImage(this.icon); menuItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected(final SelectionEvent e) { dialog.open(); } }); } -} \ No newline at end of file +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java index 9257d564..0fdda025 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java @@ -32,27 +32,27 @@ import software.aws.toolkits.eclipse.amazonq.util.PluginUtils; public class FeedbackDialog extends Dialog { - - private static final String title = "Share Feedback"; - private static final int maxCharLimit = 2000; + + private static final String TITLE = "Share Feedback"; + private static final int MAX_CHAR_LIMIT = 2000; private Composite container; private Text commentBox; private Font magnifiedFont; private Image loadedImage; private Label characterRemainingLabel; private Sentiment selectedSentiment = Sentiment.POSITIVE; - + public class CustomRadioButton extends Composite { private Label iconLabel; private Label textLabel; private Button radioButton; - public CustomRadioButton(Composite parent, Image image, String text, int style) { + public CustomRadioButton(final Composite parent, final Image image, final String text, final int style) { super(parent, style); - + Composite contentComposite = new Composite(parent, SWT.NONE); contentComposite.setLayout(new GridLayout(1, false)); - + iconLabel = new Label(contentComposite, SWT.NONE); iconLabel.setImage(image); iconLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); @@ -65,21 +65,21 @@ public CustomRadioButton(Composite parent, Image image, String text, int style) radioButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); } - public Button getRadioButton() { + public final Button getRadioButton() { return radioButton; } } - + enum Sentiment { POSITIVE, NEGATIVE } - - public FeedbackDialog(Shell parentShell) { + + public FeedbackDialog(final Shell parentShell) { super(parentShell); } - - private Image loadImage(String imagePath) { + + private Image loadImage(final String imagePath) { Image loadedImage = null; try { URL imageUrl = PluginUtils.getResource(imagePath); @@ -93,23 +93,23 @@ private Image loadImage(String imagePath) { } return loadedImage; } - + @Override - protected void createButtonsForButtonBar(Composite parent) { + protected final void createButtonsForButtonBar(final Composite parent) { createButton(parent, IDialogConstants.OK_ID, "Share", true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } - + @Override - protected void okPressed() { + protected final void okPressed() { Sentiment selectedSentiment = this.selectedSentiment; String comment = commentBox.getText(); // TODO: to remove the info log post call to telemetry feedback api implementation PluginLogger.info(String.format("Selected sentiment: %s and comment: %s", selectedSentiment.toString(), comment)); super.okPressed(); } - - private Font magnifyFontSize(Font originalFont, int fontSize) { + + private Font magnifyFontSize(final Font originalFont, final int fontSize) { FontData[] fontData = originalFont.getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(fontSize); @@ -122,218 +122,196 @@ private Font magnifyFontSize(Font originalFont, int fontSize) { this.magnifiedFont = magnifiedFont; return magnifiedFont; } - - private void handleTextModified(ModifyEvent event) { + + private void handleTextModified(final ModifyEvent event) { Text text = (Text) event.widget; - if(text.getText().length() > maxCharLimit) { - text.setText(text.getText().substring(0, maxCharLimit)); - text.setSelection(maxCharLimit); // Move the caret to the end of the text + if (text.getText().length() > MAX_CHAR_LIMIT) { + text.setText(text.getText().substring(0, MAX_CHAR_LIMIT)); + text.setSelection(MAX_CHAR_LIMIT); // Move the caret to the end of the text } updateCharacterRemainingCount(); } @Override - protected Control createDialogArea(Composite parent) { + protected final Control createDialogArea(final Composite parent) { container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); - + + createHeaderSection(container); + createJoinUsOnGithubSection(container); + createReportRequestContributeSection(container); + createShareFeedbackSection(container); + createQuestionSection(container); + + return container; + } + + private void createHeaderSection(final Composite container) { Composite headlineContainer = new Composite(container, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.spacing = 0; // to reduce space between two labels headlineContainer.setLayout(rowLayout); - Label lookingForHelpLabel = new Label(headlineContainer, SWT.NONE); - lookingForHelpLabel.setText("Looking for help? View the"); - lookingForHelpLabel.setFont(magnifyFontSize(lookingForHelpLabel.getFont(), 14)); - - Label gettingStartedReferenceLabel = new Label(headlineContainer, SWT.NONE); - gettingStartedReferenceLabel.setText("Getting Started Guide"); - gettingStartedReferenceLabel.setFont(magnifyFontSize(gettingStartedReferenceLabel.getFont(), 14)); - gettingStartedReferenceLabel.setForeground(headlineContainer.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - gettingStartedReferenceLabel.setCursor(headlineContainer.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); - gettingStartedReferenceLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - PluginUtils.openWebpage("https://aws.amazon.com/q/getting-started/"); - } - }); - - Label orSearchOurTextLabel = new Label(headlineContainer, SWT.NONE); - orSearchOurTextLabel.setText("or search our"); - orSearchOurTextLabel.setFont(magnifyFontSize(orSearchOurTextLabel.getFont(), 14)); - - Label documentationReferenceLabel = new Label(headlineContainer, SWT.NONE); - documentationReferenceLabel.setText("Documentation"); - documentationReferenceLabel.setFont(magnifyFontSize(documentationReferenceLabel.getFont(), 14)); - documentationReferenceLabel.setForeground(headlineContainer.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - documentationReferenceLabel.setCursor(headlineContainer.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); - documentationReferenceLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - PluginUtils.openWebpage("https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/what-is.html"); - } - }); - + + createLabelWithFontSize(headlineContainer, "Looking for help? View the", 14); + createLinkLabel(headlineContainer, "Getting Started Guide", 14, "https://aws.amazon.com/q/getting-started/"); + createLabelWithFontSize(headlineContainer, "or search our", 14); + createLinkLabel(headlineContainer, "Documentation", 14, "https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/what-is.html"); + } + + private void createJoinUsOnGithubSection(final Composite container) { Composite joinUsOnGithubContainer = new Composite(container, SWT.NONE); GridLayout joinUsOnGithubLayout = new GridLayout(2, false); joinUsOnGithubLayout.horizontalSpacing = 5; joinUsOnGithubContainer.setLayout(joinUsOnGithubLayout); joinUsOnGithubContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - Label joinUsGithubLabel = new Label(joinUsOnGithubContainer, SWT.NONE); - joinUsGithubLabel.setText("Join us on GitHub"); - GridData joinGithubLayout = new GridData(SWT.FILL, SWT.CENTER, false, false); - joinUsGithubLabel.setLayoutData(joinGithubLayout); - joinUsGithubLabel.setFont(magnifyFontSize(joinUsGithubLabel.getFont(), 14)); - - Label separatorLabel = new Label(joinUsOnGithubContainer, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData separatorGithubLayout = new GridData(SWT.FILL, SWT.CENTER, true, false); - separatorLabel.setLayoutData(separatorGithubLayout); + createLabelWithFontSize(joinUsOnGithubContainer, "Join us on GitHub", 14); + createSeparator(joinUsOnGithubContainer); + } + + private void createReportRequestContributeSection(final Composite container) { Composite reportRequestContributeContainer = new Composite(container, SWT.NONE); GridLayout reportRequestContributeContainerLayout = new GridLayout(2, false); reportRequestContributeContainerLayout.horizontalSpacing = 10; reportRequestContributeContainerLayout.marginLeft = 10; reportRequestContributeContainer.setLayout(reportRequestContributeContainerLayout); - - Label reportIssueImageLabel = new Label(reportRequestContributeContainer, SWT.NONE); - reportIssueImageLabel.setImage(loadImage("icons/ReportAnIssue.png")); - - String bodyMessageForReportIssueOrRequestFeature = String.format( - "--- \n" - + "Toolkit: Amazon Q for %s\n" - + "OS: %s %s\n" - + "IDE: %s %s", ClientMetadata.getIdeName(), ClientMetadata.getOSName(), - ClientMetadata.getOSVersion(), ClientMetadata.getIdeName(), - ClientMetadata.getIdeVersion()).stripIndent(); - - Label reportIssue = new Label(reportRequestContributeContainer, SWT.NONE); - reportIssue.setText("Report an issue"); - reportIssue.setForeground(reportRequestContributeContainer.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - reportIssue.setCursor(reportRequestContributeContainer.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); - reportIssue.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - PluginUtils.openWebpage(String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s", bodyMessageForReportIssueOrRequestFeature)); - } - }); - - Label requestFeatureImageLabel = new Label(reportRequestContributeContainer, SWT.NONE); - requestFeatureImageLabel.setImage(loadImage("icons/RequestFeature.png")); - - Label requestFeature = new Label(reportRequestContributeContainer, SWT.NONE); - requestFeature.setText("Request a feature"); - requestFeature.setForeground(reportRequestContributeContainer.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - requestFeature.setCursor(reportRequestContributeContainer.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); - requestFeature.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - PluginUtils.openWebpage(String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s", bodyMessageForReportIssueOrRequestFeature)); - } - }); - - Label viewSourceCodeLabel = new Label(reportRequestContributeContainer, SWT.NONE); - viewSourceCodeLabel.setImage(loadImage("icons/ViewCode.png")); - - Label viewSourceCode = new Label(reportRequestContributeContainer, SWT.NONE); - viewSourceCode.setText("View source code and contribute"); - viewSourceCode.setForeground(reportRequestContributeContainer.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - viewSourceCode.setCursor(reportRequestContributeContainer.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); - viewSourceCode.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - PluginUtils.openWebpage("https://github.com/aws/amazon-q-eclipse/"); - } - }); - + + createImageLabel(reportRequestContributeContainer, "icons/ReportAnIssue.png"); + createLinkLabel(reportRequestContributeContainer, "Report an issue", SWT.NONE, + String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s", getBodyMessageForReportIssueOrRequestFeature())); + + createImageLabel(reportRequestContributeContainer, "icons/RequestFeature.png"); + createLinkLabel(reportRequestContributeContainer, "Request a feature", SWT.NONE, + String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s", getBodyMessageForReportIssueOrRequestFeature())); + + createImageLabel(reportRequestContributeContainer, "icons/ViewCode.png"); + createLinkLabel(reportRequestContributeContainer, "View source code and contribute", SWT.NONE, "https://github.com/aws/amazon-q-eclipse/"); + } + + private void createShareFeedbackSection(final Composite container) { Composite shareFeedbackTextContainer = new Composite(container, SWT.NONE); GridLayout shareFeedbackTextContainerLayout = new GridLayout(2, false); shareFeedbackTextContainerLayout.horizontalSpacing = 5; shareFeedbackTextContainer.setLayout(shareFeedbackTextContainerLayout); shareFeedbackTextContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - Label shareFeedbackLabel = new Label(shareFeedbackTextContainer, SWT.NONE); - shareFeedbackLabel.setText("Share feedback"); - shareFeedbackLabel.setFont(magnifyFontSize(shareFeedbackLabel.getFont(), 14)); - shareFeedbackLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - - Label separatorForShareFeedbackLabel = new Label(shareFeedbackTextContainer, SWT.SEPARATOR | SWT.HORIZONTAL); - separatorForShareFeedbackLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + + createLabelWithFontSize(shareFeedbackTextContainer, "Share feedback", 14); + createSeparator(shareFeedbackTextContainer); + } + + private void createQuestionSection(final Composite container) { Composite questionsContainer = new Composite(container, SWT.NONE); GridLayout questionsContainerLayout = new GridLayout(1, false); questionsContainerLayout.marginLeft = 10; questionsContainer.setLayout(questionsContainerLayout); GridData questionsContainerLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); questionsContainer.setLayoutData(questionsContainerLayoutData); - - Label ratingQuestionLabel = new Label(questionsContainer, SWT.NONE); - ratingQuestionLabel.setText("How satisified are you with the AWS Toolkit?"); - + + createLabel(questionsContainer, "How satisified are you with the AWS Toolkit?"); + Composite sentimentContainer = new Composite(questionsContainer, SWT.NONE); RowLayout sentimentContainerLayout = new RowLayout(SWT.HORIZONTAL); sentimentContainerLayout.spacing = 0; sentimentContainer.setLayout(sentimentContainerLayout); - CustomRadioButton happySentimentButton = new CustomRadioButton(sentimentContainer, loadImage("icons/HappyFace.png"), "Satisfied", SWT.NONE); - happySentimentButton.getRadioButton().setSelection(true); - CustomRadioButton frownSentimentButton = new CustomRadioButton(sentimentContainer, loadImage("icons/FrownyFace.png"), "Unsatisfied", SWT.NONE); - happySentimentButton.getRadioButton().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - frownSentimentButton.getRadioButton().setSelection(false); - selectedSentiment = Sentiment.POSITIVE; - } - }); - frownSentimentButton.getRadioButton().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - happySentimentButton.getRadioButton().setSelection(false); - selectedSentiment = Sentiment.NEGATIVE; - } - }); - - Label feedbackQuestionLabel = new Label(questionsContainer, SWT.NONE); - feedbackQuestionLabel.setText("What do you like about the AWS Toolkit? What can we improve?"); - - + createCustomRadioButton(sentimentContainer, "icons/HappyFace.png", "Satisfied", SWT.NONE, true); + createCustomRadioButton(sentimentContainer, "icons/FrownyFace.png", "Unsatisfied", SWT.NONE, false); + + createLabel(questionsContainer, "What do you like about the AWS Toolkit? What can we improve?"); + commentBox = new Text(questionsContainer, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); GridData commentBoxLayout = new GridData(SWT.FILL, SWT.FILL, true, true); commentBoxLayout.heightHint = 200; commentBoxLayout.widthHint = 0; commentBox.setLayoutData(commentBoxLayout); commentBox.addModifyListener(this::handleTextModified); - + characterRemainingLabel = new Label(questionsContainer, SWT.NONE); characterRemainingLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); updateCharacterRemainingCount(); - - return container; } - + + private void createLabel(final Composite parent, final String text) { + Label label = new Label(parent, SWT.NONE); + label.setText(text); + } + + private void createLabelWithFontSize(final Composite parent, final String text, final int fontSize) { + Label label = new Label(parent, SWT.NONE); + label.setText(text); + label.setFont(magnifyFontSize(label.getFont(), fontSize)); + } + + private void createLinkLabel(final Composite parent, final String text, final int fontSize, final String url) { + Label label = new Label(parent, SWT.NONE); + label.setText(text); + label.setFont(magnifyFontSize(label.getFont(), fontSize)); + label.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); + label.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); + label.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(final MouseEvent e) { + PluginUtils.openWebpage(url); + } + }); + } + + private void createImageLabel(final Composite parent, final String imagePath) { + Label label = new Label(parent, SWT.NONE); + label.setImage(loadImage(imagePath)); + } + + private void createSeparator(final Composite parent) { + Label separatorLabel = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); + GridData separatorGithubLayout = new GridData(SWT.FILL, SWT.CENTER, true, false); + separatorLabel.setLayoutData(separatorGithubLayout); + } + + private void createCustomRadioButton(final Composite parent, final String imagePath, final String text, final int style, final boolean isSelected) { + CustomRadioButton button = new CustomRadioButton(parent, loadImage(imagePath), text, style); + button.getRadioButton().setSelection(isSelected); + button.getRadioButton().addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + // Handle button selection + } + }); + } + + private String getBodyMessageForReportIssueOrRequestFeature() { + return String.format( + "--- \n" + + "Toolkit: Amazon Q for %s\n" + + "OS: %s %s\n" + + "IDE: %s %s", ClientMetadata.getIdeName(), ClientMetadata.getOSName(), + ClientMetadata.getOSVersion(), ClientMetadata.getIdeName(), + ClientMetadata.getIdeVersion()).stripIndent(); + } + private void updateCharacterRemainingCount() { int currentLength = commentBox.getText().length(); - int remainingCharacters = maxCharLimit - currentLength; + int remainingCharacters = MAX_CHAR_LIMIT - currentLength; characterRemainingLabel.setText(remainingCharacters + " characters remaining"); } @Override - protected void configureShell(Shell newShell) { + protected final void configureShell(final Shell newShell) { super.configureShell(newShell); - newShell.setText(title); + newShell.setText(TITLE); } @Override - protected Point getInitialSize() { + protected final Point getInitialSize() { return new Point(800, 600); } - + @Override - public boolean close() { + public final boolean close() { disposeAllComponents(container); disposeIndependentElements(); return super.close(); } - - private void disposeAllComponents(Composite container) { + + private void disposeAllComponents(final Composite container) { for (Control control : container.getChildren()) { if (control instanceof Composite) { disposeAllComponents((Composite) control); @@ -342,8 +320,8 @@ private void disposeAllComponents(Composite container) { } } } - - public void disposeIndependentElements() { + + public final void disposeIndependentElements() { if (this.loadedImage != null && !this.loadedImage.isDisposed()) { this.loadedImage.dispose(); } @@ -351,4 +329,4 @@ public void disposeIndependentElements() { this.magnifiedFont.dispose(); } } -} \ No newline at end of file +} diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java index c97ee788..434c3bf8 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java @@ -38,7 +38,7 @@ public class ToolkitLoginWebview extends ViewPart implements ISelectionListener { public static final String ID = "software.aws.toolkits.eclipse.amazonq.views.ToolkitLoginWebview"; - private static final String shareFeedbackMenuItemText = "Share Feedback"; + private static final String SHARE_FEEDBACK_MENU_ITEM_TEXT = "Share Feedback"; @Inject private Shell shell; @@ -110,7 +110,7 @@ private void createActions(final boolean isLoggedIn) { updateSignoutActionVisibility(isLoggedIn); feedbackDialogContributionItem = new DialogContributionItem( new FeedbackDialog(shell), - shareFeedbackMenuItemText, + SHARE_FEEDBACK_MENU_ITEM_TEXT, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP) ); updateFeedbackContributionItemVisibility(isLoggedIn); @@ -163,7 +163,7 @@ private void handleAuthStatusChange(final boolean isLoggedIn) { private void updateSignoutActionVisibility(final boolean isLoggedIn) { signoutAction.setEnabled(isLoggedIn); } - + private void updateFeedbackContributionItemVisibility(final boolean isLoggedIn) { feedbackDialogContributionItem.setVisible(isLoggedIn); Display.getDefault().asyncExec(() -> { diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/Command.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/Command.java index 9dbd98a8..a3e3e675 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/Command.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/Command.java @@ -8,12 +8,12 @@ import software.aws.toolkits.eclipse.amazonq.util.PluginLogger; public enum Command { - // QChat - CHAT_READY("aws/chat/ready"), - CHAT_TAB_ADD("aws/chat/tabAdd"), - TELEMETRY_EVENT("telemetry/event"), - - // Auth + // QChat + CHAT_READY("aws/chat/ready"), + CHAT_TAB_ADD("aws/chat/tabAdd"), + TELEMETRY_EVENT("telemetry/event"), + + // Auth LOGIN_BUILDER_ID("loginBuilderId"), CANCEL_LOGIN("cancelLogin"); @@ -29,7 +29,7 @@ public static Optional fromString(final String value) { return Optional.ofNullable(command); } } - + PluginLogger.info("Unregistered command parsed: " + value); return Optional.empty(); } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/CommandRequest.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/CommandRequest.java index 91886094..3528aeb7 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/CommandRequest.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/CommandRequest.java @@ -7,16 +7,15 @@ import com.fasterxml.jackson.annotation.JsonProperty; public record CommandRequest( - @JsonProperty("command") String commandString, - @JsonProperty("params") Object params) - { + @JsonProperty("command") String commandString, + @JsonProperty("params") Object params) { public Optional getParsedCommand() { Optional command = Command.fromString(commandString); - + if (!command.isPresent()) { - return Optional.empty(); + return Optional.empty(); } - + ParsedCommand parsedCommand = new ParsedCommand(command.get(), Optional.ofNullable(params)); return Optional.ofNullable(parsedCommand); } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/ParsedCommand.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/ParsedCommand.java index 619b02b4..6d07e645 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/ParsedCommand.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/ParsedCommand.java @@ -7,19 +7,19 @@ public class ParsedCommand { private final Command command; - private final Object params; + private final Object params; - public ParsedCommand(Command command, Optional params) { + public ParsedCommand(final Command command, final Optional params) { this.command = command; this.params = params; - } - - public Command getCommand() { - return this.command; - } - - public Object getParams() { - return this.params; - } + } + + public final Command getCommand() { + return this.command; + } + + public final Object getParams() { + return this.params; + } } diff --git a/pom.xml b/pom.xml index 64b1faca..77718d4f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 software.aws.toolkits.eclipse - aws-plugin-q-group + amazon-q-eclipse-group 1.0.0-SNAPSHOT pom @@ -74,4 +74,4 @@ - \ No newline at end of file + diff --git a/updatesite/category.xml b/updatesite/category.xml index b315e8df..1480b953 100644 --- a/updatesite/category.xml +++ b/updatesite/category.xml @@ -1,6 +1,6 @@ - + diff --git a/updatesite/pom.xml b/updatesite/pom.xml index 4a504721..0c86a262 100644 --- a/updatesite/pom.xml +++ b/updatesite/pom.xml @@ -5,13 +5,13 @@ software.aws.toolkits.eclipse - aws-plugin-q-group + amazon-q-eclipse-group 1.0.0-SNAPSHOT ../ software.aws.toolkits.eclipse - aws-plugin-q-update-site + amazon-q-eclipse-update-site 1.0.0-SNAPSHOT eclipse-repository @@ -69,4 +69,4 @@ - \ No newline at end of file + From c22cc3f9b9ae81c0daad51b8833ef15f7e8a0441 Mon Sep 17 00:00:00 2001 From: Jonathan Breedlove Date: Mon, 16 Sep 2024 14:05:56 -0700 Subject: [PATCH 3/4] Trigger CI From 28144cd055693aef5db55d39c69875f6b759b094 Mon Sep 17 00:00:00 2001 From: Jonathan Breedlove Date: Mon, 16 Sep 2024 15:10:27 -0700 Subject: [PATCH 4/4] Trigger CI