Skip to content

Commit

Permalink
Fix Feedback dialog font on Windows and login path resolution bug
Browse files Browse the repository at this point in the history
  • Loading branch information
breedloj committed Nov 21, 2024
1 parent 3abd3b4 commit 8673ff4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
Expand Down Expand Up @@ -131,20 +130,6 @@ protected final void cancelPressed() {
super.cancelPressed();
}

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);
}
Font magnifiedFont = new Font(getShell().getDisplay(), fontData);
// Dispose the previous magnifiedFont, if it exists
if (this.magnifiedFont != null && !this.magnifiedFont.isDisposed()) {
this.magnifiedFont.dispose();
}
this.magnifiedFont = magnifiedFont;
return magnifiedFont;
}

private void handleTextModified(final ModifyEvent event) {
Text text = (Text) event.widget;
if (text.getText().length() > MAX_CHAR_LIMIT) {
Expand Down Expand Up @@ -193,11 +178,11 @@ private void createHeaderSection(final Composite container) {
rowLayout.spacing = PluginUtils.getPlatform().equals(PluginPlatform.WINDOWS) ? 1 : 0; // to reduce space between two labels
headlineContainer.setLayout(rowLayout);

createLabelWithFontSize(headlineContainer, "Looking for help? View the", 14);
createLinkLabel(headlineContainer, "Getting Started Guide", 14, "https://aws.amazon.com/q/getting-started/",
createLabel(headlineContainer, "Looking for help? View the");
createLinkLabel(headlineContainer, "Getting Started Guide", "https://aws.amazon.com/q/getting-started/",
"feedback_gettingStartedButton");
createLabelWithFontSize(headlineContainer, "or search our", 14);
createLinkLabel(headlineContainer, "Documentation", 14,
createLabel(headlineContainer, "or search our");
createLinkLabel(headlineContainer, "Documentation",
"https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/what-is.html",
"feedback_documentationButton");
}
Expand All @@ -209,7 +194,7 @@ private void createJoinUsOnGithubSection(final Composite container) {
joinUsOnGithubContainer.setLayout(joinUsOnGithubLayout);
joinUsOnGithubContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

createLabelWithFontSize(joinUsOnGithubContainer, "Join us on GitHub", 14);
createLabel(joinUsOnGithubContainer, "Join us on GitHub");
createSeparator(joinUsOnGithubContainer);
}

Expand All @@ -221,21 +206,21 @@ private void createReportRequestContributeSection(final Composite container) {
reportRequestContributeContainer.setLayout(reportRequestContributeContainerLayout);

createImageLabel(reportRequestContributeContainer, "icons/ReportAnIssue.png");
createLinkLabel(reportRequestContributeContainer, "Report an issue", SWT.NONE,
createLinkLabel(reportRequestContributeContainer, "Report an issue",
String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s",
getBodyMessageForReportIssueOrRequestFeature()),
"feedback_reportIssueButton");

createImageLabel(reportRequestContributeContainer, "icons/RequestFeature.png");
createLinkLabel(reportRequestContributeContainer, "Request a feature", SWT.NONE,
createLinkLabel(reportRequestContributeContainer, "Request a feature",
String.format("https://github.com/aws/amazon-q-eclipse/issues/new?body=%s",
getBodyMessageForReportIssueOrRequestFeature()),
"feedback_requestFeatureButton");

ThemeDetector themeDetector = new ThemeDetector();
createImageLabel(reportRequestContributeContainer,
themeDetector.isDarkTheme() ? "icons/ViewCode-White.png" : "icons/ViewCode-Black.png");
createLinkLabel(reportRequestContributeContainer, "View source code and contribute", SWT.NONE,
createLinkLabel(reportRequestContributeContainer, "View source code and contribute",
"https://github.com/aws/amazon-q-eclipse/", "feedback_viewSourceCodeButton");
}

Expand All @@ -246,7 +231,7 @@ private void createShareFeedbackSection(final Composite container) {
shareFeedbackTextContainer.setLayout(shareFeedbackTextContainerLayout);
shareFeedbackTextContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

createLabelWithFontSize(shareFeedbackTextContainer, "Share feedback", 14);
createLabel(shareFeedbackTextContainer, "Share feedback");
createSeparator(shareFeedbackTextContainer);
}

Expand Down Expand Up @@ -355,12 +340,11 @@ public void paintControl(final PaintEvent event) {
characterRemainingLabel = new Label(questionsContainer, SWT.NONE);
characterRemainingLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
updateCharacterRemainingCount();
createLabelWithFontSize(questionsContainer,
createLabel(questionsContainer,
"Don't add personally identifiable information (PII), confidential or sensitive "
+ "information in your feedback.",
10);
createLabelWithFontSize(questionsContainer,
"Please remove any PII when sharing file paths, error messages, etc.", 10);
+ "information in your feedback.");
createLabel(questionsContainer,
"Please remove any PII when sharing file paths, error messages, etc.");

}

Expand All @@ -369,17 +353,10 @@ private void createLabel(final Composite parent, final String text) {
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,
private void createLinkLabel(final Composite parent, final String text, final String url,
final String telemetryLabel) {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
package software.aws.toolkits.eclipse.amazonq.views;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.eclipse.swt.browser.BrowserFunction;
import org.eclipse.swt.browser.ProgressAdapter;
Expand Down Expand Up @@ -110,7 +112,7 @@ public void onAuthStatusChanged(final AuthState authState) {
private String getContent() {
try {
URL jsFile = PluginUtils.getResource("webview/build/assets/js/getStart.js");
var jsParent = Path.of(jsFile.getPath()).getParent();
var jsParent = Paths.get(jsFile.toURI()).getParent();
var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString();

webviewAssetServer = new WebviewAssetServer();
Expand Down Expand Up @@ -168,7 +170,7 @@ private String getContent() {
</html>
""",
loginJsPath, loginJsPath, loginJsPath, getWaitFunction(), isDarkTheme);
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
return "Failed to load JS";
}
}
Expand Down

0 comments on commit 8673ff4

Please sign in to comment.