Example usage for com.intellij.openapi.options ConfigurationException ConfigurationException

List of usage examples for com.intellij.openapi.options ConfigurationException ConfigurationException

Introduction

In this page you can find the example usage for com.intellij.openapi.options ConfigurationException ConfigurationException.

Prototype

public ConfigurationException(String message) 

Source Link

Usage

From source file:au.com.borner.salesforce.plugin.panels.InstanceCredentialsPanel.java

License:Apache License

public void validate() throws ConfigurationException {
    if (instanceName.isVisible()) {
        if (instanceName.getText() == null || instanceName.getText().trim().length() == 0) {
            throw new ConfigurationException("Please specify an instance name.");
        }/*from  w ww  .ja  v  a2s  . c o m*/
        if (DuplicateInstanceNameChecker.isDuplicate(instanceName.getText())) {
            throw new ConfigurationException("Instance name already exists - please specify a different name.");
        }
    }
    if (username.getText() == null || username.getText().trim().length() == 0) {
        throw new ConfigurationException("Please specify your Username.");
    }
    if (password.getPassword().length == 0) {
        throw new ConfigurationException("Please specify your Password.");
    }
    //        if (securityToken.getPassword().length == 0) {
    //            throw new ConfigurationException("Please specify your Security Token");
    //        }
    if (environmentComboBox.getSelectedIndex() < 0) {
        throw new ConfigurationException("Please select an Environment.");
    }
    if (environmentComboBox.getSelectedItem().equals(InstanceUtils.OTHER)) {
        if (otherUrl.getText() == null || otherUrl.getText().trim().length() == 0) {
            throw new ConfigurationException("Please specify Other URL.");
        }
    }
}

From source file:au.com.borner.salesforce.plugin.project.SalesForceInstanceSelectionStep.java

License:Apache License

@Override
public boolean validate() throws ConfigurationException {
    if (instanceSelectionPanel.getSelectedInstance() == null) {
        throw new ConfigurationException("Please select an instance.");
    }/*from w  w w.  j  a va  2  s.  c o m*/
    return true;
}

From source file:bazaar4idea.ui.BzrConfigurationIdePanel.java

License:Apache License

private void validateExePath() throws ConfigurationException {
    String bzrCmd = pathSelector.getText();
    if (!ShellCommandService.isValid(bzrCmd)) {
        pathSelector.getTextField().setForeground(Color.RED);
        throw new ConfigurationException(
                BzrBundle.message("bzr4intellij.configuration.executable.error", bzrCmd));
    } else {/*from w  w w.ja va 2 s  .  c  o m*/
        pathSelector.getTextField().setForeground(Color.BLACK);
    }
}

From source file:com.android.tools.idea.gradle.eclipse.AdtImportLocationStep.java

License:Apache License

@Override
public boolean validate() throws ConfigurationException {
    WizardContext context = getWizardContext();

    GradleImport importer = AdtImportProvider.getImporter(context);
    if (importer != null) {
        List<String> errors = importer.getErrors();
        if (!errors.isEmpty()) {
            throw new ConfigurationException(errors.get(0));
        }// ww w .  j  av  a  2 s. co m
    }

    // The following code is based on similar code in com.intellij.ide.util.newProjectWizard.ProjectNameStep

    String projectFileDirectory = getProjectFileDirectory();
    if (projectFileDirectory.length() == 0) {
        throw new ConfigurationException(
                String.format("Enter %1$s file location", context.getPresentationName()));
    }

    boolean shouldPromptCreation = myIsPathChangedByUser;
    if (!ProjectWizardUtil.createDirectoryIfNotExists(
            String.format("The %1$s file directory\n", context.getPresentationName()), projectFileDirectory,
            shouldPromptCreation)) {
        return false;
    }

    boolean shouldContinue = true;

    File projectFile = new File(getProjectFileDirectory());
    String title = "New Project";
    if (projectFile.isFile()) {
        shouldContinue = false;
        String message = String.format("%s exists and is a file.\nPlease specify a different project location",
                projectFile.getAbsolutePath());
        Messages.showErrorDialog(message, title);
    } else if (projectFile.isDirectory()) {
        File[] files = projectFile.listFiles();
        if (files != null && files.length > 0) {
            String message = String.format(
                    "%1$s folder already exists and is not empty.\nIts content may be overwritten.\nContinue?",
                    projectFile.getAbsolutePath());
            int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
            shouldContinue = answer == 0;
        }
    }
    return shouldContinue;
}

From source file:com.android.tools.idea.gradle.eclipse.AdtImportWarningsStep.java

License:Apache License

