mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (modern serialization)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,21 +15,17 @@
|
||||
*/
|
||||
package com.intellij.javadoc;
|
||||
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.PsiKeyword;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import com.intellij.util.xmlb.SerializationFilter;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Apr 24, 2004
|
||||
* @since Apr 24, 2004
|
||||
*/
|
||||
public class JavadocConfiguration implements JDOMExternalizable {
|
||||
public class JavadocConfiguration {
|
||||
public static final SerializationFilter FILTER = (accessor, bean) ->
|
||||
!accessor.getName().equals("OPTION_LINK_TO_JDK_DOCS") || ((JavadocConfiguration)bean).OPTION_LINK_TO_JDK_DOCS;
|
||||
|
||||
public String OUTPUT_DIRECTORY;
|
||||
public String OPTION_SCOPE = PsiKeyword.PROTECTED;
|
||||
public boolean OPTION_HIERARCHY = true;
|
||||
@@ -47,21 +43,4 @@ public class JavadocConfiguration implements JDOMExternalizable {
|
||||
public boolean OPEN_IN_BROWSER = true;
|
||||
public boolean OPTION_INCLUDE_LIBS = false;
|
||||
public boolean OPTION_LINK_TO_JDK_DOCS = false;
|
||||
|
||||
public JavadocConfiguration() {
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element, new DefaultJDOMExternalizer.JDOMFilter() {
|
||||
@Override
|
||||
public boolean isAccept(@NotNull Field field) {
|
||||
return !field.getName().equals("OPTION_LINK_TO_JDK_DOCS") || OPTION_LINK_TO_JDK_DOCS;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,17 +24,14 @@ import com.intellij.execution.util.ExecutionErrorDialog;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@State(name = "JavadocGenerationManager")
|
||||
public final class JavadocGenerationManager implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.javadoc.JavadocGenerationManager");
|
||||
private final JavadocConfiguration myConfiguration;
|
||||
private final JavadocConfiguration myConfiguration = new JavadocConfiguration();
|
||||
private final Project myProject;
|
||||
|
||||
public static JavadocGenerationManager getInstance(@NotNull Project project) {
|
||||
@@ -43,31 +40,19 @@ public final class JavadocGenerationManager implements PersistentStateComponent<
|
||||
|
||||
JavadocGenerationManager(Project project) {
|
||||
myProject = project;
|
||||
myConfiguration = new JavadocConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
final Element state = new Element("state");
|
||||
try {
|
||||
myConfiguration.writeExternal(state);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return state;
|
||||
return XmlSerializer.serialize(myConfiguration, JavadocConfiguration.FILTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
myConfiguration.readExternal(state);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
XmlSerializer.deserializeInto(myConfiguration, state);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JavadocConfiguration getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
@@ -81,4 +66,4 @@ public final class JavadocGenerationManager implements PersistentStateComponent<
|
||||
ExecutionErrorDialog.show(e, CommonBundle.getErrorTitle(), myProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user