@Nullable @Override public Element getState() { Element element = new Element("mule-sdks"); try { for (MuleSdk sdk : sdks) { final Element sdkElement = new Element("mule-sdk"); XmlSerializer.serializeInto(sdk, sdkElement, new SkipDefaultValuesSerializationFilters()); element.addContent(sdkElement); } } catch (XmlSerializationException e) { LOG.error(e); } return element; }
@Override public void loadState(Element state) { final List<Element> children = state.getChildren(); for (Element child : children) { try { final MuleSdk deserialize = XmlSerializer.deserialize(child, MuleSdk.class); if (deserialize != null && deserialize.getMuleHome() != null) { sdks.add(deserialize); } } catch (XmlSerializationException e) { LOG.error(e); } } }
/** * Read in settings from XML config. * Default implementation uses XmlSerializer so you may use public fields (like <code>int TOOL_OPTION</code>) * and bean-style getters/setters (like <code>int getToolOption(), void setToolOption(int)</code>) to store your options. * * @param node to read settings from. * @throws InvalidDataException if the loaded data was not valid. */ @SuppressWarnings("deprecation") public void readSettings(@NotNull Element node) throws InvalidDataException { if (useNewSerializer()) { try { XmlSerializer.deserializeInto(this, node); } catch (XmlSerializationException e) { throw new InvalidDataException(e); } } else { //noinspection UnnecessaryFullyQualifiedName com.intellij.openapi.util.DefaultJDOMExternalizer.readExternal(this, node); } }
@Nullable private static Artifacts deserialize(@Nullable URL url) { if (url == null) return null; Artifacts allArtifacts = null; try { allArtifacts = XmlSerializer.deserialize(url, Artifacts.class); } catch (XmlSerializationException e) { final Throwable cause = e.getCause(); if (!(cause instanceof IOException)) { LOG.error(e); } } return allArtifacts; }
public static ArrayList<TaskRepository> loadRepositories(Element element) { ArrayList<TaskRepository> repositories = new ArrayList<TaskRepository>(); for (TaskRepositoryType repositoryType : TaskRepositoryType.getRepositoryTypes()) { for (Object o : element.getChildren()) { if (((Element)o).getName().equals(repositoryType.getName())) { try { @SuppressWarnings({"unchecked"}) TaskRepository repository = (TaskRepository)XmlSerializer.deserialize((Element)o, repositoryType.getRepositoryClass()); if (repository != null) { repository.setRepositoryType(repositoryType); repositories.add(repository); } } catch (XmlSerializationException e) { LOG.error(e.getMessage(), e); } } } } return repositories; }
@Nullable private static IdeSettingsDescriptors deserialize(@Nullable URL url) { if (url == null) return null; IdeSettingsDescriptors ideSettingsDescriptor = null; try { ideSettingsDescriptor = XmlSerializer.deserialize(url, IdeSettingsDescriptors.class); } catch (XmlSerializationException e) { final Throwable cause = e.getCause(); if (!(cause instanceof IOException)) { LOG.error(e); } } return ideSettingsDescriptor; }
public static ArrayList<TaskRepository> loadRepositories(Element element) { ArrayList<TaskRepository> repositories = new ArrayList<TaskRepository>(); for (TaskRepositoryType repositoryType : ourRepositoryTypes) { for (Object o : element.getChildren()) { if (((Element)o).getName().equals(repositoryType.getName())) { try { @SuppressWarnings({"unchecked"}) TaskRepository repository = (TaskRepository)XmlSerializer.deserialize((Element)o, repositoryType.getRepositoryClass()); if (repository != null) { repository.setRepositoryType(repositoryType); repositories.add(repository); } } catch (XmlSerializationException e) { // ignore } } } } return repositories; }
/** * Read in settings from XML config. * Default implementation uses XmlSerializer so you may use public fields (like <code>int TOOL_OPTION</code>) * and bean-style getters/setters (like <code>int getToolOption(), void setToolOption(int)</code>) to store your options. * * @param node to read settings from. * @throws InvalidDataException if the loaded data was not valid. */ @SuppressWarnings("deprecation") public void readSettings(@Nonnull Element node) throws InvalidDataException { if (useNewSerializer()) { try { XmlSerializer.deserializeInto(this, node); } catch (XmlSerializationException e) { throw new InvalidDataException(e); } } else { //noinspection UnnecessaryFullyQualifiedName com.intellij.openapi.util.DefaultJDOMExternalizer.readExternal(this, node); } }
private static int getCourseId(@NotNull StudyTaskManager taskManager, @NotNull Element component) { try { taskManager.loadState(component); Course course = taskManager.getCourse(); if (course instanceof RemoteCourse) { return ((RemoteCourse)course).getId(); } } catch (IllegalStateException | XmlSerializationException ignored) { } return 0; }
@Nullable private static LibraryJarDescriptors deserialize(@Nullable URL url) { if (url == null) return null; LibraryJarDescriptors libraryJarDescriptors = null; try { libraryJarDescriptors = XmlSerializer.deserialize(url, LibraryJarDescriptors.class); } catch (XmlSerializationException e) { // } return libraryJarDescriptors; }
@Override public void loadState(final Element state) { try { XmlSerializer.deserializeInto(this, state); } catch (XmlSerializationException e) { LOG.info(e); } }
public void writeExternal(final Element element) { try { XmlSerializer.serializeInto(this, element, new SkipDefaultValuesSerializationFilters()); } catch (XmlSerializationException e) { LOG.info(e); } }
@Override public void projectOpened() { ProjectSettings projectSettings = ServiceManager.getService(myProject, ProjectSettings.class); try { if (projectSettings.applications.isEmpty()) { detectCleverApp(); } else { CcLogsToolWindow ccLogsToolWindow = new CcLogsToolWindow(myProject); } } catch (XmlSerializationException e) { e.printStackTrace(); } }
public static ArrayList<TaskRepository> loadRepositories(Element element) { ArrayList<TaskRepository> repositories = new ArrayList<>(); for(TaskRepositoryType repositoryType : TaskRepositoryType.getRepositoryTypes()) { for(Object o : element.getChildren()) { if(((Element) o).getName().equals(repositoryType.getName())) { try { @SuppressWarnings({"unchecked"}) TaskRepository repository = (TaskRepository) XmlSerializer.deserialize((Element) o, repositoryType.getRepositoryClass()); if(repository != null) { repository.setRepositoryType(repositoryType); repositories.add(repository); } } catch(XmlSerializationException e) { LOG.error(e.getMessage(), e); } } } } return repositories; }
@Override public void loadState(final Element state) { try { XmlSerializer.deserializeInto(this, state); } catch(XmlSerializationException e) { JavaSmartKeysSettings.LOGGER.info(e); } }
public void writeExternal(final Element element) { try { XmlSerializer.serializeInto(this, element, new SkipDefaultValuesSerializationFilters()); } catch(XmlSerializationException e) { JavaSmartKeysSettings.LOGGER.info(e); } }