From 4e8e6af935291d4b2f2962642804b7b8b59e114e Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 30 Jun 2017 13:51:41 +0300 Subject: [PATCH] [project view] track pane selection from content manager --- .../ide/projectView/impl/ProjectViewImpl.java | 11 +++++++- .../ide/projectView/impl/statistics.kt | 28 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 platform/lang-impl/src/com/intellij/ide/projectView/impl/statistics.kt diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index 5ccdd2e85c2b..5c678abaef17 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -106,6 +106,8 @@ import java.awt.*; import java.util.*; import java.util.List; +import static com.intellij.ide.projectView.impl.StatisticsKt.triggerProjectViewPane; + @State(name = "ProjectView", storages = @Storage(StoragePathMacros.WORKSPACE_FILE)) public class ProjectViewImpl extends ProjectView implements PersistentStateComponent, Disposable, QuickActionProvider, BusyObject { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.impl.ProjectViewImpl"); @@ -546,7 +548,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo @Override public void selectionChanged(ContentManagerEvent event) { if (event.getOperation() == ContentManagerEvent.ContentOperation.add) { - viewSelectionChanged(); + viewSelectionChanged(true); } } }); @@ -575,6 +577,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo } private boolean viewSelectionChanged() { + return viewSelectionChanged(false); + } + + private boolean viewSelectionChanged(boolean fromContentManager) { Content content = getContentManager().getSelectedContent(); if (content == null) return false; final String id = content.getUserData(ID_KEY); @@ -584,6 +590,9 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo if (newPane == null) return false; newPane.setSubId(subId); showPane(newPane); + if (fromContentManager) { + triggerProjectViewPane(myCurrentViewId, myCurrentViewSubId); + } ProjectViewSelectInTarget target = getProjectViewSelectInTarget(newPane); if (target != null) target.setSubId(subId); if (isAutoscrollFromSource(id)) { diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/statistics.kt b/platform/lang-impl/src/com/intellij/ide/projectView/impl/statistics.kt new file mode 100644 index 000000000000..bb42b146c88b --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/statistics.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.projectView.impl + +import com.intellij.internal.statistic.UsageTrigger +import com.intellij.internal.statistic.beans.ConvertUsagesUtil.ensureProperKey + +private val prefix = "project.view.pane" + +internal fun triggerProjectViewPane(id: String?, subId: String?) { + if (id == null) return + val featureString = if (subId == null) "$prefix.$id" else "$prefix.$id.$subId" + val key = ensureProperKey(featureString) + UsageTrigger.trigger(key) +}