Java Code Examples for com.intellij.util.xmlb.XmlSerializer#deserialize()
The following examples show how to use
com.intellij.util.xmlb.XmlSerializer#deserialize() .
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: LocalServerRunConfiguration.java From consulo with Apache License 2.0 | 6 votes |
@Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); ConfigurationState state = XmlSerializer.deserialize(element, ConfigurationState.class); myDeploymentSource = null; if (state != null) { Element deploymentTag = state.myDeploymentTag; if (deploymentTag != null) { String typeId = deploymentTag.getAttributeValue(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE); DeploymentSourceType<?> type = findDeploymentSourceType(typeId); if (type != null) { myDeploymentSource = type.load(deploymentTag, getProject()); myDeploymentConfiguration = myDeploymentConfigurator.createDefaultConfiguration(myDeploymentSource); ComponentSerializationUtil.loadComponentState(myDeploymentConfiguration.getSerializer(), deploymentTag.getChild(SETTINGS_ELEMENT)); } else { LOG.warn("Cannot load deployment source for '" + getName() + "' run configuration: unknown deployment type '" + typeId + "'"); } } } }
Example 2
Source File: XBreakpointManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @RequiredWriteAction <T extends XBreakpointProperties> XLineBreakpoint<T> copyLineBreakpoint(@Nonnull XLineBreakpoint<T> source, @Nonnull String fileUrl, int line) { ApplicationManager.getApplication().assertWriteAccessAllowed(); if (!(source instanceof XLineBreakpointImpl<?>)) { return null; } myDependentBreakpointManager.saveState(); final LineBreakpointState sourceState = ((XLineBreakpointImpl<?>)source).getState(); final LineBreakpointState newState = XmlSerializer.deserialize(XmlSerializer.serialize(sourceState, SERIALIZATION_FILTER), LineBreakpointState.class); newState.setLine(line); newState.setFileUrl(fileUrl); //noinspection unchecked final XLineBreakpointImpl<T> breakpoint = (XLineBreakpointImpl<T>)createBreakpoint(newState); if (breakpoint != null) { addBreakpoint(breakpoint, false, true); final XBreakpoint<?> masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(source); if (masterBreakpoint != null) { myDependentBreakpointManager.setMasterBreakpoint(breakpoint, masterBreakpoint, sourceState.getDependencyState().isLeaveEnabled()); } } return breakpoint; }
Example 3
Source File: DeployToServerRunConfiguration.java From consulo with Apache License 2.0 | 6 votes |
@Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); ConfigurationState state = XmlSerializer.deserialize(element, ConfigurationState.class); myServerName = null; myDeploymentSource = null; if (state != null) { myServerName = state.myServerName; Element deploymentTag = state.myDeploymentTag; if (deploymentTag != null) { String typeId = deploymentTag.getAttributeValue(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE); DeploymentSourceType<?> type = findDeploymentSourceType(typeId); if (type != null) { myDeploymentSource = type.load(deploymentTag, getProject()); myDeploymentConfiguration = myDeploymentConfigurator.createDefaultConfiguration(myDeploymentSource); ComponentSerializationUtil.loadComponentState(myDeploymentConfiguration.getSerializer(), deploymentTag.getChild(SETTINGS_ELEMENT)); } else { LOG.warn("Cannot load deployment source for '" + getName() + "' run configuration: unknown deployment type '" + typeId + "'"); } } } }
Example 4
Source File: MuleSdkManagerImpl.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@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); } } }
Example 5
Source File: ThriftFacetConfigurationSerializer.java From intellij-thrift with Apache License 2.0 | 6 votes |
@Override protected ThriftCompilerOptions loadExtension(@NotNull Element facetConfigurationElement, String name, JpsElement parent, JpsModule module) { ThriftCompilerOptions configuration = XmlSerializer.deserialize( facetConfigurationElement, ThriftCompilerOptions.class ); if (configuration == null) { configuration = new ThriftCompilerOptions(); } return configuration; }
Example 6
Source File: DefaultStateSerializer.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked"}) @Nullable public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass) throws StateStorageException { if (stateElement == null) return null; if (stateClass.equals(Element.class)) { //assert mergeInto == null; return (T)stateElement; } else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) { final T t = ReflectionUtil.newInstance(stateClass); try { ((JDOMExternalizable)t).readExternal(stateElement); return t; } catch (InvalidDataException e) { throw new StateStorageException(e); } } else { return XmlSerializer.deserialize(stateElement, stateClass); } }
Example 7
Source File: FeatureUsageTrackerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void loadState(final Element element) { List featuresList = element.getChildren(FEATURE_TAG); for (Object aFeaturesList : featuresList) { Element featureElement = (Element)aFeaturesList; FeatureDescriptor descriptor = ((ProductivityFeaturesRegistryImpl)myRegistry).getFeatureDescriptorEx(featureElement.getAttributeValue(ATT_ID)); if (descriptor != null) { descriptor.readStatistics(featureElement); } } Element stats = element.getChild(COMPLETION_STATS_TAG); if (stats != null) { myCompletionStats = XmlSerializer.deserialize(stats, CompletionStatistics.class); } Element fStats = element.getChild(FIXES_STATS_TAG); if (fStats != null) { myFixesStats = XmlSerializer.deserialize(fStats, CumulativeStatistics.class); } HAVE_BEEN_SHOWN = Boolean.valueOf(element.getAttributeValue(ATT_HAVE_BEEN_SHOWN)); }
Example 8
Source File: MasterDetailsStateService.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public MasterDetailsState getComponentState(@Nonnull @NonNls String key, Class<? extends MasterDetailsState> stateClass) { ComponentState state = myStates.get(key); if (state == null) return null; final Element settings = state.mySettings; return settings != null ? XmlSerializer.deserialize(settings, stateClass) : null; }
Example 9
Source File: ExternalSystemRunConfiguration.java From consulo with Apache License 2.0 | 5 votes |
@Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); Element e = element.getChild(ExternalSystemTaskExecutionSettings.TAG_NAME); if (e != null) { mySettings = XmlSerializer.deserialize(e, ExternalSystemTaskExecutionSettings.class); } }
Example 10
Source File: JpsHaxeSdkType.java From intellij-haxe with Apache License 2.0 | 5 votes |
public static JpsSdkPropertiesSerializer<JpsHaxeSdkAdditionalData> createJpsSdkPropertiesSerializer() { return new JpsSdkPropertiesSerializer<JpsHaxeSdkAdditionalData>(HaxeCommonBundle.message("haxe.sdk.name"), INSTANCE) { @NotNull public JpsHaxeSdkAdditionalData loadProperties(@Nullable final Element propertiesElement) { final HaxeSdkAdditionalDataBase sdkData = XmlSerializer.deserialize(propertiesElement, HaxeSdkAdditionalDataBaseImpl.class); return new JpsHaxeSdkAdditionalDataImpl(sdkData); } public void saveProperties(@NotNull final JpsHaxeSdkAdditionalData properties, @NotNull final Element element) { XmlSerializer.serializeInto(properties.getSdkData(), element); } }; }
Example 11
Source File: JpsHaskellBuildOptionsSerializer.java From intellij-haskforce with Apache License 2.0 | 5 votes |
@Override public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) { JpsHaskellBuildOptionsExtension extension = JpsHaskellBuildOptionsExtension.getOrCreateExtension(project); HaskellBuildOptions options = XmlSerializer.deserialize(componentTag, HaskellBuildOptions.class); if (options != null) { extension.setOptions(options); } }
Example 12
Source File: ProjectCacheStoreTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void getSetState(TemporaryFolder tmpDir) throws PrimitiveMap.UnmarshalException { ProjectCacheStore.State state = new ProjectCacheStore.State(); ClientServerRef ref = new ClientServerRef( P4ServerName.forPortNotNull("test:1234"), "client1" ); state.clientState = Collections.singletonList(new ClientQueryCacheStore(ref).getState()); state.serverState = Collections.singletonList(new ServerQueryCacheStore(ref.getServerName()).getState()); MockFilePath fp = new MockFilePath(tmpDir.newFile("test-file.txt")); ActionStore.State actionState = ActionStore.getState( ActionStore.getSourceId(ref), new MoveFilesToChangelistAction(new P4ChangelistIdImpl(1, ref), Collections.singletonList(fp))); state.pendingActions = Collections.singletonList(actionState); Element serialized = XmlSerializer.serialize(state); ProjectCacheStore.State unmarshalled = XmlSerializer.deserialize(serialized, ProjectCacheStore.State.class); assertNotNull(unmarshalled); assertSize(1, unmarshalled.clientState); assertSize(1, unmarshalled.serverState); assertSize(1, unmarshalled.pendingActions); assertNotNull(unmarshalled.pendingActions.get(0)); ActionStore.PendingAction moveAction = ActionStore.read(unmarshalled.pendingActions.get(0)); assertThat(moveAction.clientAction, instanceOf(MoveFilesToChangelistAction.class)); }
Example 13
Source File: PathMappingSettings.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static PathMappingSettings readExternal(@Nullable final Element element) { if (element == null) { return null; } final Element settingsElement = element.getChild(PathMappingSettings.class.getSimpleName()); if (settingsElement == null) { return null; } return XmlSerializer.deserialize(settingsElement, PathMappingSettings.class); }
Example 14
Source File: VcsRootCacheStoreTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Test void serializeRestore_two() { MockVirtualFile localDir = MockVirtualFileSystem.createTree("/my/local/file", "data").get("/my/local/file"); when(idea.getMockLocalFilesystem().findFileByPath("/my/local/file")).thenReturn(localDir); VcsRootCacheStore store = new VcsRootCacheStore(localDir); ClientNameConfigPart part1 = new ClientNameConfigPart("source"); part1.setClientname("client-name-1"); ServerFingerprintDataPart part2 = new ServerFingerprintDataPart("source1"); part2.setServerFingerprint("fingerprint-1"); store.setConfigParts(Arrays.asList(part1, part2)); VcsRootCacheStore.State originalState = store.getState(); Element serialized = XmlSerializer.serialize(originalState); assertNotNull(serialized); VcsRootCacheStore.State restored = XmlSerializer.deserialize(serialized, VcsRootCacheStore.State.class); assertNotNull(restored); assertEquals("/my/local/file", restored.rootDirectory); assertSize(2, restored.configParts); assertNotNull(restored.configParts.get(0)); assertEquals(restored.configParts.get(0).className, ClientNameConfigPart.class.getName()); assertNull(restored.configParts.get(0).children); assertNotNull(restored.configParts.get(1)); assertEquals(restored.configParts.get(1).className, ServerFingerprintDataPart.class.getName()); assertNull(restored.configParts.get(1).children); VcsRootCacheStore loaded = new VcsRootCacheStore(restored, getClass().getClassLoader()); assertEquals(localDir, loaded.getRootDirectory()); assertSize(2, loaded.getConfigParts()); assertThat(loaded.getConfigParts().get(0), instanceOf(ClientNameConfigPart.class)); ClientNameConfigPart part1Restored = (ClientNameConfigPart) loaded.getConfigParts().get(0); assertEquals("client-name-1", part1Restored.getClientname()); assertThat(loaded.getConfigParts().get(1), instanceOf(ServerFingerprintDataPart.class)); ServerFingerprintDataPart part2Restored = (ServerFingerprintDataPart) loaded.getConfigParts().get(1); assertEquals("fingerprint-1", part2Restored.getServerFingerprint()); }
Example 15
Source File: PersistentRootConfigComponent.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void loadState(Element element) { if (element == null || element.getChildren().isEmpty()) { LOG.warn("Loaded null or empty state"); return; } synchronized (sync) { rootPartMap.clear(); for (Element root : element.getChildren("root")) { if (root.getChildren().isEmpty()) { LOG.warn("Invalid parsing of serialized node " + new XMLOutputter().outputString(root)); continue; } final VcsRootCacheStore.State state = XmlSerializer.deserialize( root.getChildren().get(0), VcsRootCacheStore.State.class); if (state.rootDirectory == null) { LOG.warn("Loaded a null root directory configuration; assuming root directory " + ProjectUtil.findProjectBaseDir(project)); state.rootDirectory = project.getBasePath(); } final VcsRootCacheStore store = new VcsRootCacheStore(state, null); VirtualFile rootDir = store.getRootDirectory(); rootPartMap.put(rootDir, store.getConfigParts()); } if (LOG.isDebugEnabled()) { LOG.debug("Loaded state from XML: " + rootPartMap); } } }
Example 16
Source File: DarkModeSyncThemesTest.java From dark-mode-sync-plugin with MIT License | 5 votes |
/** * Verifies that the {@link DarkModeSyncThemes.State} class may be serialized and de-serialized * using the {@link XmlSerializer}. */ @Test void state_serialization_test() { final State expected = new State(); final Element element = XmlSerializer.serialize(expected); final State actual = XmlSerializer.deserialize(element, State.class); assertEquals(expected, actual); }
Example 17
Source File: HaxeSdkType.java From intellij-haxe with Apache License 2.0 | 4 votes |
@Override public SdkAdditionalData loadAdditionalData(Element additional) { return XmlSerializer.deserialize(additional, HaxeSdkData.class); }
Example 18
Source File: XmlUtils.java From intellij-xquery with Apache License 2.0 | 4 votes |
public static <T> T deserializeFromXml(Element element, Class<T> deserializedElementClass) { return XmlSerializer.deserialize(element, deserializedElementClass); }
Example 19
Source File: PhpStanValidatorConfigurationBaseManager.java From idea-php-generics-plugin with MIT License | 4 votes |
@Nullable protected PhpStanValidatorConfiguration loadLocal(Element element) { return XmlSerializer.deserialize(element, PhpStanValidatorConfiguration.class); }
Example 20
Source File: PsalmValidatorRemoteConfigurationProvider.java From idea-php-generics-plugin with MIT License | 4 votes |
@Nullable public PsalmValidatorConfiguration load(@NotNull Element element) { return XmlSerializer.deserialize(element, PsalmValidatorRemoteConfiguration.class); }