@Override
 public void apply() throws ConfigurationException {
   myBuildTargetSettings.setOS(selected(myOSCombo, myDefaultOSValue));
   myBuildTargetSettings.setArch(selected(myArchCombo, myDefaultArchValue));
   myBuildTargetSettings.setGoVersion(selected(myGoVersionCombo, myDefaultGoVersion));
   myBuildTargetSettings.setCompiler(selectedCompiler());
   myBuildTargetSettings.setCgo(selectedCgo());
   myBuildTargetSettings.setCustomFlags(selectedCustomFlags());
 }
 @Override
 public void reset() {
   myOSCombo.setSelectedItem(expandDefault(myBuildTargetSettings.getOS(), myDefaultOSValue));
   myArchCombo.setSelectedItem(expandDefault(myBuildTargetSettings.getArch(), myDefaultArchValue));
   myGoVersionCombo.setSelectedItem(
       expandDefault(myBuildTargetSettings.getGoVersion(), myDefaultGoVersion));
   myCgoCombo.setSelectedItem(expandDefault(cgo(myBuildTargetSettings.getCgo()), myDefaultCgo));
   myCompilerCombo.setSelectedItem(myBuildTargetSettings.getCompiler());
   myCustomFlagsField.setText(StringUtil.join(myBuildTargetSettings.getCustomFlags(), " "));
 }
 @Override
 public boolean isModified() {
   return !myBuildTargetSettings.getOS().equals(selected(myOSCombo, myDefaultOSValue))
       || !myBuildTargetSettings.getArch().equals(selected(myArchCombo, myDefaultArchValue))
       || !myBuildTargetSettings
           .getGoVersion()
           .equals(selected(myGoVersionCombo, myDefaultGoVersion))
       || !myBuildTargetSettings.getCgo().equals(selectedCgo())
       || !myBuildTargetSettings.getCompiler().equals(selectedCompiler())
       || !Arrays.equals(myBuildTargetSettings.getCustomFlags(), selectedCustomFlags());
 }
  public GoBuildTargetConfigurable(@NotNull Project project, boolean dialogMode) {
    if (dialogMode) {
      myPanel.setPreferredSize(new Dimension(400, -1));
    }

    myBuildTargetSettings = GoBuildTargetSettings.getInstance(project);

    myDefaultOSValue = "Default (" + GoUtil.systemOS() + ")";
    myDefaultArchValue = "Default (" + GoUtil.systemArch() + ")";
    myDefaultGoVersion =
        "Project SDK ("
            + StringUtil.notNullize(GoSdkService.getInstance(project).getSdkVersion(null), "any")
            + ")";
    myDefaultCgo = "Default (" + cgo(GoUtil.systemCgo(myDefaultOSValue, myDefaultArchValue)) + ")";

    myOSCombo.setModel(createModel(GoConstants.KNOWN_OS, myDefaultOSValue));
    myArchCombo.setModel(createModel(GoConstants.KNOWN_ARCH, myDefaultArchValue));
    myCgoComboModel = createModel(ContainerUtil.newArrayList(ENABLED, DISABLED), myDefaultCgo);
    myCgoCombo.setModel(myCgoComboModel);
    myCompilerCombo.setModel(
        createModel(GoConstants.KNOWN_COMPILERS, GoBuildTargetSettings.ANY_COMPILER));
    myGoVersionCombo.setModel(createModel(GoConstants.KNOWN_VERSIONS, myDefaultGoVersion));

    ActionListener updateCgoListener =
        new ActionListener() {
          @Override
          public void actionPerformed(@NotNull ActionEvent event) {
            String selected = StringUtil.notNullize(myCgoComboModel.getSelected(), myDefaultCgo);
            String oldDefault = myDefaultCgo;
            String os = expandDefault(selected(myOSCombo, myDefaultOSValue), GoUtil.systemOS());
            String arch =
                expandDefault(selected(myArchCombo, myDefaultArchValue), GoUtil.systemArch());

            myDefaultCgo = "Default (" + cgo(GoUtil.systemCgo(os, arch)) + ")";
            myCgoComboModel.update(ContainerUtil.newArrayList(myDefaultCgo, ENABLED, DISABLED));
            myCgoComboModel.setSelectedItem(oldDefault.equals(selected) ? myDefaultCgo : selected);
          }
        };
    myOSCombo.addActionListener(updateCgoListener);
    myArchCombo.addActionListener(updateCgoListener);
  }