mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: generalize 'Send Feedback' action
It's description refer to actual host instead of 'JetBrain Web site', $VERSION placeholder is supported in feedback URLs, action is hidden for OSes which don't have official distributions. This is needed to reuse the action in Android Studio instead of overriding it (IDEA-209167).
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.FeedbackDescriptionProvider;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
@@ -31,12 +32,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SendFeedbackAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
ApplicationInfoEx info = ApplicationInfoEx.getInstanceEx();
|
||||
e.getPresentation().setEnabledAndVisible(info != null && info.getFeedbackUrl() != null);
|
||||
boolean isSupportedOS = SystemInfo.isMac || SystemInfo.isLinux || SystemInfo.isWindows;
|
||||
if (info != null && info.getFeedbackUrl() != null && isSupportedOS) {
|
||||
String feedbackSite = getFeedbackHost(info.getFeedbackUrl(), info.getCompanyName());
|
||||
e.getPresentation().setDescription(ActionsBundle.message("action.SendFeedback.detailed.description", feedbackSite));
|
||||
e.getPresentation().setEnabledAndVisible(true);
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFeedbackHost(String feedbackUrl, String companyName) {
|
||||
Pattern uriPattern = Pattern.compile("[^:/?#]+://(?:www\\.)?([^/?#]*).*", Pattern.DOTALL);
|
||||
Matcher matcher = uriPattern.matcher(feedbackUrl);
|
||||
return matcher.matches() ? matcher.group(1) : companyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,6 +78,7 @@ public class SendFeedbackAction extends AnAction implements DumbAware {
|
||||
String url = urlTemplate
|
||||
.replace("$BUILD", eap ? appInfo.getBuild().asStringWithoutProductCode() : appInfo.getBuild().asString())
|
||||
.replace("$TIMEZONE", System.getProperty("user.timezone"))
|
||||
.replace("$VERSION", appInfo.getFullVersion())
|
||||
.replace("$EVAL", la != null && la.isEvaluationLicense() ? "true" : "false")
|
||||
.replace("$DESCR", description);
|
||||
BrowserUtil.browse(url, project);
|
||||
|
||||
@@ -1251,7 +1251,7 @@ action.ShowCoverageInfo.text=Show Co&verage Info
|
||||
action.HideCoverageInfo.text=Hide Co&verage Info
|
||||
|
||||
action.SendFeedback.text=Submit _Feedback...
|
||||
action.SendFeedback.description=Submit feedback to the JetBrains Web site
|
||||
action.SendFeedback.detailed.description=Submit feedback to {0}
|
||||
action.ShowLog.text=Show _Log in File Manager
|
||||
action.ShowLog.description=Opens folder with log file
|
||||
action.CollectZippedLogs.text=Compress Logs and Show in File Manager
|
||||
|
||||
Reference in New Issue
Block a user