use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class ProjectLevelVcsManagerImpl method readDirectoryMappings.
void readDirectoryMappings(final Element element) {
myMappings.clear();
final List<VcsDirectoryMapping> mappingsList = new ArrayList<>();
boolean haveNonEmptyMappings = false;
for (Element child : element.getChildren(ELEMENT_MAPPING)) {
final String vcs = child.getAttributeValue(ATTRIBUTE_VCS);
if (vcs != null && !vcs.isEmpty()) {
haveNonEmptyMappings = true;
}
VcsDirectoryMapping mapping = new VcsDirectoryMapping(child.getAttributeValue(ATTRIBUTE_DIRECTORY), vcs);
mappingsList.add(mapping);
Element rootSettingsElement = child.getChild(ELEMENT_ROOT_SETTINGS);
if (rootSettingsElement != null) {
String className = rootSettingsElement.getAttributeValue(ATTRIBUTE_CLASS);
AbstractVcs vcsInstance = findVcsByName(mapping.getVcs());
if (vcsInstance != null && className != null) {
final VcsRootSettings rootSettings = vcsInstance.createEmptyVcsRootSettings();
if (rootSettings != null) {
try {
rootSettings.readExternal(rootSettingsElement);
mapping.setRootSettings(rootSettings);
} catch (InvalidDataException e) {
LOG.error("Failed to load VCS root settings class " + className + " for VCS " + vcsInstance.getClass().getName(), e);
}
}
}
}
}
boolean defaultProject = Boolean.TRUE.toString().equals(element.getAttributeValue(ATTRIBUTE_DEFAULT_PROJECT));
// run autodetection if there's no VCS in default project and
if (haveNonEmptyMappings || !defaultProject) {
myMappingsLoaded = true;
}
myMappings.setDirectoryMappings(mappingsList);
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-plugins by JetBrains.
the class FlexModuleConverter method isApplicableLibrary.
static boolean isApplicableLibrary(final Element library, Function<String, String> pathExpander) {
String libraryType = library.getAttributeValue(LibraryImpl.LIBRARY_TYPE_ATTR);
if (FlexLibraryType.FLEX_LIBRARY.getKindId().equals(libraryType)) {
return true;
}
if (libraryType != null) {
// ignore explicit non-Flex libraries
return false;
}
final Element rootChild = library.getChild(OrderRootType.CLASSES.name());
if (rootChild == null) {
// corrupted element
return false;
}
JarDirectories jarDirectories = new JarDirectories();
try {
jarDirectories.readExternal(library);
} catch (InvalidDataException ignored) {
jarDirectories.clear();
}
List<Element> classesRoots = rootChild.getChildren(LibraryImpl.ROOT_PATH_ELEMENT);
if (classesRoots.isEmpty()) {
// no classes root
return false;
}
for (Element root : classesRoots) {
final String url = root.getAttributeValue("url");
if (url == null) {
// corrupted element
continue;
}
final String path = getPathFromUrl(url);
if (path == null) {
continue;
}
if (path.toLowerCase().endsWith(".swc")) {
return true;
} else {
if (jarDirectories.contains(OrderRootType.CLASSES, url)) {
String expanded = pathExpander.fun(path);
File file = new File(expanded);
if (!file.isDirectory()) {
return true;
}
String[] allChildren = file.list();
if (allChildren == null || allChildren.length == 0) {
return true;
}
File[] swcs = file.listFiles(FileFilters.filesWithExtension("swc"));
if (swcs != null && swcs.length > 0) {
return true;
}
File[] jars = file.listFiles(FileFilters.filesWithExtension("jar"));
if (jars != null && jars.length > 0) {
continue;
}
return true;
} else if (!path.toLowerCase().endsWith(".jar")) {
return true;
}
}
}
return false;
}
use of com.intellij.openapi.util.InvalidDataException in project azure-tools-for-java by Microsoft.
the class RemoteDebugRunConfiguration method readExternal.
@Override
public void readExternal(Element rootElement) throws InvalidDataException {
super.readExternal(rootElement);
SparkSubmitModel model = getSubmitModel();
SparkSubmissionParameter parameter = Optional.ofNullable(model.getSubmissionParameter()).orElse(new SparkSubmissionParameter("", false, "", "", "", "", new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), Arrays.stream(SparkSubmissionParameter.defaultParameters).collect(Collectors.toMap(Pair::first, Pair::second))));
Optional.ofNullable(rootElement.getChild(SUBMISSION_CONTENT_NAME)).ifPresent((element -> {
Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_CLUSTER_NAME)).ifPresent(attribute -> parameter.setClusterName(attribute.getValue()));
Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_IS_LOCAL_ARTIFACT)).ifPresent(attribute -> parameter.setLocalArtifact(attribute.getValue().toLowerCase().equals("true")));
Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_ARTIFACT_NAME)).ifPresent(attribute -> parameter.setArtifactName(attribute.getValue()));
Optional.ofNullable(element.getAttribute(SUBMISSION_ATTRIBUTE_CLASSNAME)).ifPresent(attribute -> parameter.setClassName(attribute.getValue()));
model.setSubmissionParameters(parameter);
}));
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class ModulesDetectionStep method validate.
@Override
public boolean validate() throws ConfigurationException {
final boolean validated = super.validate();
if (!validated) {
return false;
}
final List<ModuleDescriptor> modules = myModulesLayoutPanel.getChosenEntries();
final Map<String, ModuleDescriptor> errors = new LinkedHashMap<>();
for (ModuleDescriptor module : modules) {
try {
final String moduleFilePath = module.computeModuleFilePath();
if (new File(moduleFilePath).exists()) {
errors.put(IdeBundle.message("warning.message.the.module.file.0.already.exist.and.will.be.overwritten", moduleFilePath), module);
}
} catch (InvalidDataException e) {
errors.put(e.getMessage(), module);
}
}
if (!errors.isEmpty()) {
final int answer = Messages.showYesNoCancelDialog(getComponent(), IdeBundle.message("warning.text.0.do.you.want.to.overwrite.these.files", StringUtil.join(errors.keySet(), "\n"), errors.size()), IdeBundle.message("title.file.already.exists"), "Overwrite", "Reuse", "Cancel", Messages.getQuestionIcon());
if (answer == Messages.CANCEL) {
return false;
}
if (answer != Messages.YES) {
for (ModuleDescriptor moduleDescriptor : errors.values()) {
moduleDescriptor.reuseExisting(true);
}
}
}
return true;
}
use of com.intellij.openapi.util.InvalidDataException 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) {
}
}
Aggregations