當前位置: 首頁>>代碼示例>>Java>>正文


Java AnActionEvent.getData方法代碼示例

本文整理匯總了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);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:21,代碼來源:CCCreateStudyItemActionBase.java

示例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);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:22,代碼來源:CCChangeCourseInfo.java

示例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();
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:25,代碼來源:NewClassAction.java

示例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();
    }
}
 
開發者ID:Jamling,項目名稱:Android-ORM-ASPlugin,代碼行數:24,代碼來源:NewProviderAction.java

示例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();
}
 
開發者ID:BolexLiu,項目名稱:ReciteWords,代碼行數:20,代碼來源:ReciteWords.java

示例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;
}
 
開發者ID:diederikd,項目名稱:DeBrug,代碼行數:20,代碼來源:VisualiseerToestanden_Action.java

示例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");
    }
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:34,代碼來源:CCPushTask.java

示例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);
}
 
開發者ID:LightSun,項目名稱:intellij-plugin-tools,代碼行數:14,代碼來源:BuilderClassAction.java

示例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;
}
 
開發者ID:Jamling,項目名稱:Android-ORM-ASPlugin,代碼行數:11,代碼來源:Utils.java

示例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);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:9,代碼來源:CCFromCourseArchive.java

示例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);
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:14,代碼來源:ConvertAction.java

示例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");
    }
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:31,代碼來源:CCPushLesson.java

示例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();
}
 
開發者ID:serical,項目名稱:patcher,代碼行數:11,代碼來源:CreatePatcherAction.java

示例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);
      }
    }
  });
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:43,代碼來源:CCPushTask.java

示例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();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:42,代碼來源:CCPushCourse.java


注:本文中的com.intellij.openapi.actionSystem.AnActionEvent.getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。