Java Code Examples for com.intellij.openapi.util.JDOMUtil#loadDocument()
The following examples show how to use
com.intellij.openapi.util.JDOMUtil#loadDocument() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TelegramSettingsManager.java From teamcity-telegram-plugin with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: S3PreSignUrlHelper.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 6 votes |
@NotNull public static Map<String, URL> readPreSignUrlMapping(String data) throws IOException { Document document; try { document = JDOMUtil.loadDocument(data); } catch (JDOMException e) { return Collections.emptyMap(); } final 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)) { final Element mapEntryElementCasted = (Element)mapEntryElement; final String s3ObjectKey = mapEntryElementCasted.getChild(S3_OBJECT_KEY).getValue(); final String preSignUrlString = mapEntryElementCasted.getChild(PRE_SIGN_URL).getValue(); result.put(s3ObjectKey, new URL(preSignUrlString)); } return result; }
Example 3
Source File: S3PreSignUrlHelper.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 6 votes |
@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; }
Example 4
Source File: PluginErrorSubmitDialog.java From BashSupport with Apache License 2.0 | 6 votes |
public void prepare(String additionalInfo, String stacktrace, String versionId) { reportComponent.descriptionField.setText(additionalInfo); reportComponent.stacktraceField.setText(stacktrace); reportComponent.versionField.setText(versionId); File file = new File(getOptionsFilePath()); if (file.exists()) { try { Document document = JDOMUtil.loadDocument(file); Element applicationElement = document.getRootElement(); if (applicationElement == null) { throw new InvalidDataException("Expected root element >application< not found"); } Element componentElement = applicationElement.getChild("component"); if (componentElement == null) { throw new InvalidDataException("Expected element >component< not found"); } DefaultJDOMExternalizer.readExternal(this, componentElement); reportComponent.nameField.setText(USERNAME); } catch (Exception e) { LOGGER.info("Unable to read configuration file", e); } } }
Example 5
Source File: UnityFunctionManager.java From consulo-unity3d with Apache License 2.0 | 6 votes |
public UnityFunctionManager() { try { Document document = JDOMUtil.loadDocument(UnityFunctionManager.class.getResourceAsStream("/functions.xml")); for(Element typeElement : document.getRootElement().getChildren()) { String typeName = typeElement.getAttributeValue("name"); Map<String, FunctionInfo> value = new THashMap<>(); myFunctionsByType.put(typeName, value); for(Element element : typeElement.getChildren()) { FunctionInfo functionInfo = new FunctionInfo(element); value.put(functionInfo.myName, functionInfo); } } } catch(JDOMException | IOException e) { LOGGER.error(e); } }
Example 6
Source File: InspectionTestUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void compareToolResults(@Nonnull GlobalInspectionContextImpl context, @Nonnull 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); } }
Example 7
Source File: FileEditorManagerTest.java From consulo with Apache License 2.0 | 6 votes |
private void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException { Document document = JDOMUtil.loadDocument(s); Element rootElement = document.getRootElement(); ExpandMacroToPathMap map = new ExpandMacroToPathMap(); map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath()); map.substitute(rootElement, true, true); myManager.loadState(rootElement); UIAccess uiAccess = UIAccess.get(); Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { myManager.getMainSplitters().openFiles(uiAccess); } }); future.get(); }
Example 8
Source File: DefaultKeymap.java From consulo with Apache License 2.0 | 6 votes |
public DefaultKeymap() { for(BundledKeymapEP bundledKeymapEP : BundledKeymapEP.EP_NAME.getExtensions()) { try { InputStream inputStream = bundledKeymapEP.getLoaderForClass().getResourceAsStream(bundledKeymapEP.file + ".xml"); if(inputStream == null) { LOG.warn("Keymap: " + bundledKeymapEP.file + " not found in " + bundledKeymapEP.getPluginDescriptor().getPluginId().getIdString()); continue; } Document document = JDOMUtil.loadDocument(inputStream); loadKeymapsFromElement(document.getRootElement()); } catch (Exception e) { LOG.error(e); } } }
Example 9
Source File: InspectionDiff.java From consulo with Apache License 2.0 | 6 votes |
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(); } }
Example 10
Source File: AbstractImportTestsAction.java From consulo with Apache License 2.0 | 5 votes |
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) { } }
Example 11
Source File: ExternalOptionHelper.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static List<CopyrightProfile> loadOptions(File file) { try { List<CopyrightProfile> profiles = new ArrayList<CopyrightProfile>(); Document doc = JDOMUtil.loadDocument(file); Element root = doc.getRootElement(); if (root.getName().equals("component")) { final Element copyrightElement = root.getChild("copyright"); if (copyrightElement != null) extractNewNoticeAndKeyword(copyrightElement, profiles); } else { List list = root.getChildren("component"); for (Object element : list) { Element component = (Element)element; String name = component.getAttributeValue("name"); if (name.equals("CopyrightManager")) { for (Object o : component.getChildren("copyright")) { extractNewNoticeAndKeyword((Element)o, profiles); } } else if (name.equals("copyright")) { extractNoticeAndKeyword(component, profiles); } } } return profiles; } catch (Exception e) { logger.info(e); Messages.showErrorDialog(e.getMessage(), "Import Failure"); return null; } }