diff --git a/register_actions/register_actions.iml b/register_actions/register_actions.iml deleted file mode 100644 index 3700dfbf1..000000000 --- a/register_actions/register_actions.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/register_actions/resources/META-INF/plugin.xml b/register_actions/resources/META-INF/plugin.xml deleted file mode 100644 index 2d40c39e1..000000000 --- a/register_actions/resources/META-INF/plugin.xml +++ /dev/null @@ -1,88 +0,0 @@ - - org.jetbrains.tutorials.actions.RegisterActions - Sample for working with IntelliJ Action System - 1.1 - JetBrains - - Illustration of the Action System with various registration variants - - Refactor to give users feedback when menu items are selected. - - - com.intellij.modules.platform - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/register_actions/src/org/jetbrains/tutorials/actions/CustomDefaultActionGroup.java b/register_actions/src/org/jetbrains/tutorials/actions/CustomDefaultActionGroup.java deleted file mode 100644 index b36e4d75b..000000000 --- a/register_actions/src/org/jetbrains/tutorials/actions/CustomDefaultActionGroup.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package org.jetbrains.tutorials.actions; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.editor.Editor; - -/** - * Creates an action group to contain menu actions. See plugin.xml declarations. - * @see DefaultActionGroup - * @author Anna Bulenkova - */ -public class CustomDefaultActionGroup extends DefaultActionGroup { - - /** - * Given CustomDefaultActionGroup is derived from AnAction, in this context - * update() determines whether the action group itself should be enabled or disabled. - * Requires an editor to be active in order to enable the group functionality. - * @see com.intellij.openapi.actionSystem.AnAction#update(AnActionEvent) - * @param event Event received when the associated group-id menu is chosen. - */ - @Override - public void update(AnActionEvent event) { - // Enable/disable depending on whether user is editing - Editor editor = event.getData(CommonDataKeys.EDITOR); - event.getPresentation().setEnabled(editor != null); - // Always make visible. - event.getPresentation().setVisible(true); - // Take this opportunity to set an icon for the menu entry. - event.getPresentation().setIcon(AllIcons.General.Error); - } -} diff --git a/register_actions/src/org/jetbrains/tutorials/actions/DynamicActionGroup.java b/register_actions/src/org/jetbrains/tutorials/actions/DynamicActionGroup.java deleted file mode 100644 index f2e521dc4..000000000 --- a/register_actions/src/org/jetbrains/tutorials/actions/DynamicActionGroup.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package org.jetbrains.tutorials.actions; - -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import org.jetbrains.annotations.*; - -/** - * Demonstrates adding an action group to a menu statically in plugin.xml, and then creating a menu item - * within the group at runtime. See plugin.xml for the declaration of DynamicActionGroup, - * and note the group declaration does not contain an action. - * DynamicActionGroup is based on ActionGroup because menu children are determined - * on rules other than just positional constraints. - * - * @author Anna Bulenkova - * @see ActionGroup - */ -public class DynamicActionGroup extends ActionGroup { - - /** - * Returns an array of menu actions for the group. - * - * @param anActionEvent Event received when the associated group-id menu is chosen. - * @return AnAction[] An instance of AnAction, in this case containing a single instance of the - * SimplePopDialogAction class. - */ - @NotNull - @Override - public AnAction[] getChildren(AnActionEvent anActionEvent) { - return new AnAction[]{ new SimplePopDialogAction("Action Added at Runtime", - "Dynamic Action Demo", - null) - }; - } - -} diff --git a/register_actions/src/org/jetbrains/tutorials/actions/SimplePopDialogAction.java b/register_actions/src/org/jetbrains/tutorials/actions/SimplePopDialogAction.java deleted file mode 100755 index 13de550dd..000000000 --- a/register_actions/src/org/jetbrains/tutorials/actions/SimplePopDialogAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package org.jetbrains.tutorials.actions; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.pom.Navigatable; -import org.jetbrains.annotations.*; - -import javax.swing.*; - -/** - * Action class to demonstrate how to interact with the IntelliJ Platform. - * The only action this class performs is to provide the user with a popup dialog as feedback. - * Typically this class is instantiated by the IntelliJ Platform framework based on declarations - * in the plugin.xml file. But when added at runtime this class is instantiated by an action group. - * @see com.intellij.openapi.actionSystem.AnAction - * @see com.intellij.openapi.actionSystem.AnActionEvent - */ -public class SimplePopDialogAction extends AnAction { - - /** - * This default constructor is used by the IntelliJ Platform framework to - * instantiate this class based on plugin.xml declarations. Only needed in SimplePopDialogAction - * class because another constructor is overridden. - * @see AnAction#AnAction() - */ - public SimplePopDialogAction() { - super(); - } - - /** - * This constructor is used to support dynamically added menu actions. - * It sets the text, description to be displayed for the menu item. - * Otherwise, the default AnAction constructor is used by the IntelliJ Platform. - * @see AnAction#AnAction(String, String, Icon) - * @param menuText The text to be displayed as a menu item. - * @param menuDescription The description of the menu item. - * @param menuIcon The icon to be used with the menu item. - */ - public SimplePopDialogAction(@Nullable String menuText, @Nullable String menuDescription, @Nullable Icon menuIcon) { - super(menuText, menuDescription, menuIcon); - } - - /** - * Gives the user feedback when the dynamic action menu is chosen. - * Pops a simple message dialog. See the psi_demo plugin for an - * example of how to use AnActionEvent to access data. - * @param anActionEvent Event received when the associated menu item is chosen. - */ - @Override - public void actionPerformed(@NotNull AnActionEvent anActionEvent) { - // Using the event, create and show a dialog - Project currentProject = anActionEvent.getProject(); - StringBuffer dlgMsg = new StringBuffer(anActionEvent.getPresentation().getText() + " Selected!"); - String dlgTitle = anActionEvent.getPresentation().getDescription(); - // If an element is selected in the editor, add info about it. - Navigatable nav = anActionEvent.getData(CommonDataKeys.NAVIGATABLE); - if (nav != null) { - dlgMsg.append(String.format("\nSelected Element: %s", nav.toString())); - } - Messages.showMessageDialog(currentProject, dlgMsg.toString(), dlgTitle, Messages.getInformationIcon()); - } - - /** - * Determines whether this menu item is available for the current context. - * Requires a project to be open. - * @param anActionEvent Event received when the associated group-id menu is chosen. - */ - @Override - public void update(AnActionEvent anActionEvent) { - // Set the availability based on whether a project is open - Project project = anActionEvent.getProject(); - anActionEvent.getPresentation().setEnabledAndVisible(project != null); - } - -}