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


Java AnActionEvent.getDataContext方法代碼示例

本文整理匯總了Java中com.intellij.openapi.actionSystem.AnActionEvent.getDataContext方法的典型用法代碼示例。如果您正苦於以下問題:Java AnActionEvent.getDataContext方法的具體用法?Java AnActionEvent.getDataContext怎麽用?Java AnActionEvent.getDataContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.actionSystem.AnActionEvent的用法示例。


在下文中一共展示了AnActionEvent.getDataContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExtensionDirectory

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public static PsiDirectory getExtensionDirectory(@NotNull AnActionEvent event) {
    Project project = event.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
        return null;
    }

    DataContext dataContext = event.getDataContext();
    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return null;
    }

    PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
        return null;
    }

    return FilesystemUtil.findParentExtensionDirectory(directories[0]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ExtensionUtility.java

示例2: update

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);

  Project project = e.getProject();
  if (project == null) {
    return;
  }
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  DataContext context = e.getDataContext();
  VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  if (file == null ) {
    return;
  }
  TaskFile taskFile = StudyUtils.getTaskFile(project, file);
  if (taskFile == null || taskFile.getAnswerPlaceholders().isEmpty()) {
    return;
  }
  presentation.setEnabledAndVisible(true);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:24,代碼來源:CCDeleteAllAnswerPlaceholdersAction.java

示例3: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (virtualFile == null || project == null || editor == null) {
    return;
  }
  Task task = StudyUtils.getTaskForFile(project, virtualFile);
  if (task == null) return;
  if (!(task instanceof TaskWithSubtasks)) {
    task = convertToTaskWithSubtasks(task, project);
  }
  addSubtask((TaskWithSubtasks)task, project);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:17,代碼來源:CCNewSubtaskAction.java

示例4: update

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void update(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);
  VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (virtualFile == null || project == null) {
    return;
  }
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  if (StudyUtils.getTaskForFile(project, virtualFile) != null || StudyUtils.getTask(project, virtualFile) != null) {
    presentation.setEnabledAndVisible(true);
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:18,代碼來源:CCNewSubtaskAction.java

示例5: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
    public void actionPerformed(AnActionEvent e) {
//            DocumentUtil.saveDocument();
        dataContext = e.getDataContext();
        project = e.getProject();

        doAction(e);
    }
 
開發者ID:beansoftapp,項目名稱:react-native-console,代碼行數:9,代碼來源:BaseRNConsoleAction.java

示例6: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://translate.google.com/#en/zh-CN/" + URLEncoder.encode(var4));
        }
    }
}
 
開發者ID:kookob,項目名稱:mybatis-log-plugin,代碼行數:12,代碼來源:GoogleTranslateAction.java

示例7: update

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public void update(AnActionEvent var1) {
    Presentation var2 = var1.getPresentation();
    DataContext var3 = var1.getDataContext();
    CopyProvider var4 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var3);
    boolean var5 = var4 != null && var4.isCopyEnabled(var3) && var4.isCopyVisible(var3);
    var2.setEnabled(var5);
    var2.setVisible(var5);
}
 
開發者ID:kookob,項目名稱:mybatis-log-plugin,代碼行數:9,代碼來源:GoogleTranslateAction.java

示例8: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://www.baidu.com/s?wd=" + URLEncoder.encode(var4));
        }
    }
}
 
開發者ID:kookob,項目名稱:mybatis-log-plugin,代碼行數:12,代碼來源:BaiduSearchAction.java

示例9: findDirectoryFromActionEvent

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
/**
 * Finds the directories on which an action was performed on.
 *
 * @param actionEvent The source action event
 * @return an array of directories the action was performed on
 */
