Search in sources :

Example 1 with WizardStep

use of com.intellij.ui.wizard.WizardStep in project azure-tools-for-java by Microsoft.

the class MachineSettingsStep method onNext.

@Override
public WizardStep onNext(VMWizardModel model) {
    WizardStep wizardStep = super.onNext(model);
    String name = vmNameTextField.getText();
    if (name.length() > 15 || name.length() < 3) {
        JOptionPane.showMessageDialog(null, "Invalid virtual machine name. The name must be between 3 and 15 character long.", "Error creating the virtual machine", JOptionPane.ERROR_MESSAGE);
        return this;
    }
    if (!name.matches("^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$")) {
        JOptionPane.showMessageDialog(null, "Invalid virtual machine name. The name must start with a letter, \n" + "contain only letters, numbers, and hyphens, " + "and end with a letter or number.", "Error creating the virtual machine", JOptionPane.ERROR_MESSAGE);
        return this;
    }
    String password = passwordCheckBox.isSelected() ? new String(vmPasswordField.getPassword()) : "";
    if (passwordCheckBox.isSelected()) {
        String conf = new String(confirmPasswordField.getPassword());
        if (!password.equals(conf)) {
            JOptionPane.showMessageDialog(null, "Password confirmation should match password", "Error creating the service", JOptionPane.ERROR_MESSAGE);
            return this;
        }
        if (!password.matches("(?=^.{8,255}$)((?=.*\\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*")) {
            JOptionPane.showMessageDialog(null, "The password does not conform to complexity requirements.\n" + "It should be at least eight characters long and contain a mixture of upper case, lower case, digits and symbols.", "Error creating the virtual machine", JOptionPane.ERROR_MESSAGE);
            return this;
        }
    }
    String certificate = certificateCheckBox.isSelected() ? certificateField.getText() : "";
    model.setName(name);
    model.setSize((String) vmSizeComboBox.getSelectedItem());
    model.setUserName(vmUserTextField.getText());
    model.setPassword(password);
    model.setCertificate(certificate);
    return wizardStep;
}
Also used : AzureWizardStep(com.microsoft.intellij.ui.components.AzureWizardStep) WizardStep(com.intellij.ui.wizard.WizardStep)

Example 2 with WizardStep

use of com.intellij.ui.wizard.WizardStep in project intellij-community by JetBrains.

the class SelectPluginsStep method onPrevious.

@Override
public WizardStep onPrevious(final StartupWizardModel model) {
    final WizardStep prev = super.onPrevious(model);
    if (prev instanceof SelectPluginsStep) {
        final SelectPluginsStep selectPluginsStep = (SelectPluginsStep) prev;
        final String id = selectPluginsStep.getRequirePlugin();
        if (id != null && model.getDisabledPluginIds().contains(id) && !model.isFirst(prev)) {
            return model.getPreviousFor(prev);
        }
    }
    return prev;
}
Also used : WizardStep(com.intellij.ui.wizard.WizardStep)

Example 3 with WizardStep

use of com.intellij.ui.wizard.WizardStep in project azure-tools-for-java by Microsoft.

the class MachineSettingsStep method onNext.

@Override
public WizardStep onNext(VMWizardModel model) {
    String name = vmNameTextField.getText();
    if (name.length() > 15 || name.length() < 3) {
        DefaultLoader.getUIHelper().showError("Invalid virtual machine name. The name must be between 3 and 15 " + "character long.", "Error creating the virtual machine");
        return this;
    }
    if (!name.matches("^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$")) {
        DefaultLoader.getUIHelper().showError("Invalid virtual machine name. The name must start with a letter, \ncontain only letters, " + "numbers, and hyphens, and end with a letter or number.", "Error creating the virtual machine");
        return this;
    }
    String password = passwordCheckBox.isSelected() ? new String(vmPasswordField.getPassword()) : "";
    if (passwordCheckBox.isSelected()) {
        String conf = new String(confirmPasswordField.getPassword());
        if (!password.equals(conf)) {
            DefaultLoader.getUIHelper().showError("Password confirmation should match password", "Error creating " + "the service");
            return this;
        }
        if (!password.matches("(?=^.{8,255}$)((?=.*\\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\\d)(?=.*[^A-Za-z0-9])" + "(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|" + "(?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*")) {
            DefaultLoader.getUIHelper().showError("The password does not conform to complexity requirements.\nIt should be at least eight " + "characters long and contain a mixture of upper case, lower case, digits and " + "symbols.", "Error creating the virtual machine");
            return this;
        }
    }
    String certificate = certificateCheckBox.isSelected() ? certificateField.getText() : "";
    model.setName(name);
    model.setSize((String) vmSizeComboBox.getSelectedItem());
    model.setUserName(vmUserTextField.getText());
    model.setPassword(password);
    model.setCertificate(certificate);
    WizardStep wizardStep = super.onNext(model);
    return wizardStep;
}
Also used : AzureWizardStep(com.microsoft.intellij.ui.components.AzureWizardStep) WizardStep(com.intellij.ui.wizard.WizardStep) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 4 with WizardStep

use of com.intellij.ui.wizard.WizardStep in project intellij-community by JetBrains.

the class SelectPluginsStep method onNext.

@Override
public WizardStep onNext(final StartupWizardModel model) {
    final WizardStep next = super.onNext(model);
    if (next instanceof SelectPluginsStep) {
        final SelectPluginsStep selectPluginsStep = (SelectPluginsStep) next;
        final String id = selectPluginsStep.getRequirePlugin();
        if (id != null && model.getDisabledPluginIds().contains(id) && !model.isLast(next)) {
            for (IdeaPluginDescriptor descriptor : selectPluginsStep.getPlugins()) {
                model.getDisabledPluginIds().add(descriptor.getPluginId().getIdString());
            }
            return model.getNextFor(next);
        }
    }
    return next;
}
Also used : WizardStep(com.intellij.ui.wizard.WizardStep) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor)

Aggregations

WizardStep (com.intellij.ui.wizard.WizardStep)4 AzureWizardStep (com.microsoft.intellij.ui.components.AzureWizardStep)2 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1