本文整理汇总了Java中com.intellij.openapi.project.Project.getBaseDir方法的典型用法代码示例。如果您正苦于以下问题:Java Project.getBaseDir方法的具体用法?Java Project.getBaseDir怎么用?Java Project.getBaseDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.project.Project
的用法示例。
在下文中一共展示了Project.getBaseDir方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskDir
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
@Nullable
public VirtualFile getTaskDir(@NotNull final Project project) {
String lessonDirName = EduNames.LESSON + String.valueOf(myLesson.getIndex());
String taskDirName = EduNames.TASK + String.valueOf(myIndex);
VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
VirtualFile lessonDir = courseDir.findChild(lessonDirName);
if (lessonDir != null) {
VirtualFile taskDir = lessonDir.findChild(taskDirName);
if (taskDir == null) {
return null;
}
VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
return srcDir != null ? srcDir : taskDir;
}
}
return null;
}
示例2: actionPerformed
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
Project project = anActionEvent.getProject();
if (project != null) {
String currentApkPath = PropertiesManager.getData(project, PropertyKeys.APK_PATH);
VirtualFile fileToSelectOnCreate =
TextUtils.isEmpty(currentApkPath)
? project.getBaseDir()
: LocalFileSystem.getInstance().findFileByPath(currentApkPath);
VirtualFile apkFile = new FileChooserDialogManager.Builder(project, fileToSelectOnCreate)
.setFileTypes(FileTypes.FILE)
.setTitle(Strings.TITLE_ASK_APK_FILE)
.setDescription(Strings.MESSAGE_ASK_APK_FILE)
.withFileFilter("apk")
.create()
.getSelectedFile();
if (apkFile != null) {
PropertiesManager.putData(project, PropertyKeys.APK_PATH, apkFile.getPath());
}
}
}
示例3: actionPerformed
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
Project project = anActionEvent.getProject();
VirtualFile virtualFile = project.getBaseDir();
VirtualFile source = Utils.getSourceFile(virtualFile, null);
Crowdin crowdin = new Crowdin();
String branch = Utils.getCurrentBranch(project);
crowdin.exportTranslations(branch);
File downloadTranslations = crowdin.downloadTranslations(source, branch);
Utils.extractTranslations(downloadTranslations);
if (downloadTranslations.delete()) {
System.out.println("all.zip was deleted");
} else {
System.out.println("all.zip wasn't deleted");
}
}
示例4: actionPerformed
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) return;
final PsiDirectory[] directories = view.getDirectories();
PsiDirectory currentDirectory = directories.length > 0 ? directories[0] : null;
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) return;
VirtualFile directoryFile = currentDirectory != null ? currentDirectory.getVirtualFile() : project.getBaseDir();
openLoadDirectoryDialog(project, directoryFile, null);
}
示例5: findBaseRoot
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
public static VirtualFile findBaseRoot(Project project) {
VirtualFile baseDir = m_baseDirs.get(project);
if (baseDir == null) {
baseDir = project.getBaseDir();
if (baseDir.findChild("node_modules") == null) {
// try to find it one level deeper
baseDir = Arrays.stream(baseDir.getChildren()).filter(file -> file.findChild("node_modules") != null).findFirst().orElse(baseDir);
}
m_baseDirs.put(project, baseDir);
}
return baseDir;
}
示例6: createCheckProcess
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
}
final File testRunner = new File(myTaskDir.getPath(), testsFileName);
myCommandLine = new GeneralCommandLine();
myCommandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = myCommandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
myCommandLine.setExePath(pythonPath);
myCommandLine.addParameter(testRunner.getPath());
myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return myCommandLine.createProcess();
}
}
return null;
}
示例7: getGeneratedFilesFolder
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
public static VirtualFile getGeneratedFilesFolder(@NotNull Project project, @NotNull Module module) {
VirtualFile baseDir = project.getBaseDir();
VirtualFile folder = baseDir.findChild(GENERATED_FILES_FOLDER);
if (folder != null) {
return folder;
}
final Ref<VirtualFile> generatedRoot = new Ref<>();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
generatedRoot.set(baseDir.createChildDirectory(this, GENERATED_FILES_FOLDER));
VirtualFile contentRootForFile =
ProjectRootManager.getInstance(module.getProject()).getFileIndex().getContentRootForFile(generatedRoot.get());
if (contentRootForFile == null) {
return;
}
ModuleRootModificationUtil.updateExcludedFolders(module, contentRootForFile, Collections.emptyList(),
Collections.singletonList(generatedRoot.get().getUrl()));
}
catch (IOException e) {
LOG.info("Failed to create folder for generated files", e);
}
}
});
return generatedRoot.get();
}
示例8: generateFromStudentCourse
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
public static void generateFromStudentCourse(Project project, Course course) {
StudyTaskManager.getInstance(project).setCourse(course);
course.setCourseMode(CCUtils.COURSE_MODE);
final VirtualFile baseDir = project.getBaseDir();
final Application application = ApplicationManager.getApplication();
application.invokeAndWait(() -> application.runWriteAction(() -> {
final VirtualFile[] children = baseDir.getChildren();
for (VirtualFile child : children) {
StudyUtils.deleteFile(child);
}
StudyGenerator.createCourse(course, baseDir);
}));
baseDir.refresh(false, true);
int index = 1;
int taskIndex = 1;
for (Lesson lesson : course.getLessons()) {
final VirtualFile lessonDir = project.getBaseDir().findChild(EduNames.LESSON + String.valueOf(index));
lesson.setIndex(index);
if (lessonDir == null) continue;
for (Task task : lesson.getTaskList()) {
final VirtualFile taskDir = lessonDir.findChild(EduNames.TASK + String.valueOf(taskIndex));
task.setIndex(taskIndex);
task.setLesson(lesson);
if (taskDir == null) continue;
for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
application.invokeAndWait(() -> application.runWriteAction(() -> createAnswerFile(project, taskDir, entry)));
}
taskIndex += 1;
}
index += 1;
taskIndex = 1;
}
course.initCourse(true);
application.invokeAndWait(() -> StudyUtils.registerStudyToolWindow(course, project));
synchronize(project);
}
示例9: deleteLesson
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
private static void deleteLesson(@NotNull final Course course, @NotNull final VirtualFile removedLessonFile, Project project) {
Lesson removedLesson = course.getLesson(removedLessonFile.getName());
if (removedLesson == null) {
return;
}
VirtualFile courseDir = project.getBaseDir();
CCUtils.updateHigherElements(courseDir.getChildren(), file -> course.getLesson(file.getName()), removedLesson.getIndex(), EduNames.LESSON, -1);
course.removeLesson(removedLesson);
}
示例10: actionPerformed
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
@Override
public void actionPerformed(@NotNull final AnActionEvent anActionEvent) {
Project project = anActionEvent.getProject();
VirtualFile virtualFile = project.getBaseDir();
String sourcesProp = Utils.getPropertyValue(PROPERTY_SOURCES, true);
List<String> sourcesList = Utils.getSourcesList(sourcesProp);
Crowdin crowdin = new Crowdin();
for (String src : sourcesList) {
VirtualFile source = Utils.getSourceFile(virtualFile, src);
String branch = Utils.getCurrentBranch(project);
crowdin.uploadFile(source, branch);
}
}
示例11: createAdditionalLesson
import com.intellij.openapi.project.Project; //导入方法依赖的package包/类
@Nullable
public static Lesson createAdditionalLesson(Course course, Project project) {
final VirtualFile baseDir = project.getBaseDir();
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById());
final Lesson lesson = new Lesson();
lesson.setName(EduNames.PYCHARM_ADDITIONAL);
final Task task = new PyCharmTask();
task.setLesson(lesson);
task.setName(EduNames.PYCHARM_ADDITIONAL);
task.setIndex(1);
VfsUtilCore.visitChildrenRecursively(baseDir, new VirtualFileVisitor(VirtualFileVisitor.NO_FOLLOW_SYMLINKS) {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
final String name = file.getName();
if (name.equals(EduNames.COURSE_META_FILE) || name.equals(EduNames.HINTS) || name.startsWith(".")) return false;
String sanitizedName = FileUtil.sanitizeFileName(course.getName());
final String archiveName = sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName;
if (name.equals(archiveName + ".zip")) return false;
if (GENERATED_FILES_FOLDER.equals(name) || Project.DIRECTORY_STORE_FOLDER.equals(name)) {
return false;
}
if (file.isDirectory()) return true;
if (StudyUtils.isTestsFile(project, name)) return true;
if (name.contains(".iml") || (configurator != null && configurator.excludeFromArchive(file.getPath()))) {
return false;
}
final TaskFile taskFile = StudyUtils.getTaskFile(project, file);
if (taskFile == null) {
final String path = VfsUtilCore.getRelativePath(file, baseDir);
try {
if (EduUtils.isImage(file.getName())) {
task.addTestsTexts(path, Base64.encodeBase64URLSafeString(FileUtil.loadBytes(file.getInputStream())));
}
else {
task.addTestsTexts(path, FileUtil.loadTextAndClose(file.getInputStream()));
}
}
catch (IOException e) {
LOG.error("Can't find file " + path);
}
}
return true;
}
});
if (task.getTestsText().isEmpty()) return null;
lesson.addTask(task);
lesson.setIndex(course.getLessons().size());
return lesson;
}