當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。