package jetbrains.mps.ide.ui.dialogs.properties.editors;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import jetbrains.mps.project.structure.modules.mappingpriorities.RuleType;
import jetbrains.mps.ide.ui.dialogs.properties.renderers.RuleTypeRenderer;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;

@GeneratedClass(node = "r:e46d921f-36a3-4bc0-aa46-fc10c6f85948(jetbrains.mps.ide.ui.dialogs.properties.editors)/3995997045458443074", model = "r:e46d921f-36a3-4bc0-aa46-fc10c6f85948(jetbrains.mps.ide.ui.dialogs.properties.editors)")
public class RuleTypeEditor extends DefaultCellEditor {
  private JComboBox myComboBox;
  public RuleTypeEditor() {
    super(new JComboBox());
    myComboBox = (JComboBox) editorComponent;
    myComboBox.addItem(RuleType.STRICTLY_BEFORE);
    myComboBox.addItem(RuleType.BEFORE_OR_TOGETHER);
    myComboBox.addItem(RuleType.STRICTLY_AFTER);
    myComboBox.addItem(RuleType.AFTER_OR_TOGETHER);
    myComboBox.addItem(RuleType.STRICTLY_TOGETHER);
    editorComponent = RuleTypeRenderer.createCenterAlignmentInCell(editorComponent);
    editorComponent.addKeyListener(new KeyListener() {
      public void keyTyped(KeyEvent p0) {
      }
      public void keyPressed(KeyEvent p0) {
        if (p0.isActionKey() || p0.getKeyCode() == KeyEvent.VK_ENTER) {
          myComboBox.processKeyEvent(p0);
          p0.consume();
        }
      }
      public void keyReleased(KeyEvent p0) {
      }
    });
  }
}
