[project view] track pane selection from content manager

This commit is contained in:
Daniil Ovchinnikov
2017-06-30 13:57:16 +03:00
parent abe554019b
commit 4e8e6af935
2 changed files with 38 additions and 1 deletions
@@ -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<Element>, 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)) {
@@ -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)
}