Skip to content
Permalink
Browse files

remove deprecated API usages: facet config no longer uses JDOMExterna…

…lizable
  • Loading branch information
guymahieu committed Feb 11, 2020
1 parent a089c68 commit c6a1ec1447407f780e8ce04316e5e4d3f68fe173
@@ -2,10 +2,8 @@
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="IvyIDEA" name="IvyIDEA">
<configuration ivyFile="$MODULE_DIR$/ivy.xml" useProjectSettings="true" useCustomIvySettings="true" ivySettingsFile="" onlyResolveSelectedConfigs="false">
<propertiesSettings>
<propertiesFiles includeProjectLevelPropertiesFiles="true" />
</propertiesSettings>
<configuration>
<option name="ivyFile" value="$MODULE_DIR$/ivy.xml" />
</configuration>
</facet>
</component>
@@ -26,7 +26,7 @@
import org.clarent.ivyidea.config.model.IvyIdeaProjectSettings;
import org.clarent.ivyidea.exception.IvySettingsFileReadException;
import org.clarent.ivyidea.exception.IvySettingsNotFoundException;
import org.clarent.ivyidea.intellij.IvyIdeaProjectComponent;
import org.clarent.ivyidea.intellij.IvyIdeaProjectService;
import org.clarent.ivyidea.intellij.facet.config.FacetPropertiesSettings;
import org.clarent.ivyidea.intellij.facet.config.IvyIdeaFacetConfiguration;
import org.clarent.ivyidea.logging.IvyLogLevel;
@@ -137,7 +137,7 @@ public static boolean detectDependenciesOnOtherModulesWhileResolving(final Proje

@NotNull
private static IvyIdeaProjectSettings getProjectConfig(Project project) {
IvyIdeaProjectComponent component = project.getComponent(IvyIdeaProjectComponent.class);
IvyIdeaProjectService component = project.getComponent(IvyIdeaProjectService.class);
return component.getState();
}

@@ -178,7 +178,7 @@ private static String getModuleIvySettingsFile(Module module, IvyIdeaFacetConfig

@Nullable
public static String getProjectIvySettingsFile(Project project) throws IvySettingsNotFoundException {
IvyIdeaProjectComponent component = project.getComponent(IvyIdeaProjectComponent.class);
IvyIdeaProjectService component = project.getComponent(IvyIdeaProjectService.class);
final IvyIdeaProjectSettings state = component.getState();
if (state.isUseCustomIvySettings()) {
String settingsFile = StringUtils.trim(state.getIvySettingsFile());
@@ -24,13 +24,7 @@
*/
public class PropertiesSettings {

private List<String> propertyFiles = new ArrayList<String>();

public static PropertiesSettings copyDataFrom(PropertiesSettings propertiesSettings) {
PropertiesSettings result = new PropertiesSettings();
result.propertyFiles = new ArrayList<String>(propertiesSettings.propertyFiles);
return result;
}
private List<String> propertyFiles = new ArrayList<>();

public List<String> getPropertyFiles() {
return propertyFiles;
@@ -27,16 +27,16 @@
* @author Guy Mahieu
*/
@State(
name = IvyIdeaProjectComponent.COMPONENT_NAME,
name = IvyIdeaProjectService.COMPONENT_NAME,
storages = {@Storage("$PROJECT_FILE$")}
)
public class IvyIdeaProjectComponent implements PersistentStateComponent<IvyIdeaProjectSettings> {
public class IvyIdeaProjectService implements PersistentStateComponent<IvyIdeaProjectSettings> {

public static final String COMPONENT_NAME = "IvyIDEA.ProjectSettings";

private final IvyIdeaProjectSettings internalState;

public IvyIdeaProjectComponent() {
public IvyIdeaProjectService() {
this.internalState = new IvyIdeaProjectSettings();
}

@@ -34,12 +34,14 @@

public static final FacetTypeId<IvyIdeaFacet> ID = new FacetTypeId<>("IvyIDEA");

public static final String STRING_ID = "IvyIDEA";

public static IvyIdeaFacetType getInstance() {
return findInstance(IvyIdeaFacetType.class);
}

public IvyIdeaFacetType() {
super(ID, "IvyIDEA", "IvyIDEA");
super(ID, STRING_ID, "IvyIDEA");
}

public IvyIdeaFacetConfiguration createDefaultConfiguration() {
@@ -16,22 +16,14 @@

package org.clarent.ivyidea.intellij.facet.config;

import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import org.clarent.ivyidea.config.model.PropertiesSettings;
import org.jdom.Element;

import java.util.ArrayList;
import java.util.List;

/**
* @author Guy Mahieu
*/
public class FacetPropertiesSettings extends PropertiesSettings implements JDOMExternalizable {
public class FacetPropertiesSettings extends PropertiesSettings {

private boolean includeProjectLevelPropertiesFiles = true;
private boolean includeProjectLevelAdditionalProperties = true;

public boolean isIncludeProjectLevelPropertiesFiles() {
return includeProjectLevelPropertiesFiles;
@@ -41,35 +33,4 @@ public void setIncludeProjectLevelPropertiesFiles(boolean includeProjectLevelPro
this.includeProjectLevelPropertiesFiles = includeProjectLevelPropertiesFiles;
}

public boolean isIncludeProjectLevelAdditionalProperties() {
return includeProjectLevelAdditionalProperties;
}

public void setIncludeProjectLevelAdditionalProperties(boolean includeProjectLevelAdditionalProperties) {
this.includeProjectLevelAdditionalProperties = includeProjectLevelAdditionalProperties;
}

public void readExternal(Element propertiesSettingsElement) throws InvalidDataException {
final Element propertiesFilesElement = propertiesSettingsElement.getChild("propertiesFiles");
List<String> fileNames = new ArrayList<String>();
if (propertiesFilesElement != null) {
setIncludeProjectLevelPropertiesFiles(Boolean.parseBoolean(propertiesFilesElement.getAttributeValue("includeProjectLevelPropertiesFiles", Boolean.TRUE.toString())));
final List<Element> propertiesFileNames = propertiesFilesElement.getChildren("fileName");
for (Element element : propertiesFileNames) {
fileNames.add(element.getValue());
}
}
setPropertyFiles(fileNames);

}

public void writeExternal(Element propertiesSettingsElement) throws WriteExternalException {
final Element propertiesFilesElement = new Element("propertiesFiles");
propertiesFilesElement.setAttribute("includeProjectLevelPropertiesFiles", Boolean.toString(isIncludeProjectLevelPropertiesFiles()));
propertiesSettingsElement.addContent(propertiesFilesElement);
for (String fileName : getPropertyFiles()) {
propertiesFilesElement.addContent(new Element("fileName").setText(fileName));
}

}
}

0 comments on commit c6a1ec1

Please sign in to comment.
You can’t perform that action at this time.