use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class PyCharmEduInitialConfigurator method unregisterAction.
private static void unregisterAction(String actionId, String groupId) {
ActionManager actionManager = ActionManager.getInstance();
AnAction action = actionManager.getAction(actionId);
if (action != null) {
AnAction actionGroup = actionManager.getAction(groupId);
if (actionGroup != null && actionGroup instanceof DefaultActionGroup) {
((DefaultActionGroup) actionGroup).remove(action);
actionManager.unregisterAction(actionId);
}
}
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class PyExecuteFileLineMarkerProvider method collectSlowLineMarkers.
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
if (elements.isEmpty()) {
return;
}
Optional<PsiElement> psiElement = elements.stream().filter((element) -> element instanceof PsiFile).findFirst();
if (!psiElement.isPresent())
return;
final PsiElement file = psiElement.get();
final RunContextAction runAction = new PyStudyRunContextAction(DefaultRunExecutor.getRunExecutorInstance());
final PyExecuteFileExtensionPoint[] extensions = ApplicationManager.getApplication().getExtensions(PyExecuteFileExtensionPoint.EP_NAME);
final List<AnAction> actions = new ArrayList<>();
final DefaultActionGroup group = new DefaultActionGroup();
if (PlatformUtils.isPyCharmEducational()) {
group.add(runAction);
}
for (PyExecuteFileExtensionPoint extension : extensions) {
AnAction action = extension.getRunAction();
if (action != null && extension.accept(file.getProject())) {
actions.add(action);
group.add(action);
}
}
if (actions.isEmpty() && !PlatformUtils.isPyCharmEducational()) {
return;
}
Icon icon = PlatformUtils.isPyCharmEducational() ? AllIcons.Actions.Execute : actions.get(0).getTemplatePresentation().getIcon();
final LineMarkerInfo<PsiElement> markerInfo = new LineMarkerInfo<PsiElement>(file, file.getTextRange(), icon, Pass.LINE_MARKERS, e -> {
String text = "Execute '" + e.getContainingFile().getName() + "'";
return PlatformUtils.isPyCharmEducational() ? text : actions.get(0).getTemplatePresentation().getText();
}, null, GutterIconRenderer.Alignment.RIGHT) {
@Nullable
@Override
public GutterIconRenderer createGutterRenderer() {
return new LineMarkerGutterIconRenderer<PsiElement>(this) {
@Override
public AnAction getClickAction() {
return PlatformUtils.isPyCharmEducational() ? runAction : actions.get(0);
}
@Nullable
@Override
public ActionGroup getPopupMenuActions() {
if (!PlatformUtils.isPyCharmEducational() && actions.isEmpty()) {
return null;
}
if (actions.size() == 1) {
return null;
}
return group;
}
};
}
};
result.add(markerInfo);
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class PyStudyPluginConfigurator method getActionGroup.
@NotNull
@Override
public DefaultActionGroup getActionGroup(Project project) {
final DefaultActionGroup baseGroup = super.getActionGroup(project);
final DefaultActionGroup group = new DefaultActionGroup();
group.add(new PyStudyCheckAction());
group.addAll(baseGroup);
return group;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class SurroundWithTemplateHandler method invoke.
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!EditorModificationUtil.checkModificationAllowed(editor))
return;
DefaultActionGroup group = createActionGroup(project, editor, file);
if (group == null)
return;
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(CodeInsightBundle.message("templates.select.template.chooser.title"), group, DataManager.getInstance().getDataContext(editor.getContentComponent()), JBPopupFactory.ActionSelectionAid.MNEMONICS, false);
popup.showInBestPositionFor(editor);
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class ContentEntryTreeEditor method setContentEntryEditor.
/**
* @param contentEntryEditor : null means to clear the editor
*/
public void setContentEntryEditor(final ContentEntryEditor contentEntryEditor) {
if (myContentEntryEditor != null && myContentEntryEditor.equals(contentEntryEditor)) {
return;
}
if (myFileSystemTree != null) {
Disposer.dispose(myFileSystemTree);
myFileSystemTree = null;
}
if (myContentEntryEditor != null) {
myContentEntryEditor.removeContentEntryEditorListener(myContentEntryEditorListener);
myContentEntryEditor = null;
}
if (contentEntryEditor == null) {
((DefaultTreeModel) myTree.getModel()).setRoot(EMPTY_TREE_ROOT);
myTreePanel.setVisible(false);
if (myFileSystemTree != null) {
Disposer.dispose(myFileSystemTree);
}
return;
}
myTreePanel.setVisible(true);
myContentEntryEditor = contentEntryEditor;
myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
final ContentEntry entry = contentEntryEditor.getContentEntry();
assert entry != null : contentEntryEditor;
final VirtualFile file = entry.getFile();
if (file != null) {
myDescriptor.setRoots(file);
} else {
String path = VfsUtilCore.urlToPath(entry.getUrl());
myDescriptor.setTitle(FileUtil.toSystemDependentName(path));
}
final Runnable init = () -> {
//noinspection ConstantConditions
myFileSystemTree.updateTree();
myFileSystemTree.select(file, null);
};
myFileSystemTree = new FileSystemTreeImpl(myProject, myDescriptor, myTree, getContentEntryCellRenderer(), init, null) {
@Override
protected AbstractTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, Comparator<NodeDescriptor> comparator, FileChooserDescriptor descriptor, final Runnable onInitialized) {
return new MyFileTreeBuilder(tree, treeModel, treeStructure, comparator, descriptor, onInitialized);
}
};
myFileSystemTree.showHiddens(true);
Disposer.register(myProject, myFileSystemTree);
final NewFolderAction newFolderAction = new MyNewFolderAction();
final DefaultActionGroup mousePopupGroup = new DefaultActionGroup();
mousePopupGroup.add(myEditingActionsGroup);
mousePopupGroup.addSeparator();
mousePopupGroup.add(newFolderAction);
myFileSystemTree.registerMouseListener(mousePopupGroup);
}
Aggregations