Provide tw toolbar actions data context with the systemId (IDEA-198453)

This commit is contained in:
Vladislav.Soroka
2018-11-08 17:24:46 +03:00
parent f00d0ac299
commit 89a2a067a5
3 changed files with 7 additions and 4 deletions
@@ -16,6 +16,7 @@
package com.intellij.openapi.externalSystem.action;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsCollector;
import com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl;
import org.jetbrains.annotations.NotNull;
@@ -44,7 +45,9 @@ public abstract class ExternalSystemViewGearAction extends ExternalSystemToggleA
public void setSelected(@NotNull AnActionEvent e, boolean state) {
final ExternalProjectsViewImpl view = getView();
if (view != null){
ExternalSystemActionsCollector.trigger(getProject(e), getSystemId(e), this, e);
// es system id does not available in the action context, get it from the view
ProjectSystemId systemId = view.getSystemId();
ExternalSystemActionsCollector.trigger(getProject(e), systemId, this, e);
setSelected(view, state);
}
}
@@ -78,7 +78,6 @@ public class RefreshAllExternalProjectsAction extends AnAction implements AnActi
e.getPresentation().setEnabled(false);
return;
}
ExternalSystemActionsCollector.trigger(project, null, this, e);
final List<ProjectSystemId> systemIds = getSystemIds(e);
if (systemIds.isEmpty()) {
@@ -90,6 +89,7 @@ public class RefreshAllExternalProjectsAction extends AnAction implements AnActi
FileDocumentManager.getInstance().saveAllDocuments();
for (ProjectSystemId externalSystemId : systemIds) {
ExternalSystemActionsCollector.trigger(project, externalSystemId, this, e);
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(project, externalSystemId)
.forceWhenUptodate(true)
@@ -305,8 +305,8 @@ public class ExternalProjectsViewImpl extends SimpleToolWindowPanel implements D
ActionToolbar actionToolbar = actionManager.createActionToolbar(myExternalSystemId.getReadableName() + " View Toolbar",
(DefaultActionGroup)actionManager
.getAction("ExternalSystemView.ActionsToolbar"), true);
actionToolbar.setTargetComponent(myTree);
// make the view data context available for the toolbar actions
actionToolbar.setTargetComponent(this);
setToolbar(actionToolbar.getComponent());
setContent(ScrollPaneFactory.createScrollPane(myTree));