本文整理匯總了Java中com.intellij.openapi.actionSystem.AnActionEvent.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java AnActionEvent.getData方法的具體用法?Java AnActionEvent.getData怎麽用?Java AnActionEvent.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.actionSystem.AnActionEvent
的用法示例。
在下文中一共展示了AnActionEvent.getData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getProject();
if (view == null || project == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory directory = directories[0];
if (directory == null) return;
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
createItem(view, project, directory, course);
}
示例2: update
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void update(@NotNull AnActionEvent event) {
final Project project = event.getProject();
final Presentation presentation = event.getPresentation();
if (project == null) {
return;
}
presentation.setEnabledAndVisible(false);
if (!CCUtils.isCourseCreator(project)) {
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
presentation.setEnabledAndVisible(true);
}
示例3: isAvailable
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@CheckReturnValue
@VisibleForTesting
@SuppressWarnings("WeakerAccess")
static boolean isAvailable(@Nonnull AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return false;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return false;
}
final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
final ProjectFileIndex fileIndex = rootManager.getFileIndex();
final Optional<PsiDirectory> sourceDirectory = Stream.of(view.getDirectories())
.filter(directory -> {
final VirtualFile virtualFile = directory.getVirtualFile();
return fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES);
})
.findFirst();
return sourceDirectory.isPresent();
}
示例4: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
List<VirtualFile> javaFiles = Utils.getSelectJavaFiles(e, true);
int size = javaFiles.size();
for (int i = 0; i < javaFiles.size(); i++) {
VirtualFile vf = javaFiles.get(i);
if (!Utils.hasOrm(project, vf)) {
javaFiles.remove(i);
i--;
}
}
// if (!javaFiles.isEmpty())
{
NewProviderDialog dialog = new NewProviderDialog();
dialog.init(project, e.getData(PlatformDataKeys.VIRTUAL_FILE), javaFiles);
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
dialog.dispose();
}
}
示例5: getTranslation
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
private void getTranslation(AnActionEvent event) {
Editor mEditor = event.getData(PlatformDataKeys.EDITOR);
Project project = event.getData(PlatformDataKeys.PROJECT);
String basePath = project.getBasePath();
if (null == mEditor) {
return;
}
SelectionModel model = mEditor.getSelectionModel();
String selectedText = model.getSelectedText();
if (TextUtils.isEmpty(selectedText)) {
selectedText = getCurrentWords(mEditor);
if (TextUtils.isEmpty(selectedText)) {
return;
}
}
String queryText = strip(addBlanks(selectedText));
new Thread(new RequestRunnable(mEditor, queryText,basePath)).start();
}
示例6: collectActionData
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
protected boolean collectActionData(AnActionEvent event, final Map<String, Object> _params) {
if (!(super.collectActionData(event, _params))) {
return false;
}
{
SModel model = event.getData(MPSCommonDataKeys.CONTEXT_MODEL);
if (model == null) {
return false;
}
}
{
SNode node = event.getData(MPSCommonDataKeys.NODE);
if (node == null) {
return false;
}
}
return true;
}
示例7: update
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null || !(course instanceof RemoteCourse)) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE)) return;
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory taskDir = directories[0];
if (taskDir == null || !taskDir.getName().contains(EduNames.TASK)) {
return;
}
final PsiDirectory lessonDir = taskDir.getParentDirectory();
if (lessonDir == null) return;
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && lesson.getId() > 0 && ((RemoteCourse)course).getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
final com.jetbrains.edu.learning.courseFormat.tasks.Task task = lesson.getTask(taskDir.getName());
if (task.getStepId() <= 0) {
e.getPresentation().setText("Upload Task to Stepik");
}
}
}
示例8: getPsiClassFromContext
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
private PsiClass getPsiClassFromContext(AnActionEvent e) {
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (psiFile == null || editor == null) {
return null;
}
int offset = editor.getCaretModel().getOffset();
PsiElement element = psiFile.findElementAt(offset);
return PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
示例9: getSelectJavaFiles
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public static List<VirtualFile> getSelectJavaFiles(AnActionEvent e, boolean recursive) {
List<VirtualFile> list = new ArrayList<VirtualFile>();
VirtualFile[] vfs = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
if (vfs != null) {
for (VirtualFile vf : vfs) {
list.addAll(Utils.getJavaFileTree(e.getProject(), vf, recursive));
}
}
return list;
}
示例10: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
unpackCourseArchive(project);
}
示例11: getPsiClassFromContext
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
private PsiClass getPsiClassFromContext(AnActionEvent e) {
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
// psiFile.getViewProvider().getVirtualFile()
if (psiFile == null || editor == null) {
return null;
}
int offset = editor.getCaretModel().getOffset();
PsiElement element = psiFile.findElementAt(offset);
return PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
示例12: update
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null || !(course instanceof RemoteCourse)) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE)) return;
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory lessonDir = directories[0];
if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && ((RemoteCourse)course).getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
if (lesson.getId() <= 0) {
e.getPresentation().setText("Upload Lesson to Stepik");
}
}
}
示例13: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
VirtualFile[] data = e.getData(DataKeys.VIRTUAL_FILE_ARRAY);
// TODO: insert action logic here
PatcherDialog dialog = new PatcherDialog(e);
dialog.setSize(600, 400);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
dialog.requestFocus();
}
示例14: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory taskDir = directories[0];
if (taskDir == null || !taskDir.getName().contains(EduNames.TASK)) {
return;
}
final PsiDirectory lessonDir = taskDir.getParentDirectory();
if (lessonDir == null) return;
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson == null) return;
final com.jetbrains.edu.learning.courseFormat.tasks.Task task = lesson.getTask(taskDir.getName());
if (task == null) return;
ProgressManager.getInstance().run(new Task.Modal(project, "Uploading Task", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Uploading task to " + EduStepicNames.STEPIC_URL);
if (task.getStepId() <= 0) {
CCStepicConnector.postTask(project, task, lesson.getId());
}
else {
CCStepicConnector.updateTask(project, task);
}
}
});
}
示例15: actionPerformed
import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (course instanceof RemoteCourse) {
ProgressManager.getInstance().run(new Task.Modal(project, "Updating Course", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(false);
for (Lesson lesson : course.getLessons()) {
indicator.checkCanceled();
indicator.setText2("Publishing lesson " + lesson.getIndex());
if (lesson.getId() > 0) {
CCStepicConnector.updateLesson(project, lesson);
}
else {
final int lessonId = CCStepicConnector.postLesson(project, lesson);
if (lessonId != -1) {
final List<Integer> sections = ((RemoteCourse)course).getSections();
final Integer sectionId = sections.get(sections.size() - 1);
CCStepicConnector.postUnit(lessonId, lesson.getIndex(), sectionId, project);
}
}
indicator.setFraction((double)lesson.getIndex()/course.getLessons().size());
}
}
});
}
else {
CCStepicConnector.postCourseWithProgress(project, course);
}
EduUsagesCollector.courseUploaded();
}