当前位置: 首页>>代码示例>>Java>>正文


Java JDOMUtil.writeDocument方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.JDOMUtil.writeDocument方法的典型用法代码示例。如果您正苦于以下问题:Java JDOMUtil.writeDocument方法的具体用法?Java JDOMUtil.writeDocument怎么用?Java JDOMUtil.writeDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.JDOMUtil的用法示例。


在下文中一共展示了JDOMUtil.writeDocument方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writePreSignUrlMapping

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public static String writePreSignUrlMapping(@NotNull Map<String, URL> data) throws IOException {
  Element rootElement = new Element(S3_PRESIGN_URL_MAPPING);
  for (String s3ObjectKey : data.keySet()){
    URL preSignUrl = data.get(s3ObjectKey);
    Element mapEntry = new Element(S3_PRESIGN_URL_MAP_ENTRY);
    Element preSignUrlElement = new Element(PRE_SIGN_URL);
    preSignUrlElement.addContent(preSignUrl.toString());
    mapEntry.addContent(preSignUrlElement);
    Element s3ObjectKeyElement = new Element(S3_OBJECT_KEY);
    s3ObjectKeyElement.addContent(s3ObjectKey);
    mapEntry.addContent(s3ObjectKeyElement);
    rootElement.addContent(mapEntry);
  }
  return JDOMUtil.writeDocument(new Document(rootElement), System.getProperty("line.separator"));
}
 
开发者ID:JetBrains,项目名称:teamcity-s3-artifact-storage-plugin,代码行数:17,代码来源:S3PreSignUrlHelper.java

