use of com.intellij.openapi.roots.ProjectRootManager in project intellij-plugins by JetBrains.
the class VFSUtilTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final File dir = createTempDirectory();
updateRoots(new Updater() {
@Override
public void update(ModifiableRootModel modifiableModel) {
myContentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
try {
VirtualFile src = myContentRoot.createChildDirectory(this, "src");
myContentEntry = modifiableModel.addContentEntry(myContentRoot);
myContentEntry.addSourceFolder(src, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
myContentRoot = rootManager.getContentRoots()[0];
mySourceRoot = rootManager.getContentSourceRoots()[0];
VFSUtil._setProject(getProject());
}
use of com.intellij.openapi.roots.ProjectRootManager in project intellij-plugins by JetBrains.
the class FlexProjectConverter method preProcessingFinished.
@Override
public void preProcessingFinished() throws CannotConvertException {
ComponentManagerSettings projectRootManagerSettings = myContext.getProjectRootManagerSettings();
if (projectRootManagerSettings == null)
return;
Element projectRootManager = projectRootManagerSettings.getComponentElement(ProjectRootManager.class.getSimpleName());
if (projectRootManager == null)
return;
getParams().projectSdkName = projectRootManager.getAttributeValue(ProjectRootManagerImpl.PROJECT_JDK_NAME_ATTR);
ConversionParams.convertFlexSdks();
}
use of com.intellij.openapi.roots.ProjectRootManager in project checkstyle-idea by jshiell.
the class ScanProject method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent event) {
try {
final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
return;
}
final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
toolWindow.activate(() -> {
try {
setProgressText(toolWindow, "plugin.status.in-progress.project");
Runnable scanAction = null;
if (scope == ScanScope.Everything) {
scanAction = new ScanEverythingAction(project, getSelectedOverride(toolWindow));
} else {
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
final VirtualFile[] sourceRoots = projectRootManager.getContentSourceRoots();
if (sourceRoots.length > 0) {
scanAction = new ScanSourceRootsAction(project, sourceRoots, getSelectedOverride(toolWindow));
}
}
if (scanAction != null) {
ApplicationManager.getApplication().runReadAction(scanAction);
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Project scan", e);
}
});
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Project scan", e);
}
}
use of com.intellij.openapi.roots.ProjectRootManager in project ideavim by JetBrains.
the class FileGroup method findFile.
@Nullable
public VirtualFile findFile(@NotNull String filename, @NotNull Project proj) {
VirtualFile found = null;
if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
String homefile = filename.substring(2);
String dir = System.getProperty("user.home");
if (logger.isDebugEnabled()) {
logger.debug("home dir file");
logger.debug("looking for " + homefile + " in " + dir);
}
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
} else {
if (proj == null) {
return null;
}
ProjectRootManager prm = ProjectRootManager.getInstance(proj);
VirtualFile[] roots = prm.getContentRoots();
for (int i = 0; i < roots.length; i++) {
if (logger.isDebugEnabled()) {
logger.debug("root[" + i + "] = " + roots[i].getPath());
}
found = findFile(roots[i], filename);
if (found != null) {
break;
}
}
if (found == null) {
found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
}
}
return found;
}
use of com.intellij.openapi.roots.ProjectRootManager in project intellij-community by JetBrains.
the class ThumbnailViewUI method findFiles.
private Set<VirtualFile> findFiles(VirtualFile file) {
Set<VirtualFile> files = new HashSet<>(0);
Project project = thumbnailView.getProject();
if (!project.isDisposed()) {
ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
boolean projectIgnored = rootManager.getFileIndex().isExcluded(file);
if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file)) {
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
if (file.isDirectory()) {
if (thumbnailView.isRecursive()) {
files.addAll(findFiles(file.getChildren()));
} else if (isImagesInDirectory(file)) {
files.add(file);
}
} else if (typeManager.isImage(file)) {
files.add(file);
}
}
}
return files;
}
Aggregations