Java Code Examples for com.intellij.openapi.project.ProjectUtil#guessProjectDir()
The following examples show how to use
com.intellij.openapi.project.ProjectUtil#guessProjectDir() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectBuildModelImpl.java From ok-gradle with Apache License 2.0 | 6 votes |
@Override @Nullable public GradleSettingsModel getProjectSettingsModel() { VirtualFile virtualFile = null; // If we don't have a root build file, guess the location of the settings file from the project. if (myProjectBuildFile == null) { VirtualFile projectDir = ProjectUtil.guessProjectDir(myBuildModelContext.getProject()); if (projectDir != null) { File ioFile = VfsUtilCore.virtualToIoFile(projectDir); virtualFile = getGradleSettingsFile(ioFile); } } else { virtualFile = myProjectBuildFile.tryToFindSettingsFile(); } if (virtualFile == null) { return null; } GradleSettingsFile settingsFile = myBuildModelContext.getOrCreateSettingsFile(virtualFile); return new GradleSettingsModelImpl(settingsFile); }
Example 2
Source File: ImagesProjectNode.java From intellij-sdk-docs with Apache License 2.0 | 5 votes |
private void addAllByExt(Project project, String ext) { final Set<VirtualFile> imagesFiles = getImagesFiles(project); final VirtualFile projectDir = ProjectUtil.guessProjectDir(project); for (VirtualFile file : FilenameIndex.getAllFilesByExt(project, ext)) { while (file != null && !file.equals(projectDir)) { imagesFiles.add(file); file = file.getParent(); } } }
Example 3
Source File: Utils.java From idea-gitignore with MIT License | 5 votes |
/** * Wraps {@link ProjectUtil#guessProjectDir} and returns null for the default project. * * @param project to check * @return project's dir or null if project is default */ public static VirtualFile guessProjectDir(@Nullable Project project) { if (project == null) { return null; } try { return ProjectUtil.guessProjectDir(project); } catch (IllegalStateException e) { return null; } }
Example 4
Source File: ReferencePointTab.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Checks all open projects if the name of its base directory or the name of one of the content * roots of one of its modules matches the name of the shared reference point. If such a directory * is found, the corresponding project is chosen as the default selection. If multiple of such * projects exist, the first one found by the search is used. If no project is found, the first * one of the list is selected instead. * * <p>Calls {@link #setInitialInputForProject(Project)} with the selected project to determine the * default values and selection for the other fields. */ private void setInitialInput() { int projectCount = projectComboBox.getItemCount(); for (int i = 0; i < projectCount; i++) { Project project = projectComboBox.getItemAt(i); VirtualFile projectBaseDir = ProjectUtil.guessProjectDir(project); if (projectBaseDir != null && projectBaseDir.getName().equals(referencePointName)) { setInitialInputForProject(project); return; } Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) { if (contentRoot.getName().equals(referencePointName)) { setInitialInputForProject(project); return; } } } } if (projectCount > 0) { setInitialInputForProject(projectComboBox.getItemAt(0)); } }
Example 5
Source File: ReferencePointTab.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Updates the contained fields for the given project. Sets the given reference point name as the * new directory name. Sets the base path of the chosen project as the base directory for the new * directory. * * <p>Also sets the default option for the selected project. If the name of the project root * directory matches the name of the shared reference point or the project contains a module with * a content root that matches the given reference point name, the option to use it for the * resource negotiation is selected by default. Otherwise, the option to create a new directory is * selected by default. * * @param project the newly selected project to set the default values and selection for */ private void updateFieldsForProjectChange(@NotNull Project project) { newDirectoryNameTextField.setText(referencePointName); VirtualFile projectBaseDir = ProjectUtil.guessProjectDir(project); if (projectBaseDir != null) { newDirectoryBasePathTextField.setText(projectBaseDir.getPath()); if (projectBaseDir.getName().equals(referencePointName)) { useExistingDirectoryRadioButton.doClick(); existingDirectoryPathTextField.setText(projectBaseDir.getPath()); return; } } Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) { if (contentRoot.getName().equals(referencePointName)) { useExistingDirectoryRadioButton.doClick(); existingDirectoryPathTextField.setText(contentRoot.getPath()); return; } } } createNewDirectoryRadioButton.doClick(); }
Example 6
Source File: ImagesProjectNode.java From intellij-sdk-docs with Apache License 2.0 | 4 votes |
public ImagesProjectNode(final Project project) { super(project, ProjectUtil.guessProjectDir(project)); scanImages(project); subscribeToVFS(project); }