本文整理汇总了Java中com.intellij.openapi.util.JDOMUtil.loadDocument方法的典型用法代码示例。如果您正苦于以下问题:Java JDOMUtil.loadDocument方法的具体用法?Java JDOMUtil.loadDocument怎么用?Java JDOMUtil.loadDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.JDOMUtil
的用法示例。
在下文中一共展示了JDOMUtil.loadDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reloadConfiguration
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private synchronized void reloadConfiguration() throws JDOMException, IOException {
LOG.info("Loading configuration file: " + configFile);
Document document = JDOMUtil.loadDocument(configFile.toFile());
Element root = document.getRootElement();
TelegramSettings newSettings = new TelegramSettings();
newSettings.setBotToken(unscramble(root.getAttributeValue(BOT_TOKEN_ATTR)));
newSettings.setPaused(Boolean.parseBoolean(root.getAttributeValue(PAUSE_ATTR)));
newSettings.setUseProxy(Boolean.parseBoolean(root.getAttributeValue(USE_PROXY_ATTR)));
newSettings.setProxyServer(root.getAttributeValue(PROXY_SERVER_ATTR));
newSettings.setProxyPort(restoreInteger(root.getAttributeValue(PROXY_PORT_ATTR)));
newSettings.setProxyUsername(root.getAttributeValue(PROXY_PASSWORD_ATTR));
newSettings.setProxyPassword(unscramble(root.getAttributeValue(PROXY_PASSWORD_ATTR)));
settings = newSettings;
botManager.reloadIfNeeded(settings);
}
示例2: readPreSignUrlMapping
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public static Map<String, URL> readPreSignUrlMapping(String data) throws IOException {
Document document;
try {
document = JDOMUtil.loadDocument(data);
} catch (JDOMException e) {
return Collections.emptyMap();
}
Element rootElement = document.getRootElement();
if(!rootElement.getName().equals(S3_PRESIGN_URL_MAPPING)) return Collections.emptyMap();
final Map<String, URL> result = new HashMap<String, URL>();
for(Object mapEntryElement : rootElement.getChildren(S3_PRESIGN_URL_MAP_ENTRY)){
Element mapEntryElementCasted = (Element) mapEntryElement;
String s3ObjectKey = mapEntryElementCasted.getChild(S3_OBJECT_KEY).getValue();
String preSignUrlString = mapEntryElementCasted.getChild(PRE_SIGN_URL).getValue();
result.put(s3ObjectKey, new URL(preSignUrlString));
}
return result;
}
示例3: readS3ObjectKeys
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public static Collection<String> readS3ObjectKeys(String data) throws IOException {
Document document;
try {
document = JDOMUtil.loadDocument(data);
} catch (JDOMException e) {
return Collections.emptyList();
}
Element rootElement = document.getRootElement();
if(!rootElement.getName().equals(S3_OBJECT_KEYS)) return Collections.emptyList();
Collection<String> result = new HashSet<String>();
for(Object element : rootElement.getChildren(S3_OBJECT_KEY)) {
Element elementCasted = (Element) element;
result.add(elementCasted.getValue());
}
return result;
}
示例4: openFiles
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
protected void openFiles(@NotNull String femSerialisedText) throws IOException, JDOMException, InterruptedException, ExecutionException {
Document document = JDOMUtil.loadDocument(femSerialisedText);
Element rootElement = document.getRootElement();
ExpandMacroToPathMap map = new ExpandMacroToPathMap();
map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
map.substitute(rootElement, true, true);
myManager.readExternal(rootElement);
Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
myManager.getMainSplitters().openFiles();
}
});
while (true) {
try {
future.get(100, TimeUnit.MILLISECONDS);
return;
}
catch (TimeoutException e) {
UIUtil.dispatchAllInvocationEvents();
}
}
}
示例5: compareToolResults
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public static void compareToolResults(@NotNull GlobalInspectionContextImpl context,
@NotNull InspectionToolWrapper toolWrapper,
boolean checkRange,
String testDir) {
final Element root = new Element("problems");
final Document doc = new Document(root);
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
presentation.updateContent(); //e.g. dead code need check for reachables
presentation.exportResults(root);
File file = new File(testDir + "/expected.xml");
try {
Document expectedDocument = JDOMUtil.loadDocument(file);
compareWithExpected(expectedDocument, doc, checkRange);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: testConditionConvert
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public void testConditionConvert() {
String condition = "old-style condition";
String logExpression = "old-style expression";
String oldStyle =
"<breakpoint-manager>" +
"<breakpoints>" +
"<line-breakpoint enabled=\"true\" type=\"" + MY_LINE_BREAKPOINT_TYPE.getId() + "\">" +
" <condition>" + condition + "</condition>" +
" <url>url</url>" +
" <log-expression>" + logExpression + "</log-expression>" +
"</line-breakpoint>" +
"</breakpoints>" +
"<option name=\"time\" value=\"1\" />" +
"</breakpoint-manager>";
try {
Document document = JDOMUtil.loadDocument(oldStyle);
load(document.getRootElement());
}
catch (Exception e) {
e.printStackTrace();
fail();
}
XLineBreakpoint<MyBreakpointProperties> breakpoint = assertOneElement(myBreakpointManager.getBreakpoints(MY_LINE_BREAKPOINT_TYPE));
assertEquals(condition, breakpoint.getCondition());
assertEquals(logExpression, breakpoint.getLogExpression());
}
示例7: loadCachedConversionResult
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
private static CachedConversionResult loadCachedConversionResult(File projectFile) {
try {
final File infoFile = getConversionInfoFile(projectFile);
if (!infoFile.exists()) {
return new CachedConversionResult();
}
final Document document = JDOMUtil.loadDocument(infoFile);
final CachedConversionResult result = XmlSerializer.deserialize(document, CachedConversionResult.class);
return result != null ? result : new CachedConversionResult();
}
catch (Exception e) {
LOG.info(e);
return new CachedConversionResult();
}
}
示例8: 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();
}
}
示例9: loadControls
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private static Control[] loadControls() {
Document document;
try {
// use temporary bytes stream because otherwise inputStreamSkippingBOM will fail
// on ZipFileInputStream used in jar files
final InputStream stream = HTMLControls.class.getResourceAsStream("HtmlControls.xml");
final byte[] bytes = FileUtilRt.loadBytes(stream);
stream.close();
final UnsyncByteArrayInputStream bytesStream = new UnsyncByteArrayInputStream(bytes);
document = JDOMUtil.loadDocument(CharsetToolkit.inputStreamSkippingBOM(bytesStream));
bytesStream.close();
} catch (Exception e) {
LOG.error(e);
return new Control[0];
}
if (!document.getRootElement().getName().equals("htmlControls")) {
LOG.error("HTMLControls storage is broken");
return new Control[0];
}
return XmlSerializer.deserialize(document, Control[].class);
}
示例10: getGradleProjectConfiguration
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public GradleProjectConfiguration getGradleProjectConfiguration(@NotNull File dataStorageRoot) {
final File configFile = new File(dataStorageRoot, GradleProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);
GradleProjectConfiguration config;
synchronized (myLoadedConfigs) {
config = myLoadedConfigs.get(configFile);
if (config == null) {
config = new GradleProjectConfiguration();
try {
final Document document = JDOMUtil.loadDocument(configFile);
XmlSerializer.deserializeInto(config, document.getRootElement());
}
catch (Exception e) {
LOG.info(e);
}
myLoadedConfigs.put(configFile, config);
}
}
return config;
}
示例11: loadLastConfiguration
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
private GradleProjectConfiguration loadLastConfiguration(@NotNull File gradleConfigFile) {
final GradleProjectConfiguration projectConfig = new GradleProjectConfiguration();
if (gradleConfigFile.exists()) {
try {
final Document document = JDOMUtil.loadDocument(gradleConfigFile);
XmlSerializer.deserializeInto(projectConfig, document.getRootElement());
// filter orphan modules
final Set<String> actualModules = myModulesConfigurationHash.keySet();
for (Iterator<Map.Entry<String, GradleModuleResourceConfiguration>> iterator =
projectConfig.moduleConfigurations.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<String, GradleModuleResourceConfiguration> configurationEntry = iterator.next();
if (!actualModules.contains(configurationEntry.getKey())) {
iterator.remove();
}
}
}
catch (Exception e) {
LOG.info(e);
}
}
return projectConfig;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GradleResourceCompilerConfigurationGenerator.java
示例12: loadContext
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private synchronized boolean loadContext(String zipPostfix, String entryName) {
JBZipFile archive = null;
try {
archive = getTasksArchive(zipPostfix);
JBZipEntry entry = archive.getEntry(StringUtil.startsWithChar(entryName, '/') ? entryName : "/" + entryName);
if (entry != null) {
byte[] bytes = entry.getData();
Document document = JDOMUtil.loadDocument(new String(bytes));
Element rootElement = document.getRootElement();
loadContext(rootElement);
return true;
}
}
catch (Exception e) {
LOG.error(e);
}
finally {
closeArchive(archive);
}
return false;
}
示例13: getMavenProjectConfiguration
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
public MavenProjectConfiguration getMavenProjectConfiguration(@NotNull File dataStorageRoot) {
final File configFile = new File(dataStorageRoot, MavenProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);
MavenProjectConfiguration config;
synchronized (myLoadedConfigs) {
config = myLoadedConfigs.get(configFile);
if (config == null) {
config = new MavenProjectConfiguration();
try {
final Document document = JDOMUtil.loadDocument(configFile);
XmlSerializer.deserializeInto(config, document.getRootElement());
}
catch (Exception e) {
LOG.info(e);
}
myLoadedConfigs.put(configFile, config);
}
}
return config;
}
示例14: computeModuleType
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@NotNull
private static ModuleType computeModuleType(LocalArchivedTemplate template) {
String iml = template.readEntry(".iml");
if (iml == null) return ModuleType.EMPTY;
try {
Document document = JDOMUtil.loadDocument(iml);
String type = document.getRootElement().getAttributeValue(Module.ELEMENT_TYPE);
return ModuleTypeManager.getInstance().findByID(type);
}
catch (Exception e) {
return ModuleType.EMPTY;
}
}
示例15: ImportRunProfile
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
public ImportRunProfile(VirtualFile file, Project project) {
myFile = file;
myProject = project;
try {
final Document document = JDOMUtil.loadDocument(VfsUtilCore.virtualToIoFile(myFile));
final Element config = document.getRootElement().getChild("config");
if (config != null) {
String configTypeId = config.getAttributeValue("configId");
if (configTypeId != null) {
final ConfigurationType configurationType = ConfigurationTypeUtil.findConfigurationType(configTypeId);
if (configurationType != null) {
myConfiguration = configurationType.getConfigurationFactories()[0].createTemplateConfiguration(project);
myConfiguration.setName(config.getAttributeValue("name"));
myConfiguration.readExternal(config);
final Executor executor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
if (executor != null) {
if (myConfiguration instanceof SMRunnerConsolePropertiesProvider) {
myProperties = ((SMRunnerConsolePropertiesProvider)myConfiguration).createTestConsoleProperties(executor);
}
}
}
}
myTargetId = config.getAttributeValue("target");
}
}
catch (Exception ignore) {
}
}