Search in sources :

Example 6 with ConfigurationException

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

the class PythonSdkChooserCombo method showOptions.

private void showOptions(final Project project) {
    final PyConfigurableInterpreterList interpreterList = PyConfigurableInterpreterList.getInstance(project);
    final Sdk[] sdks = interpreterList.getModel().getSdks();
    //noinspection unchecked
    final JComboBox<Sdk> comboBox = getComboBox();
    final Sdk oldSelectedSdk = (Sdk) comboBox.getSelectedItem();
    PythonSdkDetailsStep.show(project, sdks, null, this, getButton().getLocationOnScreen(), sdk -> {
        if (sdk == null)
            return;
        final ProjectSdksModel projectSdksModel = interpreterList.getModel();
        if (projectSdksModel.findSdk(sdk) == null) {
            projectSdksModel.addSdk(sdk);
            try {
                projectSdksModel.apply();
            } catch (ConfigurationException e) {
                LOG.error("Error adding new python interpreter " + e.getMessage());
            }
        }
        final List<Sdk> committedSdks = interpreterList.getAllPythonSdks();
        final Sdk copiedSdk = interpreterList.getModel().findSdk(sdk.getName());
        comboBox.setModel(new CollectionComboBoxModel<>(committedSdks, oldSelectedSdk));
        comboBox.setSelectedItem(copiedSdk);
    }, true);
}
Also used : PyConfigurableInterpreterList(com.jetbrains.python.configuration.PyConfigurableInterpreterList) ProjectSdksModel(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 7 with ConfigurationException

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

the class BuildoutConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    final BuildoutFacet facet = myModule != null ? BuildoutFacet.getInstance(myModule) : null;
    final boolean got_facet = facet != null;
    boolean facet_is_desired = myEnabledCheckbox.isSelected();
    mySettingsPanel.apply();
    List<String> paths_from_script;
    if (facet_is_desired) {
        String script_name = mySettingsPanel.getScriptName();
        VirtualFile script_file = BuildoutConfigPanel.getScriptFile(script_name);
        paths_from_script = BuildoutFacet.extractBuildoutPaths(script_file);
        if (paths_from_script == null) {
            throw new ConfigurationException("Failed to extract paths from '" + script_file.getPresentableName() + "'");
        }
        mySettingsPanel.getConfiguration().setPaths(paths_from_script);
    }
    if (facet_is_desired && !got_facet)
        addFacet(mySettingsPanel.getConfiguration());
    if (!facet_is_desired && got_facet)
        removeFacet(facet);
    if (facet_is_desired)
        BuildoutFacet.attachLibrary(myModule);
    else
        BuildoutFacet.detachLibrary(myModule);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 8 with ConfigurationException

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

the class ArrayRendererConfigurable method isModified.

public boolean isModified() {
    ArrayRenderer cloneRenderer = myRenderer.clone();
    try {
        applyTo(cloneRenderer, false);
    } catch (ConfigurationException e) {
        return true;
    }
    final boolean valuesEqual = (myRenderer.END_INDEX == cloneRenderer.END_INDEX) && (myRenderer.START_INDEX == cloneRenderer.START_INDEX) && (myRenderer.ENTRIES_LIMIT == cloneRenderer.ENTRIES_LIMIT);
    return !valuesEqual;
}
Also used : ArrayRenderer(com.intellij.debugger.ui.tree.render.ArrayRenderer) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 9 with ConfigurationException

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

the class TemplateProjectDirectoryGenerator method validate.

@NotNull
@Override
public ValidationResult validate(@NotNull String baseDirPath) {
    String message = "Invalid settings";
    for (WizardInputField field : myTemplate.getInputFields()) {
        try {
            if (field.validate()) {
                continue;
            }
        } catch (ConfigurationException e) {
            message = e.getMessage();
        }
        return new ValidationResult(message);
    }
    ValidationResult result = myTemplate.validate(baseDirPath);
    if (result != null) {
        return result;
    }
    return ValidationResult.OK;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) WizardInputField(com.intellij.ide.util.projectWizard.WizardInputField) ValidationResult(com.intellij.facet.ui.ValidationResult) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with ConfigurationException

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

the class ExportToHTMLManager method executeExport.

/**
   * Should be invoked in event dispatch thread
   */
public static void executeExport(final DataContext dataContext) throws FileNotFoundException {
    PsiDirectory psiDirectory = null;
    PsiElement psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
    if (psiElement instanceof PsiDirectory) {
        psiDirectory = (PsiDirectory) psiElement;
    }
    final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext);
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    String shortFileName = null;
    String directoryName = null;
    if (psiFile != null || psiDirectory != null) {
        if (psiFile != null) {
            shortFileName = psiFile.getVirtualFile().getName();
            if (psiDirectory == null) {
                psiDirectory = psiFile.getContainingDirectory();
            }
        }
        if (psiDirectory != null) {
            directoryName = psiDirectory.getVirtualFile().getPresentableUrl();
        }
    }
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    boolean isSelectedTextEnabled = false;
    if (editor != null && editor.getSelectionModel().hasSelection()) {
        isSelectedTextEnabled = true;
    }
    ExportToHTMLDialog exportToHTMLDialog = new ExportToHTMLDialog(shortFileName, directoryName, isSelectedTextEnabled, project);
    ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project);
    if (exportToHTMLSettings.OUTPUT_DIRECTORY == null) {
        final VirtualFile baseDir = project.getBaseDir();
        if (baseDir != null) {
            exportToHTMLSettings.OUTPUT_DIRECTORY = baseDir.getPresentableUrl() + File.separator + "exportToHTML";
        } else {
            exportToHTMLSettings.OUTPUT_DIRECTORY = "";
        }
    }
    exportToHTMLDialog.reset();
    if (!exportToHTMLDialog.showAndGet()) {
        return;
    }
    try {
        exportToHTMLDialog.apply();
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle());
    }
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    final String outputDirectoryName = exportToHTMLSettings.OUTPUT_DIRECTORY;
    if (exportToHTMLSettings.getPrintScope() != PrintSettings.PRINT_DIRECTORY) {
        if (psiFile == null || psiFile.getText() == null) {
            return;
        }
        final String dirName = constructOutputDirectory(psiFile, outputDirectoryName);
        HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS);
        if (exportToHTMLSettings.getPrintScope() == PrintSettings.PRINT_SELECTED_TEXT && editor != null && editor.getSelectionModel().hasSelection()) {
            int firstLine = editor.getDocument().getLineNumber(editor.getSelectionModel().getSelectionStart());
            textPainter.setSegment(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), firstLine);
        }
        textPainter.paint(null, psiFile.getFileType());
        if (exportToHTMLSettings.OPEN_IN_BROWSER) {
            BrowserUtil.browse(textPainter.getHTMLFileName());
        }
    } else {
        myLastException = null;
        ExportRunnable exportRunnable = new ExportRunnable(exportToHTMLSettings, psiDirectory, outputDirectoryName, project);
        ProgressManager.getInstance().runProcessWithProgressSynchronously(exportRunnable, CodeEditorBundle.message("export.to.html.title"), true, project);
        if (myLastException != null) {
            throw myLastException;
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Editor(com.intellij.openapi.editor.Editor)

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