@Override
public boolean validate() throws ConfigurationException {
    GradleImport importer = AdtImportProvider.getImporter(getWizardContext());
    if (importer != null && !importer.getErrors().isEmpty()) {
        throw new ConfigurationException("There are unrecoverable errors which must be corrected first");
    }// ww w  .j  a  v  a 2s .  c  om
    return super.validate();
}

From source file:com.android.tools.idea.gradle.eclipse.AdtWorkspaceForm.java

License:Apache License

@Override
public boolean validate() throws ConfigurationException {
    for (Map.Entry<String, File> entry : myPathMap.entrySet()) {
        String path = entry.getKey();
        File file = entry.getValue();
        if (file == null || file.getPath().trim().isEmpty()) {
            throw new ConfigurationException("Enter a value for workspace path " + path);
        } else if (!file.exists()) {
            throw new ConfigurationException(file.getPath() + " does not exist");
        }//from  w  w  w  . j  ava2  s . c o m
    }

    return super.validate();
}

From source file:com.android.tools.idea.gradle.structure.DefaultSdksConfigurable.java

License:Apache License

public boolean validate() throws ConfigurationException {
    if (!DefaultSdks.isValidAndroidSdkPath(getSdkLocation())) {
        throw new ConfigurationException(CHOOSE_VALID_SDK_DIRECTORY_ERR);
    }/*ww w.  ja  va 2 s  . c  o  m*/

    if (!JavaSdk.checkForJdk(getJdkLocation())) {
        throw new ConfigurationException(CHOOSE_VALID_JDK_DIRECTORY_ERR);
    }
    return true;
}

From source file:com.android.tools.idea.gradle.structure.editors.AndroidModuleConfigurable.java

License:Apache License

@Override
public void apply() throws ConfigurationException {
    VirtualFile file = getGradleBuildFile(myModule);
    if (file != null && !ensureFilesWritable(myModule.getProject(), file)) {
        throw new ConfigurationException(String.format("Build file %1$s is not writable", file.getPath()));
    }// www.  j  a  v  a2 s  .  c om
    myModuleEditor.apply();
}

From source file:com.android.tools.idea.gradle.structure.editors.AndroidProjectConfigurable.java

License:Apache License

@Override
public void apply() throws ConfigurationException {
    if (myGradleBuildFile == null) {
        return;/*  w w  w. ja  v  a  2  s .c o  m*/
    }
    VirtualFile file = myGradleBuildFile.getFile();
    if (!ReadonlyStatusHandler.ensureFilesWritable(myProject, file)) {
        throw new ConfigurationException(String.format("Build file %1$s is not writable", file.getPath()));
    }

    CommandProcessor.getInstance().runUndoTransparentAction(() -> {
        try {
            ActionRunner.runInsideWriteAction(() -> {
                for (BuildFileKey key : PROJECT_PROPERTIES) {
                    if (key == BuildFileKey.GRADLE_WRAPPER_VERSION || !myModifiedKeys.contains(key)) {
                        continue;
                    }
                    Object value = myProjectProperties.get(key);
                    if (value != null) {
                        myGradleBuildFile.setValue(key, value);
                    } else {
                        myGradleBuildFile.removeValue(null, key);
                    }
                }
                Object wrapperVersion = myProjectProperties.get(BuildFileKey.GRADLE_WRAPPER_VERSION);
                GradleWrapper gradleWrapper = GradleWrapper.find(myProject);
                if (wrapperVersion != null && gradleWrapper != null) {
                    boolean updated = gradleWrapper
                            .updateDistributionUrlAndDisplayFailure(wrapperVersion.toString());
                    if (updated) {
                        VirtualFile virtualFile = gradleWrapper.getPropertiesFile();
                        if (virtualFile != null) {
                            virtualFile.refresh(false, false);
                        }
                    }
                }
                myModifiedKeys.clear();
            });
        } catch (Exception e) {
            LOG.error("Error while applying changes", e);
        }
    });
}

From source file:com.android.tools.idea.gradle.structure.IdeSdksConfigurable.java

License:Apache License

public boolean validate() throws ConfigurationException {
    String msg = validateAndroidSdkPath();
    if (msg != null) {
        throw new ConfigurationException(msg);
    }/*  w ww.j  a  va2s . com*/

    if (!useEmbeddedJdk()) {
        File validJdkLocation = validateJdkPath(getJdkLocation());
        if (validJdkLocation == null) {
            throw new ConfigurationException(CHOOSE_VALID_JDK_DIRECTORY_ERR);
        }
    }

    msg = validateAndroidNdkPath();
    if (msg != null) {
        throw new ConfigurationException(msg);
    }

    return true;
}