本文整理匯總了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]);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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));
}
}
}
示例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);
}
示例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));
}
}
}
示例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();
}
示例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"));
}
示例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);
}
示例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");
}
}
示例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);
}
示例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);
}
示例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);
}