mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Feature event log: collect open/close dialog events
(cherry picked from commit da59ad8)
This commit is contained in:
+33
@@ -1,6 +1,9 @@
|
||||
// Copyright 2000-2018 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.eventLog
|
||||
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
|
||||
object FeatureUsageUiEvents {
|
||||
private const val UI_RECORDER_ID = "ui-recorder"
|
||||
|
||||
@@ -8,10 +11,20 @@ object FeatureUsageUiEvents {
|
||||
private val APPLY_CONFIGURABLE_DATA = HashMap<String, Any>()
|
||||
private val RESET_CONFIGURABLE_DATA = HashMap<String, Any>()
|
||||
|
||||
private val SHOW_DIALOG_DATA = ContainerUtil.newHashMap<String, Any>()
|
||||
private val CLOSE_OK_DIALOG_DATA = ContainerUtil.newHashMap<String, Any>()
|
||||
private val CLOSE_CANCEL_DIALOG_DATA = ContainerUtil.newHashMap<String, Any>()
|
||||
|
||||
init {
|
||||
SELECT_CONFIGURABLE_DATA["type"] = "select"
|
||||
APPLY_CONFIGURABLE_DATA["type"] = "apply"
|
||||
RESET_CONFIGURABLE_DATA["type"] = "reset"
|
||||
|
||||
SHOW_DIALOG_DATA["type"] = "show"
|
||||
CLOSE_OK_DIALOG_DATA["type"] = "close"
|
||||
CLOSE_OK_DIALOG_DATA["code"] = DialogWrapper.OK_EXIT_CODE
|
||||
CLOSE_CANCEL_DIALOG_DATA["type"] = "close"
|
||||
CLOSE_CANCEL_DIALOG_DATA["code"] = DialogWrapper.CANCEL_EXIT_CODE
|
||||
}
|
||||
|
||||
fun logSelectConfigurable(name: String) {
|
||||
@@ -25,4 +38,24 @@ object FeatureUsageUiEvents {
|
||||
fun logResetConfigurable(name: String) {
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, RESET_CONFIGURABLE_DATA)
|
||||
}
|
||||
|
||||
fun logShowDialog(name: String) {
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, SHOW_DIALOG_DATA)
|
||||
}
|
||||
|
||||
fun logCloseDialog(name: String, exitCode: Int) {
|
||||
val customData: MutableMap<String, Any>
|
||||
if (exitCode == DialogWrapper.OK_EXIT_CODE) {
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, CLOSE_OK_DIALOG_DATA)
|
||||
}
|
||||
else if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, CLOSE_CANCEL_DIALOG_DATA)
|
||||
}
|
||||
else {
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, SHOW_DIALOG_DATA)
|
||||
customData = ContainerUtil.newHashMap<String, Any>(CLOSE_OK_DIALOG_DATA)
|
||||
customData["code"] = exitCode
|
||||
FeatureUsageLogger.log(UI_RECORDER_ID, name, customData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.actions.ActionsCollector;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageUiEvents;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
@@ -21,6 +22,7 @@ import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
@@ -426,6 +428,7 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
|
||||
public final void close(int exitCode) {
|
||||
logCloseDialogEvent(exitCode);
|
||||
close(exitCode, exitCode != CANCEL_EXIT_CODE);
|
||||
}
|
||||
|
||||
@@ -1621,6 +1624,7 @@ public abstract class DialogWrapper {
|
||||
* @see #showAndGetOk()
|
||||
*/
|
||||
public void show() {
|
||||
logShowDialogEvent();
|
||||
invokeShow();
|
||||
}
|
||||
|
||||
@@ -1775,6 +1779,20 @@ public abstract class DialogWrapper {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void logCloseDialogEvent(int exitCode) {
|
||||
final String title = getTitle();
|
||||
if (StringUtil.isNotEmpty(title)) {
|
||||
FeatureUsageUiEvents.INSTANCE.logCloseDialog(title, exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void logShowDialogEvent() {
|
||||
final String title = getTitle();
|
||||
if (StringUtil.isNotEmpty(title)) {
|
||||
FeatureUsageUiEvents.INSTANCE.logShowDialog(title);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for dialog wrapper actions that need to ensure that only
|
||||
* one action for the dialog is running.
|
||||
|
||||
Reference in New Issue
Block a user