Search in sources :

Example 1 with FacetEditorValidator

use of com.intellij.facet.ui.FacetEditorValidator in project intellij-community by JetBrains.

the class PyCCProjectGenerator method extendBasePanel.

@Nullable
@Override
public JPanel extendBasePanel() throws ProcessCanceledException {
    mySettingsPanel = new CCNewProjectPanel();
    mySettingsPanel.registerValidators(new FacetValidatorsManager() {

        public void registerValidator(FacetEditorValidator validator, JComponent... componentsToWatch) {
            throw new UnsupportedOperationException();
        }

        public void validate() {
            fireStateChanged();
        }
    });
    return mySettingsPanel.getMainPanel();
}
Also used : FacetValidatorsManager(com.intellij.facet.ui.FacetValidatorsManager) FacetEditorValidator(com.intellij.facet.ui.FacetEditorValidator) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FacetEditorValidator

use of com.intellij.facet.ui.FacetEditorValidator in project intellij-community by JetBrains.

the class BuildoutConfigPanel method initErrorValidation.

private void initErrorValidation() {
    FacetErrorPanel facetErrorPanel = new FacetErrorPanel();
    myErrorPanel.add(facetErrorPanel.getComponent(), BorderLayout.CENTER);
    facetErrorPanel.getValidatorsManager().registerValidator(new FacetEditorValidator() {

        @NotNull
        @Override
        public ValidationResult check() {
            if (!myFacetEnabled) {
                return ValidationResult.OK;
            }
            return validateScriptName(getScriptName());
        }
    }, myScript);
    facetErrorPanel.getValidatorsManager().validate();
}
Also used : FacetErrorPanel(com.intellij.facet.impl.ui.FacetErrorPanel) FacetEditorValidator(com.intellij.facet.ui.FacetEditorValidator) ValidationResult(com.intellij.facet.ui.ValidationResult) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with FacetEditorValidator

use of com.intellij.facet.ui.FacetEditorValidator in project intellij-community by JetBrains.

the class PyIntegratedToolsConfigurable method initErrorValidation.

private void initErrorValidation() {
    final FacetErrorPanel facetErrorPanel = new FacetErrorPanel();
    myErrorPanel.add(facetErrorPanel.getComponent(), BorderLayout.CENTER);
    facetErrorPanel.getValidatorsManager().registerValidator(new FacetEditorValidator() {

        @NotNull
        @Override
        public ValidationResult check() {
            final Sdk sdk = PythonSdkType.findPythonSdk(myModule);
            if (sdk != null) {
                final Object selectedItem = myTestRunnerComboBox.getSelectedItem();
                if (PythonTestConfigurationsModel.PY_TEST_NAME.equals(selectedItem)) {
                    if (!VFSTestFrameworkListener.getInstance().isPyTestInstalled(sdk)) {
                        return new ValidationResult(PyBundle.message("runcfg.testing.no.test.framework", "py.test"), createQuickFix(sdk, facetErrorPanel, PyNames.PY_TEST));
                    }
                } else if (PythonTestConfigurationsModel.PYTHONS_NOSETEST_NAME.equals(selectedItem)) {
                    if (!VFSTestFrameworkListener.getInstance().isNoseTestInstalled(sdk)) {
                        return new ValidationResult(PyBundle.message("runcfg.testing.no.test.framework", "nosetest"), createQuickFix(sdk, facetErrorPanel, PyNames.NOSE_TEST));
                    }
                }
            }
            return ValidationResult.OK;
        }
    }, myTestRunnerComboBox);
    facetErrorPanel.getValidatorsManager().validate();
}
Also used : FacetErrorPanel(com.intellij.facet.impl.ui.FacetErrorPanel) FacetEditorValidator(com.intellij.facet.ui.FacetEditorValidator) Sdk(com.intellij.openapi.projectRoots.Sdk) ValidationResult(com.intellij.facet.ui.ValidationResult) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with FacetEditorValidator

use of com.intellij.facet.ui.FacetEditorValidator in project intellij-community by JetBrains.

the class AbstractCreateVirtualEnvDialog method setupDialog.

void setupDialog(Project project, final List<Sdk> allSdks) {
    myProject = project;
    final GridBagLayout layout = new GridBagLayout();
    myMainPanel = new JPanel(layout);
    myName = new JTextField();
    myDestination = new TextFieldWithBrowseButton();
    myMakeAvailableToAllProjectsCheckbox = new JBCheckBox(PyBundle.message("sdk.create.venv.dialog.make.available.to.all.projects"));
    if (project == null || project.isDefault() || !PlatformUtils.isPyCharm()) {
        myMakeAvailableToAllProjectsCheckbox.setSelected(true);
        myMakeAvailableToAllProjectsCheckbox.setVisible(false);
    }
    layoutPanel(allSdks);
    init();
    setOKActionEnabled(false);
    registerValidators(new FacetValidatorsManager() {

        public void registerValidator(FacetEditorValidator validator, JComponent... componentsToWatch) {
        }

        public void validate() {
            checkValid();
        }
    });
    myMainPanel.setPreferredSize(new Dimension(300, 50));
    checkValid();
    setInitialDestination();
    addUpdater(myName);
    new LocationNameFieldsBinding(project, myDestination, myName, myInitialPath, PyBundle.message("sdk.create.venv.dialog.select.venv.location"));
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FacetValidatorsManager(com.intellij.facet.ui.FacetValidatorsManager) LocationNameFieldsBinding(com.intellij.platform.LocationNameFieldsBinding) FacetEditorValidator(com.intellij.facet.ui.FacetEditorValidator) JBCheckBox(com.intellij.ui.components.JBCheckBox)

Aggregations

FacetEditorValidator (com.intellij.facet.ui.FacetEditorValidator)4 FacetErrorPanel (com.intellij.facet.impl.ui.FacetErrorPanel)2 FacetValidatorsManager (com.intellij.facet.ui.FacetValidatorsManager)2 ValidationResult (com.intellij.facet.ui.ValidationResult)2 NotNull (org.jetbrains.annotations.NotNull)2 Sdk (com.intellij.openapi.projectRoots.Sdk)1 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)1 LocationNameFieldsBinding (com.intellij.platform.LocationNameFieldsBinding)1 JBCheckBox (com.intellij.ui.components.JBCheckBox)1 CCNewProjectPanel (com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel)1 Nullable (org.jetbrains.annotations.Nullable)1