本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}
示例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);
}
示例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);
}