public void apply() {
    if (!isModified()) return;

    final ScalaProjectSettings scalaProjectSettings = ScalaProjectSettings.getInstance(myProject);
    scalaProjectSettings.setImplicitParametersSearchDepth(
        (Integer) implicitParametersSearchDepthSpinner.getValue());
    scalaProjectSettings.setOutputLimit((Integer) outputSpinner.getValue());
    scalaProjectSettings.setInProcessMode(runWorksheetInTheCheckBox.isSelected());
    scalaProjectSettings.setInteractiveMode(worksheetInteractiveModeCheckBox.isSelected());

    scalaProjectSettings.setSearchAllSymbols(searchAllSymbolsIncludeCheckBox.isSelected());
    scalaProjectSettings.setEnableJavaToScalaConversion(
        enableConversionOnCopyCheckBox.isSelected());
    scalaProjectSettings.setDontShowConversionDialog(donTShowDialogCheckBox.isSelected());
    scalaProjectSettings.setTreatDocCommentAsBlockComment(
        treatDocCommentAsBlockComment.isSelected());

    scalaProjectSettings.setShowImplisitConversions(showImplicitConversionsInCheckBox.isSelected());
    scalaProjectSettings.setShowArgumentsToByNameParams(
        showArgumentsToByNameParametersCheckBox.isSelected());
    scalaProjectSettings.setIncludeBlockExpressions(
        includeBlockExpressionsExpressionsCheckBox.isSelected());
    scalaProjectSettings.setIncludeLiterals(includeLiteralsCheckBox.isSelected());

    scalaProjectSettings.setIgnorePerformance(myResolveToAllClassesCheckBox.isSelected());
    scalaProjectSettings.setDisableLangInjection(myDisableLanguageInjection.isSelected());
    scalaProjectSettings.setDisableI18N(myDisablei18n.isSelected());
    scalaProjectSettings.setDontCacheCompoundTypes(myDontCacheCompound.isSelected());
    scalaProjectSettings.setScalaPriority(useScalaClassesPriorityCheckBox.isSelected());
    scalaProjectSettings.setCollectionTypeHighlightingLevel(
        collectionHighlightingChooser.getSelectedIndex());
    injectionPrefixTable.saveSettings(scalaProjectSettings);
  }
  @SuppressWarnings({"ConstantConditions", "RedundantIfStatement"})
  public boolean isModified() {

    final ScalaProjectSettings scalaProjectSettings = ScalaProjectSettings.getInstance(myProject);

    if (scalaProjectSettings.isShowImplisitConversions()
        != showImplicitConversionsInCheckBox.isSelected()) return true;
    if (scalaProjectSettings.isShowArgumentsToByNameParams()
        != showArgumentsToByNameParametersCheckBox.isSelected()) return true;
    if (scalaProjectSettings.isIncludeBlockExpressions()
        != includeBlockExpressionsExpressionsCheckBox.isSelected()) return true;
    if (scalaProjectSettings.isIncludeLiterals() != includeLiteralsCheckBox.isSelected())
      return true;

    if (scalaProjectSettings.getImplicitParametersSearchDepth()
        != (Integer) implicitParametersSearchDepthSpinner.getValue()) return true;
    if (scalaProjectSettings.getOutputLimit() != (Integer) outputSpinner.getValue()) return true;
    if (scalaProjectSettings.isInProcessMode() != runWorksheetInTheCheckBox.isSelected())
      return true;
    if (scalaProjectSettings.isInteractiveMode() != worksheetInteractiveModeCheckBox.isSelected())
      return true;

    if (scalaProjectSettings.isSearchAllSymbols() != searchAllSymbolsIncludeCheckBox.isSelected())
      return true;
    if (scalaProjectSettings.isEnableJavaToScalaConversion()
        != enableConversionOnCopyCheckBox.isSelected()) return true;
    if (scalaProjectSettings.isDontShowConversionDialog() != donTShowDialogCheckBox.isSelected())
      return true;
    if (scalaProjectSettings.isTreatDocCommentAsBlockComment()
        != treatDocCommentAsBlockComment.isSelected()) return true;

    if (scalaProjectSettings.isIgnorePerformance() != myResolveToAllClassesCheckBox.isSelected())
      return true;

    if (scalaProjectSettings.isDisableLangInjection() != myDisableLanguageInjection.isSelected())
      return true;

    if (scalaProjectSettings.isDisableI18N() != myDisablei18n.isSelected()) return true;

    if (scalaProjectSettings.isDontCacheCompoundTypes() != myDontCacheCompound.isSelected())
      return true;

    if (scalaProjectSettings.isScalaPriority() != useScalaClassesPriorityCheckBox.isSelected())
      return true;

    if (scalaProjectSettings.getCollectionTypeHighlightingLevel()
        != collectionHighlightingChooser.getSelectedIndex()) return true;

    if (injectionPrefixTable.isModified(scalaProjectSettings)) return true;

    return false;
  }
  private void setSettings() {
    final ScalaProjectSettings scalaProjectSettings = ScalaProjectSettings.getInstance(myProject);
    setValue(
        implicitParametersSearchDepthSpinner,
        scalaProjectSettings.getImplicitParametersSearchDepth());
    setValue(outputSpinner, scalaProjectSettings.getOutputLimit());
    setValue(runWorksheetInTheCheckBox, scalaProjectSettings.isInProcessMode());
    setValue(worksheetInteractiveModeCheckBox, scalaProjectSettings.isInteractiveMode());

    setValue(searchAllSymbolsIncludeCheckBox, scalaProjectSettings.isSearchAllSymbols());
    setValue(enableConversionOnCopyCheckBox, scalaProjectSettings.isEnableJavaToScalaConversion());
    setValue(donTShowDialogCheckBox, scalaProjectSettings.isDontShowConversionDialog());
    setValue(treatDocCommentAsBlockComment, scalaProjectSettings.isTreatDocCommentAsBlockComment());

    setValue(showImplicitConversionsInCheckBox, scalaProjectSettings.isShowImplisitConversions());
    setValue(
        showArgumentsToByNameParametersCheckBox,
        scalaProjectSettings.isShowArgumentsToByNameParams());
    setValue(
        includeBlockExpressionsExpressionsCheckBox,
        scalaProjectSettings.isIncludeBlockExpressions());
    setValue(includeLiteralsCheckBox, scalaProjectSettings.isIncludeLiterals());

    setValue(myResolveToAllClassesCheckBox, scalaProjectSettings.isIgnorePerformance());

    setValue(myDisableLanguageInjection, scalaProjectSettings.isDisableLangInjection());
    setValue(myDisablei18n, scalaProjectSettings.isDisableI18N());
    setValue(myDontCacheCompound, scalaProjectSettings.isDontCacheCompoundTypes());
    setValue(useScalaClassesPriorityCheckBox, scalaProjectSettings.isScalaPriority());
    collectionHighlightingChooser.setSelectedIndex(
        scalaProjectSettings.getCollectionTypeHighlightingLevel());

    injectionPrefixTable.loadSettings(scalaProjectSettings);
  }