示例2: writeInspectionDiff

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static void writeInspectionDiff(final String oldPath, final String newPath, final String outPath) {
  try {
    InputStream oldStream = oldPath != null ? new BufferedInputStream(new FileInputStream(oldPath)) : null;
    InputStream newStream = new BufferedInputStream(new FileInputStream(newPath));

    Document oldDoc = oldStream != null ? JDOMUtil.loadDocument(oldStream) : null;
    Document newDoc = JDOMUtil.loadDocument(newStream);

    OutputStream outStream = System.out;
    if (outPath != null) {
      outStream = new BufferedOutputStream(new FileOutputStream(outPath + File.separator + new File(newPath).getName()));
    }

    Document delta = createDelta(oldDoc, newDoc);
    JDOMUtil.writeDocument(delta, outStream, "\n");
    if (outStream != System.out) {
      outStream.close();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InspectionDiff.java

示例3: testCarriageReturnInFormat

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public void testCarriageReturnInFormat() throws Exception {
  TaskRepository repository = new YouTrackRepository();
  String format = "foo \n bar";
  repository.setCommitMessageFormat(format);
  ((TaskManagerImpl)myTaskManager).setRepositories(Collections.singletonList(repository));
  TaskManagerImpl.Config config = ((TaskManagerImpl)myTaskManager).getState();
  Element element = XmlSerializer.serialize(config);
  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  JDOMUtil.writeDocument(new Document(element), stream, "\n");

  Element element1 = JDOMUtil.load(new ByteArrayInputStream(stream.toByteArray()));
  TaskManagerImpl.Config deserialize = XmlSerializer.deserialize(element1, TaskManagerImpl.Config.class);
  ((TaskManagerImpl)myTaskManager).loadState(deserialize);

  TaskRepository[] repositories = myTaskManager.getAllRepositories();
  assertEquals(format, repositories[0].getCommitMessageFormat());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TaskSettingsTest.java

示例4: appendProjectLibraries

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public static void appendProjectLibraries(final Project project, @Nullable final File userLibrariesFile) throws IOException {
  if (userLibrariesFile == null) return;
  if (userLibrariesFile.exists() && !userLibrariesFile.isFile()) return;
  final File parentFile = userLibrariesFile.getParentFile();
  if (parentFile == null) return;
  if (!parentFile.isDirectory()) {
    if (!parentFile.mkdir()) return;
  }
  final Element userLibsElement = new Element("eclipse-userlibraries");
  final List<Library> libraries = new ArrayList<Library>(Arrays.asList(ProjectLibraryTable.getInstance(project).getLibraries()));
  ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries());
  for (Library library : libraries) {
    Element libElement = new Element("library");
    libElement.setAttribute("name", library.getName());
    writeUserLibrary(library, libElement);
    userLibsElement.addContent(libElement);
  }
  JDOMUtil.writeDocument(new Document(userLibsElement), userLibrariesFile, "\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EclipseUserLibrariesHelper.java

示例5: saveUserArchetypes

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private void saveUserArchetypes() {
  Element root = new Element(ELEMENT_ARCHETYPES);
  for (MavenArchetype each : myUserArchetypes) {
    Element childElement = new Element(ELEMENT_ARCHETYPE);
    childElement.setAttribute(ELEMENT_GROUP_ID, each.groupId);
    childElement.setAttribute(ELEMENT_ARTIFACT_ID, each.artifactId);
    childElement.setAttribute(ELEMENT_VERSION, each.version);
    if (each.repository != null) {
      childElement.setAttribute(ELEMENT_REPOSITORY, each.repository);
    }
    if (each.description != null) {
      childElement.setAttribute(ELEMENT_DESCRIPTION, each.description);
    }
    root.addContent(childElement);
  }
  try {
    File file = getUserArchetypesFile();
    file.getParentFile().mkdirs();
    JDOMUtil.writeDocument(new Document(root), file, "\n");
  }
  catch (IOException e) {
    MavenLog.LOG.warn(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MavenIndicesManager.java

示例6: writeS3ObjectKeys

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public static String writeS3ObjectKeys(@NotNull Collection<String> s3ObjectKeys) throws IOException {
  Element rootElement = new Element(S3_OBJECT_KEYS);
  for (String s3ObjectKey : s3ObjectKeys){
    if(StringUtil.isEmpty(s3ObjectKey)) continue;
    Element xmlElement = new Element(S3_OBJECT_KEY);
    xmlElement.addContent(s3ObjectKey);
    rootElement.addContent(xmlElement);
  }
  return JDOMUtil.writeDocument(new Document(rootElement), System.getProperty("line.separator"));
}
 
开发者ID:JetBrains,项目名称:teamcity-s3-artifact-storage-plugin,代码行数:12,代码来源:S3PreSignUrlHelper.java

示例7: saveGlobalComponents

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private void saveGlobalComponents(JpsGlobalExtensionSerializer serializer, File optionsDir) throws IOException {
  String fileName = serializer.getConfigFileName();
  File configFile = new File(optionsDir, fileName != null ? fileName : "other.xml");
  Element rootElement = loadOrCreateRootElement(configFile);
  serializer.saveExtension(myGlobal, JDomSerializationUtil.findOrCreateComponentElement(rootElement, serializer.getComponentName()));
  JDOMUtil.writeDocument(new Document(rootElement), configFile, SystemProperties.getLineSeparator());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JpsGlobalElementSaver.java

示例8: saveExtensions

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static void saveExtensions(Map<String, Set<Plugin>> extensions) throws IOException {
  File plugins = getExtensionsFile();
  if (!plugins.isFile()) {
    FileUtil.ensureCanCreateFile(plugins);
  }
  JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(new KnownExtensions(extensions))), plugins, "\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PluginsAdvertiser.java

示例9: saveConversionResult

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static void saveConversionResult(ConversionContextImpl context) {
  final CachedConversionResult conversionResult = new CachedConversionResult();
  for (ConverterProvider provider : ConverterProvider.EP_NAME.getExtensions()) {
    conversionResult.myAppliedConverters.add(provider.getId());
  }
  conversionResult.myProjectFilesTimestamps = getProjectFilesMap(context);
  final File infoFile = getConversionInfoFile(context.getProjectFile());
  FileUtil.createParentDirs(infoFile);
  try {
    JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(conversionResult)), infoFile, SystemProperties.getLineSeparator());
  }
  catch (IOException e) {
    LOG.info(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ConversionServiceImpl.java

示例10: getReportText

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
@Override
public String getReportText() {
  final Element rootElement = new Element("root");
  rootElement.setAttribute("isBackward", String.valueOf(!myForward));
  final List<PsiFile> files = new ArrayList<PsiFile>(myDependencies.keySet());
  Collections.sort(files, new Comparator<PsiFile>() {
    @Override
    public int compare(PsiFile f1, PsiFile f2) {
      final VirtualFile virtualFile1 = f1.getVirtualFile();
      final VirtualFile virtualFile2 = f2.getVirtualFile();
      if (virtualFile1 != null && virtualFile2 != null) {
        return virtualFile1.getPath().compareToIgnoreCase(virtualFile2.getPath());
      }
      return 0;
    }
  });
  for (PsiFile file : files) {
    final Element fileElement = new Element("file");
    fileElement.setAttribute("path", file.getVirtualFile().getPath());
    for (PsiFile dep : myDependencies.get(file)) {
      Element depElement = new Element("dependency");
      depElement.setAttribute("path", dep.getVirtualFile().getPath());
      fileElement.addContent(depElement);
    }
    rootElement.addContent(fileElement);
  }
  PathMacroManager.getInstance(myProject).collapsePaths(rootElement);
  return JDOMUtil.writeDocument(new Document(rootElement), SystemProperties.getLineSeparator());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:DependenciesPanel.java

示例11: replaceRoot

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static void replaceRoot(String path, final String child, final Project project) throws IOException, JDOMException {
  final File emlFile = new File(path, child);
  String fileText = FileUtil.loadFile(emlFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
  if (!SystemInfo.isWindows) {
    fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
  }
  JDOMUtil.writeDocument(JDOMUtil.loadDocument(fileText), emlFile, "\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:EclipseEmlTest.java

示例12: save

import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public void save() throws IOException {
  JDOMUtil.writeDocument(myDocument, myFile, SystemProperties.getLineSeparator());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:SettingsXmlFile.java


注:本文中的com.intellij.openapi.util.JDOMUtil.writeDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。