本文整理汇总了Java中com.intellij.openapi.actionSystem.LangDataKeys类的典型用法代码示例。如果您正苦于以下问题:Java LangDataKeys类的具体用法?Java LangDataKeys怎么用?Java LangDataKeys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LangDataKeys类属于com.intellij.openapi.actionSystem包,在下文中一共展示了LangDataKeys类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeDialog
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
BaseDialog dialog = new BaseDialog("请输入基类前缀:",project);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
String prefix = dialog.getClassNamePrefix();
if(prefix != null && !prefix.isEmpty()){
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiElement createdElement = createProjectDir(dir,prefix);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if(view != null&&createdElement != null){
view.selectElement(createdElement);
}
});
}
}
}
示例2: getExtensionDirectory
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的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]);
}
示例3: execute
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
myOriginalHandler.execute(editor, charTyped, dataContext);
if (isMatchForClosingTag(editor, charTyped)) {
int offset = editor.getCaretModel().getOffset();
PsiFile file = dataContext.getData(LangDataKeys.PSI_FILE);
if (file == null) {
return;
}
PsiElement el = file.findElementAt(offset - 1);
TagBlockElement block = (TagBlockElement) PsiTreeUtil
.findFirstParent(el,
parent -> parent instanceof TagBlockElement && !(parent instanceof SoyChoiceClause));
if (block == null) {
return;
}
String closingTag = block.getOpeningTag().generateClosingTag();
insertClosingTag(editor, offset, closingTag);
if (editor.getProject() != null) {
PsiDocumentManager.getInstance(editor.getProject()).commitDocument(editor.getDocument());
CodeStyleManager.getInstance(editor.getProject()).reformat(block);
}
}
}
示例4: isAvailable
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的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();
}
示例5: actionPerformed
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@Override
public final void actionPerformed(AnActionEvent event) {
this.project = event.getProject();
this.actionEvent = event;
packageName = Utils.getClassPath(event);
element = event.getData(LangDataKeys.PSI_ELEMENT);
if (Utils.isEmpty(packageName)) {
NotificationUtils.infoNotification("Must be Class or Method");
return;
}
this.selectActionPerformed(event, element, packageName);
if (shouldSelectVersion()) {
data = Utils.getVersionList(packageName);
if (data == null) {
NotificationUtils.infoNotification("Invalid PackageName:" + packageName);
return;
}
this.onClassSelected(this.actionEvent, packageName);
}
}
示例6: actionPerformed
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的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 String courseId = Messages.showInputDialog("Please, enter course id", "Get Course From Stepik", null);
if (StringUtil.isNotEmpty(courseId)) {
ProgressManager.getInstance().run(new Task.Modal(project, "Creating Course", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
createCourse(project, courseId);
}
});
}
}
示例7: actionPerformed
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的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);
}
示例8: update
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的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);
}
示例9: canMove
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return CCUtils.isLessonDir(sourceDirectory);
}
示例10: canMove
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return isTaskDir(sourceDirectory);
}
示例11: isAvailable
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
/**
* Checked whether or not this action can be enabled.
*
* <p>Requirements to be enabled: * User must be in a Java source folder.
*
* @param dataContext to figure out where the user is.
* @return {@code true} when the action is available, {@code false} when the action is not
* available.
*/
private boolean isAvailable(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return false;
}
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null || view.getDirectories().length == 0) {
return false;
}
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiDirectory dir : view.getDirectories()) {
if (projectFileIndex.isUnderSourceRootOfType(
dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES)
&& checkPackageExists(dir)) {
return true;
}
}
return false;
}
示例12: update
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
Project project = e.getData(LangDataKeys.PROJECT);
if (project != null) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
e.getPresentation().setVisible(true);
Sdk luaSdk = LuaSdkType.findLuaSdk(module);
if (luaSdk == null) continue;
final String homePath = luaSdk.getHomePath();
if (homePath == null) continue;
if (LuaSdkType.getByteCodeCompilerExecutable(homePath).exists()) {
e.getPresentation().setEnabled(true);
break;
}
}
}
}
示例13: isEnabled
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
private static boolean isEnabled(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
final IdeView ideView = e.getData(LangDataKeys.IDE_VIEW);
if (project == null || ideView == null)
return false;
CatberryProjectConfigurationManager configurationManager = CatberryProjectConfigurationManager.getInstance(project);
if (!configurationManager.isCatberryEnabled())
return false;
final PsiDirectory[] directories = ideView.getDirectories();
if(directories.length != 1)
return false;
final String selectedPath = directories[0].getVirtualFile().getPath();
for(PsiDirectory dir : configurationManager.getComponentsDirectories()) {
if(selectedPath.startsWith(dir.getVirtualFile().getPath()))
return true;
}
return false;
}
示例14: actionPerformed
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final PsiElement[] elements = e.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
if (elements == null) return;
final List<File> pycFiles = new ArrayList<File>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
for (PsiElement element : elements) {
PsiDirectory dir = (PsiDirectory) element;
collectPycFiles(new File(dir.getVirtualFile().getPath()), pycFiles);
}
FileUtil.asyncDelete(pycFiles);
}
}, "Cleaning up .pyc files...", false, e.getProject());
final StatusBar statusBar = WindowManager.getInstance().getIdeFrame(e.getProject()).getStatusBar();
statusBar.setInfo("Deleted " + pycFiles.size() + " bytecode file" + (pycFiles.size() != 1 ? "s" : ""));
}
示例15: invokeDialog
import com.intellij.openapi.actionSystem.LangDataKeys; //导入依赖的package包/类
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
BaseDialog dialog = new BaseDialog("请输入基类前缀:",project);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
String prefix = dialog.getClassNamePrefix();
if(prefix != null && !prefix.isEmpty()){
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiElement[] elements = createProjectDir(dir,prefix);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if(view != null){
for (PsiElement element : elements) {
view.selectElement(element);
}
}
});
}
}
}