use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class SvnConfigureProxiesComponent method createActions.
protected ArrayList<AnAction> createActions(final boolean fromPopup) {
ArrayList<AnAction> result = new ArrayList<>();
result.add(new AnAction("Add", "Add", IconUtil.getAddIcon()) {
{
registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
public void actionPerformed(AnActionEvent event) {
addGroup(null);
}
});
result.add(new MyDeleteAction(forAll(o -> {
if (o instanceof MyNode) {
final MyNode node = (MyNode) o;
if (node.getConfigurable() instanceof GroupConfigurable) {
final ProxyGroup group = ((GroupConfigurable) node.getConfigurable()).getEditableObject();
return !group.isDefault();
}
}
return false;
})) {
public void actionPerformed(final AnActionEvent e) {
final TreePath path = myTree.getSelectionPath();
final MyNode node = (MyNode) path.getLastPathComponent();
final MyNode parentNode = (MyNode) node.getParent();
int idx = parentNode.getIndex(node);
super.actionPerformed(e);
idx = (idx == parentNode.getChildCount()) ? idx - 1 : idx;
if (parentNode.getChildCount() > 0) {
final TreePath newSelectedPath = new TreePath(parentNode.getPath()).pathByAddingChild(parentNode.getChildAt(idx));
myTree.setSelectionPath(newSelectedPath);
}
}
});
result.add(new AnAction("Copy", "Copy", PlatformIcons.COPY_ICON) {
{
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree);
}
public void actionPerformed(AnActionEvent event) {
// apply - for update of editable object
try {
getSelectedConfigurable().apply();
} catch (ConfigurationException e) {
// suppress & wait for OK
}
final ProxyGroup selectedGroup = (ProxyGroup) getSelectedObject();
if (selectedGroup != null) {
addGroup(selectedGroup);
}
}
public void update(AnActionEvent event) {
super.update(event);
event.getPresentation().setEnabled(getSelectedObject() != null);
}
});
return result;
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class EclipseClasspathStorageProvider method assertCompatible.
@Override
public void assertCompatible(final ModuleRootModel model) throws ConfigurationException {
final String moduleName = model.getModule().getName();
for (OrderEntry entry : model.getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
if (libraryEntry.isModuleLevel()) {
final Library library = libraryEntry.getLibrary();
if (library == null || libraryEntry.getRootUrls(OrderRootType.CLASSES).length != 1 || library.isJarDirectory(library.getUrls(OrderRootType.CLASSES)[0])) {
throw new ConfigurationException("Library \'" + entry.getPresentableName() + "\' from module \'" + moduleName + "\' dependencies is incompatible with eclipse format which supports only one library content root");
}
}
}
}
if (model.getContentRoots().length == 0) {
throw new ConfigurationException("Module \'" + moduleName + "\' has no content roots thus is not compatible with eclipse format");
}
final String output = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputUrl();
final String contentRoot = getContentRoot(model);
if (output == null || !StringUtil.startsWith(VfsUtilCore.urlToPath(output), contentRoot) && PathMacroManager.getInstance(model.getModule()).collapsePath(output).equals(output)) {
throw new ConfigurationException("Module \'" + moduleName + "\' output path is incompatible with eclipse format which supports output under content root only.\nPlease make sure that \"Inherit project compile output path\" is not selected");
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class CertificateConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
List<X509Certificate> existing = myTrustManager.getCertificates();
Set<X509Certificate> added = new HashSet<>(myCertificates);
added.removeAll(existing);
Set<X509Certificate> removed = new HashSet<>(existing);
removed.removeAll(myCertificates);
for (X509Certificate certificate : added) {
if (!myTrustManager.addCertificate(certificate)) {
throw new ConfigurationException("Cannot add certificate for " + getCommonName(certificate), "Cannot Add Certificate");
}
}
for (X509Certificate certificate : removed) {
if (!myTrustManager.removeCertificate(certificate)) {
throw new ConfigurationException("Cannot remove certificate for " + getCommonName(certificate), "Cannot Remove Certificate");
}
}
CertificateManager.Config state = CertificateManager.getInstance().getState();
state.ACCEPT_AUTOMATICALLY = myAcceptAutomatically.isSelected();
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class ExportEclipseProjectsAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
// to flush iml files
if (project == null) {
return;
}
project.save();
List<Module> modules = new SmartList<>();
List<Module> incompatibleModules = new SmartList<>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (!EclipseModuleManagerImpl.isEclipseStorage(module)) {
try {
ClasspathStorageProvider provider = ClasspathStorage.getProvider(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID);
if (provider != null) {
provider.assertCompatible(ModuleRootManager.getInstance(module));
}
modules.add(module);
} catch (ConfigurationException ignored) {
incompatibleModules.add(module);
}
}
}
//todo suggest smth with hierarchy modules
if (incompatibleModules.isEmpty()) {
if (modules.isEmpty()) {
Messages.showInfoMessage(project, EclipseBundle.message("eclipse.export.nothing.to.do"), EclipseBundle.message("eclipse.export.dialog.title"));
return;
}
} else if (Messages.showOkCancelDialog(project, "<html><body>Eclipse incompatible modules found:<ul><br><li>" + StringUtil.join(incompatibleModules, module -> module.getName(), "<br><li>") + "</ul><br>Would you like to proceed and possibly lose your configurations?</body></html>", EclipseBundle.message("eclipse.export.dialog.title"), Messages.getWarningIcon()) != Messages.OK) {
return;
}
modules.addAll(incompatibleModules);
ExportEclipseProjectsDialog dialog = new ExportEclipseProjectsDialog(project, modules);
if (!dialog.showAndGet()) {
return;
}
if (dialog.isLink()) {
for (Module module : dialog.getSelectedModules()) {
ClasspathStorage.setStorageType(ModuleRootManager.getInstance(module), JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID);
}
} else {
LinkedHashMap<Module, String> module2StorageRoot = new LinkedHashMap<>();
for (Module module : dialog.getSelectedModules()) {
VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
String storageRoot = contentRoots.length == 1 ? contentRoots[0].getPath() : ClasspathStorage.getStorageRootFromOptions(module);
module2StorageRoot.put(module, storageRoot);
try {
DotProjectFileHelper.saveDotProjectFile(module, storageRoot);
} catch (Exception e1) {
LOG.error(e1);
}
}
for (Module module : module2StorageRoot.keySet()) {
ModuleRootModel model = ModuleRootManager.getInstance(module);
String storageRoot = module2StorageRoot.get(module);
try {
Element classpathElement = new EclipseClasspathWriter().writeClasspath(null, model);
File classpathFile = new File(storageRoot, EclipseXml.CLASSPATH_FILE);
if (!FileUtil.createIfDoesntExist(classpathFile)) {
continue;
}
EclipseJDOMUtil.output(classpathElement, classpathFile, project);
final Element ideaSpecific = new Element(IdeaXml.COMPONENT_TAG);
if (IdeaSpecificSettings.writeIdeaSpecificClasspath(ideaSpecific, model)) {
File emlFile = new File(storageRoot, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX);
if (!FileUtil.createIfDoesntExist(emlFile)) {
continue;
}
EclipseJDOMUtil.output(ideaSpecific, emlFile, project);
}
} catch (Exception e1) {
LOG.error(e1);
}
}
}
try {
EclipseUserLibrariesHelper.appendProjectLibraries(project, dialog.getUserLibrariesFile());
} catch (IOException e1) {
LOG.error(e1);
}
project.save();
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class GradleProjectOpenProcessor method setupGradleProjectSettingsInHeadlessMode.
private boolean setupGradleProjectSettingsInHeadlessMode(GradleProjectImportProvider projectImportProvider, WizardContext wizardContext) {
final ModuleWizardStep[] wizardSteps = projectImportProvider.createSteps(wizardContext);
if (wizardSteps.length > 0 && wizardSteps[0] instanceof SelectExternalProjectStep) {
SelectExternalProjectStep selectExternalProjectStep = (SelectExternalProjectStep) wizardSteps[0];
wizardContext.setProjectBuilder(getBuilder());
try {
selectExternalProjectStep.updateStep();
final ImportFromGradleControl importFromGradleControl = getBuilder().getControl(wizardContext.getProject());
GradleProjectSettingsControl gradleProjectSettingsControl = (GradleProjectSettingsControl) importFromGradleControl.getProjectSettingsControl();
final GradleProjectSettings projectSettings = gradleProjectSettingsControl.getInitialSettings();
if (GRADLE_DISTRIBUTION_TYPE != null) {
for (DistributionType type : DistributionType.values()) {
if (type.name().equals(GRADLE_DISTRIBUTION_TYPE)) {
projectSettings.setDistributionType(type);
break;
}
}
}
if (GRADLE_HOME != null) {
projectSettings.setGradleHome(GRADLE_HOME);
}
gradleProjectSettingsControl.reset();
final GradleSystemSettingsControl systemSettingsControl = (GradleSystemSettingsControl) importFromGradleControl.getSystemSettingsControl();
assert systemSettingsControl != null;
final GradleSettings gradleSettings = systemSettingsControl.getInitialSettings();
if (GRADLE_VM_OPTIONS != null) {
gradleSettings.setGradleVmOptions(GRADLE_VM_OPTIONS);
}
if (GRADLE_OFFLINE != null) {
gradleSettings.setOfflineWork(Boolean.parseBoolean(GRADLE_OFFLINE));
}
String serviceDirectory = GRADLE_SERVICE_DIRECTORY;
if (GRADLE_SERVICE_DIRECTORY != null) {
gradleSettings.setServiceDirectoryPath(serviceDirectory);
}
systemSettingsControl.reset();
if (!selectExternalProjectStep.validate()) {
return false;
}
} catch (ConfigurationException e) {
Messages.showErrorDialog(wizardContext.getProject(), e.getMessage(), e.getTitle());
return false;
}
selectExternalProjectStep.updateDataModel();
}
return true;
}
Aggregations