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


Java ProjectRootsUtil.isSourceOrTestRoot方法代码示例

本文整理汇总了Java中com.intellij.ide.projectView.impl.ProjectRootsUtil.isSourceOrTestRoot方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectRootsUtil.isSourceOrTestRoot方法的具体用法?Java ProjectRootsUtil.isSourceOrTestRoot怎么用?Java ProjectRootsUtil.isSourceOrTestRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.ide.projectView.impl.ProjectRootsUtil的用法示例。


在下文中一共展示了ProjectRootsUtil.isSourceOrTestRoot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isModuleInProjectViewPopup

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
protected static boolean isModuleInProjectViewPopup(AnActionEvent e) {
  if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace())) {
    final Project project = getEventProject(e);
    final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
    if (project != null && module != null) {
      final VirtualFile moduleFolder = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
      if (moduleFolder == null) {
        return false;
      }
      if (ProjectRootsUtil.isModuleContentRoot(moduleFolder, project)
          || ProjectRootsUtil.isSourceOrTestRoot(moduleFolder, project)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:OpenModuleSettingsAction.java

示例2: getIcon

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
  if (element instanceof PsiDirectory) {
    final PsiDirectory psiDirectory = (PsiDirectory)element;
    final VirtualFile vFile = psiDirectory.getVirtualFile();
    boolean inTestSource = ProjectRootsUtil.isInTestSource(vFile, psiDirectory.getProject());
    boolean isSourceOrTestRoot = ProjectRootsUtil.isSourceOrTestRoot(vFile, psiDirectory.getProject());
    if (isSourceOrTestRoot) {
      return IconSet.getSourceRootIcon(inTestSource);
    }
    else {
      return PlatformIcons.DIRECTORY_CLOSED_ICON;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:DirectoryIconProvider.java

示例3: getNavigateActionText

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
public String getNavigateActionText(boolean focusEditor) {
  VirtualFile file = getVirtualFile();
  Project project = getProject();

  if (file != null) {
    if (ProjectRootsUtil.isModuleContentRoot(file, project) ||
        ProjectRootsUtil.isSourceOrTestRoot(file, project)) {
      return "Open Module Settings";
    }
    if (ProjectRootsUtil.isLibraryRoot(file, project)) {
      return "Open Library Settings";
    }
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:PsiDirectoryNode.java

示例4: isModuleInProjectViewPopup

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
protected static boolean isModuleInProjectViewPopup(AnActionEvent e) {
  if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace())) {
    final Project project = getEventProject(e);
    final Module module = e.getDataContext().getData(LangDataKeys.MODULE);
    if (project != null && module != null) {
      final VirtualFile moduleFolder = e.getDataContext().getData(PlatformDataKeys.VIRTUAL_FILE);
      if (moduleFolder == null) {
        return false;
      }
      if (ProjectRootsUtil.isModuleContentRoot(moduleFolder, project) || ProjectRootsUtil.isSourceOrTestRoot(moduleFolder, project)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:OpenModuleSettingsAction.java

示例5: getIcon

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
@Nullable
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
  if (element instanceof PsiDirectory) {
    final PsiDirectory psiDirectory = (PsiDirectory)element;
    final VirtualFile vFile = psiDirectory.getVirtualFile();
    final Project project = psiDirectory.getProject();
    boolean isJarRoot = vFile.getParent() == null && vFile.getFileSystem() instanceof JarFileSystem;
    boolean isContentRoot = ProjectRootsUtil.isModuleContentRoot(vFile, project);
    boolean inTestSource = ProjectRootsUtil.isInTestSource(vFile, project);
    boolean isSourceOrTestRoot = ProjectRootsUtil.isSourceOrTestRoot(vFile, project);
    Icon symbolIcon;
    if (isJarRoot) {
      symbolIcon = PlatformIcons.JAR_ICON;
    }
    else if (isContentRoot) {
      Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
      if (module != null) {
        symbolIcon = ModuleType.get(module).getIcon();
      }
      else {
        symbolIcon = PlatformIcons.CONTENT_ROOT_ICON_CLOSED;
      }
    }
    else if (isSourceOrTestRoot) {
      symbolIcon = IconSet.getSourceRootIcon(inTestSource);
    }
    else if (JavaDirectoryService.getInstance().getPackage(psiDirectory) != null) {
      symbolIcon = PlatformIcons.PACKAGE_ICON;
    }
    else {
      symbolIcon = PlatformIcons.DIRECTORY_CLOSED_ICON;
    }
    return ElementBase.createLayeredIcon(element, symbolIcon, 0);
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:JavaDirectoryIconProvider.java

示例6: canNavigate

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
public boolean canNavigate() {
  VirtualFile file = getVirtualFile();
  Project project = getProject();

  ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
  return file != null && ((ProjectRootsUtil.isModuleContentRoot(file, project) && service.canOpenModuleSettings()) ||
                          (ProjectRootsUtil.isSourceOrTestRoot(file, project)  && service.canOpenContentEntriesSettings()) ||
                          (ProjectRootsUtil.isLibraryRoot(file, project) && service.canOpenModuleLibrarySettings()));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:PsiDirectoryNode.java

示例7: updateImpl

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
protected void updateImpl(PresentationData data) {
  final Project project = getProject();
  final PsiDirectory psiDirectory = getValue();
  final VirtualFile directoryFile = psiDirectory.getVirtualFile();

  final Object parentValue = getParentValue();
  if (ProjectRootsUtil.isModuleContentRoot(directoryFile, project)) {
    ProjectFileIndex fi = ProjectRootManager.getInstance(project).getFileIndex();
    Module module = fi.getModuleForFile(directoryFile);

    data.setPresentableText(directoryFile.getName());
    if (module != null) {
      if (!(parentValue instanceof Module )) {
        if (!shouldShowModuleName()) {
          data.addText(directoryFile.getName() + " ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
        else if (Comparing.equal(module.getName(), directoryFile.getName())) {
          data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
        else {
          data.addText(directoryFile.getName() + " ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          data.addText("[" + module.getName() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
      }
      else {
        data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }

      if (parentValue instanceof Module || parentValue instanceof Project) {
        final String location = FileUtil.getLocationRelativeToUserHome(directoryFile.getPresentableUrl());
        data.addText(" (" + location + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else if (ProjectRootsUtil.isSourceOrTestRoot(directoryFile, project)) {
        if (ProjectRootsUtil.isInTestSource(directoryFile, project)) {
          data.addText(" (test source root)", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
        else {
          data.addText(" (source root)",  SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
      }

      setupIcon(data, psiDirectory);

      return;
    }
  }

  final String name = parentValue instanceof Project
                      ? psiDirectory.getVirtualFile().getPresentableUrl()
                      : ProjectViewDirectoryHelper.getInstance(psiDirectory.getProject()).getNodeName(getSettings(), parentValue, psiDirectory);
  if (name == null) {
    setValue(null);
    return;
  }

  data.setPresentableText(name);
  if (ProjectRootsUtil.isLibraryRoot(directoryFile, project)) {
    data.setLocationString("library home");
  }
  else {
    data.setLocationString(ProjectViewDirectoryHelper.getInstance(project).getLocationString(psiDirectory));
  }

  setupIcon(data, psiDirectory);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:67,代码来源:PsiDirectoryNode.java

示例8: updateImpl

import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Override
protected void updateImpl(PresentationData data) {
  final Project project = getProject();
  final PsiDirectory psiDirectory = getValue();
  final VirtualFile directoryFile = psiDirectory.getVirtualFile();

  final Object parentValue = getParentValue();
  if (ProjectRootsUtil.isModuleContentRoot(directoryFile, project)) {
    ProjectFileIndex fi = ProjectRootManager.getInstance(project).getFileIndex();
    Module module = fi.getModuleForFile(directoryFile);

    data.setPresentableText(directoryFile.getName());
    if (module != null) {
      if (!(parentValue instanceof Module)) {
        if (Comparing.equal(module.getName(), directoryFile.getName())) {
          data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
        else {
          data.addText(directoryFile.getName() + " ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          data.addText("[" + module.getName() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
      }
      else {
        data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }

      if (parentValue instanceof Module || parentValue instanceof Project) {
        final String location = FileUtil.getLocationRelativeToUserHome(directoryFile.getPresentableUrl());
        data.addText(" (" + location + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else if (ProjectRootsUtil.isSourceOrTestRoot(directoryFile, project)) {
        if (ProjectRootsUtil.isInTestSource(directoryFile, project)) {
          data.addText(" (test source root)", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
        else {
          data.addText(" (source root)",  SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
      }

      setupIcon(data, psiDirectory);

      return;
    }
  }

  final String name = parentValue instanceof Project
                      ? psiDirectory.getVirtualFile().getPresentableUrl()
                      : BaseProjectViewDirectoryHelper.getNodeName(getSettings(), parentValue, psiDirectory);
  if (name == null) {
    setValue(null);
    return;
  }

  data.setPresentableText(name);
  if (ProjectRootsUtil.isLibraryRoot(directoryFile, project)) {
    data.setLocationString("library home");
  }
  else {
    data.setLocationString(BaseProjectViewDirectoryHelper.getLocationString(psiDirectory));
  }

  setupIcon(data, psiDirectory);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:64,代码来源:PsiDirectoryNode.java


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