package org.jetbrains.yaml;

import com.intellij.application.options.IndentOptionsEditor;
import com.intellij.lang.Language;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @author oleg
 */
public class YAMLLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
  @Override
  public CommonCodeStyleSettings getDefaultCommonSettings() {
    CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(YAMLLanguage.INSTANCE);
    CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions();
    indentOptions.INDENT_SIZE = 2;
    indentOptions.USE_TAB_CHARACTER = false;
    return defaultSettings;
  }

  @Override
  public IndentOptionsEditor getIndentOptionsEditor() {
    return new YAMLIndentOptionsEditor();
  }

  @NotNull
  @Override
  public Language getLanguage() {
    return YAMLLanguage.INSTANCE;
  }

  @Override
  public String getCodeSample(@NotNull SettingsType settingsType) {
    return "product: \n" + "  name: RubyMine\n" + "  version: 4\n" + "  vendor: JetBrains\n" + "  url: \"http://jetbrains.com/ruby\"";
  }

  private class YAMLIndentOptionsEditor extends IndentOptionsEditor {

    @Override
    protected void addComponents() {
      addTabOptions();
      // Tabs in YAML are not allowed
      myCbUseTab.setEnabled(false);

      myTabSizeField = createIndentTextField();
      myTabSizeLabel = new JLabel(ApplicationBundle.message("editbox.indent.tab.size"));
      // Do not add
      //add(myTabSizeLabel, myTabSizeField);

      myIndentField = createIndentTextField();
      myIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.indent"));
      add(myIndentLabel, myIndentField);
    }

    public void setEnabled(boolean enabled) {
      // Do nothing
    }
  }
}

@@ -1980,11 +1980,85 @@
    %7D%0A  %7D
+%0A%0A  @Override%0A  public boolean usesSharedPreview() %7B%0A    return false;%0A  %7D
 %0A%7D%0A

Remove Yaml and JSP tabs from "Other languages"