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);
}
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);
}
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;
}
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;
}
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;
}
}
}
Aggregations