mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FB-125 Filter toolwindows from third-party plugins
This commit is contained in:
@@ -128,6 +128,11 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
return isDevelopedByJetBrains(plugin.getVendor());
|
||||
}
|
||||
|
||||
public static boolean isDevelopedByJetBrains(@Nullable PluginId pluginId) {
|
||||
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
|
||||
return plugin == null || plugin.isBundled() || isDevelopedByJetBrains(plugin.getVendor());
|
||||
}
|
||||
|
||||
public static boolean isDevelopedByJetBrains(@Nullable String vendorString) {
|
||||
if (vendorString == null) return false;
|
||||
for (String vendor : StringUtil.split(vendorString, ",")) {
|
||||
|
||||
+1
-4
@@ -2,8 +2,6 @@
|
||||
package com.intellij.internal.statistic.collectors.fus.actions.persistence;
|
||||
|
||||
import com.intellij.ide.actions.ActionsCollector;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.plugins.PluginManagerMain;
|
||||
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
|
||||
@@ -53,8 +51,7 @@ public class ActionsCollectorImpl extends ActionsCollector implements Persistent
|
||||
|
||||
private static boolean isDevelopedByJetBrains(@NotNull Class aClass) {
|
||||
final PluginId pluginId = PluginManagerCore.getPluginByClassName(aClass.getName());
|
||||
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
|
||||
return plugin == null || plugin.isBundled() || PluginManagerMain.isDevelopedByJetBrains(plugin);
|
||||
return PluginManagerMain.isDevelopedByJetBrains(pluginId);
|
||||
}
|
||||
|
||||
private State myState = new State();
|
||||
|
||||
+22
-4
@@ -1,10 +1,15 @@
|
||||
// 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.collectors.fus.actions.persistence;
|
||||
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.plugins.PluginManagerMain;
|
||||
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageLogger;
|
||||
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ToolWindowEP;
|
||||
import com.intellij.util.xmlb.annotations.MapAnnotation;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -23,31 +28,44 @@ import java.util.Map;
|
||||
}
|
||||
)
|
||||
public class ToolWindowCollector implements PersistentStateComponent<ToolWindowCollector.State> {
|
||||
private static final String DEFAULT_ID = "third.party.plugin.toolwindow";
|
||||
|
||||
public static ToolWindowCollector getInstance() {
|
||||
return ServiceManager.getService(ToolWindowCollector.class);
|
||||
}
|
||||
|
||||
public void recordActivation(String toolWindowId) {
|
||||
record(toolWindowId + " by Activation");
|
||||
record(toolWindowId, "Activation");
|
||||
}
|
||||
|
||||
//todo[kb] provide a proper way to track activations by clicks
|
||||
public void recordClick(String toolWindowId) {
|
||||
record(toolWindowId + " by Click");
|
||||
record(toolWindowId, "Click");
|
||||
}
|
||||
|
||||
private void record(String toolWindowId) {
|
||||
private void record(@Nullable String toolWindowId, @NotNull String source) {
|
||||
if (toolWindowId == null) return;
|
||||
State state = getState();
|
||||
if (state == null) return;
|
||||
|
||||
String key = ConvertUsagesUtil.escapeDescriptorName(toolWindowId);
|
||||
boolean isJB = isDevelopedByJetBrains(toolWindowId);
|
||||
final String key = ConvertUsagesUtil.escapeDescriptorName((isJB ? toolWindowId : DEFAULT_ID) + "_by_" + source);
|
||||
FeatureUsageLogger.INSTANCE.log("toolwindow", key);
|
||||
final Integer count = state.myValues.get(key);
|
||||
int value = count == null ? 1 : count + 1;
|
||||
state.myValues.put(key, value);
|
||||
}
|
||||
|
||||
public static boolean isDevelopedByJetBrains(@NotNull String toolWindowId) {
|
||||
for (ToolWindowEP ep : ToolWindowEP.EP_NAME.getExtensions()) {
|
||||
if (StringUtil.equals(toolWindowId, ep.id)) {
|
||||
final PluginId id = StringUtil.isNotEmpty(ep.factoryClass) ? PluginManagerCore.getPluginByClassName(ep.factoryClass) : null;
|
||||
return PluginManagerMain.isDevelopedByJetBrains(id);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private State myState = new State();
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user