Java Code Examples for com.intellij.openapi.options.ConfigurationException#getMessage()

The following examples show how to use com.intellij.openapi.options.ConfigurationException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleConfigurableEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredUIAccess
protected void doOKAction() {
  try {
    if (myConfigurable.isModified()) myConfigurable.apply();

    ApplicationManager.getApplication().saveAll();
  }
  catch (ConfigurationException e) {
    if (e.getMessage() != null) {
      if (myProject != null) {
        Messages.showMessageDialog(myProject, e.getMessage(), e.getTitle(), Messages.getErrorIcon());
      }
      else {
        Messages.showMessageDialog(myParentComponent, e.getMessage(), e.getTitle(), Messages.getErrorIcon());
      }
    }
    return;
  }
  super.doOKAction();
}
 
Example 2
Source File: WholeWestSingleConfigurableEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void doOKAction() {
  try {
    if (myConfigurable.isModified()) myConfigurable.apply();

    ApplicationManager.getApplication().saveAll();
  }
  catch (ConfigurationException e) {
    if (e.getMessage() != null) {
      if (myProject != null) {
        Messages.showMessageDialog(myProject, e.getMessage(), e.getTitle(), Messages.getErrorIcon());
      }
      else {
        Messages.showMessageDialog(myParentComponent, e.getMessage(), e.getTitle(), Messages.getErrorIcon());
      }
    }
    return;
  }
  super.doOKAction();
}
 
Example 3
Source File: SelectExternalProjectStep.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void validateStep(@Nonnull ExternalModuleImportContext<C> context) throws WizardStepValidationException {
  try {
    myControl.apply();
  }
  catch (ConfigurationException e) {
    throw new WizardStepValidationException(e.getMessage());
  }

  AbstractExternalModuleImportProvider<C> provider = context.getImportProvider();

  provider.ensureProjectIsDefined(context);
}
 
Example 4
Source File: DefaultSdksModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean canApply(String[] errorString, @Nullable MasterDetailsComponent rootConfigurable, boolean addedOnly) throws ConfigurationException {

    LinkedHashMap<Sdk, Sdk> sdks = new LinkedHashMap<>(mySdks);
    if (addedOnly) {
      Sdk[] allSdks = mySdkTableProvider.get().getAllSdks();
      for (Sdk sdk : allSdks) {
        sdks.remove(sdk);
      }
    }
    ArrayList<String> allNames = new ArrayList<>();
    Sdk itemWithError = null;
    for (Sdk currItem : sdks.values()) {
      String currName = currItem.getName();
      if (currName.isEmpty()) {
        itemWithError = currItem;
        errorString[0] = ProjectBundle.message("sdk.list.name.required.error");
        break;
      }
      if (allNames.contains(currName)) {
        itemWithError = currItem;
        errorString[0] = ProjectBundle.message("sdk.list.unique.name.required.error");
        break;
      }
      final SdkAdditionalData sdkAdditionalData = currItem.getSdkAdditionalData();
      if (sdkAdditionalData instanceof ValidatableSdkAdditionalData) {
        try {
          ((ValidatableSdkAdditionalData)sdkAdditionalData).checkValid(this);
        }
        catch (ConfigurationException e) {
          if (rootConfigurable != null) {
            final Object projectJdk = rootConfigurable.getSelectedObject();
            if (!(projectJdk instanceof Sdk) || !Comparing.strEqual(((Sdk)projectJdk).getName(), currName)) { //do not leave current item with current name
              rootConfigurable.selectNodeInTree(currName);
            }
          }
          throw new ConfigurationException(ProjectBundle.message("sdk.configuration.exception", currName) + " " + e.getMessage());
        }
      }
      allNames.add(currName);
    }
    if (itemWithError == null) return true;
    if (rootConfigurable != null) {
      rootConfigurable.selectNodeInTree(itemWithError.getName());
    }
    return false;
  }