package jetbrains.mps.build.pluginSolution.plugin;

/*Generated by MPS */

import jetbrains.mps.execution.api.settings.SettingsEditorEx;
import jetbrains.mps.execution.lib.ui.NodeByConceptChooser;
import jetbrains.mps.execution.lib.NodeByConcept_Configuration_Editor;
import jetbrains.mps.ant.execution.AntSettings_Configuration_Editor;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import jetbrains.mps.ide.common.LayoutUtil;
import com.intellij.openapi.options.ConfigurationException;

public class BuildScript_Configuration_Editor extends SettingsEditorEx<BuildScript_Configuration> {
  private NodeByConceptChooser myChooser;
  private NodeByConcept_Configuration_Editor myNodePointer;
  private AntSettings_Configuration_Editor mySettings;
  public void disposeEditor() {
    myChooser.dispose();
    Disposer.dispose(myNodePointer);
    Disposer.dispose(mySettings);
  }

  @NotNull
  public JPanel createEditor() {
    JPanel panel = new JPanel(new GridBagLayout());

    myChooser = myNodePointer.createEditor();
    panel.add(new JLabel("Build project:"), LayoutUtil.createLabelConstraints(0));
    panel.add(myChooser, LayoutUtil.createFieldConstraints(1));

    JPanel settings = mySettings.createEditor();
    panel.add(settings, LayoutUtil.createPanelConstraints(2));

    return panel;
  }

  public void applyEditorTo(final BuildScript_Configuration configuration) throws ConfigurationException {
    myNodePointer.applyEditorTo(configuration.getNodePointer());
    mySettings.applyEditorTo(configuration.getSettings());
  }

  public void resetEditorFrom(final BuildScript_Configuration configuration) {
    myNodePointer.resetEditorFrom(configuration.getNodePointer());
    mySettings.resetEditorFrom(configuration.getSettings());
  }
  public BuildScript_Configuration_Editor(NodeByConcept_Configuration_Editor nodePointer, AntSettings_Configuration_Editor settings) {
    myNodePointer = nodePointer;
    mySettings = settings;
  }
}
