mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Incorporated Yann's feedback.
This commit is contained in:
parent
864a45c579
commit
f089a2574c
@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.jetbrains.intellij' version '0.4.7'
|
||||
id 'org.jetbrains.intellij' version '0.4.8'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
@ -27,4 +27,4 @@ intellij {
|
||||
}
|
||||
|
||||
// Force javadoc rebuild before jar is built
|
||||
jar.dependsOn javadoc
|
||||
jar.dependsOn javadoc
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
package org.intellij.sdk.action;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@ -24,16 +23,16 @@ 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.
|
||||
* @param e 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
|
||||
* PopDialogAction class.
|
||||
* PopupDialogAction class.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(AnActionEvent anActionEvent) {
|
||||
return new AnAction[]{ new PopDialogAction("Action Added at Runtime",
|
||||
"Dynamic Action Demo",
|
||||
ActionBasicsIcons.Sdk_default_icon)
|
||||
public AnAction[] getChildren(AnActionEvent e) {
|
||||
return new AnAction[]{ new PopupDialogAction("Action Added at Runtime",
|
||||
"Dynamic Action Demo",
|
||||
ActionBasicsIcons.Sdk_default_icon)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,15 @@ import javax.swing.*;
|
||||
* 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.
|
||||
*/
|
||||
public class PopDialogAction extends AnAction {
|
||||
public class PopupDialogAction extends AnAction {
|
||||
|
||||
/**
|
||||
* This default constructor is used by the IntelliJ Platform framework to
|
||||
* instantiate this class based on plugin.xml declarations. Only needed in PopDialogAction
|
||||
* instantiate this class based on plugin.xml declarations. Only needed in PopupDialogAction
|
||||
* class because a second constructor is overridden.
|
||||
* @see AnAction#AnAction()
|
||||
*/
|
||||
public PopDialogAction() {
|
||||
public PopupDialogAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -35,12 +35,12 @@ public class PopDialogAction extends AnAction {
|
||||
* 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.
|
||||
* @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.
|
||||
* @param text The text to be displayed as a menu item.
|
||||
* @param description The description of the menu item.
|
||||
* @param icon The icon to be used with the menu item.
|
||||
*/
|
||||
public PopDialogAction(@Nullable String menuText, @Nullable String menuDescription, @Nullable Icon menuIcon) {
|
||||
super(menuText, menuDescription, menuIcon);
|
||||
public PopupDialogAction(@Nullable String text, @Nullable String description, @Nullable Icon icon) {
|
||||
super(text, description, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,13 +66,13 @@ public class PopDialogAction extends AnAction {
|
||||
/**
|
||||
* Determines whether this menu item is available for the current context.
|
||||
* Requires a project to be open.
|
||||
* @param evnt Event received when the associated group-id menu is chosen.
|
||||
* @param e Event received when the associated group-id menu is chosen.
|
||||
*/
|
||||
@Override
|
||||
public void update(AnActionEvent evnt) {
|
||||
public void update(AnActionEvent e) {
|
||||
// Set the availability based on whether a project is open
|
||||
Project project = evnt.getProject();
|
||||
evnt.getPresentation().setEnabledAndVisible(project != null);
|
||||
Project project = e.getProject();
|
||||
e.getPresentation().setEnabledAndVisible(project != null);
|
||||
}
|
||||
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
The optional "use-shortcut-of" attribute specifies the ID of the action whose keyboard shortcut this action will use.
|
||||
The optional "description" attribute specifies the text which is displayed in the status bar when the action is focused.
|
||||
The optional "icon" attribute specifies the icon which is displayed on the toolbar button or next to the menu item. -->
|
||||
<action id="org.intellij.sdk.action.PopDialogAction" class="org.intellij.sdk.action.PopDialogAction"
|
||||
<action id="org.intellij.sdk.action.PopupDialogAction" class="org.intellij.sdk.action.PopupDialogAction"
|
||||
text="Pop Dialog Action" description="SDK Action Example" icon="ActionBasicsIcons.Sdk_default_icon">
|
||||
<!-- The <keyboard-shortcut> node specifies the keyboard shortcut for the action. An action can have several keyboard shortcuts.
|
||||
The mandatory "first-keystroke" attribute specifies the first keystroke of the action. The key strokes are specified according to the regular Swing rules.
|
||||
@ -80,12 +80,12 @@
|
||||
<!-- All off the following menu groups add the action SimplePopDialogAction to menus in different ways.
|
||||
Note the action ids are unique. -->
|
||||
<!-- GroupedActions demonstrates declaring an action group using the default ActionGroup implementation provided by the
|
||||
IntelliJ Platform framework. (Note the lack of a "class" attribute.) GroupedActions gets inserted after PopDialogAction
|
||||
IntelliJ Platform framework. (Note the lack of a "class" attribute.) GroupedActions gets inserted after PopupDialogAction
|
||||
in the Tools menu. Because the group's implementation is default, it cannot impose enable/disable conditions. Instead it
|
||||
must rely on the conditions imposed by the parent menu where it is inserted. It declares one action in the group. -->
|
||||
<group id="org.intellij.sdk.action.GroupedActions" text="Static Grouped Actions" popup="true" icon="ActionBasicsIcons.Sdk_default_icon">
|
||||
<add-to-group group-id="ToolsMenu" anchor="after" relative-to-action="org.intellij.sdk.action.PopDialogAction"/>
|
||||
<action class="org.intellij.sdk.action.PopDialogAction" id="org.intellij.sdk.action.GroupPopDialogAction"
|
||||
<add-to-group group-id="ToolsMenu" anchor="after" relative-to-action="org.intellij.sdk.action.PopupDialogAction"/>
|
||||
<action class="org.intellij.sdk.action.PopupDialogAction" id="org.intellij.sdk.action.GroupPopDialogAction"
|
||||
text="A Group Action" description="SDK Static Grouped Action Example" icon="ActionBasicsIcons.Sdk_default_icon">
|
||||
</action>
|
||||
</group>
|
||||
@ -94,7 +94,7 @@
|
||||
<group id="org.intellij.sdk.action.CustomDefaultActionGroup" class="org.intellij.sdk.action.CustomDefaultActionGroup" popup="true"
|
||||
text="Popup Grouped Actions" description="Custom DefaultActionGroup Demo" icon="ActionBasicsIcons.Sdk_default_icon">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||
<action class="org.intellij.sdk.action.PopDialogAction" id="org.intellij.sdk.action.CustomGroupedAction"
|
||||
<action class="org.intellij.sdk.action.PopupDialogAction" id="org.intellij.sdk.action.CustomGroupedAction"
|
||||
text="A Popup Action" description="SDK Popup Grouped Action Example" icon="ActionBasicsIcons.Sdk_default_icon"/>
|
||||
</group>
|
||||
<!-- DynamicActionGroup demonstrates declaring an action group without a static action declaration.
|
||||
|
Loading…
x
Reference in New Issue
Block a user