public static PsiDirectory[] findDirectoryFromActionEvent(AnActionEvent actionEvent) {

    DataContext dataContext = actionEvent.getDataContext();
    IdeView data = LangDataKeys.IDE_VIEW.getData(dataContext);

    if (data == null) {
        return new PsiDirectory[]{};
    }

    return data.getDirectories();
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:18,代碼來源:ActionUtil.java

示例10: update

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
public void update(AnActionEvent event) {
    Project project = getEventProject(event);
    if (project == null) {
        this.setStatus(event, false);
        return;
    }

    if (DumbService.isDumb(project)) {
        this.setStatus(event, false);
        return;
    }

    DataContext dataContext = event.getDataContext();

    final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
    final PhpClass targetClass = editor == null || file == null ? null : PhpCodeEditUtil.findClassAtCaret(editor, file);

    if (targetClass == null) {
        setStatus(event, false);
        return;
    }

    if (ExtensionUtility.getExtensionDirectory(event) == null) {
        this.setStatus(event, false);
        return;
    }

    this.setStatus(event, PhpElementsUtil.hasSuperClass(targetClass, "\\TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController"));
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:31,代碼來源:ExtbaseControllerActionAction.java

示例11: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
/**
 * @param event Carries information on the invocation place
 */
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = getEventProject(event);
    if (project == null) {
        this.setStatus(event, false);
        return;
    }

    DataContext dataContext = event.getDataContext();

    final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
    final PhpClass targetClass = editor == null || file == null ? null : PhpCodeEditUtil.findClassAtCaret(editor, file);

    if (targetClass == null) {
        JOptionPane.showMessageDialog(null, "Could not find containing class");
        return;
    }

    String actionName = Messages.showInputDialog(project, "New action name:", "New Extbase ActionController Action", TYPO3CMSIcons.TYPO3_ICON);

    if (StringUtils.isBlank(actionName)) {
        return;
    }

    actionName = Character.toLowerCase(actionName.charAt(0)) + actionName.substring(1);

    if (!actionName.endsWith("Action")) {
        actionName += "Action";
    }

    if (!PhpNameUtil.isValidMethodName(actionName)) {
        JOptionPane.showMessageDialog(null, "Invalid method name");
        return;
    }

    write(project, targetClass, actionName);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:42,代碼來源:ExtbaseControllerActionAction.java

示例12: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
    try {
        com.intellij.openapi.actionSystem.DataContext dataContext = e.getDataContext();
        PsiJavaFile javaFile = (PsiJavaFile) ((PsiFile) DataKeys.PSI_FILE.getData(dataContext)).getContainingFile();
        String sourceName = javaFile.getName();
        Module module = (Module) DataKeys.MODULE.getData(dataContext);
        String compileRoot = CompilerModuleExtension.getInstance(module).getCompilerOutputPath().getPath();
        getVirtualFile(sourceName, CompilerModuleExtension.getInstance(module).getCompilerOutputPath().getChildren(), compileRoot);
        VirtualFileManager.getInstance().syncRefresh();
    } catch (Exception ex) {
        ex.printStackTrace();
        Messages.showErrorDialog("Please build your module or project!!!", "error");
    }
}
 
開發者ID:serical,項目名稱:patcher,代碼行數:16,代碼來源:ClassesExportAction.java

示例13: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent event) {
    Project project = getProject(event);
    DataContext context = event.getDataContext();
    TelemetryToolWindow window = TelemetryToolWindow.get(project);

    if (firstStart) {
        firstStart = false;
        window.show();
    }

    window.clear();
    deploy(window, project, context);
}
 
開發者ID:andreyfomenkov,項目名稱:green-cat,代碼行數:15,代碼來源:Deploy.java

示例14: actionPerformed

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext context = e.getDataContext();
  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  final Project project = e.getProject();
  if (file == null || project == null) {
    return;
  }
  final TaskFile taskFile = StudyUtils.getTaskFile(project, file);
  if (taskFile == null) {
    return;
  }
  Editor editor = CommonDataKeys.EDITOR.getData(context);
  if (editor == null) {
    FileEditorManager instance = FileEditorManager.getInstance(project);
    if (!instance.isFileOpen(file)) {
      return;
    }
    FileEditor fileEditor = instance.getSelectedEditor(file);
    if (!(fileEditor instanceof TextEditor)) {
      return;
    }
    editor = ((TextEditor)fileEditor).getEditor();
  }
  List<AnswerPlaceholder> placeholders = new ArrayList<>(taskFile.getAnswerPlaceholders());
  final ClearPlaceholders action = new ClearPlaceholders(taskFile, placeholders, editor);
  EduUtils.runUndoableAction(project, ACTION_NAME, action, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:29,代碼來源:CCDeleteAllAnswerPlaceholdersAction.java

示例15: update

import com.intellij.openapi.actionSystem.AnActionEvent; //導入方法依賴的package包/類
@Override
public final void update(AnActionEvent e) {
  this.dataContext = e.getDataContext();
  final Presentation presentation = e.getPresentation();

  final boolean enabled = isAvailable(dataContext);

  presentation.setVisible(enabled);
  presentation.setEnabled(enabled);
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:11,代碼來源:GenerateAction.java


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