use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class RunInspectionIntention method createProfile.
@NotNull
public static InspectionProfileImpl createProfile(@NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionManagerEx managerEx, @Nullable PsiElement psiElement) {
InspectionProfileImpl rootProfile = InspectionProfileManager.getInstance().getCurrentProfile();
LinkedHashSet<InspectionToolWrapper<?, ?>> allWrappers = new LinkedHashSet<>();
allWrappers.add(toolWrapper);
rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.getProject());
List<InspectionToolWrapper<?, ?>> toolWrappers = allWrappers.size() == 1 ? Collections.singletonList(allWrappers.iterator().next()) : new ArrayList<>(allWrappers);
InspectionProfileImpl model = InspectionProfileKt.createSimple(toolWrapper.getDisplayName(), managerEx.getProject(), toolWrappers);
try {
Element element = new Element("toCopy");
for (InspectionToolWrapper wrapper : toolWrappers) {
wrapper.getTool().writeSettings(element);
InspectionToolWrapper tw = psiElement == null ? model.getInspectionTool(wrapper.getShortName(), managerEx.getProject()) : model.getInspectionTool(wrapper.getShortName(), psiElement);
tw.getTool().readSettings(element);
}
} catch (WriteExternalException | InvalidDataException ignored) {
}
model.setSingleTool(toolWrapper.getShortName());
return model;
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class IdeaPluginDescriptorImpl method readExternal.
public void readExternal(@NotNull URL url) throws InvalidDataException, FileNotFoundException {
try {
Document document = JDOMUtil.loadDocument(url);
readExternal(document, url, JDOMXIncluder.DEFAULT_PATH_RESOLVER);
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw new InvalidDataException(e);
} catch (JDOMException e) {
throw new InvalidDataException(e);
}
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class ProjectUtil method openProject.
@Nullable
public static Project openProject(final String path, @Nullable Project projectToClose, boolean forceOpenInNewFrame) {
File file = new File(path);
if (!file.exists()) {
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", path), CommonBundle.getErrorTitle());
return null;
}
if (file.isDirectory()) {
File dir = new File(file, Project.DIRECTORY_STORE_FOLDER);
if (!dir.exists()) {
String message = IdeBundle.message("error.project.file.does.not.exist", dir.getPath());
Messages.showErrorDialog(message, CommonBundle.getErrorTitle());
return null;
}
}
Project existing = findAndFocusExistingProjectForPath(path);
if (existing != null)
return existing;
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (!forceOpenInNewFrame && openProjects.length > 0) {
int exitCode = confirmOpenNewProject(false);
if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
final Project toClose = projectToClose != null ? projectToClose : openProjects[openProjects.length - 1];
if (!closeAndDispose(toClose))
return null;
} else if (exitCode != GeneralSettings.OPEN_PROJECT_NEW_WINDOW) {
return null;
}
}
if (isRemotePath(path) && !RecentProjectsManager.getInstance().hasPath(path)) {
if (!confirmLoadingFromRemotePath(path, "warning.load.project.from.share", "title.load.project.from.share")) {
return null;
}
}
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project project = null;
try {
project = projectManager.loadAndOpenProject(path);
} catch (IOException e) {
Messages.showMessageDialog(IdeBundle.message("error.cannot.load.project", e.getMessage()), IdeBundle.message("title.cannot.load.project"), Messages.getErrorIcon());
} catch (JDOMException | InvalidDataException e) {
LOG.info(e);
Messages.showMessageDialog(IdeBundle.message("error.project.file.is.corrupted"), IdeBundle.message("title.cannot.load.project"), Messages.getErrorIcon());
}
return project;
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class LibraryTableImplUtil method loadLibrary.
public static Library loadLibrary(@NotNull Element rootElement, @NotNull RootModelImpl rootModel) throws InvalidDataException {
final List children = rootElement.getChildren(LibraryImpl.ELEMENT);
if (children.size() != 1)
throw new InvalidDataException();
Element element = (Element) children.get(0);
return new LibraryImpl(null, element, rootModel);
}
use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.
the class DeployToServerRunConfiguration method clone.
@Override
public RunConfiguration clone() {
Element element = new Element("tag");
try {
writeExternal(element);
} catch (WriteExternalException e) {
LOG.error(e);
}
DeployToServerRunConfiguration result = (DeployToServerRunConfiguration) super.clone();
try {
result.readExternal(element);
} catch (InvalidDataException e) {
LOG.error(e);
}
return result;
}
Aggregations