Advertisement
Guest User

GUINewNoun.java

a guest
Mar 14th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.11 KB | None | 0 0
  1. package cf.randers.nev.gui;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.EventQueue;
  6. import java.awt.GridBagConstraints;
  7. import java.awt.GridBagLayout;
  8. import java.awt.Insets;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import java.awt.event.ItemEvent;
  12. import java.awt.event.ItemListener;
  13. import java.util.Map;
  14.  
  15. import javax.swing.JButton;
  16. import javax.swing.JCheckBox;
  17. import javax.swing.JComboBox;
  18. import javax.swing.JDialog;
  19. import javax.swing.JLabel;
  20. import javax.swing.JPanel;
  21. import javax.swing.JTextField;
  22. import javax.swing.UIManager;
  23. import javax.swing.WindowConstants;
  24. import javax.swing.border.TitledBorder;
  25. import javax.swing.event.DocumentEvent;
  26. import javax.swing.event.DocumentListener;
  27.  
  28. import cf.randers.nev.helper.GUIHelper;
  29. import cf.randers.nev.helper.LogHelper;
  30. import cf.randers.nev.language.LanguageHelper;
  31. import cf.randers.nev.vocab.attribute.Gender;
  32. import cf.randers.nev.vocab.attribute.NounDeclension;
  33. import cf.randers.nev.vocab.descriptor.NounFormDescriptor;
  34. import cf.randers.nev.vocab.helper.NounFormHelper;
  35.  
  36. import javax.swing.JSeparator;
  37. import javax.swing.SwingConstants;
  38. import java.awt.Rectangle;
  39.  
  40. public class GUINewNoun extends JDialog {
  41.     private static final long serialVersionUID = -6435915629645877560L;
  42.    
  43.     public final DocumentListener tfChangeListener = new DocumentListener() {
  44.  
  45.         @Override
  46.         public void insertUpdate(DocumentEvent e) {
  47.             refresh();
  48.         }
  49.  
  50.         @Override
  51.         public void removeUpdate(DocumentEvent e) {
  52.             refresh();
  53.         }
  54.  
  55.         @Override
  56.         public void changedUpdate(DocumentEvent e) {
  57.             refresh();
  58.         }
  59.        
  60.     };
  61.  
  62.     public Gender gender = Gender.MASCULINE;
  63.     public NounDeclension declension = NounDeclension.O_DECLENSION;
  64.  
  65.     public JTextField tfInputSgNom, tfInputSgGen;
  66.     public JComboBox<Gender> cbGender;
  67.     public JComboBox<NounDeclension> cbDeclension;
  68.  
  69.     public JLabel lblSgNom, lblPlNom, lblSgGen, lblPlGen, lblSgDat, lblPlDat, lblSgAcc, lblPlAcc, lblSgAbl, lblPlAbl, lblSgVoc, lblPlVoc;
  70.     public JTextField tfSgNom, tfPlNom, tfSgGen, tfPlGen, tfSgDat, tfPlDat, tfSgAcc, tfPlAcc, tfSgAbl, tfPlAbl, tfSgVoc, tfPlVoc;
  71.     public JCheckBox chckbxSgNom, chckbxPlNom, chckbxSgGen, chckbxPlGen, chckbxSgDat, chckbxPlDat, chckbxSgAcc, chckbxPlAcc, chckbxSgAbl, chckbxPlAbl, chckbxSgVoc, chckbxPlVoc;
  72.  
  73.     /**
  74.      * Launch the application.
  75.      */
  76.     public static void open() throws Exception {
  77.         EventQueue.invokeLater(new Runnable() {
  78.             @Override
  79.             public void run() {
  80.                 GUINewNoun dialog = new GUINewNoun();
  81.                 dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  82.                 dialog.setVisible(true);
  83.             }
  84.         });
  85.     }
  86.  
  87.     /**
  88.      * Create the dialog.
  89.      */
  90.     public GUINewNoun() {
  91.         setResizable(false);
  92.         setTitle(LanguageHelper.localize("GUINewNounTitle"));
  93.         setBounds(100, 100, 580, 356);
  94.         GridBagLayout gridBagLayout = new GridBagLayout();
  95.         gridBagLayout.columnWidths = new int[]{0, 0};
  96.         gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
  97.         gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
  98.         gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
  99.         getContentPane().setLayout(gridBagLayout);
  100.  
  101.         JPanel panel_data = new JPanel();
  102.         panel_data.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), LanguageHelper.localize("GUINewNounDataBorderTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
  103.         GridBagConstraints gbc_panel_data = new GridBagConstraints();
  104.         gbc_panel_data.insets = new Insets(0, 0, 5, 0);
  105.         gbc_panel_data.fill = GridBagConstraints.BOTH;
  106.         gbc_panel_data.gridx = 0;
  107.         gbc_panel_data.gridy = 0;
  108.         getContentPane().add(panel_data, gbc_panel_data);
  109.         GridBagLayout gbl_panel_data = new GridBagLayout();
  110.         gbl_panel_data.columnWidths = new int[]{0, 0, 0};
  111.         gbl_panel_data.rowHeights = new int[]{0, 0, 0, 0, 0};
  112.         gbl_panel_data.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
  113.         gbl_panel_data.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  114.         panel_data.setLayout(gbl_panel_data);
  115.  
  116.         JLabel lblInputSgNom = new JLabel(LanguageHelper.localize("GUINewNounSingularNominative"));
  117.         GridBagConstraints gbc_lblInputSgNom = new GridBagConstraints();
  118.         gbc_lblInputSgNom.insets = new Insets(0, 0, 5, 5);
  119.         gbc_lblInputSgNom.anchor = GridBagConstraints.EAST;
  120.         gbc_lblInputSgNom.gridx = 0;
  121.         gbc_lblInputSgNom.gridy = 0;
  122.         panel_data.add(lblInputSgNom, gbc_lblInputSgNom);
  123.  
  124.         tfInputSgNom = new JTextField();
  125.         tfInputSgNom.getDocument().addDocumentListener(tfChangeListener);
  126.         GridBagConstraints gbc_tfInputSgNom = new GridBagConstraints();
  127.         gbc_tfInputSgNom.insets = new Insets(0, 0, 5, 0);
  128.         gbc_tfInputSgNom.fill = GridBagConstraints.HORIZONTAL;
  129.         gbc_tfInputSgNom.gridx = 1;
  130.         gbc_tfInputSgNom.gridy = 0;
  131.         panel_data.add(tfInputSgNom, gbc_tfInputSgNom);
  132.         tfInputSgNom.setColumns(10);
  133.  
  134.         JLabel lblInputSgGen = new JLabel(LanguageHelper.localize("GUINewNounSingularGenitive"));
  135.         GridBagConstraints gbc_lblInputSgGen = new GridBagConstraints();
  136.         gbc_lblInputSgGen.anchor = GridBagConstraints.EAST;
  137.         gbc_lblInputSgGen.insets = new Insets(0, 0, 5, 5);
  138.         gbc_lblInputSgGen.gridx = 0;
  139.         gbc_lblInputSgGen.gridy = 1;
  140.         panel_data.add(lblInputSgGen, gbc_lblInputSgGen);
  141.  
  142.         tfInputSgGen = new JTextField();
  143.         tfInputSgGen.getDocument().addDocumentListener(tfChangeListener);
  144.         GridBagConstraints gbc_tfInputSgGen = new GridBagConstraints();
  145.         gbc_tfInputSgGen.insets = new Insets(0, 0, 5, 0);
  146.         gbc_tfInputSgGen.fill = GridBagConstraints.HORIZONTAL;
  147.         gbc_tfInputSgGen.gridx = 1;
  148.         gbc_tfInputSgGen.gridy = 1;
  149.         panel_data.add(tfInputSgGen, gbc_tfInputSgGen);
  150.         tfInputSgGen.setColumns(10);
  151.  
  152.         JLabel lblGender = new JLabel(LanguageHelper.localize("GUINewNounGender"));
  153.         GridBagConstraints gbc_lblGender = new GridBagConstraints();
  154.         gbc_lblGender.anchor = GridBagConstraints.EAST;
  155.         gbc_lblGender.insets = new Insets(0, 0, 5, 5);
  156.         gbc_lblGender.gridx = 0;
  157.         gbc_lblGender.gridy = 2;
  158.         panel_data.add(lblGender, gbc_lblGender);
  159.  
  160.         cbGender = new JComboBox<Gender>();
  161.         cbGender.addItem(Gender.MASCULINE);
  162.         cbGender.addItem(Gender.FEMININE);
  163.         cbGender.addItem(Gender.NEUTER);
  164.         cbGender.setSelectedItem(Gender.MASCULINE);
  165.         cbGender.setMaximumRowCount(3);
  166.         GridBagConstraints gbc_cbGender = new GridBagConstraints();
  167.         gbc_cbGender.insets = new Insets(0, 0, 5, 0);
  168.         gbc_cbGender.fill = GridBagConstraints.BOTH;
  169.         gbc_cbGender.gridx = 1;
  170.         gbc_cbGender.gridy = 2;
  171.         panel_data.add(cbGender, gbc_cbGender);
  172.  
  173.         JLabel lblDeclension = new JLabel(LanguageHelper.localize("GUINewNounDeclension"));
  174.         GridBagConstraints gbc_lblDeclension = new GridBagConstraints();
  175.         gbc_lblDeclension.anchor = GridBagConstraints.EAST;
  176.         gbc_lblDeclension.insets = new Insets(0, 0, 0, 5);
  177.         gbc_lblDeclension.gridx = 0;
  178.         gbc_lblDeclension.gridy = 3;
  179.         panel_data.add(lblDeclension, gbc_lblDeclension);
  180.  
  181.         cbDeclension = new JComboBox<NounDeclension>();
  182.         cbDeclension.addItem(NounDeclension.O_DECLENSION);
  183.         cbDeclension.addItem(NounDeclension.A_DECLENSION);
  184.         cbDeclension.addItem(NounDeclension.CONSONANTICAL_DECLENSION);
  185.         cbDeclension.addItem(NounDeclension.E_DECLENSION);
  186.         cbDeclension.addItem(NounDeclension.I_DECLENSION);
  187.         cbDeclension.addItem(NounDeclension.U_DECLENSION);
  188.         cbDeclension.addItem(NounDeclension.MIXED_DECLENSION);
  189.         cbDeclension.setSelectedItem(NounDeclension.O_DECLENSION);
  190.         GridBagConstraints gbc_cbDeclension = new GridBagConstraints();
  191.         gbc_cbDeclension.fill = GridBagConstraints.HORIZONTAL;
  192.         gbc_cbDeclension.gridx = 1;
  193.         gbc_cbDeclension.gridy = 3;
  194.         panel_data.add(cbDeclension, gbc_cbDeclension);
  195.  
  196.         JPanel panel_forms = new JPanel();
  197.         panel_forms.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), LanguageHelper.localize("GUINewNounFormsBorderTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
  198.         GridBagConstraints gbc_panel_forms = new GridBagConstraints();
  199.         gbc_panel_forms.insets = new Insets(0, 0, 5, 0);
  200.         gbc_panel_forms.fill = GridBagConstraints.BOTH;
  201.         gbc_panel_forms.gridx = 0;
  202.         gbc_panel_forms.gridy = 1;
  203.         getContentPane().add(panel_forms, gbc_panel_forms);
  204.         GridBagLayout gbl_panel_forms = new GridBagLayout();
  205.         gbl_panel_forms.columnWidths = new int[]{0, 0, 0, 0, 0};
  206.         gbl_panel_forms.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
  207.         gbl_panel_forms.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
  208.         gbl_panel_forms.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  209.         panel_forms.setLayout(gbl_panel_forms);
  210.  
  211.         lblSgNom = new JLabel(GUIHelper.unknownForm);
  212.         GridBagConstraints gbc_lblSgNom = new GridBagConstraints();
  213.         gbc_lblSgNom.anchor = GridBagConstraints.WEST;
  214.         gbc_lblSgNom.insets = new Insets(0, 0, 5, 5);
  215.         gbc_lblSgNom.gridx = 1;
  216.         gbc_lblSgNom.gridy = 0;
  217.         panel_forms.add(lblSgNom, gbc_lblSgNom);
  218.  
  219.         tfSgNom = new JTextField();
  220.         GridBagConstraints gbc_tfSgNom = new GridBagConstraints();
  221.         gbc_tfSgNom.fill = GridBagConstraints.HORIZONTAL;
  222.         gbc_tfSgNom.insets = new Insets(0, 0, 5, 5);
  223.         gbc_tfSgNom.gridx = 1;
  224.         gbc_tfSgNom.gridy = 0;
  225.         tfSgNom.setVisible(false);
  226.         panel_forms.add(tfSgNom, gbc_tfSgNom);
  227.  
  228.         chckbxSgNom = new JCheckBox();
  229.         chckbxSgNom.addItemListener(new ItemListener() {
  230.             public void itemStateChanged(ItemEvent e) {
  231.                 LogHelper.debug("Click: " + Integer.toString(e.getStateChange()));
  232.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  233.                     LogHelper.debug("Selected");
  234.                     lblSgNom.setVisible(false);
  235.                     tfSgNom.setVisible(true);
  236.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  237.                     LogHelper.debug("Deselected");
  238.                     tfSgNom.setVisible(false);
  239.                     lblSgNom.setVisible(true);
  240.                 }
  241.             }
  242.         });
  243.         GridBagConstraints gbc_chckbxSgNom = new GridBagConstraints();
  244.         gbc_chckbxSgNom.insets = new Insets(0, 0, 5, 5);
  245.         gbc_chckbxSgNom.gridx = 0;
  246.         gbc_chckbxSgNom.gridy = 0;
  247.         panel_forms.add(chckbxSgNom, gbc_chckbxSgNom);
  248.  
  249.         chckbxPlNom = new JCheckBox();
  250.         chckbxPlNom.addItemListener(new ItemListener() {
  251.             public void itemStateChanged(ItemEvent e) {
  252.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  253.                     lblPlNom.setVisible(false);
  254.                     tfPlNom.setVisible(true);
  255.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  256.                     tfPlNom.setVisible(false);
  257.                     lblPlNom.setVisible(true);
  258.                 }
  259.             }
  260.         });
  261.        
  262.         GridBagConstraints gbc_chckbxPlNom = new GridBagConstraints();
  263.         gbc_chckbxPlNom.insets = new Insets(0, 0, 5, 5);
  264.         gbc_chckbxPlNom.gridx = 2;
  265.         gbc_chckbxPlNom.gridy = 0;
  266.         panel_forms.add(chckbxPlNom, gbc_chckbxPlNom);
  267.  
  268.         lblPlNom = new JLabel(GUIHelper.unknownForm);
  269.         GridBagConstraints gbc_lblPlNom = new GridBagConstraints();
  270.         gbc_lblPlNom.anchor = GridBagConstraints.WEST;
  271.         gbc_lblPlNom.insets = new Insets(0, 0, 5, 0);
  272.         gbc_lblPlNom.gridx = 3;
  273.         gbc_lblPlNom.gridy = 0;
  274.         panel_forms.add(lblPlNom, gbc_lblPlNom);
  275.        
  276.         tfPlNom = new JTextField();
  277.         GridBagConstraints gbc_tfPlNom = new GridBagConstraints();
  278.         gbc_tfPlNom.fill = GridBagConstraints.HORIZONTAL;
  279.         gbc_tfPlNom.insets = new Insets(0, 0, 5, 0);
  280.         gbc_tfPlNom.gridx = 3;
  281.         gbc_tfPlNom.gridy = 0;
  282.         tfPlNom.setVisible(false);
  283.         panel_forms.add(tfPlNom, gbc_tfPlNom);
  284.  
  285.         chckbxSgGen = new JCheckBox();
  286.         chckbxSgGen.addItemListener(new ItemListener() {
  287.             public void itemStateChanged(ItemEvent e) {
  288.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  289.                     lblSgGen.setVisible(false);
  290.                     tfSgGen.setVisible(true);
  291.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  292.                     tfSgGen.setVisible(false);
  293.                     lblSgGen.setVisible(true);
  294.                 }
  295.             }
  296.         });
  297.         GridBagConstraints gbc_chckbxSgGen = new GridBagConstraints();
  298.         gbc_chckbxSgGen.insets = new Insets(0, 0, 5, 5);
  299.         gbc_chckbxSgGen.gridx = 0;
  300.         gbc_chckbxSgGen.gridy = 1;
  301.         panel_forms.add(chckbxSgGen, gbc_chckbxSgGen);
  302.  
  303.         lblSgGen = new JLabel(GUIHelper.unknownForm);
  304.         GridBagConstraints gbc_lblSgGen = new GridBagConstraints();
  305.         gbc_lblSgGen.anchor = GridBagConstraints.WEST;
  306.         gbc_lblSgGen.insets = new Insets(0, 0, 5, 5);
  307.         gbc_lblSgGen.gridx = 1;
  308.         gbc_lblSgGen.gridy = 1;
  309.         panel_forms.add(lblSgGen, gbc_lblSgGen);
  310.        
  311.         tfSgGen = new JTextField();
  312.         GridBagConstraints gbc_tfSgGen = new GridBagConstraints();
  313.         gbc_tfSgGen.fill = GridBagConstraints.HORIZONTAL;
  314.         gbc_tfSgGen.insets = new Insets(0, 0, 5, 5);
  315.         gbc_tfSgGen.gridx = 1;
  316.         gbc_tfSgGen.gridy = 1;
  317.         tfSgGen.setVisible(false);
  318.         panel_forms.add(tfSgGen, gbc_tfSgGen);
  319.  
  320.         chckbxPlGen = new JCheckBox();
  321.         chckbxPlGen.addItemListener(new ItemListener() {
  322.             public void itemStateChanged(ItemEvent e) {
  323.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  324.                     lblPlGen.setVisible(false);
  325.                     tfPlGen.setVisible(true);
  326.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  327.                     tfPlGen.setVisible(false);
  328.                     lblPlGen.setVisible(true);
  329.                 }
  330.             }
  331.         });
  332.         GridBagConstraints gbc_chckbxPlGen = new GridBagConstraints();
  333.         gbc_chckbxPlGen.insets = new Insets(0, 0, 5, 5);
  334.         gbc_chckbxPlGen.gridx = 2;
  335.         gbc_chckbxPlGen.gridy = 1;
  336.         panel_forms.add(chckbxPlGen, gbc_chckbxPlGen);
  337.  
  338.         lblPlGen = new JLabel(GUIHelper.unknownForm);
  339.         GridBagConstraints gbc_lblPlGen = new GridBagConstraints();
  340.         gbc_lblPlGen.anchor = GridBagConstraints.WEST;
  341.         gbc_lblPlGen.insets = new Insets(0, 0, 5, 0);
  342.         gbc_lblPlGen.gridx = 3;
  343.         gbc_lblPlGen.gridy = 1;
  344.         panel_forms.add(lblPlGen, gbc_lblPlGen);
  345.        
  346.         tfPlGen = new JTextField();
  347.         GridBagConstraints gbc_tfPlGen = new GridBagConstraints();
  348.         gbc_tfPlGen.fill = GridBagConstraints.HORIZONTAL;
  349.         gbc_tfPlGen.insets = new Insets(0, 0, 5, 0);
  350.         gbc_tfPlGen.gridx = 3;
  351.         gbc_tfPlGen.gridy = 1;
  352.         tfPlGen.setVisible(false);
  353.         panel_forms.add(tfPlGen, gbc_tfPlGen);
  354.  
  355.         chckbxSgDat = new JCheckBox();
  356.         chckbxSgDat.addItemListener(new ItemListener() {
  357.             public void itemStateChanged(ItemEvent e) {
  358.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  359.                     lblSgDat.setVisible(false);
  360.                     tfSgDat.setVisible(true);
  361.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  362.                     tfSgDat.setVisible(false);
  363.                     lblSgDat.setVisible(true);
  364.                 }
  365.             }
  366.         });
  367.         GridBagConstraints gbc_chckbxSgDat = new GridBagConstraints();
  368.         gbc_chckbxSgDat.insets = new Insets(0, 0, 5, 5);
  369.         gbc_chckbxSgDat.gridx = 0;
  370.         gbc_chckbxSgDat.gridy = 2;
  371.         panel_forms.add(chckbxSgDat, gbc_chckbxSgDat);
  372.  
  373.         lblSgDat = new JLabel(GUIHelper.unknownForm);
  374.         GridBagConstraints gbc_lblSgDat = new GridBagConstraints();
  375.         gbc_lblSgDat.anchor = GridBagConstraints.WEST;
  376.         gbc_lblSgDat.insets = new Insets(0, 0, 5, 5);
  377.         gbc_lblSgDat.gridx = 1;
  378.         gbc_lblSgDat.gridy = 2;
  379.         panel_forms.add(lblSgDat, gbc_lblSgDat);
  380.        
  381.         tfSgDat = new JTextField();
  382.         GridBagConstraints gbc_tfSgDat = new GridBagConstraints();
  383.         gbc_tfSgDat.fill = GridBagConstraints.HORIZONTAL;
  384.         gbc_tfSgDat.insets = new Insets(0, 0, 5, 5);
  385.         gbc_tfSgDat.gridx = 1;
  386.         gbc_tfSgDat.gridy = 2;
  387.         tfSgDat.setVisible(false);
  388.         panel_forms.add(tfSgDat, gbc_tfSgDat);
  389.  
  390.         chckbxPlDat = new JCheckBox();
  391.         chckbxPlDat.addItemListener(new ItemListener() {
  392.             public void itemStateChanged(ItemEvent e) {
  393.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  394.                     lblPlDat.setVisible(false);
  395.                     tfPlDat.setVisible(true);
  396.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  397.                     tfPlDat.setVisible(false);
  398.                     lblPlDat.setVisible(true);
  399.                 }
  400.             }
  401.         });
  402.         GridBagConstraints gbc_chckbxPlDat = new GridBagConstraints();
  403.         gbc_chckbxPlDat.insets = new Insets(0, 0, 5, 5);
  404.         gbc_chckbxPlDat.gridx = 2;
  405.         gbc_chckbxPlDat.gridy = 2;
  406.         panel_forms.add(chckbxPlDat, gbc_chckbxPlDat);
  407.  
  408.         lblPlDat = new JLabel(GUIHelper.unknownForm);
  409.         GridBagConstraints gbc_lblPlDat = new GridBagConstraints();
  410.         gbc_lblPlDat.anchor = GridBagConstraints.WEST;
  411.         gbc_lblPlDat.insets = new Insets(0, 0, 5, 0);
  412.         gbc_lblPlDat.gridx = 3;
  413.         gbc_lblPlDat.gridy = 2;
  414.         panel_forms.add(lblPlDat, gbc_lblPlDat);
  415.        
  416.         tfPlDat = new JTextField();
  417.         GridBagConstraints gbc_tfPlDat = new GridBagConstraints();
  418.         gbc_tfPlDat.fill = GridBagConstraints.HORIZONTAL;
  419.         gbc_tfPlDat.insets = new Insets(0, 0, 5, 0);
  420.         gbc_tfPlDat.gridx = 3;
  421.         gbc_tfPlDat.gridy = 2;
  422.         tfPlDat.setVisible(false);
  423.         panel_forms.add(tfPlDat, gbc_tfPlDat);
  424.  
  425.         chckbxSgAcc = new JCheckBox();
  426.         chckbxSgAcc.addItemListener(new ItemListener() {
  427.             public void itemStateChanged(ItemEvent e) {
  428.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  429.                     lblSgAcc.setVisible(false);
  430.                     tfSgAcc.setVisible(true);
  431.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  432.                     tfSgAcc.setVisible(false);
  433.                     lblSgAcc.setVisible(true);
  434.                 }
  435.             }
  436.         });
  437.         GridBagConstraints gbc_chckbxSgAcc = new GridBagConstraints();
  438.         gbc_chckbxSgAcc.insets = new Insets(0, 0, 5, 5);
  439.         gbc_chckbxSgAcc.gridx = 0;
  440.         gbc_chckbxSgAcc.gridy = 3;
  441.         panel_forms.add(chckbxSgAcc, gbc_chckbxSgAcc);
  442.  
  443.         lblSgAcc = new JLabel(GUIHelper.unknownForm);
  444.         GridBagConstraints gbc_lblSgAcc = new GridBagConstraints();
  445.         gbc_lblSgAcc.anchor = GridBagConstraints.WEST;
  446.         gbc_lblSgAcc.insets = new Insets(0, 0, 5, 5);
  447.         gbc_lblSgAcc.gridx = 1;
  448.         gbc_lblSgAcc.gridy = 3;
  449.         panel_forms.add(lblSgAcc, gbc_lblSgAcc);
  450.        
  451.         tfSgAcc = new JTextField();
  452.         GridBagConstraints gbc_tfSgAcc = new GridBagConstraints();
  453.         gbc_tfSgAcc.fill = GridBagConstraints.HORIZONTAL;
  454.         gbc_tfSgAcc.insets = new Insets(0, 0, 5, 5);
  455.         gbc_tfSgAcc.gridx = 1;
  456.         gbc_tfSgAcc.gridy = 3;
  457.         tfSgAcc.setVisible(false);
  458.         panel_forms.add(tfSgAcc, gbc_tfSgAcc);
  459.  
  460.         chckbxPlAcc = new JCheckBox();
  461.         chckbxPlAcc.addItemListener(new ItemListener() {
  462.             public void itemStateChanged(ItemEvent e) {
  463.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  464.                     lblPlAcc.setVisible(false);
  465.                     tfPlAcc.setVisible(true);
  466.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  467.                     tfPlAcc.setVisible(false);
  468.                     lblPlAcc.setVisible(true);
  469.                 }
  470.             }
  471.         });
  472.         GridBagConstraints gbc_chckbxPlAcc = new GridBagConstraints();
  473.         gbc_chckbxPlAcc.insets = new Insets(0, 0, 5, 5);
  474.         gbc_chckbxPlAcc.gridx = 2;
  475.         gbc_chckbxPlAcc.gridy = 3;
  476.         panel_forms.add(chckbxPlAcc, gbc_chckbxPlAcc);
  477.  
  478.         lblPlAcc = new JLabel(GUIHelper.unknownForm);
  479.         GridBagConstraints gbc_lblPlAcc = new GridBagConstraints();
  480.         gbc_lblPlAcc.anchor = GridBagConstraints.WEST;
  481.         gbc_lblPlAcc.insets = new Insets(0, 0, 5, 0);
  482.         gbc_lblPlAcc.gridx = 3;
  483.         gbc_lblPlAcc.gridy = 3;
  484.         panel_forms.add(lblPlAcc, gbc_lblPlAcc);
  485.        
  486.         tfPlAcc = new JTextField();
  487.         GridBagConstraints gbc_tfPlAcc = new GridBagConstraints();
  488.         gbc_tfPlAcc.fill = GridBagConstraints.HORIZONTAL;
  489.         gbc_tfPlAcc.insets = new Insets(0, 0, 5, 0);
  490.         gbc_tfPlAcc.gridx = 3;
  491.         gbc_tfPlAcc.gridy = 3;
  492.         tfPlAcc.setVisible(false);
  493.         panel_forms.add(tfPlAcc, gbc_tfPlAcc);
  494.  
  495.         chckbxSgAbl = new JCheckBox();
  496.         chckbxSgAbl.addItemListener(new ItemListener() {
  497.             public void itemStateChanged(ItemEvent e) {
  498.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  499.                     lblSgAbl.setVisible(false);
  500.                     tfSgAbl.setVisible(true);
  501.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  502.                     tfSgAbl.setVisible(false);
  503.                     lblSgAbl.setVisible(true);
  504.                 }
  505.             }
  506.         });
  507.         GridBagConstraints gbc_chckbxSgAbl = new GridBagConstraints();
  508.         gbc_chckbxSgAbl.insets = new Insets(0, 0, 5, 5);
  509.         gbc_chckbxSgAbl.gridx = 0;
  510.         gbc_chckbxSgAbl.gridy = 4;
  511.         panel_forms.add(chckbxSgAbl, gbc_chckbxSgAbl);
  512.  
  513.         lblSgAbl = new JLabel(GUIHelper.unknownForm);
  514.         GridBagConstraints gbc_lblSgAbl = new GridBagConstraints();
  515.         gbc_lblSgAbl.anchor = GridBagConstraints.WEST;
  516.         gbc_lblSgAbl.insets = new Insets(0, 0, 5, 5);
  517.         gbc_lblSgAbl.gridx = 1;
  518.         gbc_lblSgAbl.gridy = 4;
  519.         panel_forms.add(lblSgAbl, gbc_lblSgAbl);
  520.        
  521.         tfSgAbl = new JTextField();
  522.         GridBagConstraints gbc_tfSgAbl = new GridBagConstraints();
  523.         gbc_tfSgAbl.fill = GridBagConstraints.HORIZONTAL;
  524.         gbc_tfSgAbl.insets = new Insets(0, 0, 5, 5);
  525.         gbc_tfSgAbl.gridx = 1;
  526.         gbc_tfSgAbl.gridy = 4;
  527.         tfSgAbl.setVisible(false);
  528.         panel_forms.add(tfSgAbl, gbc_tfSgAbl);
  529.  
  530.         chckbxPlAbl = new JCheckBox();
  531.         chckbxPlAbl.addItemListener(new ItemListener() {
  532.             public void itemStateChanged(ItemEvent e) {
  533.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  534.                     lblPlAbl.setVisible(false);
  535.                     tfPlAbl.setVisible(true);
  536.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  537.                     tfPlAbl.setVisible(false);
  538.                     lblPlAbl.setVisible(true);
  539.                 }
  540.             }
  541.         });
  542.         GridBagConstraints gbc_chckbxPlAbl = new GridBagConstraints();
  543.         gbc_chckbxPlAbl.insets = new Insets(0, 0, 5, 5);
  544.         gbc_chckbxPlAbl.gridx = 2;
  545.         gbc_chckbxPlAbl.gridy = 4;
  546.         panel_forms.add(chckbxPlAbl, gbc_chckbxPlAbl);
  547.  
  548.         lblPlAbl = new JLabel(GUIHelper.unknownForm);
  549.         GridBagConstraints gbc_lblPlAbl = new GridBagConstraints();
  550.         gbc_lblPlAbl.anchor = GridBagConstraints.WEST;
  551.         gbc_lblPlAbl.insets = new Insets(0, 0, 5, 0);
  552.         gbc_lblPlAbl.gridx = 3;
  553.         gbc_lblPlAbl.gridy = 4;
  554.         panel_forms.add(lblPlAbl, gbc_lblPlAbl);
  555.        
  556.         tfPlAbl = new JTextField();
  557.         GridBagConstraints gbc_tfPlAbl = new GridBagConstraints();
  558.         gbc_tfPlAbl.fill = GridBagConstraints.HORIZONTAL;
  559.         gbc_tfPlAbl.insets = new Insets(0, 0, 5, 0);
  560.         gbc_tfPlAbl.gridx = 3;
  561.         gbc_tfPlAbl.gridy = 4;
  562.         tfPlAbl.setVisible(false);
  563.         panel_forms.add(tfPlAbl, gbc_tfPlAbl);
  564.  
  565.         chckbxSgVoc = new JCheckBox();
  566.         chckbxSgVoc.addItemListener(new ItemListener() {
  567.             public void itemStateChanged(ItemEvent e) {
  568.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  569.                     lblSgVoc.setVisible(false);
  570.                     tfSgVoc.setVisible(true);
  571.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  572.                     tfSgVoc.setVisible(false);
  573.                     lblSgVoc.setVisible(true);
  574.                 }
  575.             }
  576.         });
  577.         GridBagConstraints gbc_chckbxSgVoc = new GridBagConstraints();
  578.         gbc_chckbxSgVoc.insets = new Insets(0, 0, 0, 5);
  579.         gbc_chckbxSgVoc.gridx = 0;
  580.         gbc_chckbxSgVoc.gridy = 5;
  581.         panel_forms.add(chckbxSgVoc, gbc_chckbxSgVoc);
  582.  
  583.         lblSgVoc = new JLabel(GUIHelper.unknownForm);
  584.         GridBagConstraints gbc_lblSgVoc = new GridBagConstraints();
  585.         gbc_lblSgVoc.anchor = GridBagConstraints.WEST;
  586.         gbc_lblSgVoc.insets = new Insets(0, 0, 0, 5);
  587.         gbc_lblSgVoc.gridx = 1;
  588.         gbc_lblSgVoc.gridy = 5;
  589.         panel_forms.add(lblSgVoc, gbc_lblSgVoc);
  590.        
  591.         tfSgVoc = new JTextField();
  592.         GridBagConstraints gbc_tfSgVoc = new GridBagConstraints();
  593.         gbc_tfSgVoc.fill = GridBagConstraints.HORIZONTAL;
  594.         gbc_tfSgVoc.insets = new Insets(0, 0, 0, 5);
  595.         gbc_tfSgVoc.gridx = 1;
  596.         gbc_tfSgVoc.gridy = 5;
  597.         tfSgVoc.setVisible(false);
  598.         panel_forms.add(tfSgVoc, gbc_tfSgVoc);
  599.  
  600.         chckbxPlVoc = new JCheckBox();
  601.         chckbxPlVoc.addItemListener(new ItemListener() {
  602.             public void itemStateChanged(ItemEvent e) {
  603.                 if (e.getStateChange() == ItemEvent.SELECTED) {
  604.                     lblPlVoc.setVisible(false);
  605.                     tfPlVoc.setVisible(true);
  606.                 } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  607.                     tfPlVoc.setVisible(false);
  608.                     lblPlVoc.setVisible(true);
  609.                 }
  610.             }
  611.         });
  612.         GridBagConstraints gbc_chckbxPlVoc = new GridBagConstraints();
  613.         gbc_chckbxPlVoc.insets = new Insets(0, 0, 0, 5);
  614.         gbc_chckbxPlVoc.gridx = 2;
  615.         gbc_chckbxPlVoc.gridy = 5;
  616.         panel_forms.add(chckbxPlVoc, gbc_chckbxPlVoc);
  617.  
  618.         lblPlVoc = new JLabel(GUIHelper.unknownForm);
  619.         GridBagConstraints gbc_lblPlVoc = new GridBagConstraints();
  620.         gbc_lblPlVoc.anchor = GridBagConstraints.WEST;
  621.         gbc_lblPlVoc.gridx = 3;
  622.         gbc_lblPlVoc.gridy = 5;
  623.         panel_forms.add(lblPlVoc, gbc_lblPlVoc);
  624.        
  625.         tfPlVoc = new JTextField();
  626.         GridBagConstraints gbc_tfPlVoc = new GridBagConstraints();
  627.         gbc_tfPlVoc.fill = GridBagConstraints.HORIZONTAL;
  628.         gbc_tfPlVoc.gridx = 3;
  629.         gbc_tfPlVoc.gridy = 5;
  630.         tfPlVoc.setVisible(false);
  631.         panel_forms.add(tfPlVoc, gbc_tfPlVoc);
  632.  
  633.         JPanel panel_buttons = new JPanel();
  634.         GridBagConstraints gbc_panel_buttons = new GridBagConstraints();
  635.         gbc_panel_buttons.fill = GridBagConstraints.BOTH;
  636.         gbc_panel_buttons.gridx = 0;
  637.         gbc_panel_buttons.gridy = 2;
  638.         getContentPane().add(panel_buttons, gbc_panel_buttons);
  639.         GridBagLayout gbl_panel_buttons = new GridBagLayout();
  640.         gbl_panel_buttons.columnWidths = new int[]{0, 0, 0};
  641.         gbl_panel_buttons.rowHeights = new int[]{0, 0};
  642.         gbl_panel_buttons.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
  643.         gbl_panel_buttons.rowWeights = new double[]{1.0, Double.MIN_VALUE};
  644.         panel_buttons.setLayout(gbl_panel_buttons);
  645.  
  646.         JButton btnSaveExit = new JButton(LanguageHelper.localize("GUINewNounButtonSaveExit"));
  647.         btnSaveExit.addActionListener(new ActionListener() {
  648.             public void actionPerformed(ActionEvent e) {
  649.                 instance().dispose();
  650.             }
  651.         });
  652.         GridBagConstraints gbc_btnSaveExit = new GridBagConstraints();
  653.         gbc_btnSaveExit.fill = GridBagConstraints.HORIZONTAL;
  654.         gbc_btnSaveExit.insets = new Insets(0, 0, 0, 5);
  655.         gbc_btnSaveExit.gridx = 0;
  656.         gbc_btnSaveExit.gridy = 0;
  657.         panel_buttons.add(btnSaveExit, gbc_btnSaveExit);
  658.  
  659.         JButton btnCancel = new JButton(LanguageHelper.localize("GUINewNounButtonCancel"));
  660.         btnCancel.addActionListener(new ActionListener() {
  661.             public void actionPerformed(ActionEvent e) {
  662.                 instance().dispose();
  663.             }
  664.         });
  665.         GridBagConstraints gbc_btnCancel = new GridBagConstraints();
  666.         gbc_btnCancel.fill = GridBagConstraints.HORIZONTAL;
  667.         gbc_btnCancel.gridx = 1;
  668.         gbc_btnCancel.gridy = 0;
  669.         panel_buttons.add(btnCancel, gbc_btnCancel);
  670.  
  671.     }
  672.  
  673.     public JDialog instance() {
  674.         return this;
  675.     }
  676.  
  677.     public void refresh() {
  678.         LogHelper.debug("Refresh fired!");
  679.         try {
  680.             String nomsg = tfInputSgNom.getText();
  681.             String gensg = tfInputSgGen.getText();
  682.             NounDeclension dec = (NounDeclension) cbDeclension.getSelectedItem();
  683.             Gender g = (Gender) cbGender.getSelectedItem();
  684.  
  685.  
  686.             Map<NounFormDescriptor, String> map = NounFormHelper.generateForms(nomsg, gensg, dec, g);
  687. //          map = NounFormHelper.protectNulls(map);
  688.  
  689.             lblSgNom.setText(map.get(NounFormDescriptor.nomsg));
  690.             lblPlNom.setText(map.get(NounFormDescriptor.nompl));
  691.             lblSgGen.setText(map.get(NounFormDescriptor.gensg));
  692.             lblPlGen.setText(map.get(NounFormDescriptor.genpl));
  693.             lblSgDat.setText(map.get(NounFormDescriptor.datsg));
  694.             lblPlDat.setText(map.get(NounFormDescriptor.datpl));
  695.             lblSgAcc.setText(map.get(NounFormDescriptor.accsg));
  696.             lblPlAcc.setText(map.get(NounFormDescriptor.accpl));
  697.             lblSgAbl.setText(map.get(NounFormDescriptor.ablsg));
  698.             lblPlAbl.setText(map.get(NounFormDescriptor.ablpl));
  699.             lblSgVoc.setText(map.get(NounFormDescriptor.vocsg));
  700.             lblPlVoc.setText(map.get(NounFormDescriptor.vocpl));
  701.         } catch (Exception e) {
  702.             e.printStackTrace();
  703.         }
  704.     }
  705. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement