mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Update action system tutorial
Clean up structure, link from necessary places, update sample plugin code to demonstrate best practices, fix some English
This commit is contained in:
parent
f0c2d8a50c
commit
0caaec2817
@ -2,9 +2,6 @@ package org.jetbrains.tutorials.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public class CustomGroupedAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent anActionEvent) {
|
||||
|
@ -2,13 +2,9 @@ package org.jetbrains.tutorials.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public class GroupedAction extends AnAction {
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
event.getPresentation().setEnabledAndVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,27 +1,26 @@
|
||||
package org.jetbrains.tutorials.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public class SimpleAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent anActionEvent) {
|
||||
Object navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||
if (navigatable != null) {
|
||||
Messages.showDialog(navigatable.toString(), "Selected Element:", new String[]{"OK"}, -1, null);
|
||||
Project project = anActionEvent.getProject();
|
||||
Navigatable navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||
if (project != null && navigatable != null) {
|
||||
Messages.showMessageDialog(project, navigatable.toString(), "Selected Element", Messages.getInformationIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent anActionEvent) {
|
||||
final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
|
||||
if (project != null)
|
||||
return;
|
||||
Object navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||
anActionEvent.getPresentation().setVisible(navigatable != null);
|
||||
Project project = anActionEvent.getProject();
|
||||
Navigatable navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||
anActionEvent.getPresentation().setEnabledAndVisible(project != null && navigatable != null);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user