private void addLexemePropertiesPopupMenu() {
   menuLexemeProperties =
       new JPopupMenu() {
         @Override
         public void show(Component c, int x, int y) {
           intLexemePropertiesPopup = leksēmuĪpašībuTabula.rowAtPoint(new Point(x, y));
           super.show(c, x, y);
         }
       };
   JMenuItem addLexemeProperty = new JMenuItem("Pievienot īpašību");
   addLexemeProperty.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           if (intLexemePropertiesPopup >= 0
               && intLexemePropertiesPopup < leksēmuĪpašībuTabula.getRowCount())
             addLexemeProperty();
         }
       });
   JMenuItem deleteLexemeProperty = new JMenuItem("Dzēst īpašību");
   deleteLexemeProperty.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           if (intLexemePropertiesPopup >= 0
               && intLexemePropertiesPopup < leksēmuĪpašībuTabula.getRowCount())
             deleteLexemeProperty(intLexemePropertiesPopup);
         }
       });
   menuLexemeProperties.add(addLexemeProperty);
   menuLexemeProperties.add(deleteLexemeProperty);
   leksēmuĪpašībuTabula.setComponentPopupMenu(menuLexemeProperties);
 }
  public LeksikonaEditorsFrame(Lexicon _lexicon) {
    this.lexicon = _lexicon;

    JPanel panelis = (JPanel) this.getContentPane();
    //	    panelis.setMaximumSize(new Dimension(820, 672));
    panelis.setMinimumSize(new Dimension(820, 610));
    //	    this.setLocale(java.util.Locale.getDefault());
    this.setPreferredSize(new Dimension(820, 610));
    this.setTitle("Leksikona redaktors");
    // this.setResizable(false);

    panelis.setLayout(new BorderLayout());

    vgrMod = new VardgrupuModelis(lexicon);
    vārdgrupas = new JTable(vgrMod);
    vārdgrupas.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    TableColumn column = null;
    for (int i = 0; i < vgrMod.getColumnCount(); i++) {
      column = vārdgrupas.getColumnModel().getColumn(i);
      if (i == 1) {
        column.setPreferredWidth(300); // third column is bigger
      } else {
        column.setPreferredWidth(50);
      }
    }
    vārdgrupas
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    vārdgrupas
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    vārdgrupas
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteWGroup(vārdgrupas.convertRowIndexToModel(vārdgrupas.getSelectedRow()));
              }
            });
    vārdgrupas
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                insertWGroup();
              }
            });

    vārdgrupas.setBorder(BorderFactory.createLineBorder(Color.black));
    vārdgrupas
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                vārdgrupaSelektēta();
              }
            });

    vgrĪpMod = new AttributeModel(null);
    vgrĪpašībuTabula = new IpasibuTable(vgrĪpMod);
    vgrĪpašībuTabula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    vgrĪpašībuTabula.setBorder(BorderFactory.createLineBorder(Color.black));
    vgrĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    vgrĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    vgrĪpašībuTabula
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteWgroupProperty(
                    vgrĪpašībuTabula.convertRowIndexToModel(vgrĪpašībuTabula.getSelectedRow()));
              }
            });
    vgrĪpašībuTabula
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                addWgroupProperty();
              }
            });

    galMod = new EndingModel();
    galotņuTabula = new JTable(galMod);
    galotņuTabula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //	    galotņuTabula.setPreferredScrollableViewportSize(new Dimension(500, 70));
    galotņuTabula.setBorder(BorderFactory.createLineBorder(Color.black));
    galotņuTabula
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                galotneSelektēta();
              }
            });
    galotņuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    galotņuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    galotņuTabula
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteEnding(galotņuTabula.convertRowIndexToModel(galotņuTabula.getSelectedRow()));
              }
            });
    galotņuTabula
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                addEnding();
              }
            });

    galĪpMod = new AttributeModel(null);
    galotņuĪpašībuTabula = new IpasibuTable(galĪpMod);
    galotņuĪpašībuTabula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //	    galotņuĪpašībuTabula.setPreferredScrollableViewportSize(new Dimension(500, 70));
    galotņuĪpašībuTabula.setBorder(BorderFactory.createLineBorder(Color.black));
    galotņuĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    galotņuĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    galotņuĪpašībuTabula
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteEndingProperty(
                    galotņuĪpašībuTabula.convertRowIndexToModel(
                        galotņuĪpašībuTabula.getSelectedRow()));
              }
            });
    galotņuĪpašībuTabula
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                addEndingProperty();
              }
            });

    leksMod = new LexemeModel();

    leksēmuTabula = new JTable(leksMod);
    leksēmuTabula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leksēmuTabula.setBorder(BorderFactory.createLineBorder(Color.black));
    // leksēmuTabula.setAutoCreateRowSorter(true);
    leksēmuTabula
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                leksēmaSelektēta();
              }
            });

    leksēmuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    leksēmuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    leksēmuTabula
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteLexeme(leksēmuTabula.convertRowIndexToModel(leksēmuTabula.getSelectedRow()));
              }
            });
    leksēmuTabula
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                addLexeme();
              }
            });

    leksĪpMod = new AttributeModel(null);
    leksēmuĪpašībuTabula = new IpasibuTable(leksĪpMod);
    leksēmuĪpašībuTabula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leksēmuĪpašībuTabula.setBorder(BorderFactory.createLineBorder(Color.black));
    leksēmuĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "deleteRow");
    leksēmuĪpašībuTabula
        .getInputMap()
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, java.awt.event.InputEvent.CTRL_DOWN_MASK),
            "insertRow");
    leksēmuĪpašībuTabula
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                deleteLexemeProperty(
                    leksēmuĪpašībuTabula.convertRowIndexToModel(
                        leksēmuĪpašībuTabula.getSelectedRow()));
              }
            });
    leksēmuĪpašībuTabula
        .getActionMap()
        .put(
            "insertRow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                addLexemeProperty();
              }
            });

    JPanel leja = new JPanel(new BorderLayout());
    JPanel pnlVgrTab = new JPanel(new BorderLayout());
    JPanel pnlVgrĪpTab = new JPanel(new BorderLayout());
    JPanel pnlGalTab = new JPanel(new BorderLayout());
    JPanel pnlGalĪpTab = new JPanel(new BorderLayout());
    JPanel pnlLeksTab = new JPanel(new BorderLayout());
    JPanel pnlLeksĪpTab = new JPanel(new BorderLayout());

    pnlVgrTab.add(lblVgr, BorderLayout.NORTH);
    pnlVgrTab.add(vārdgrupas, BorderLayout.SOUTH);
    pnlVgrTab.add(spanVgr);
    spanVgr.getViewport().add(vārdgrupas, null);

    pnlVgrĪpTab.add(lblVgrĪp, BorderLayout.NORTH);
    pnlVgrĪpTab.add(vgrĪpašībuTabula, BorderLayout.SOUTH);
    pnlVgrĪpTab.add(spanVgrĪp);
    spanVgrĪp.getViewport().add(vgrĪpašībuTabula, null);

    pnlGalTab.add(lblGal, BorderLayout.NORTH);
    pnlGalTab.add(galotņuTabula, BorderLayout.SOUTH);
    pnlGalTab.add(spanGal);
    spanGal.getViewport().add(galotņuTabula, null);

    pnlGalĪpTab.add(lblGalĪp, BorderLayout.NORTH);
    pnlGalĪpTab.add(galotņuĪpašībuTabula, BorderLayout.SOUTH);
    pnlGalĪpTab.add(spanGalĪp);
    spanGalĪp.getViewport().add(galotņuĪpašībuTabula, null);

    pnlLeksTab.add(lblLeks, BorderLayout.NORTH);
    pnlLeksTab.add(leksēmuTabula, BorderLayout.SOUTH);
    pnlLeksTab.add(spanLeks);
    spanLeks.getViewport().add(leksēmuTabula, null);

    pnlLeksĪpTab.add(lblLeksĪp, BorderLayout.NORTH);
    pnlLeksĪpTab.add(leksēmuĪpašībuTabula, BorderLayout.SOUTH);
    pnlLeksĪpTab.add(spanLeksĪp);
    spanLeksĪp.getViewport().add(leksēmuĪpašībuTabula, null);

    pnlGalTab.setPreferredSize(new Dimension(400, 400));
    pnlGalotnes.add(pnlGalTab, BorderLayout.CENTER);
    pnlGalĪpTab.setPreferredSize(new Dimension(400, 150));
    pnlGalotnes.add(pnlGalĪpTab, BorderLayout.SOUTH);

    pnlLeksTab.setPreferredSize(new Dimension(400, 400));
    pnlLeksēmas.add(pnlLeksTab, BorderLayout.CENTER);
    pnlLeksĪpTab.setPreferredSize(new Dimension(400, 150));
    pnlLeksēmas.add(pnlLeksĪpTab, BorderLayout.SOUTH);

    pnlVgrTab.setPreferredSize(new Dimension(400, 400));
    pnlKreisais.add(pnlVgrTab, BorderLayout.CENTER);
    pnlVgrĪpTab.setPreferredSize(new Dimension(400, 150));
    pnlKreisais.add(pnlVgrĪpTab, BorderLayout.SOUTH);

    centrs.add(pnlKreisais, BorderLayout.WEST);
    centrs.add(pnlLeksēmas, BorderLayout.CENTER);

    pārslēgt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            changeTables();
          }
        });

    aizvērt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            aizvērtLogu();
          }
        });

    leja.add(pārslēgt, BorderLayout.LINE_START);
    leja.add(aizvērt, BorderLayout.LINE_END);

    panelis.add(centrs, BorderLayout.CENTER);
    panelis.add(leja, BorderLayout.SOUTH);

    addWGroupPopupMenu();
    addWGroupPropertiesPopupMenu();
    addEndingPopupMenu();
    addEngingPropertiesPopupMenu();
    addLexemePopupMenu();
    addLexemePropertiesPopupMenu();

    this.pack();
  }