Search in sources :

Example 56 with ConfigurationException

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;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 57 with ConfigurationException

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();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ArrayList(java.util.ArrayList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 58 with ConfigurationException

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);
        }
    }
}
Also used : MavenPlugin(org.jetbrains.idea.maven.model.MavenPlugin) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) BuildConfigurationEntry(com.intellij.lang.javascript.flex.projectStructure.model.BuildConfigurationEntry) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 59 with ConfigurationException

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();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ContentEntry(com.intellij.openapi.roots.ContentEntry) IOException(java.io.IOException) Module(com.intellij.openapi.module.Module) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 60 with ConfigurationException

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();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) ApplicationLibraryTable(com.intellij.openapi.roots.impl.libraries.ApplicationLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) THashMap(gnu.trove.THashMap) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) Pair(com.intellij.openapi.util.Pair)

Aggregations

ConfigurationException (com.intellij.openapi.options.ConfigurationException)102 File (java.io.File)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Project (com.intellij.openapi.project.Project)22 Module (com.intellij.openapi.module.Module)18 IOException (java.io.IOException)14 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)7 Sdk (com.intellij.openapi.projectRoots.Sdk)7 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)6 Disposable (com.intellij.openapi.Disposable)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 Pair (com.intellij.openapi.util.Pair)4 GradleProjectImporter (com.android.tools.idea.gradle.project.importing.GradleProjectImporter)3 ExecutionException (com.intellij.execution.ExecutionException)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3