use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlashBuilderOpenProcessor method doQuickImport.
protected boolean doQuickImport(final VirtualFile file, final WizardContext wizardContext) {
assert !file.isDirectory() : file.getPath();
final String title = FlexBundle.message("open.project.0", file.getName());
if (FlashBuilderProjectFinder.hasArchiveExtension(file.getPath())) {
try {
FlashBuilderProjectFinder.checkArchiveContainsFBProject(file.getPath());
} catch (ConfigurationException e) {
Messages.showErrorDialog(wizardContext.getProject(), e.getMessage(), title);
return false;
}
final String label = FlashBuilderProjectFinder.isMultiProjectArchive(file.getPath()) ? FlexBundle.message("folder.to.unzip.several.FB.projects") : FlexBundle.message("folder.to.unzip.one.FB.project");
final String path = FileUtil.toSystemDependentName(wizardContext.getProjectFileDirectory() + "/" + file.getNameWithoutExtension());
final AskPathDialog dialog = new AskPathDialog(title, label, path);
if (!dialog.showAndGet()) {
return false;
}
final File projectDir = new File(dialog.getPath());
if (!projectDir.exists() && !projectDir.mkdirs()) {
Messages.showErrorDialog("Unable to create folder: " + dialog.getPath(), title);
return false;
}
wizardContext.setProjectFileDirectory(dialog.getPath());
}
getBuilder().setInitiallySelectedPath(file.getPath());
getBuilder().setList(Collections.singletonList(file.getPath()));
wizardContext.setProjectName(getBuilder().getSuggestedProjectName());
return true;
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class SelectDirWithFlashBuilderProjectsStep method validate.
public boolean validate() throws ConfigurationException {
final String path = myInitialPathComponent.getComponent().getText().trim();
if (path.length() == 0) {
throw new ConfigurationException(FlexBundle.message("specify.flash.builder.workspace.or.project.dir"), CommonBundle.getErrorTitle());
}
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
if (file == null) {
throw new ConfigurationException(FlexBundle.message("file.or.folder.not.found", path), CommonBundle.getErrorTitle());
}
if (file.isDirectory()) {
final List<String> projectPaths = new ArrayList<>();
// false if user cancelled
final boolean ok = FlashBuilderProjectFinder.collectAllProjectPaths(getWizardContext().getProject(), projectPaths, path);
if (ok) {
if (projectPaths.isEmpty()) {
throw new ConfigurationException(FlexBundle.message("flash.builder.projects.not.found.in"), CommonBundle.getErrorTitle());
}
((FlashBuilderImporter) getBuilder()).setList(projectPaths);
}
return ok && checkProjectNameAndPath();
} else {
if (FlashBuilderProjectFinder.hasArchiveExtension(file.getPath())) {
FlashBuilderProjectFinder.checkArchiveContainsFBProject(file.getPath());
final File dir = new File(getWizardContext().isCreatingNewProject() ? myProjectLocationComponent.getComponent().getText().trim() : myExtractPathComponent.getComponent().getText().trim());
if (dir.isDirectory() && dir.list().length > 0) {
final String title = StringUtil.capitalizeWords(ProjectBundle.message("project.new.wizard.import.title", getWizardContext().getPresentationName()), true);
if (Messages.YES != Messages.showYesNoDialog(myMainPanel, FlexBundle.message("folder.not.empty", dir.getPath()), title, Messages.getWarningIcon())) {
return false;
}
}
} else if (!FlashBuilderProjectFinder.isFlashBuilderProject(file)) {
throw new ConfigurationException(FlexBundle.message("not.flash.builder.project"), CommonBundle.getErrorTitle());
}
((FlashBuilderImporter) getBuilder()).setList(Collections.singletonList(path));
return checkProjectNameAndPath();
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexmojosImporter method process.
public void process(final IdeModifiableModelsProvider modelsProvider, final Module module, final MavenRootModelAdapter modelAdapter, final MavenProjectsTree mavenTree, final MavenProject mavenProject, final MavenProjectChanges changes, final Map<MavenProject, String> mavenProjectToModuleName, final List<MavenProjectsProcessorTask> postTasks) {
expireNotification();
final FlexProjectConfigurationEditor currentEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
final boolean needToCommit = currentEditor == null;
final LibraryTable.ModifiableModel projectLibrariesModel = modelsProvider.getModifiableProjectLibrariesModel();
final Map<Module, ModifiableRootModel> moduleToModifiableModel = Collections.singletonMap(module, modelAdapter.getRootModel());
final FlexProjectConfigurationEditor flexEditor = currentEditor != null ? currentEditor : new FlexProjectConfigurationEditor(module.getProject(), FlexProjectConfigurationEditor.createModelProvider(moduleToModifiableModel, projectLibrariesModel, null)) {
@Nullable
protected Module findModuleWithBC(final BuildConfigurationEntry bcEntry) {
// don't check BC presence here because corresponding BC may appear later in next import cycle
return modelAdapter.findModuleByName(bcEntry.getModuleName());
}
};
final MavenPlugin flexmojosPlugin = getFlexmojosPlugin(mavenProject);
final Flexmojos3Configurator configurator = StringUtil.compareVersionNumbers(flexmojosPlugin.getVersion(), "5") >= 0 ? new Flexmojos5Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this) : StringUtil.compareVersionNumbers(flexmojosPlugin.getVersion(), "4") >= 0 ? new Flexmojos4Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this) : new Flexmojos3Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this);
configurator.configureAndAppendTasks(postTasks);
if (needToCommit) {
try {
flexEditor.commit();
} catch (ConfigurationException e) {
// can't happen
MavenLog.LOG.error(e);
}
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexModuleBuilder method setupRootModel.
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
final ContentEntry contentEntry = doAddContentEntry(modifiableRootModel);
if (contentEntry == null)
return;
final VirtualFile sourceRoot = createSourceRoot(contentEntry);
final Module module = modifiableRootModel.getModule();
final FlexProjectConfigurationEditor currentFlexEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
final boolean needToCommitFlexEditor = currentFlexEditor == null;
final FlexProjectConfigurationEditor flexConfigEditor;
flexConfigEditor = currentFlexEditor != null ? currentFlexEditor : FlexProjectConfigurationEditor.createEditor(module.getProject(), Collections.singletonMap(module, modifiableRootModel), null, null);
final ModifiableFlexBuildConfiguration[] configurations = flexConfigEditor.getConfigurations(module);
assert configurations.length == 1;
final ModifiableFlexBuildConfiguration bc = configurations[0];
setupBC(modifiableRootModel, bc);
if (bc.getOutputType() == OutputType.Application) {
createRunConfiguration(module, bc);
}
if (sourceRoot != null && myCreateSampleApp && myFlexSdk != null) {
try {
final boolean flex4 = !FlexSdkUtils.isAirSdkWithoutFlex(myFlexSdk) && StringUtil.compareVersionNumbers(myFlexSdk.getVersionString(), "4") >= 0;
FlexUtils.createSampleApp(module.getProject(), sourceRoot, mySampleAppName, myTargetPlatform, flex4);
} catch (IOException ex) {
throw new ConfigurationException(ex.getMessage());
}
}
if (myCreateHtmlWrapperTemplate && myFlexSdk != null) {
final String path = VfsUtilCore.urlToPath(contentEntry.getUrl()) + "/" + CreateHtmlWrapperTemplateDialog.HTML_TEMPLATE_FOLDER_NAME;
if (CreateHtmlWrapperTemplateDialog.createHtmlWrapperTemplate(module.getProject(), myFlexSdk, path, myEnableHistory, myCheckPlayerVersion, myExpressInstall)) {
bc.setUseHtmlWrapper(true);
bc.setWrapperTemplatePath(path);
}
}
if (needToCommitFlexEditor) {
flexConfigEditor.commit();
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class AddAsSwcLibDialog method doOKAction.
@Override
protected void doOKAction() {
final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs = myBCTree.getSelectedBCs();
final Map<Module, ModifiableRootModel> moduleToModifiableModelMap = new THashMap<>();
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCs) {
moduleToModifiableModelMap.put(moduleAndBC.first, ModuleRootManager.getInstance(moduleAndBC.first).getModifiableModel());
}
final LibraryTable.ModifiableModel projectLibsModel = ProjectLibraryTable.getInstance(myProject).getModifiableModel();
final LibraryTable.ModifiableModel globalLibsModel = ApplicationLibraryTable.getApplicationTable().getModifiableModel();
final FlexProjectConfigurationEditor flexConfigEditor = FlexProjectConfigurationEditor.createEditor(myProject, moduleToModifiableModelMap, projectLibsModel, globalLibsModel);
addLib(flexConfigEditor, modulesAndBCs, myRoots);
try {
flexConfigEditor.commit();
} catch (ConfigurationException e) {
Logger.getInstance(AddAsSwcLibDialog.class).error(e);
}
ApplicationManager.getApplication().runWriteAction(() -> {
globalLibsModel.commit();
projectLibsModel.commit();
for (ModifiableRootModel modifiableRootModel : moduleToModifiableModelMap.values()) {
modifiableRootModel.commit();
}
});
if (myOpenProjectStructureCheckBox.isSelected()) {
final Pair<Module, FlexBuildConfiguration> moduleAndBc = modulesAndBCs.iterator().next();
openProjectStructure(moduleAndBc.first, moduleAndBc.second);
}
super.doOKAction();
}
Aggregations