Search in sources :

Example 96 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project azure-tools-for-java by Microsoft.

the class FunctionDeployConfiguration method validate.

@Override
public void validate() throws ConfigurationException {
    checkAzurePreconditions();
    if (this.module == null) {
        throw new ConfigurationException(message("function.deploy.validate.noModule"));
    }
    final FunctionAppConfig functionAppConfig = functionDeployModel.getFunctionAppConfig();
    if (StringUtils.isAllEmpty(functionAppConfig.getResourceId(), functionAppConfig.getName())) {
        throw new ConfigurationException(message("function.deploy.validate.noTarget"));
    }
}
Also used : FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 97 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project moe-ide-integration by multi-os-engine.

the class MOEModuleBuilder method setupRootModel.

@Override
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
    Project project = rootModel.getProject();
    Module module = rootModel.getModule();
    myJdk = MOESdkType.getJDK();
    ProjectRootManager.getInstance(project).setProjectSdk(myJdk);
    rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(MOESdkType.REQUIRED_JAVA_LANGUAGE_LEVEL);
    super.setupRootModel(rootModel);
    ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
    String projectPath = rootModel.getProject().getBasePath();
    String contentEntryPath = getContentEntryPath();
    if (contentEntryPath == null || contentEntryPath.isEmpty()) {
        throw new RuntimeException("Can't get content entry path.");
    }
    VirtualFile contentRoot = LocalFileSystem.getInstance().findFileByIoFile(new File(contentEntryPath));
    try {
        createModule(contentRoot, project);
    } catch (MOEProjectComposer.MOEProjectComposerException e) {
        throw new ConfigurationException(e.getMessage());
    }
    VirtualFile[] contentFiles = new VirtualFile[] { contentRoot };
    VfsUtil.markDirtyAndRefresh(false, true, true, contentFiles);
    new ReformatCodeProcessor(project, module, false).run();
    String resourcePath = "src/main/" + MOESdkPlugin.getResourcesFolderName();
    String sourcePath = "src/main/java";
    for (ContentEntry entry : rootModel.getContentEntries()) {
        for (SourceFolder srcFolder : entry.getSourceFolders()) {
            entry.removeSourceFolder(srcFolder);
        }
        VirtualFile sourceFile = null;
        if (contentRoot != null) {
            sourceFile = contentRoot.findFileByRelativePath(sourcePath);
        }
        if (sourceFile != null) {
            entry.addSourceFolder(sourceFile, false);
        }
        VirtualFile resourceFolder = null;
        if (contentRoot != null) {
            resourceFolder = contentRoot.findFileByRelativePath(resourcePath);
        }
        if (resourceFolder != null && resourceFolder.exists()) {
            SourceFolder sourceFolder = entry.addSourceFolder(resourceFolder, JavaResourceRootType.RESOURCE);
            JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
            if (properties != null) {
                properties.setForGeneratedSources(true);
            }
        }
    }
    try {
        configureGradle(rootModel);
    } catch (IOException e) {
        MOEToolWindow.getInstance(project).error("Error occurred during gradle configuration: " + e.getMessage());
    }
    if (!isNewProject) {
        File settingsGradle = new File(projectPath, "settings.gradle");
        try {
            if (!settingsGradle.exists()) {
                if (!settingsGradle.createNewFile()) {
                    MOEToolWindow.getInstance(project).error("Error occurred during gradle settings file.");
                }
            }
            modifyGradleSettings(settingsGradle, new Module[] { rootModel.getModule() });
        } catch (IOException e) {
            MOEToolWindow.getInstance(project).error("Error occurred during gradle configuration: " + e.getMessage());
        }
    }
    if (contentRoot != null) {
        contentRoot.refresh(false, true);
    }
    Sdk sdk = MOESdkType.getMOESdk(rootModel.getModule());
    if (sdk != null) {
        rootModel.setSdk(sdk);
    } else {
        MOEToolWindow.getInstance(project).error("Error, unable set Sdk.");
    }
    rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(MOESdkType.REQUIRED_JAVA_LANGUAGE_LEVEL);
    StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {

        @Override
        public void run() {
            configureRun(rootModel);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MOEProjectComposer(org.moe.generator.project.MOEProjectComposer) ReformatCodeProcessor(com.intellij.codeInsight.actions.ReformatCodeProcessor) IOException(java.io.IOException) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) Project(com.intellij.openapi.project.Project) SourceFolder(com.intellij.openapi.roots.SourceFolder) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ContentEntry(com.intellij.openapi.roots.ContentEntry) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) LanguageLevelModuleExtension(com.intellij.openapi.roots.LanguageLevelModuleExtension) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 98 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project moe-ide-integration by multi-os-engine.

the class MOERunConfigurationEditor method applyEditorTo.

