FUS: rename events validation scheme actions (IDEA-243852)

GitOrigin-RevId: a574ccec095c8d2b3a0db1fef3ef8f3732ed4453
This commit is contained in:
Svetlana.Zemlyanskaya
2020-06-18 19:45:24 +03:00
committed by intellij-monorepo-bot
parent 42a10ea132
commit a32862d5ed
27 changed files with 222 additions and 223 deletions
@@ -2299,26 +2299,26 @@ action.$Redo.text=Redo
action.$Undo.text=Undo
group.Vcs.KeymapGroup.text=Version Control Systems
group.InspectCodeGroup.text=Inspect Code Actions
action.ConfigureWhitelistAction.text=Configure Whitelist
action.ConfigureWhitelistAction.description=Configure whitelist from the custom folder
action.ConfigureEventsSchemeFileAction.text=Configure Events Scheme File
action.ConfigureEventsSchemeFileAction.description=Load Events Scheme from the custom folder
action.ShowStatisticsEventLogAction.text=Show Statistics Event Log
action.ShowStatisticsEventLogAction.description=Opens toolwindow with feature usage statistics event log
action.ReportSettingsToFUS.text=Record Changed Settings to Event Log
action.CleanupLocalWhitelistAction.text=Clean Up Local Whitelist
action.CleanupLocalWhitelistAction.description=Removes all groups from the local whitelist
action.CleanupEventsTestSchemeAction.text=Clean Up Events Test Scheme
action.CleanupEventsTestSchemeAction.description=Removes all groups registered in the test scheme
action.RecordStateCollectors.text=Record State Collectors to Event Log
action.RecordStateCollectors.description=Invokes all state collectors and records result to event log
action.ShowChangedStateStatisticsAction.text=Show Only Changed State Events
action.ShowChangedStateStatisticsAction.description=Invokes all state collectors and shows only changed events since previous record
action.AddTestGroupToLocalWhitelistAction.text=Add Test Group to Local Whitelist
action.AddTestGroupToLocalWhitelistAction.description=Allows all data from the group. Use it to test new collector locally.
action.EditLocalWhitelistAction.text=Edit Local Whitelist
action.EditLocalWhitelistAction.description=Allows all data from the group. Use it to test new collector locally.
action.AddGroupToTestSchemeAction.text=Add Group to Events Test Scheme
action.AddGroupToTestSchemeAction.description=Allows all data from the group. Use it to test new collector locally.
action.EditTestSchemeAction.text=Edit Events Test Scheme
action.EditTestSchemeAction.description=Allows all data from the group. Use it to test new collector locally.
group.OpenEventLogFileAction.text=Open Event Log in Editor
group.OpenEventLogFileAction.description=Opens active event log file in IDE
group.OpenLocalWhitelistFileAction.description=Opens local whitelist file in IDE
group.OpenWhitelistFileAction.description=Opens whitelist file in IDE
group.UpdateWhitelistAction.description=Updates the main whitelist from the server if necessary. Also updates local whitelist from the file.
group.OpenEventsTestSchemeFileAction.description=Opens events test scheme file in IDE
group.OpenEventsSchemeFileAction.description=Opens events scheme file in IDE
group.UpdateEventsSchemeAction.description=Updates the main events scheme from the server if necessary. Also re-loads events test scheme from the file.
action.SendEventLogStatistics.text=Send Feature Usage Event Log
action.SendEventLogStatistics.description=Sends event log files to qa server
group.FeatureUsage.Internal.text=Feature Usages Statistics
@@ -2331,7 +2331,7 @@ action.UsedIconsListing.text=List Used Icons
action.GenerateVisitorByHierarchy.text=Generate Hierarchy Visitor...
group.Internal.Java.text=Java
action.CollectFUStatisticsAction.text=Collect Statistics from Collector...
action.TestParseEventLogWhitelistAction.text=Test Parsing Event Log Whitelist...
action.TestParseEventsSchemeAction.text=Test Parsing Events Scheme...
action.ValidateLocalHistory.text=Validate Local History Storage
action.FixLineSeparators.text=Fix Line Separators
action.PruneEmptyDirectories.text=Prune Empty Directories
@@ -3,18 +3,18 @@
<group id="FeatureUsage.Internal" popup="true" internal="true" compact="true">
<action internal="true" id="RecordStateCollectors"
class="com.intellij.internal.statistic.actions.RecordStateStatisticsEventLogAction"/>
<action internal="true" id="AddTestGroupToLocalWhitelistAction"
class="com.intellij.internal.statistic.actions.localWhitelist.AddTestGroupToLocalWhitelistAction"/>
<action internal="true" id="EditLocalWhitelistAction"
class="com.intellij.internal.statistic.actions.localWhitelist.EditLocalWhitelistAction"/>
<action internal="true" id="CleanupLocalWhitelistAction"
class="com.intellij.internal.statistic.actions.CleanupLocalWhitelistAction"/>
<action internal="true" id="AddGroupToTestSchemeAction"
class="com.intellij.internal.statistic.actions.scheme.AddGroupToTestSchemeAction"/>
<action internal="true" id="EditTestSchemeAction"
class="com.intellij.internal.statistic.actions.scheme.EditEventsTestSchemeAction"/>
<action internal="true" id="CleanupEventsTestSchemeAction"
class="com.intellij.internal.statistic.actions.CleanupEventsTestSchemeAction"/>
<add-to-group group-id="Internal" anchor="last"/>
</group>
<action internal="true" id="SendEventLogStatistics" class="com.intellij.internal.statistic.actions.SendEventLogAction"/>
<action internal="true" id="OpenLocalWhitelistFileAction" class="com.intellij.internal.statistic.actions.OpenLocalWhitelistFileAction"/>
<action internal="true" id="ConfigureWhitelistAction" class="com.intellij.internal.statistic.actions.ConfigureWhitelistAction"/>
<action internal="true" id="OpenWhitelistFileAction" class="com.intellij.internal.statistic.actions.OpenWhitelistFileAction"/>
<action internal="true" id="OpenEventsTestSchemeFileAction" class="com.intellij.internal.statistic.actions.OpenEventsTestSchemeFileAction"/>
<action internal="true" id="ConfigureEventsSchemeFileAction" class="com.intellij.internal.statistic.actions.ConfigureEventsSchemeFileAction"/>
<action internal="true" id="OpenEventsSchemeFileAction" class="com.intellij.internal.statistic.actions.OpenEventsSchemeFileAction"/>
<action internal="true" id="ReportSettingsToFUS" class="com.intellij.internal.statistic.actions.ReportSettingsToFUSAction"/>
<group internal="true" id="OpenEventLogFileAction" class="com.intellij.internal.statistic.groups.OpenEventLogFileActionGroup"/>
<group internal="true" id="CleanupEventLog" class="com.intellij.internal.statistic.groups.CleanupEventLogByIdActionGroup"/>
@@ -24,9 +24,9 @@
anchor="bottom" canCloseContents="true" order="last"/>
<notificationWhitelist groupIds="FeatureUsageStatistics"/>
<completion.contributor language="JSON"
implementationClass="com.intellij.internal.statistic.actions.localWhitelist.ValidationRulesCompletionContributor"/>
implementationClass="com.intellij.internal.statistic.actions.scheme.ValidationRulesCompletionContributor"/>
</extensions>
<extensions defaultExtensionNs="JavaScript.JsonSchema">
<ProviderFactory implementation="com.intellij.internal.statistic.actions.localWhitelist.LocalWhitelistJsonSchemaProviderFactory"/>
<ProviderFactory implementation="com.intellij.internal.statistic.actions.scheme.EventsSchemeJsonSchemaProviderFactory"/>
</extensions>
</idea-plugin>
@@ -1,9 +1,9 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://jetbrains.com/local-whitelist.schema.json",
"$id": "https://jetbrains.com/events-test-scheme.schema.json",
"type": "object",
"title": "Feature Usage Statistics Local Whitelist",
"description": "Feature Usage Statistics Local Whitelist",
"title": "Feature Usage Statistics Test Scheme",
"description": "Feature Usage Statistics Test Scheme",
"required": [
"event_id",
"event_data"
@@ -10,15 +10,15 @@ import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbAwareAction
class CleanupLocalWhitelistAction(private val recorderId: String? = null)
: DumbAwareAction(ActionsBundle.message("action.CleanupLocalWhitelistAction.text"),
ActionsBundle.message("action.CleanupLocalWhitelistAction.description"),
class CleanupEventsTestSchemeAction(private val recorderId: String? = null)
: DumbAwareAction(ActionsBundle.message("action.CleanupEventsTestSchemeAction.text"),
ActionsBundle.message("action.CleanupEventsTestSchemeAction.description"),
AllIcons.Actions.GC) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Removing Local Whitelist", false) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Removing Test Scheme", false) {
override fun run(indicator: ProgressIndicator) {
if (recorderId == null) {
WhitelistTestGroupStorage.cleanupAll()
@@ -16,41 +16,41 @@ import com.intellij.openapi.project.DumbAwareAction
import com.intellij.ui.LayeredIcon
import com.intellij.ui.components.dialog
class ConfigureWhitelistAction(private var myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.message("action.ConfigureWhitelistAction.text"),
ActionsBundle.message("action.ConfigureWhitelistAction.description"),
class ConfigureEventsSchemeFileAction(private var myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.message("action.ConfigureEventsSchemeFileAction.text"),
ActionsBundle.message("action.ConfigureEventsSchemeFileAction.description"),
null) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val whitelistConfigurationModel = WhitelistConfigurationModel()
val configurationModel = EventsSchemeConfigurationModel()
val dialog = dialog(
title = "Configure Whitelist",
panel = whitelistConfigurationModel.panel,
title = "Configure Custom Events Scheme",
panel = configurationModel.panel,
resizable = true,
project = project,
ok = { listOfNotNull(whitelistConfigurationModel.validate()) }
ok = { listOfNotNull(configurationModel.validate()) }
)
if (!dialog.showAndGet()) return
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Saving Whitelist Configuration...", false) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Saving Events Scheme Configuration...", false) {
override fun run(indicator: ProgressIndicator) {
updateWhitelistSettings(whitelistConfigurationModel.recorderToSettings)
updateSchemeSettings(configurationModel.recorderToSettings)
}
})
}
private fun updateWhitelistSettings(recorderToSettings: MutableMap<String, WhitelistConfigurationModel.WhitelistPathSettings>) {
val whitelistSettingsPersistence = EventLogWhitelistSettingsPersistence.getInstance()
private fun updateSchemeSettings(recorderToSettings: MutableMap<String, EventsSchemeConfigurationModel.WhitelistPathSettings>) {
val settingsPersistence = EventLogWhitelistSettingsPersistence.getInstance()
for ((recorder, settings) in recorderToSettings) {
val customPath = settings.customPath
if (settings.useCustomPath && customPath != null) {
whitelistSettingsPersistence.setPathSettings(recorder, WhitelistPathSettings(customPath, true))
settingsPersistence.setPathSettings(recorder, WhitelistPathSettings(customPath, true))
}
else {
val oldSettings = whitelistSettingsPersistence.getPathSettings(recorder)
val oldSettings = settingsPersistence.getPathSettings(recorder)
if (oldSettings != null && oldSettings.isUseCustomPath) {
whitelistSettingsPersistence.setPathSettings(recorder, WhitelistPathSettings(oldSettings.customPath, false))
settingsPersistence.setPathSettings(recorder, WhitelistPathSettings(oldSettings.customPath, false))
}
}
val validator = SensitiveDataValidator.getInstance(recorder)
@@ -16,7 +16,7 @@ import com.intellij.ui.layout.*
import javax.swing.JCheckBox
import javax.swing.event.DocumentEvent
class WhitelistConfigurationModel {
class EventsSchemeConfigurationModel {
val panel: DialogPanel
val recorderToSettings: MutableMap<String, WhitelistPathSettings> = mutableMapOf()
private val recorderComboBox = ComboBox<String>()
@@ -31,7 +31,7 @@ class WhitelistConfigurationModel {
}
recorderComboBox.addActionListener { updatePanel() }
pathField.addBrowseFolderListener("Select Whitelist Location ", null, null, FileChooserDescriptorFactory.createSingleFileDescriptor())
pathField.addBrowseFolderListener("Select Events Scheme Location ", null, null, FileChooserDescriptorFactory.createSingleFileDescriptor())
pathField.textField.document.addDocumentListener(object : DocumentAdapter() {
override fun textChanged(e: DocumentEvent) {
if (useCustomPathCheckBox.isSelected) {
@@ -103,7 +103,7 @@ class WhitelistConfigurationModel {
val customPath = settings.customPath
if (customPath.isNullOrBlank()) {
return ValidationInfo("Specify whitelist path.", pathField.textField)
return ValidationInfo("Specify events scheme path.", pathField.textField)
}
else if (!FileUtil.exists(customPath)) {
return ValidationInfo("File doesn't exist.", pathField.textField)
@@ -126,9 +126,9 @@ class WhitelistConfigurationModel {
val currentPath: String
get() {
val customWhitelistPath = customPath
return if (useCustomPath && customWhitelistPath != null) {
customWhitelistPath
val customEventsSchemePath = customPath
return if (useCustomPath && customEventsSchemePath != null) {
customEventsSchemePath
}
else {
defaultPath
@@ -7,7 +7,6 @@ import com.intellij.internal.statistic.StatisticsBundle
import com.intellij.internal.statistic.StatisticsDevKitUtil
import com.intellij.internal.statistic.StatisticsDevKitUtil.showNotification
import com.intellij.internal.statistic.eventLog.validator.persistence.BaseEventLogWhitelistPersistence
import com.intellij.internal.statistic.eventLog.validator.persistence.EventLogWhitelistPersistence
import com.intellij.internal.statistic.eventLog.validator.persistence.EventLogWhitelistPersistence.EVENTS_SCHEME_FILE
import com.intellij.internal.statistic.eventLog.validator.persistence.EventLogWhitelistSettingsPersistence
import com.intellij.notification.NotificationType
@@ -18,9 +17,9 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtil
import java.io.File
class OpenWhitelistFileAction(private val myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(StatisticsBundle.message("stats.open.0.whitelist.file", myRecorderId),
ActionsBundle.message("group.OpenWhitelistFileAction.description"),
class OpenEventsSchemeFileAction(private val myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(StatisticsBundle.message("stats.open.0.scheme.file", myRecorderId),
ActionsBundle.message("group.OpenEventsSchemeFileAction.description"),
AllIcons.FileTypes.Config) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
@@ -5,14 +5,14 @@ import com.intellij.icons.AllIcons
import com.intellij.idea.ActionsBundle
import com.intellij.internal.statistic.StatisticsBundle
import com.intellij.internal.statistic.StatisticsDevKitUtil
import com.intellij.internal.statistic.actions.OpenWhitelistFileAction.Companion.openFileInEditor
import com.intellij.internal.statistic.actions.OpenEventsSchemeFileAction.Companion.openFileInEditor
import com.intellij.internal.statistic.eventLog.validator.persistence.EventLogTestWhitelistPersistence
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
class OpenLocalWhitelistFileAction(private val myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(StatisticsBundle.message("stats.open.0.local.whitelist.file", myRecorderId),
ActionsBundle.message("group.OpenLocalWhitelistFileAction.description"),
class OpenEventsTestSchemeFileAction(private val myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(StatisticsBundle.message("stats.open.0.test.scheme.file", myRecorderId),
ActionsBundle.message("group.OpenEventsTestSchemeFileAction.description"),
AllIcons.FileTypes.Any_type) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
@@ -12,7 +12,7 @@ import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TestParseEventLogWhitelistAction extends DumbAwareAction {
public class TestParseEventsSchemeAction extends DumbAwareAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
@@ -22,7 +22,7 @@ public class TestParseEventLogWhitelistAction extends DumbAwareAction {
final Editor editor =
fileType != null && StringUtil.equalsIgnoreCase(fileType.getFileType().getName(), "json") ?
e.getData(CommonDataKeys.EDITOR) : null;
new TestParseEventLogWhitelistDialog(project, editor).show();
new TestParseEventsSchemeDialog(project, editor).show();
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.internal.statistic.actions.TestParseEventLogWhitelistDialog">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.internal.statistic.actions.TestParseEventsSchemeDialog">
<grid id="27dc6" binding="myMainPanel" default-binding="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -52,7 +52,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="ecf31" binding="myWhitelistPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="ecf31" binding="myEventsSchemePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
@@ -52,24 +52,24 @@ import java.util.List;
import static com.intellij.openapi.command.WriteCommandAction.writeCommandAction;
public class TestParseEventLogWhitelistDialog extends DialogWrapper {
private static final Logger LOG = Logger.getInstance(TestParseEventLogWhitelistDialog.class);
public class TestParseEventsSchemeDialog extends DialogWrapper {
private static final Logger LOG = Logger.getInstance(TestParseEventsSchemeDialog.class);
private static final int IN_DIVIDER_LOCATION = 650;
private static final int IN_OUT_DIVIDER_LOCATION = 300;
private JPanel myMainPanel;
private JPanel myWhitelistPanel;
private JPanel myEventsSchemePanel;
private JPanel myResultPanel;
private JEditorPane myEventLogPanel;
private JSplitPane myInputDataSplitPane;
private JSplitPane myInputOutputSplitPane;
private final Project myProject;
private final EditorEx myWhitelistEditor;
private final EditorEx myEventsSchemeEditor;
private final EditorEx myResultEditor;
private final List<PsiFile> myTempFiles = new ArrayList<>();
protected TestParseEventLogWhitelistDialog(@NotNull Project project, @Nullable Editor selectedEditor) {
protected TestParseEventsSchemeDialog(@NotNull Project project, @Nullable Editor selectedEditor) {
super(project);
myProject = project;
setOKButtonText("&Filter Event Log");
@@ -77,8 +77,8 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper {
Disposer.register(myProject, getDisposable());
VirtualFile selectedFile = selectedEditor == null ? null : FileDocumentManager.getInstance().getFile(selectedEditor.getDocument());
setTitle(selectedFile == null ? "Event Log Filter" : "Event Log Filter by: " + selectedFile.getName());
myWhitelistEditor = initEditor(selectedEditor, "event-log-whitelist", "{\"groups\":[]}");
myWhitelistEditor.getSettings().setLineMarkerAreaShown(false);
myEventsSchemeEditor = initEditor(selectedEditor, "events-scheme", "{\"groups\":[]}");
myEventsSchemeEditor.getSettings().setLineMarkerAreaShown(false);
myResultEditor = initEditor(null, "event-log-filter-result", "{}");
myResultEditor.getSettings().setLineMarkerAreaShown(false);
@@ -89,9 +89,9 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper {
ApplicationManager.getApplication().invokeLater(() -> {
IdeFocusManager.getGlobalInstance()
.doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myWhitelistEditor.getContentComponent(), true));
myWhitelistEditor.getCaretModel().moveToOffset(selectedEditor.getCaretModel().getOffset());
myWhitelistEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
.doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myEventsSchemeEditor.getContentComponent(), true));
myEventsSchemeEditor.getCaretModel().moveToOffset(selectedEditor.getCaretModel().getOffset());
myEventsSchemeEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
}, ModalityState.stateForComponent(myMainPanel));
}
}
@@ -151,7 +151,7 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper {
@Override
protected void init() {
configEditorPanel(myProject, myWhitelistPanel, myWhitelistEditor);
configEditorPanel(myProject, myEventsSchemePanel, myEventsSchemeEditor);
configEditorPanel(myProject, myResultPanel, myResultEditor);
myInputDataSplitPane.setDividerLocation(IN_DIVIDER_LOCATION);
@@ -179,26 +179,26 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper {
@Override
@NotNull
protected String getDimensionServiceKey() {
return TestParseEventLogWhitelistDialog.class.getCanonicalName();
return TestParseEventsSchemeDialog.class.getCanonicalName();
}
@SuppressWarnings("TestOnlyProblems")
@Override
protected void doOKAction() {
myWhitelistEditor.getSelectionModel().removeSelection();
myEventsSchemeEditor.getSelectionModel().removeSelection();
myResultEditor.getSelectionModel().removeSelection();
updateResultRequest("{}");
try {
StatisticsWhitelistConditions whitelist = StatisticsWhitelistLoader.parseApprovedGroups(myWhitelistEditor.getDocument().getText());
String parsed = parseLogAndFilter(new LogEventWhitelistFilter(whitelist), myEventLogPanel.getText());
StatisticsWhitelistConditions scheme = StatisticsWhitelistLoader.parseApprovedGroups(myEventsSchemeEditor.getDocument().getText());
String parsed = parseLogAndFilter(new LogEventWhitelistFilter(scheme), myEventLogPanel.getText());
updateResultRequest(parsed.trim());
}
catch (EventLogWhitelistParseException e) {
Messages.showErrorDialog(myProject, e.getMessage(), "Failed Parsing Whitelist");
Messages.showErrorDialog(myProject, e.getMessage(), "Failed Parsing Events Scheme");
}
catch (IOException | ParseEventLogWhitelistException e) {
Messages.showErrorDialog(myProject, e.getMessage(), "Failed Applying Whitelist to Event Log");
Messages.showErrorDialog(myProject, e.getMessage(), "Failed Applying Events Scheme to Event Log");
}
}
@@ -257,8 +257,8 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper {
}
});
if (!myWhitelistEditor.isDisposed()) {
EditorFactory.getInstance().releaseEditor(myWhitelistEditor);
if (!myEventsSchemeEditor.isDisposed()) {
EditorFactory.getInstance().releaseEditor(myEventsSchemeEditor);
}
if (!myResultEditor.isDisposed()) {
@@ -11,14 +11,14 @@ import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbAwareAction
class UpdateWhitelistAction(val recorder: String)
: DumbAwareAction(StatisticsBundle.message("stats.update.whitelist"),
ActionsBundle.message("group.UpdateWhitelistAction.description"),
class UpdateEventsSchemeAction(val recorder: String)
: DumbAwareAction(StatisticsBundle.message("stats.update.events.scheme"),
ActionsBundle.message("group.UpdateEventsSchemeAction.description"),
AllIcons.Actions.Refresh) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
ProgressManager.getInstance().run(object : Task.Backgroundable(project, StatisticsBundle.message("stats.updating.whitelist"), false) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, StatisticsBundle.message("stats.updating.events.scheme"), false) {
override fun run(indicator: ProgressIndicator) {
val validator = SensitiveDataValidator.getInstance(recorder)
validator.update()
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.icons.AllIcons
import com.intellij.idea.ActionsBundle
@@ -23,46 +23,46 @@ import com.intellij.ui.components.dialog
import java.io.IOException
/**
* Action adds not whitelisted statistics group to a local whitelist for testing.
* Action adds group which are not yet registered on the server to a test groups scheme for testing.
*
* If "Add custom validation rules" is disabled, all event id and event data values from the group will be allowed.
*/
class AddTestGroupToLocalWhitelistAction constructor(private val recorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.messagePointer("action.AddTestGroupToLocalWhitelistAction.text"),
ActionsBundle.messagePointer("action.AddTestGroupToLocalWhitelistAction.description"),
class AddGroupToTestSchemeAction constructor(private val recorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.messagePointer("action.AddGroupToTestSchemeAction.text"),
ActionsBundle.messagePointer("action.AddGroupToTestSchemeAction.description"),
AllIcons.General.Add) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val testWhitelistStorage = WhitelistTestGroupStorage.getTestStorage(recorderId)
if (testWhitelistStorage == null) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.cannot.find.test.whitelist.storage"))
val testStorage = WhitelistTestGroupStorage.getTestStorage(recorderId)
if (testStorage == null) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.cannot.find.test.scheme.storage"))
return
}
val whitelistGroup = LocalWhitelistGroup("", false)
val dialog = createAddToLocalWhitelistDialog(project, testWhitelistStorage, whitelistGroup)
val group = LocalWhitelistGroup("", false)
val dialog = createAddToTestSchemeDialog(project, testStorage, group)
if (dialog == null || !dialog.showAndGet()) return
runBackgroundableTask(StatisticsBundle.message("stats.updating.local.whitelist"), project, false) {
runBackgroundableTask(StatisticsBundle.message("stats.updating.test.scheme"), project, false) {
try {
testWhitelistStorage.addTestGroup(whitelistGroup)
showNotification(project, NotificationType.INFORMATION, StatisticsBundle.message("stats.local.whitelist.was.updated"))
testStorage.addTestGroup(group)
showNotification(project, NotificationType.INFORMATION, StatisticsBundle.message("stats.test.scheme.was.updated"))
}
catch (ex: IOException) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.failed.updating.local.whitelist.0", ex.message))
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.failed.updating.test.scheme.0", ex.message))
}
}
}
companion object {
fun createAddToLocalWhitelistDialog(project: Project,
testGroupStorage: WhitelistTestGroupStorage,
group: LocalWhitelistGroup): DialogWrapper? {
fun createAddToTestSchemeDialog(project: Project,
testGroupStorage: WhitelistTestGroupStorage,
group: LocalWhitelistGroup): DialogWrapper? {
val productionGroups = loadProductionGroups(project, testGroupStorage)
if (productionGroups == null) return null
val groupConfiguration = LocalWhitelistGroupConfiguration(project, productionGroups, group)
val groupConfiguration = EventsTestSchemeGroupConfiguration(project, productionGroups, group)
val dialog = dialog(
StatisticsBundle.message("stats.add.test.group.to.local.whitelist"),
StatisticsBundle.message("stats.add.test.group.to.test.scheme"),
panel = groupConfiguration.panel,
resizable = true,
focusedComponent = groupConfiguration.getFocusedComponent(),
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.icons.AllIcons
import com.intellij.idea.ActionsBundle
@@ -28,65 +28,65 @@ import java.awt.Font
import java.io.IOException
/**
* Action opens `Edit Local Whitelist` dialog.
* Action opens `Edit Events Test Scheme` dialog.
*
* If "Add custom validation rules" is disabled, all event id and event data values from the group will be allowed.
*/
class EditLocalWhitelistAction(private val recorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.messagePointer("action.EditLocalWhitelistAction.text"),
ActionsBundle.messagePointer("action.EditLocalWhitelistAction.description"),
class EditEventsTestSchemeAction(private val recorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER)
: DumbAwareAction(ActionsBundle.messagePointer("action.EditTestSchemeAction.text"),
ActionsBundle.messagePointer("action.EditTestSchemeAction.description"),
ICON) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val testWhitelistStorage = WhitelistTestGroupStorage.getTestStorage(recorderId)
if (testWhitelistStorage == null) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.cannot.find.test.whitelist.storage"))
val testSchemeStorage = WhitelistTestGroupStorage.getTestStorage(recorderId)
if (testSchemeStorage == null) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.cannot.find.test.scheme.storage"))
return
}
val whitelist = loadWhitelist(project, testWhitelistStorage)
if (whitelist == null) return
val scheme = loadEventsScheme(project, testSchemeStorage)
if (scheme == null) return
val editLocalWhitelistPanel = EditLocalWhitelistPanel(project, whitelist.localGroups, whitelist.productionGroups)
val editTestSchemePanel = EditEventsTestSchemePanel(project, scheme.localGroups, scheme.productionGroups)
val dialog = dialog(
StatisticsBundle.message("stats.edit.local.whitelist"),
panel = editLocalWhitelistPanel,
StatisticsBundle.message("stats.edit.test.scheme"),
panel = editTestSchemePanel,
resizable = true,
focusedComponent = editLocalWhitelistPanel.getFocusedComponent(),
focusedComponent = editTestSchemePanel.getFocusedComponent(),
project = project,
ok = { editLocalWhitelistPanel.validateGroups() }
ok = { editTestSchemePanel.validateGroups() }
)
Disposer.register(dialog.disposable, editLocalWhitelistPanel)
Disposer.register(dialog.disposable, editTestSchemePanel)
if (!dialog.showAndGet()) return
runBackgroundableTask(StatisticsBundle.message("stats.updating.local.whitelist"), project, false) {
runBackgroundableTask(StatisticsBundle.message("stats.updating.test.scheme"), project, false) {
try {
testWhitelistStorage.updateTestGroups(editLocalWhitelistPanel.getGroups())
showNotification(project, NotificationType.INFORMATION, StatisticsBundle.message("stats.local.whitelist.was.updated"))
testSchemeStorage.updateTestGroups(editTestSchemePanel.getGroups())
showNotification(project, NotificationType.INFORMATION, StatisticsBundle.message("stats.test.scheme.was.updated"))
}
catch (ex: IOException) {
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.failed.updating.local.whitelist.0", ex.message))
showNotification(project, NotificationType.ERROR, StatisticsBundle.message("stats.failed.updating.test.scheme.0", ex.message))
}
}
}
private fun loadWhitelist(project: Project, testWhitelistStorage: WhitelistTestGroupStorage): Whitelist? {
return ProgressManager.getInstance().run(object : Task.WithResult<Whitelist?, IOException>(
project, StatisticsBundle.message("stats.loading.local.whitelist"), true) {
override fun compute(indicator: ProgressIndicator): Whitelist? {
val localGroups = testWhitelistStorage.loadLocalWhitelistGroups()
private fun loadEventsScheme(project: Project, testSchemeStorage: WhitelistTestGroupStorage): EventsTestScheme? {
return ProgressManager.getInstance().run(object : Task.WithResult<EventsTestScheme?, IOException>(
project, StatisticsBundle.message("stats.loading.test.scheme"), true) {
override fun compute(indicator: ProgressIndicator): EventsTestScheme? {
val localGroups = testSchemeStorage.loadLocalWhitelistGroups()
if (indicator.isCanceled) return null
val productionGroups = testWhitelistStorage.loadProductionGroups()
val productionGroups = testSchemeStorage.loadProductionGroups()
if (indicator.isCanceled) return null
return Whitelist(localGroups, productionGroups)
return EventsTestScheme(localGroups, productionGroups)
}
})
}
override fun update(e: AnActionEvent) {
val localWhitelistSize = WhitelistTestGroupStorage.getTestStorage(recorderId)?.size() ?: 0
val text = if (localWhitelistSize < 100) localWhitelistSize.toString() else "99+"
val testSchemeSize = WhitelistTestGroupStorage.getTestStorage(recorderId)?.size() ?: 0
val text = if (testSchemeSize < 100) testSchemeSize.toString() else "99+"
val sizeCountIcon = TextIcon(text, JBColor.DARK_GRAY, UIUtil.getLabelBackground(), 1)
sizeCountIcon.setFont(Font(UIUtil.getLabelFont().name, Font.BOLD, JBUIScale.scale(9)))
sizeCountIcon.setInsets(1, 1, 0, 0)
@@ -102,7 +102,7 @@ class EditLocalWhitelistAction(private val recorderId: String = StatisticsDevKit
}
}
class Whitelist(
class EventsTestScheme(
val localGroups: List<LocalWhitelistGroup>,
val productionGroups: FUStatisticsWhiteListGroupsService.WLGroups
)
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.internal.statistic.StatisticsBundle
import com.intellij.internal.statistic.eventLog.whitelist.LocalWhitelistGroup
@@ -21,12 +21,12 @@ import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.SwingConstants
class EditLocalWhitelistPanel(private val project: Project,
localWhitelistGroups: List<LocalWhitelistGroup>,
productionGroups: FUStatisticsWhiteListGroupsService.WLGroups) : JPanel(), Disposable {
private val groupsModel = CollectionListModel(localWhitelistGroups)
class EditEventsTestSchemePanel(private val project: Project,
testSchemeGroups: List<LocalWhitelistGroup>,
productionGroups: FUStatisticsWhiteListGroupsService.WLGroups) : JPanel(), Disposable {
private val groupsModel = CollectionListModel(testSchemeGroups)
private val groupsList: JBList<LocalWhitelistGroup> = JBList(groupsModel)
private var groupConfiguration: LocalWhitelistGroupConfiguration
private var groupConfiguration: EventsTestSchemeGroupConfiguration
private val cardLayout = CardLayout()
private val detailsComponent: JPanel = JPanel(cardLayout)
@@ -35,7 +35,7 @@ class EditLocalWhitelistPanel(private val project: Project,
init {
val initialGroup = LocalWhitelistGroup("", false)
groupConfiguration = LocalWhitelistGroupConfiguration(project, productionGroups, initialGroup) { group ->
groupConfiguration = EventsTestSchemeGroupConfiguration(project, productionGroups, initialGroup) { group ->
groupsModel.contentsChanged(group)
}
@@ -65,7 +65,7 @@ class EditLocalWhitelistPanel(private val project: Project,
detailsComponent.add(EMPTY_KEY, emptyPanel)
detailsComponent.add(CONTENT_KEY, groupConfiguration.panel)
val splitter = JBSplitter(false, .3f).apply {
splitterProportionKey = "EditLocalWhitelist.splitter"
splitterProportionKey = "EditTestScheme.splitter"
firstComponent = groupListPanel
secondComponent = detailsComponent
}
@@ -94,11 +94,11 @@ class EditLocalWhitelistPanel(private val project: Project,
fun getGroups(): List<LocalWhitelistGroup> = groupsModel.items
fun validateGroups(): List<ValidationInfo> {
for (whitelistGroup in groupsModel.items) {
val validationInfo = LocalWhitelistGroupConfiguration.validateWhitelistGroup(project, whitelistGroup,
groupConfiguration.groupIdTextField)
for (group in groupsModel.items) {
val validationInfo = EventsTestSchemeGroupConfiguration.validateTestSchemeGroup(project, group,
groupConfiguration.groupIdTextField)
if (validationInfo.isNotEmpty()) {
groupsList.selectedIndex = groupsModel.getElementIndex(whitelistGroup)
groupsList.selectedIndex = groupsModel.getElementIndex(group)
return validationInfo
}
}
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.internal.statistic.eventLog.validator.rules.impl.TestModeValidationRule
import com.intellij.openapi.project.Project
@@ -9,24 +9,24 @@ import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory
import com.jetbrains.jsonSchema.extension.SchemaType
internal class LocalWhitelistJsonSchemaProviderFactory : JsonSchemaProviderFactory {
override fun getProviders(project: Project): List<JsonSchemaFileProvider> = listOf(LocalWhitelistJsonSchemaFileProvider())
internal class EventsSchemeJsonSchemaProviderFactory : JsonSchemaProviderFactory {
override fun getProviders(project: Project): List<JsonSchemaFileProvider> = listOf(EventsSchemeJsonSchemaFileProvider())
private class LocalWhitelistJsonSchemaFileProvider : JsonSchemaFileProvider {
private class EventsSchemeJsonSchemaFileProvider : JsonSchemaFileProvider {
override fun isAvailable(file: VirtualFile): Boolean {
val isValidationRulesFile = file.getUserData(LOCAL_WHITELIST_VALIDATION_RULES_KEY) ?: false
val isValidationRulesFile = file.getUserData(EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY) ?: false
return isValidationRulesFile && TestModeValidationRule.isTestModeEnabled()
}
override fun getName(): String = "Local Whitelist"
override fun getName(): String = "Events Test Scheme"
override fun getSchemaFile(): VirtualFile? = JsonSchemaProviderFactory.getResourceFile(
LocalWhitelistJsonSchemaProviderFactory::class.java, "/schemas/local-whitelist.schema.json")
EventsSchemeJsonSchemaProviderFactory::class.java, "/schemas/events-test-scheme.schema.json")
override fun getSchemaType(): SchemaType = SchemaType.embeddedSchema
}
companion object {
val LOCAL_WHITELIST_VALIDATION_RULES_KEY = Key.create<Boolean>("statistics.localWhitelist.validation.rules.file")
val EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY = Key.create<Boolean>("statistics.events.test.scheme.validation.rules.file")
}
}
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.google.gson.Gson
import com.google.gson.JsonObject
@@ -10,7 +10,7 @@ import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.LocalInspectionToolSession
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.internal.statistic.StatisticsBundle
import com.intellij.internal.statistic.actions.TestParseEventLogWhitelistDialog
import com.intellij.internal.statistic.actions.TestParseEventsSchemeDialog
import com.intellij.internal.statistic.eventLog.whitelist.LocalWhitelistGroup
import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService
import com.intellij.json.JsonLanguage
@@ -45,14 +45,14 @@ import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
class LocalWhitelistGroupConfiguration(private val project: Project,
private val productionGroups: FUStatisticsWhiteListGroupsService.WLGroups,
initialGroup: LocalWhitelistGroup,
groupIdChangeListener: ((LocalWhitelistGroup) -> Unit)? = null) : Disposable {
class EventsTestSchemeGroupConfiguration(private val project: Project,
private val productionGroups: FUStatisticsWhiteListGroupsService.WLGroups,
initialGroup: LocalWhitelistGroup,
groupIdChangeListener: ((LocalWhitelistGroup) -> Unit)? = null) : Disposable {
val panel: JPanel
val groupIdTextField: TextFieldWithCompletion
private val log = logger<LocalWhitelistGroupConfiguration>()
private val log = logger<EventsTestSchemeGroupConfiguration>()
private var currentGroup: LocalWhitelistGroup = initialGroup
private val addCustomRuleCheckBox: JBCheckBox = JBCheckBox(StatisticsBundle.message("stats.use.custom.validation.rules"),
initialGroup.useCustomRules)
@@ -69,9 +69,9 @@ class LocalWhitelistGroupConfiguration(private val project: Project,
}
groupIdTextField = TextFieldWithCompletion(project, completionProvider, initialGroup.groupId, true, true, false)
tempFile = TestParseEventLogWhitelistDialog.createTempFile(project, "event-log-validation-rules", currentGroup.customRules)!!
tempFile.virtualFile.putUserData(LocalWhitelistJsonSchemaProviderFactory.LOCAL_WHITELIST_VALIDATION_RULES_KEY, true)
tempFile.putUserData(FUS_WHITELIST_COMMON_RULES_KEY, ProductionRules(productionGroups.rules))
tempFile = TestParseEventsSchemeDialog.createTempFile(project, "event-log-validation-rules", currentGroup.customRules)!!
tempFile.virtualFile.putUserData(EventsSchemeJsonSchemaProviderFactory.EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY, true)
tempFile.putUserData(FUS_TEST_SCHEME_COMMON_RULES_KEY, ProductionRules(productionGroups.rules))
validationRulesEditor = createEditor(project, tempFile)
validationRulesEditor.document.addDocumentListener(object : DocumentListener {
override fun documentChanged(event: com.intellij.openapi.editor.event.DocumentEvent) {
@@ -103,7 +103,7 @@ class LocalWhitelistGroupConfiguration(private val project: Project,
row {
cell {
addCustomRuleCheckBox()
ContextHelpLabel.create(StatisticsBundle.message("stats.local.whitelist.custom.rules.help"))()
ContextHelpLabel.create(StatisticsBundle.message("stats.test.scheme.custom.rules.help"))()
}
}
row {
@@ -175,30 +175,30 @@ class LocalWhitelistGroupConfiguration(private val project: Project,
}
fun validate(): List<ValidationInfo> {
return validateWhitelistGroup(project, currentGroup, groupIdTextField, tempFile)
return validateTestSchemeGroup(project, currentGroup, groupIdTextField, tempFile)
}
companion object {
internal val FUS_WHITELIST_COMMON_RULES_KEY = Key.create<ProductionRules>("statistics.localWhitelist.validation.rules.file")
internal val FUS_TEST_SCHEME_COMMON_RULES_KEY = Key.create<ProductionRules>("statistics.test.scheme.validation.rules.file")
fun validateWhitelistGroup(project: Project,
localWhitelistGroup: LocalWhitelistGroup,
groupIdTextField: JComponent): List<ValidationInfo> {
return validateWhitelistGroup(project, localWhitelistGroup, groupIdTextField, null)
fun validateTestSchemeGroup(project: Project,
testSchemeGroup: LocalWhitelistGroup,
groupIdTextField: JComponent): List<ValidationInfo> {
return validateTestSchemeGroup(project, testSchemeGroup, groupIdTextField, null)
}
private fun validateWhitelistGroup(project: Project,
localWhitelistGroup: LocalWhitelistGroup,
groupIdTextField: JComponent,
customRulesFile: PsiFile?): List<ValidationInfo> {
val groupId: String = localWhitelistGroup.groupId
private fun validateTestSchemeGroup(project: Project,
testSchemeGroup: LocalWhitelistGroup,
groupIdTextField: JComponent,
customRulesFile: PsiFile?): List<ValidationInfo> {
val groupId: String = testSchemeGroup.groupId
val validationInfo = mutableListOf<ValidationInfo>()
if (groupId.isEmpty()) {
validationInfo.add(ValidationInfo(StatisticsBundle.message("stats.specify.group.id"), groupIdTextField))
}
if (localWhitelistGroup.useCustomRules) {
validationInfo.addAll(validateCustomValidationRules(project, localWhitelistGroup.customRules, customRulesFile))
if (testSchemeGroup.useCustomRules) {
validationInfo.addAll(validateCustomValidationRules(project, testSchemeGroup.customRules, customRulesFile))
}
return validationInfo
}
@@ -210,7 +210,7 @@ class LocalWhitelistGroupConfiguration(private val project: Project,
customRulesFile
} else {
val psiFile = PsiFileFactory.getInstance(project).createFileFromText(JsonLanguage.INSTANCE, customRules)
psiFile.virtualFile.putUserData(LocalWhitelistJsonSchemaProviderFactory.LOCAL_WHITELIST_VALIDATION_RULES_KEY, true)
psiFile.virtualFile.putUserData(EventsSchemeJsonSchemaProviderFactory.EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY, true)
psiFile
}
if (!isValidJson(customRules)) return listOf(ValidationInfo(StatisticsBundle.message("stats.unable.to.parse.validation.rules")))
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.codeInsight.completion.CompletionContributor
import com.intellij.codeInsight.completion.CompletionParameters
@@ -18,7 +18,7 @@ internal class ValidationRulesCompletionContributor : CompletionContributor() {
override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
val file = parameters.originalFile
if (file.virtualFile?.getUserData(LocalWhitelistJsonSchemaProviderFactory.LOCAL_WHITELIST_VALIDATION_RULES_KEY) != true) return
if (file.virtualFile?.getUserData(EventsSchemeJsonSchemaProviderFactory.EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY) != true) return
val element = parameters.position
val parent = element.originalElement.parent as? JsonStringLiteral ?: return
@@ -37,7 +37,7 @@ internal class ValidationRulesCompletionContributor : CompletionContributor() {
}
resultSet.addAllElements(prefixVariants)
val commonRules = file.getUserData(LocalWhitelistGroupConfiguration.FUS_WHITELIST_COMMON_RULES_KEY)
val commonRules = file.getUserData(EventsTestSchemeGroupConfiguration.FUS_TEST_SCHEME_COMMON_RULES_KEY)
if (commonRules != null) {
result.addAllElements(commonRules.enums.map { LookupElementBuilder.create("{enum#$it}") })
result.addAllElements(commonRules.regexps.map { LookupElementBuilder.create("{regexp#$it}") })
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@Internal
package com.intellij.internal.statistic.actions.localWhitelist;
package com.intellij.internal.statistic.actions.scheme;
import org.jetbrains.annotations.ApiStatus.Internal;
@@ -4,8 +4,8 @@ package com.intellij.internal.statistic.toolwindow
import com.intellij.diagnostic.logging.LogConsoleBase
import com.intellij.internal.statistic.StatisticsBundle
import com.intellij.internal.statistic.actions.*
import com.intellij.internal.statistic.actions.localWhitelist.AddTestGroupToLocalWhitelistAction
import com.intellij.internal.statistic.actions.localWhitelist.EditLocalWhitelistAction
import com.intellij.internal.statistic.actions.scheme.AddGroupToTestSchemeAction
import com.intellij.internal.statistic.actions.scheme.EditEventsTestSchemeAction
import com.intellij.internal.statistic.eventLog.EventLogNotificationService
import com.intellij.internal.statistic.eventLog.LogEvent
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType.*
@@ -57,14 +57,14 @@ internal class StatisticsEventLogToolWindow(project: Project, private val record
topToolbarActions.add(RecordStateStatisticsEventLogAction(recorderId, false))
topToolbarActions.add(ShowChangedStateEventsAction(recorderId))
topToolbarActions.add(OpenEventLogFileAction(recorderId))
topToolbarActions.addSeparator(StatisticsBundle.message("stats.whitelist"))
topToolbarActions.add(ConfigureWhitelistAction(recorderId))
topToolbarActions.add(UpdateWhitelistAction(recorderId))
topToolbarActions.add(OpenWhitelistFileAction(recorderId))
topToolbarActions.addSeparator(StatisticsBundle.message("stats.local.whitelist"))
topToolbarActions.add(AddTestGroupToLocalWhitelistAction(recorderId))
topToolbarActions.add(CleanupLocalWhitelistAction())
topToolbarActions.add(EditLocalWhitelistAction(recorderId))
topToolbarActions.addSeparator(StatisticsBundle.message("stats.events.scheme"))
topToolbarActions.add(ConfigureEventsSchemeFileAction(recorderId))
topToolbarActions.add(UpdateEventsSchemeAction(recorderId))
topToolbarActions.add(OpenEventsSchemeFileAction(recorderId))
topToolbarActions.addSeparator(StatisticsBundle.message("stats.events.test.scheme"))
topToolbarActions.add(AddGroupToTestSchemeAction(recorderId))
topToolbarActions.add(CleanupEventsTestSchemeAction())
topToolbarActions.add(EditEventsTestSchemeAction(recorderId))
val toolbar = ActionManager.getInstance().createActionToolbar("FusEventLogToolWindow", topToolbarActions, true)
toolbar.setShowSeparatorTitles(true)
return toolbar.component
@@ -12,10 +12,10 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
import org.junit.Test
class CleanupLocalWhitelistActionTest : BasePlatformTestCase() {
class CleanupEventsTestSchemeActionTest : BasePlatformTestCase() {
@Test
fun testCleanupLocalWhitelist() {
fun testCleanupEventsTestScheme() {
val groupId = "test.group"
val recorderId = "FUS"
@@ -23,7 +23,7 @@ class CleanupLocalWhitelistActionTest : BasePlatformTestCase() {
WhitelistTestGroupStorage.getTestStorage(recorderId)!!.addTestGroup(LocalWhitelistGroup("groupId", false))
val dataContext = getProjectContext(myFixture.project)
val e = AnActionEvent(null, dataContext, "test", Presentation(), ActionManager.getInstance(), 0)
CleanupLocalWhitelistAction(recorderId).actionPerformed(e)
CleanupEventsTestSchemeAction(recorderId).actionPerformed(e)
TestCase.assertNull(
WhitelistTestGroupStorage.getTestStorage(recorderId)!!.getGroupRules(groupId)
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService
import com.intellij.testFramework.UsefulTestCase
@@ -7,7 +7,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
import org.intellij.lang.annotations.Language
class LocalWhitelistGroupConfigurationTest : BasePlatformTestCase() {
class EventsTestSchemeGroupConfigurationTest : BasePlatformTestCase() {
override fun setUp() {
super.setUp()
@@ -50,7 +50,7 @@ class LocalWhitelistGroupConfigurationTest : BasePlatformTestCase() {
globalRules.regexps = mapOf("integer" to "testIntegerRegexp")
globalRules.enums = mapOf("boolean" to setOf("true", "false"))
val validationInfo = LocalWhitelistGroupConfiguration.validateCustomValidationRules(project, rules, null)
val validationInfo = EventsTestSchemeGroupConfiguration.validateCustomValidationRules(project, rules, null)
assertEmpty("Validation errors were found: ${validationInfo.joinToString { "\"${it.message}\"" }}", validationInfo)
}
@@ -63,7 +63,7 @@ class LocalWhitelistGroupConfigurationTest : BasePlatformTestCase() {
}
}
""".trimIndent()
val validationInfo = LocalWhitelistGroupConfiguration.validateCustomValidationRules(project, rules, null)
val validationInfo = EventsTestSchemeGroupConfiguration.validateCustomValidationRules(project, rules, null)
UsefulTestCase.assertSize(1, validationInfo)
TestCase.assertTrue("Validation info should contains error",
validationInfo.first().message.contains("Line 4"))
@@ -78,7 +78,7 @@ class LocalWhitelistGroupConfigurationTest : BasePlatformTestCase() {
}
}
""".trimIndent()
val validationInfo = LocalWhitelistGroupConfiguration.validateCustomValidationRules(project, rules, null)
val validationInfo = EventsTestSchemeGroupConfiguration.validateCustomValidationRules(project, rules, null)
UsefulTestCase.assertSize(1, validationInfo)
TestCase.assertTrue("Validation info should contains incorrect eventId",
validationInfo.first().message.contains("Line 2"))
@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.actions.localWhitelist
package com.intellij.internal.statistic.actions.scheme
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.psi.PsiFile
@@ -118,8 +118,8 @@ class ValidationRulesCompletionContributorTest : BasePlatformTestCase() {
}
}
""".trimIndent())
file.putUserData(LocalWhitelistGroupConfiguration.FUS_WHITELIST_COMMON_RULES_KEY,
LocalWhitelistGroupConfiguration.ProductionRules(setOf("version", "integer"), setOf("boolean")))
file.putUserData(EventsTestSchemeGroupConfiguration.FUS_TEST_SCHEME_COMMON_RULES_KEY,
EventsTestSchemeGroupConfiguration.ProductionRules(setOf("version", "integer"), setOf("boolean")))
markValidationRulesFile(file)
myFixture.completeBasic()
val strings = myFixture.lookupElementStrings!!
@@ -127,6 +127,6 @@ class ValidationRulesCompletionContributorTest : BasePlatformTestCase() {
}
private fun markValidationRulesFile(file: PsiFile) {
file.virtualFile.putUserData(LocalWhitelistJsonSchemaProviderFactory.LOCAL_WHITELIST_VALIDATION_RULES_KEY, true)
file.virtualFile.putUserData(EventsSchemeJsonSchemaProviderFactory.EVENTS_TEST_SCHEME_VALIDATION_RULES_KEY, true)
}
}
@@ -16,14 +16,14 @@ stats.config.details=<html>We are asking your permission to send information abo
stats.cleanup.0.event.log=Cleanup {0} Event Log
stats.open.0.event.log=Open {0} Event Log
stats.open.0.whitelist.file=Open {0} Whitelist File
stats.open.0.local.whitelist.file=Open {0} Local Whitelist File
stats.open.0.scheme.file=Open {0} Scheme File
stats.open.0.test.scheme.file=Open {0} Test Scheme File
stats.feature.usage.statistics=Feature usage statistics
stats.file.0.does.not.exist=File {0} does not exist.
stats.whitelist=Whitelist:
stats.local.whitelist=Local Whitelist:
stats.update.whitelist=Update Whitelist
stats.updating.whitelist=Updating Whitelist
stats.events.scheme=Scheme:
stats.events.test.scheme=Test Scheme:
stats.update.events.scheme=Update Events Scheme
stats.updating.events.scheme=Updating Events Scheme
action.NotificationAction.RecordStateStatisticsEventLogAction.text.show.log.file=Show Log File
stats.logging.is.disabled=Logging is disabled. Please enable data sharing and restart IDE
stats.there.is.no.active.event.log=There's no active event log file. Please enable data sharing and restart IDE
@@ -40,17 +40,17 @@ There are 3 types of validation rules: \
<li><b><code>{util#class_name}</code></b> checks that the value is a class name from platform, JB plugin or a plugin from JB plugin repository with a java code (see CustomWhiteListRule).\
</ul> \
</html>
stats.cannot.find.test.whitelist.storage=Cannot find test whitelist storage
stats.updating.local.whitelist=Updating Local Whitelist...
stats.local.whitelist.was.updated=Local whitelist was updated
stats.failed.updating.local.whitelist.0=Failed updating local whitelist: {0}
stats.edit.local.whitelist=Edit Local Whitelist
stats.add.test.group.to.local.whitelist=Add Test Group to Local Whitelist
stats.cannot.find.test.scheme.storage=Cannot find events test scheme storage
stats.updating.test.scheme=Updating Events Test Scheme...
stats.test.scheme.was.updated=Test Scheme was updated
stats.failed.updating.test.scheme.0=Failed updating test scheme: {0}
stats.edit.test.scheme=Edit Events Test Scheme
stats.add.test.group.to.test.scheme=Add Group to Test Scheme
stats.use.custom.validation.rules=Use custom validation rules
stats.group.id=Group ID:
stats.local.whitelist.custom.rules.help=Should be used before whitelisting to test that validation rules for the group work correctly
stats.test.scheme.custom.rules.help=Should be used before registering group on the server to test that validation rules for the group work correctly
stats.select.group.to.view.or.edit.details=Select a group to view or edit its details here
stats.loading.validation.rules=Loading validation rules...
stats.loading.local.whitelist=Loading local whitelist...
stats.loading.test.scheme=Loading test scheme...
stats.failed.recording.state=Failed recording state collectors to log
stats.no.changed.events=There are no changed events
@@ -27,7 +27,7 @@ import java.util.Set;
* <ol>
* <li>
* If group is not whitelisted, add it to local whitelist with "Add Test Group to Local Whitelist" action.<br/>
* {@link com.intellij.internal.statistic.actions.localWhitelist.AddTestGroupToLocalWhitelistAction}
* {@link com.intellij.internal.statistic.actions.scheme.AddGroupToTestSchemeAction}
* </li>
* <li>
* Open toolwindow with event logs with "Show Statistics Event Log" action.<br/>
@@ -33,7 +33,7 @@ import java.util.Set;
* <ol>
* <li>
* If group is not whitelisted, add it to local whitelist with "Add Test Group to Local Whitelist" action.<br/>
* {@link com.intellij.internal.statistic.actions.localWhitelist.AddTestGroupToLocalWhitelistAction}
* {@link com.intellij.internal.statistic.actions.scheme.AddGroupToTestSchemeAction}
* </li>
* <li>
* Open toolwindow with event logs with "Show Statistics Event Log" action.<br/>
+2 -2
View File
@@ -150,8 +150,8 @@
<add-to-group group-id="Internal" anchor="last"/>
</group>
<action internal="true" id="TestParseEventLogWhitelistAction"
class="com.intellij.internal.statistic.actions.TestParseEventLogWhitelistAction">
<action internal="true" id="TestParseEventsSchemeAction"
class="com.intellij.internal.statistic.actions.TestParseEventsSchemeAction">
</action>
<action internal="true" id="CollectFUStatisticsAction"