當前位置: 首頁>>代碼示例>>Java>>正文


Java Project.getBaseDir方法代碼示例

本文整理匯總了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;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:Task.java

示例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());
        }
    }
}
 
開發者ID:kaygisiz,項目名稱:Dependency-Injection-Graph,代碼行數:25,代碼來源:SetApkPathAction.java

示例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");
    }
}
 
開發者ID:crowdin,項目名稱:android-studio-plugin,代碼行數:17,代碼來源:DownloadAction.java

示例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);
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:14,代碼來源:LoadDictionaryAction.java

示例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;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:13,代碼來源:Platform.java

示例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;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:30,代碼來源:PyStudyTestRunner.java

示例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();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:28,代碼來源:CCUtils.java

示例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);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:39,代碼來源:CCFromCourseArchive.java

示例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);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:10,代碼來源:CCVirtualFileListener.java

示例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);
    }
}
 
開發者ID:crowdin,項目名稱:android-studio-plugin,代碼行數:14,代碼來源:UploadAction.java

示例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;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:54,代碼來源:CCUtils.java


注:本文中的com.intellij.openapi.project.Project.getBaseDir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。