use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by StepicOrg.
the class StepikProjectManager method refreshCourse.
private void refreshCourse() {
if (project == null || root == null) {
return;
}
root.setProject(project);
executor.execute(() -> {
StepikApiClient stepikApiClient = authAndGetStepikApiClient();
if (isAuthenticated()) {
root.reloadData(project, stepikApiClient);
}
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Synchronize Project") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (project.isDisposed()) {
return;
}
repairProjectFiles(root);
repairSandbox();
ApplicationManager.getApplication().invokeLater(() -> {
VirtualFileManager.getInstance().syncRefresh();
setSelected(selected, false);
});
}
private void repairSandbox() {
VirtualFile projectDir = project.getBaseDir();
if (projectDir != null && projectDir.findChild(EduNames.SANDBOX_DIR) == null) {
Application application = ApplicationManager.getApplication();
ModifiableModuleModel model = application.runReadAction((Computable<ModifiableModuleModel>) () -> ModuleManager.getInstance(project).getModifiableModel());
application.invokeLater(() -> application.runWriteAction(() -> {
try {
new SandboxModuleBuilder(projectDir.getPath()).createModule(model);
model.commit();
} catch (IOException | ConfigurationException | JDOMException | ModuleWithNameAlreadyExists e) {
logger.warn("Failed repair Sandbox", e);
}
}));
}
}
});
});
}
use of com.intellij.openapi.options.ConfigurationException in project android by JetBrains.
the class AndroidGradleTestCase method importProject.
protected void importProject(@NotNull String projectName, @NotNull File projectRoot, @Nullable GradleSyncListener listener) throws Exception {
Ref<Throwable> throwableRef = new Ref<>();
SyncListener syncListener = new SyncListener();
Project project = getProject();
GradleSyncState.subscribe(project, syncListener);
runWriteCommandAction(project, () -> {
try {
// When importing project for tests we do not generate the sources as that triggers a compilation which finishes asynchronously.
// This causes race conditions and intermittent errors. If a test needs source generation this should be handled separately.
GradleProjectImporter.Request request = new GradleProjectImporter.Request();
request.setProject(project).setGenerateSourcesOnSuccess(false);
GradleProjectImporter.getInstance().importProject(projectName, projectRoot, request, listener);
} catch (Throwable e) {
throwableRef.set(e);
}
});
Throwable throwable = throwableRef.get();
if (throwable != null) {
if (throwable instanceof IOException) {
throw (IOException) throwable;
} else if (throwable instanceof ConfigurationException) {
throw (ConfigurationException) throwable;
} else {
throw new RuntimeException(throwable);
}
}
syncListener.await();
if (syncListener.failureMessage != null && listener == null) {
fail(syncListener.failureMessage);
}
}
use of com.intellij.openapi.options.ConfigurationException in project android by JetBrains.
the class IdeSdksConfigurable method validate.
public boolean validate() throws ConfigurationException {
String msg = validateAndroidSdkPath();
if (msg != null) {
throw new ConfigurationException(msg);
}
if (!useEmbeddedJdk()) {
File validJdkLocation = validateJdkPath(getJdkLocation());
if (validJdkLocation == null) {
throw new ConfigurationException(CHOOSE_VALID_JDK_DIRECTORY_ERR);
}
}
msg = validateAndroidNdkPath();
if (msg != null) {
throw new ConfigurationException(msg);
}
return true;
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexBCConfigurator method copy.
public void copy(final CompositeConfigurable configurable, final Runnable treeNodeNameUpdater) {
try {
configurable.apply();
} catch (ConfigurationException ignored) {
/**/
}
ModifiableFlexBuildConfiguration existingBC = myConfigurablesMap.getKeysByValue(configurable).get(0);
FlexBCConfigurable unwrapped = FlexBCConfigurable.unwrap(configurable);
final String title = FlexBundle.message("copy.build.configuration", existingBC.getName(), unwrapped.getModule().getName());
Module module = unwrapped.getModule();
AddBuildConfigurationDialog dialog = new AddBuildConfigurationDialog(module.getProject(), title, getUsedNames(module), existingBC.getNature(), true);
dialog.reset("", existingBC.getAndroidPackagingOptions().isEnabled(), existingBC.getIosPackagingOptions().isEnabled());
if (!dialog.showAndGet()) {
return;
}
final String newBCName = dialog.getBCName();
final String fileName = PathUtil.suggestFileName(newBCName);
final BuildConfigurationNature newNature = dialog.getNature();
ModifiableFlexBuildConfiguration newBC = myConfigEditor.copyConfiguration(existingBC, newNature);
newBC.setName(newBCName);
newBC.setOutputFileName(fileName + (newBC.getOutputType() == OutputType.Library ? ".swc" : ".swf"));
updatePackageFileName(newBC, fileName);
if (newNature.isApp() && newNature.isMobilePlatform()) {
newBC.getAndroidPackagingOptions().setEnabled(dialog.isAndroidEnabled());
newBC.getIosPackagingOptions().setEnabled(dialog.isIOSEnabled());
}
createConfigurableNode(newBC, unwrapped.getModule(), treeNodeNameUpdater);
}
use of com.intellij.openapi.options.ConfigurationException in project android by JetBrains.
the class AdtImportLocationStep method validate.
@Override
public boolean validate() throws ConfigurationException {
WizardContext context = getWizardContext();
GradleImport importer = AdtImportProvider.getImporter(context);
if (importer != null) {
List<String> errors = importer.getErrors();
if (!errors.isEmpty()) {
throw new ConfigurationException(errors.get(0));
}
}
// The following code is based on similar code in com.intellij.ide.util.newProjectWizard.ProjectNameStep
String projectFileDirectory = getProjectFileDirectory();
if (projectFileDirectory.length() == 0) {
throw new ConfigurationException(String.format("Enter %1$s file location", context.getPresentationName()));
}
boolean shouldPromptCreation = myIsPathChangedByUser;
if (!ProjectWizardUtil.createDirectoryIfNotExists(String.format("The %1$s file directory\n", context.getPresentationName()), projectFileDirectory, shouldPromptCreation)) {
return false;
}
boolean shouldContinue = true;
File projectFile = new File(getProjectFileDirectory());
String title = "New Project";
if (projectFile.isFile()) {
shouldContinue = false;
String message = String.format("%s exists and is a file.\nPlease specify a different project location", projectFile.getAbsolutePath());
Messages.showErrorDialog(message, title);
} else if (projectFile.isDirectory()) {
File[] files = projectFile.listFiles();
if (files != null && files.length > 0) {
String message = String.format("%1$s folder already exists and is not empty.\nIts content may be overwritten.\nContinue?", projectFile.getAbsolutePath());
int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
shouldContinue = answer == 0;
}
}
return shouldContinue;
}
Aggregations