package jetbrains.mps.ide.devkit.actions; /*Generated by MPS */ import jetbrains.mps.workbench.action.BaseAction; import javax.swing.Icon; import com.intellij.openapi.actionSystem.AnActionEvent; import java.util.Map; import com.intellij.openapi.project.Project; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import com.intellij.ide.structureView.StructureViewBuilder; import com.intellij.ide.structureView.StructureView; import com.intellij.ide.util.FileStructurePopup; public class ShowStructure_Action extends BaseAction { private static final Icon ICON = null; public ShowStructure_Action() { super("Show Structure", "", ICON); this.setIsAlwaysVisible(false); this.setExecuteOutsideCommand(true); } @Override public boolean isDumbAware() { return true; } @Override protected boolean collectActionData(AnActionEvent event, final Map<String, Object> _params) { if (!(super.collectActionData(event, _params))) { return false; } { Project p = event.getData(CommonDataKeys.PROJECT); if (p == null) { return false; } } { FileEditor p = event.getData(PlatformDataKeys.FILE_EDITOR); if (p == null) { return false; } } { VirtualFile p = event.getData(CommonDataKeys.VIRTUAL_FILE); if (p == null) { return false; } } return true; } @Override public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) { final StructureViewBuilder structureViewBuilder = event.getData(PlatformDataKeys.FILE_EDITOR).getStructureViewBuilder(); if (structureViewBuilder == null) { return; } StructureView structureView = structureViewBuilder.createStructureView(event.getData(PlatformDataKeys.FILE_EDITOR), event.getData(CommonDataKeys.PROJECT)); FileStructurePopup popup = new FileStructurePopup(event.getData(CommonDataKeys.PROJECT), event.getData(PlatformDataKeys.FILE_EDITOR), structureView, true); if (event.getData(CommonDataKeys.VIRTUAL_FILE) != null) { // todo: look like this action is unnecessary (it's just ctrl+f12 idea action by logic and implementation) popup.setTitle(event.getData(CommonDataKeys.VIRTUAL_FILE).getName()); } popup.show(); } }