@Override
protected void applyEditorTo(MOERunConfiguration configuration) throws ConfigurationException {
    if (configurationCombo.getSelectedItem() != null) {
        configuration.configuration(configurationCombo.getSelectedItem().toString());
    }
    if (simulatorCombo.getSelectedItem() != null) {
        configuration.simulatorDeviceName(simulatorCombo.getSelectedItem().toString());
        configuration.simulatorUdid(((SimulatorComboItem) simulatorCombo.getSelectedItem()).udid());
    }
    if (deviceCombo.getSelectedItem() != null) {
        String deviceUdid = deviceCombo.getSelectedItem().toString();
        if (deviceUdid.equals(MOEText.get("First.Device.Available"))) {
            deviceUdid = "";
        }
        configuration.deviceUdid(deviceUdid);
    }
    if (moduleCombo.getSelectedItem() == null) {
        throw new ConfigurationException("Please select a module");
    }
    try {
        configuration.moduleName(moduleCombo.getSelectedItem().toString());
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
    String port = textDebugPort.getText();
    if (!InputValidationHelper.isInteger(port)) {
        throw new ConfigurationException("Wrong debug port number, please enter a numeric value.");
    }
    configuration.debugPort(Integer.parseInt(port));
    port = textDebugRemotePort.getText();
    if (!InputValidationHelper.isInteger(port)) {
        throw new ConfigurationException("Wrong remote debug port number, please enter a numeric value.");
    }
    if (enableRemoteBuildCheckBox.isSelected()) {
        Properties properties = RemoteSettings.getProperties(hostTextField.getText(), portTextField.getText(), userTextField.getText(), knownhostsTextField.getText(), identityTextField.getText(), keychainNameTextField.getText(), keychainPassTextField.getText(), keychainLocktimeoutTextField.getText(), gradleRepositoriesTextField.getText());
        try {
            RemoteSettings.validate(properties);
        } catch (ConfigurationValidationException e) {
            throw new ConfigurationException(e.getErrorMessage());
        }
    }
    configuration.debugRemotePort(Integer.parseInt(port));
    configuration.runOnSimulator(simulatorRadio.isSelected());
    configuration.runJUnitTests(runJUnitTestsCheckBox.isSelected());
    configuration.setTestType(getTestingType());
    updateButtonsAndLabelComponents(configuration.getTestType());
    configuration.setTestClassName(myClassComponent.getComponent().getText());
    configuration.setTestPackageName(myPackageComponent.getComponent().getText());
    configuration.setRemoteBuildEnabled(enableRemoteBuildCheckBox.isSelected());
    configuration.setRemoteHost(hostTextField.getText());
    String remotePort = portTextField.getText();
    remotePort = remotePort == null || remotePort.isEmpty() ? "0" : remotePort;
    configuration.setRemotePort(Integer.parseInt(remotePort));
    configuration.setRemoteUser(userTextField.getText());
    configuration.setRemoteKnownhosts(knownhostsTextField.getText());
    configuration.setRemoteIdentity(identityTextField.getText());
    configuration.setRemoteKeychainPass(keychainPassTextField.getText());
    configuration.setRemoteKeychainName(keychainNameTextField.getText());
    String remoteBuildTimeout = keychainLocktimeoutTextField.getText();
    remoteBuildTimeout = remoteBuildTimeout == null || remoteBuildTimeout.isEmpty() ? "0" : remoteBuildTimeout;
    configuration.setRemoteKeychainLocktimeout(Integer.parseInt(remoteBuildTimeout));
    configuration.setRemoteGradleRepositories(gradleRepositoriesTextField.getText());
    configuration.setOpenDeploymentTargetDialog(openSelectDeploymentTargetCheckBox.isSelected());
    argumentsPanel.applyEditorTo(configuration);
}
Also used : ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Properties(java.util.Properties) ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) IOException(java.io.IOException)

Example 99 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project clion-embedded-arm by elmot.

the class OpenOcdLauncher method createProcess.

@Override
protected ProcessHandler createProcess(@NotNull CommandLineState commandLineState) throws ExecutionException {
    File runFile = findRunFile(commandLineState);
    findOpenOcdAction(commandLineState.getEnvironment().getProject()).stopOpenOcd();
    try {
        GeneralCommandLine commandLine = OpenOcdComponent.createOcdCommandLine(commandLineState.getEnvironment().getProject(), runFile, "reset", true);
        OSProcessHandler osProcessHandler = new OSProcessHandler(commandLine);
        osProcessHandler.addProcessListener(new ProcessAdapter() {

            @Override
            public void processTerminated(@NotNull ProcessEvent event) {
                super.processTerminated(event);
                Project project = commandLineState.getEnvironment().getProject();
                if (event.getExitCode() == 0) {
                    Informational.showSuccessfulDownloadNotification(project);
                } else {
                    Informational.showFailedDownloadNotification(project);
                }
            }
        });
        return osProcessHandler;
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(getProject(), e.getLocalizedMessage(), e.getTitle());
        throw new ExecutionException(e);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ConfigurationException(com.intellij.openapi.options.ConfigurationException) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File)

Example 100 with ConfigurationException

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

the class ModuleUtils method createStepModule.

static void createStepModule(@NotNull Project project, @NotNull StepNode step, @NotNull ModifiableModuleModel moduleModel) {
    StudyNode lesson = step.getParent();
    if (lesson != null) {
        String moduleDir = String.join("/", project.getBasePath(), lesson.getPath());
        StepModuleBuilder stepModuleBuilder = new StepModuleBuilder(moduleDir, step);
        try {
            stepModuleBuilder.createModule(moduleModel);
        } catch (IOException | ModuleWithNameAlreadyExists | JDOMException | ConfigurationException e) {
            logger.warn("Cannot create step: " + step.getDirectory(), e);
        }
    }
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) StudyNode(org.stepik.core.courseFormat.StudyNode) StepModuleBuilder(org.stepik.plugin.projectWizard.idea.StepModuleBuilder)

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