本文整理汇总了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"));
}
示例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();
}
}
示例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());
}
示例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");
}
示例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);
}
}
示例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"));
}
示例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());
}
示例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");
}
示例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);
}
}
示例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());
}
示例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");
}
示例12: save
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public void save() throws IOException {
JDOMUtil.writeDocument(myDocument, myFile, SystemProperties.getLineSeparator());
}