mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27: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.*;
|
import com.intellij.openapi.actionSystem.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Anna Bulenkova
|
|
||||||
*/
|
|
||||||
public class CustomGroupedAction extends AnAction {
|
public class CustomGroupedAction extends AnAction {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(AnActionEvent anActionEvent) {
|
public void actionPerformed(AnActionEvent anActionEvent) {
|
||||||
|
@ -2,13 +2,9 @@ package org.jetbrains.tutorials.actions;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.*;
|
import com.intellij.openapi.actionSystem.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Anna Bulenkova
|
|
||||||
*/
|
|
||||||
public class GroupedAction extends AnAction {
|
public class GroupedAction extends AnAction {
|
||||||
@Override
|
@Override
|
||||||
public void update(AnActionEvent event) {
|
public void update(AnActionEvent event) {
|
||||||
event.getPresentation().setEnabledAndVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
package org.jetbrains.tutorials.actions;
|
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.project.Project;
|
||||||
import com.intellij.openapi.ui.Messages;
|
import com.intellij.openapi.ui.Messages;
|
||||||
|
import com.intellij.pom.Navigatable;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Anna Bulenkova
|
|
||||||
*/
|
|
||||||
public class SimpleAction extends AnAction {
|
public class SimpleAction extends AnAction {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(AnActionEvent anActionEvent) {
|
public void actionPerformed(AnActionEvent anActionEvent) {
|
||||||
Object navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
Project project = anActionEvent.getProject();
|
||||||
if (navigatable != null) {
|
Navigatable navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||||
Messages.showDialog(navigatable.toString(), "Selected Element:", new String[]{"OK"}, -1, null);
|
if (project != null && navigatable != null) {
|
||||||
|
Messages.showMessageDialog(project, navigatable.toString(), "Selected Element", Messages.getInformationIcon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(AnActionEvent anActionEvent) {
|
public void update(AnActionEvent anActionEvent) {
|
||||||
final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
|
Project project = anActionEvent.getProject();
|
||||||
if (project != null)
|
Navigatable navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
||||||
return;
|
anActionEvent.getPresentation().setEnabledAndVisible(project != null && navigatable != null);
|
||||||
Object navigatable = anActionEvent.getData(CommonDataKeys.NAVIGATABLE);
|
|
||||||
anActionEvent.getPresentation().setVisible(navigatable != null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user