Search in sources :

Example 31 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.

the class LibraryBundlingEditorComponent method applyTo.

public void applyTo(ApplicationSettings settings) throws ConfigurationException {
    updateCurrentRule();
    for (int i = 0; i < myRulesModel.getSize(); i++) {
        try {
            myRulesModel.getElementAt(i).validate();
        } catch (IllegalArgumentException e) {
            myRulesList.setSelectedIndex(i);
            throw new ConfigurationException(e.getMessage());
        }
    }
    settings.setLibraryBundlificationRules(ContainerUtil.newArrayList(myRulesModel.getItems()));
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 32 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.

the class Flexmojos3GenerateConfigTask method updateMainClass.

public static void updateMainClass(final Module module, final VirtualFile configFile) {
    // Project Structure open
    if (FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor() != null)
        return;
    try {
        final String mainClassPath = FlexUtils.findXMLElement(configFile.getInputStream(), "<flex-config><file-specs><path-element>");
        final VirtualFile mainClassFile = mainClassPath == null ? null : LocalFileSystem.getInstance().findFileByPath(mainClassPath);
        if (mainClassFile == null || mainClassFile.isDirectory())
            return;
        final VirtualFile sourceRoot = ProjectRootManager.getInstance(module.getProject()).getFileIndex().getSourceRootForFile(mainClassFile);
        final String relativePath = sourceRoot == null ? null : VfsUtilCore.getRelativePath(mainClassFile, sourceRoot, '/');
        final String mainClass = relativePath == null ? mainClassFile.getNameWithoutExtension() : FileUtil.getNameWithoutExtension(relativePath).replace('/', '.');
        final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
        final LibraryTable.ModifiableModel librariesModel = ProjectLibraryTable.getInstance(module.getProject()).getModifiableModel();
        final FlexProjectConfigurationEditor flexEditor = FlexProjectConfigurationEditor.createEditor(module.getProject(), Collections.singletonMap(module, modifiableModel), librariesModel, null);
        final ModifiableFlexBuildConfiguration[] bcs = flexEditor.getConfigurations(module);
        final ModifiableFlexBuildConfiguration mainBC = ContainerUtil.find(bcs, bc -> bc.getOutputType() == OutputType.Application && module.getName().equals(bc.getName()));
        if (mainBC != null) {
            mainBC.setMainClass(mainClass);
        }
        flexEditor.commit();
        Disposer.dispose(librariesModel);
        modifiableModel.dispose();
    } catch (IOException ignore) {
    /**/
    } catch (ConfigurationException ignore) {
    /**/
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ConfigurationException(com.intellij.openapi.options.ConfigurationException) IOException(java.io.IOException) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 33 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.

the class FlexCompilerProjectConfigurable method apply.

public void apply() throws ConfigurationException {
    if (!myProject.isDefault()) {
        final FlexCompilerHandler flexCompilerHandler = FlexCompilerHandler.getInstance(myProject);
        flexCompilerHandler.getCompilerDependenciesCache().clear();
        flexCompilerHandler.quitCompilerShell();
        flexCompilerHandler.getBuiltInFlexCompilerHandler().stopCompilerProcess();
    }
    myConfig.USE_BUILT_IN_COMPILER = myBuiltInCompilerRadioButton.isSelected();
    myConfig.USE_MXMLC_COMPC = myMxmlcCompcRadioButton.isSelected();
    myConfig.PREFER_ASC_20 = myPreferASC20CheckBox.isSelected();
    try {
        final int heapSizeMb = Integer.parseInt(myHeapSizeTextField.getText().trim());
        if (heapSizeMb > 0) {
            myConfig.HEAP_SIZE_MB = heapSizeMb;
        } else {
            throw new ConfigurationException(FlexBundle.message("invalid.flex.compiler.heap.size"));
        }
    } catch (NumberFormatException e) {
        throw new ConfigurationException(FlexBundle.message("invalid.flex.compiler.heap.size"));
    }
    myConfig.VM_OPTIONS = myVMOptionsEditor.getText().trim();
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 34 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.

the class FlexBuildTargetScopeProvider method appendBCDependencies.

private static void appendBCDependencies(final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs, final Module module, final FlexBuildConfiguration bc) throws ConfigurationException {
    for (final DependencyEntry entry : bc.getDependencies().getEntries()) {
        if (entry instanceof BuildConfigurationEntry) {
            final BuildConfigurationEntry bcEntry = (BuildConfigurationEntry) entry;
            final Module dependencyModule = bcEntry.findModule();
            final FlexBuildConfiguration dependencyBC = dependencyModule == null ? null : bcEntry.findBuildConfiguration();
            if (dependencyModule == null || dependencyBC == null) {
                throw new ConfigurationException(FlexBundle.message("bc.dependency.does.not.exist", bcEntry.getBcName(), bcEntry.getModuleName(), bc.getName(), module.getName()));
            }
            final Pair<Module, FlexBuildConfiguration> dependencyModuleAndBC = Pair.create(dependencyModule, dependencyBC);
            if (!dependencyBC.isSkipCompile()) {
                if (modulesAndBCs.add(dependencyModuleAndBC)) {
                    appendBCDependencies(modulesAndBCs, dependencyModule, dependencyBC);
                }
            }
        }
    }
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module)

Example 35 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.

the class FlexBCConfigurator method createBcConfigurable.

private CompositeConfigurable createBcConfigurable(final Module module, final ModifiableFlexBuildConfiguration bc, final Runnable treeNodeNameUpdater) {
    final ProjectStructureConfigurable c = ProjectStructureConfigurable.getInstance(module.getProject());
    final Runnable bcNatureModifier = createBCNatureModifier(bc);
    return new FlexBCConfigurable(module, bc, bcNatureModifier, myConfigEditor, c.getProjectJdksModel(), c.getContext()) {

        public void apply() throws ConfigurationException {
            super.apply();
            myBCToOutputPathMap.put(bc, bc.getActualOutputFilePath());
        }

        @Override
        public void setDisplayName(final String name) {
            super.setDisplayName(name);
            treeNodeNameUpdater.run();
            myEventDispatcher.getMulticaster().buildConfigurationRenamed(this);
        }
    }.wrapInTabs();
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) FlexBCConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)

Aggregations

ConfigurationException (com.intellij.openapi.options.ConfigurationException)86 VirtualFile (com.intellij.openapi.vfs.VirtualFile)20 File (java.io.File)17 Module (com.intellij.openapi.module.Module)16 Project (com.intellij.openapi.project.Project)15 IOException (java.io.IOException)12 NotNull (org.jetbrains.annotations.NotNull)9 Nullable (org.jetbrains.annotations.Nullable)8 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)7 Sdk (com.intellij.openapi.projectRoots.Sdk)6 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)5 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 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3 FlexBCConfigurable (com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable)3 Disposable (com.intellij.openapi.Disposable)3 Library (com.intellij.openapi.roots.libraries.Library)3