当前位置: 首页>>代码示例>>Java>>正文


Java LangDataKeys类代码示例

本文整理汇总了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);
                }
            });
        }
    }
}
 
开发者ID:wangtotang,项目名称:DaggerHelper,代码行数:20,代码来源:NewModuleDirAction.java

示例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]);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:20,代码来源:ExtensionUtility.java

示例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);
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:24,代码来源:ClosingTagHandler.java

示例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();
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:25,代码来源:NewClassAction.java

示例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);
    }
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:21,代码来源:BaseSourceAction.java

示例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);
      }
    });
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:18,代码来源:CCGetCourseFromStepic.java

示例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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:CCCreateStudyItemActionBase.java

示例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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:22,代码来源:CCChangeCourseInfo.java

示例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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:CCLessonMoveHandlerDelegate.java

示例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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:18,代码来源:CCTaskMoveHandlerDelegate.java

示例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;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:32,代码来源:GenerateAction.java

示例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;
            }
        }
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:22,代码来源:GenerateLuaListingAction.java

示例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;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:23,代码来源:CreateCatberryComponentAction.java

示例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" : ""));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CleanPycAction.java

示例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);
                    }
                }
            });
        }
    }
}
 
开发者ID:wangtotang,项目名称:DaggerHelper,代码行数:22,代码来源:NewProjectDirAction.java


注:本文中的com.intellij.openapi.actionSystem.LangDataKeys类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。