Search in sources :

Example 26 with WriteExternalException

use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.

the class ConfigureTasksActivationDialog method updateTree.

private void updateTree(@Nullable CachingSimpleNode nodeToUpdate) {
    Set<CachingSimpleNode> toUpdate = ContainerUtil.newIdentityTroveSet();
    if (nodeToUpdate == null) {
        for (DefaultMutableTreeNode node : myTree.getSelectedNodes(DefaultMutableTreeNode.class, null)) {
            final Object userObject = node.getUserObject();
            if (userObject instanceof SimpleNode && ((SimpleNode) userObject).getParent() instanceof CachingSimpleNode) {
                toUpdate.add((CachingSimpleNode) ((SimpleNode) userObject).getParent());
            }
        }
    } else {
        toUpdate.add(nodeToUpdate);
    }
    if (toUpdate.isEmpty()) {
        toUpdate.add(myRootNode);
    }
    Element treeStateElement = new Element("root");
    try {
        TreeState.createOn(myTree).writeExternal(treeStateElement);
    } catch (WriteExternalException ignore) {
    }
    for (CachingSimpleNode node : toUpdate) {
        cleanUpEmptyNodes(node);
    }
    TreeState treeState = new TreeState();
    try {
        treeState.readExternal(treeStateElement);
        treeState.applyTo(myTree);
    } catch (InvalidDataException ignore) {
    }
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 27 with WriteExternalException

use of com.intellij.openapi.util.WriteExternalException in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfiguration method writeExternal.

@Override
public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);
    final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.getProject());
    final Element appConfigElement = XmlSerializer.serialize(this.appConfig, (accessor, o) -> !"artifact".equalsIgnoreCase(accessor.getName()));
    final IArtifact artifact = this.appConfig.getDeployment().getArtifact();
    Optional.ofNullable(this.appConfig).map(config -> XmlSerializer.serialize(config, (accessor, o) -> !"artifact".equalsIgnoreCase(accessor.getName()))).ifPresent(element::addContent);
    Optional.ofNullable(this.appConfig).map(config -> (WrappedAzureArtifact) config.getDeployment().getArtifact()).map((a) -> manager.getArtifactIdentifier(a.getArtifact())).map(id -> new Element("Artifact").setAttribute("identifier", id)).ifPresent(element::addContent);
}
Also used : XmlSerializer(com.intellij.util.xmlb.XmlSerializer) Setter(lombok.Setter) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig) Getter(lombok.Getter) ConfigurationType(com.intellij.execution.configurations.ConfigurationType) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) InvalidDataException(com.intellij.openapi.util.InvalidDataException) RunProfileState(com.intellij.execution.configurations.RunProfileState) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Project(com.intellij.openapi.project.Project) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) LocatableConfiguration(com.intellij.execution.configurations.LocatableConfiguration) SettingsEditor(com.intellij.openapi.options.SettingsEditor) LocatableConfigurationBase(com.intellij.execution.configurations.LocatableConfigurationBase) Executor(com.intellij.execution.Executor) IArtifact(com.microsoft.azure.toolkit.lib.common.model.IArtifact) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AzureValidationInfo(com.microsoft.azure.toolkit.lib.common.form.AzureValidationInfo) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Optional(java.util.Optional) ConfigurationException(com.intellij.openapi.options.ConfigurationException) WriteExternalException(com.intellij.openapi.util.WriteExternalException) NotNull(org.jetbrains.annotations.NotNull) Element(org.jdom.Element) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) Element(org.jdom.Element) IArtifact(com.microsoft.azure.toolkit.lib.common.model.IArtifact) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)

Aggregations

WriteExternalException (com.intellij.openapi.util.WriteExternalException)27 Element (org.jdom.Element)27 InvalidDataException (com.intellij.openapi.util.InvalidDataException)7 Nullable (org.jetbrains.annotations.Nullable)5 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)2 PsiElement (com.intellij.psi.PsiElement)2 NonNls (org.jetbrains.annotations.NonNls)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 LocatableConfiguration (com.intellij.execution.configurations.LocatableConfiguration)1 LocatableConfigurationBase (com.intellij.execution.configurations.LocatableConfigurationBase)1 RunProfileState (com.intellij.execution.configurations.RunProfileState)1 RuntimeConfigurationException (com.intellij.execution.configurations.RuntimeConfigurationException)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1