Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cf.randers.nev.gui;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.EventQueue;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.util.Map;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JDialog;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import javax.swing.UIManager;
- import javax.swing.WindowConstants;
- import javax.swing.border.TitledBorder;
- import javax.swing.event.DocumentEvent;
- import javax.swing.event.DocumentListener;
- import cf.randers.nev.helper.GUIHelper;
- import cf.randers.nev.helper.LogHelper;
- import cf.randers.nev.language.LanguageHelper;
- import cf.randers.nev.vocab.attribute.Gender;
- import cf.randers.nev.vocab.attribute.NounDeclension;
- import cf.randers.nev.vocab.descriptor.NounFormDescriptor;
- import cf.randers.nev.vocab.helper.NounFormHelper;
- import javax.swing.JSeparator;
- import javax.swing.SwingConstants;
- import java.awt.Rectangle;
- public class GUINewNoun extends JDialog {
- private static final long serialVersionUID = -6435915629645877560L;
- public final DocumentListener tfChangeListener = new DocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- refresh();
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- refresh();
- }
- @Override
- public void changedUpdate(DocumentEvent e) {
- refresh();
- }
- };
- public Gender gender = Gender.MASCULINE;
- public NounDeclension declension = NounDeclension.O_DECLENSION;
- public JTextField tfInputSgNom, tfInputSgGen;
- public JComboBox<Gender> cbGender;
- public JComboBox<NounDeclension> cbDeclension;
- public JLabel lblSgNom, lblPlNom, lblSgGen, lblPlGen, lblSgDat, lblPlDat, lblSgAcc, lblPlAcc, lblSgAbl, lblPlAbl, lblSgVoc, lblPlVoc;
- public JTextField tfSgNom, tfPlNom, tfSgGen, tfPlGen, tfSgDat, tfPlDat, tfSgAcc, tfPlAcc, tfSgAbl, tfPlAbl, tfSgVoc, tfPlVoc;
- public JCheckBox chckbxSgNom, chckbxPlNom, chckbxSgGen, chckbxPlGen, chckbxSgDat, chckbxPlDat, chckbxSgAcc, chckbxPlAcc, chckbxSgAbl, chckbxPlAbl, chckbxSgVoc, chckbxPlVoc;
- /**
- * Launch the application.
- */
- public static void open() throws Exception {
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- GUINewNoun dialog = new GUINewNoun();
- dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- }
- });
- }
- /**
- * Create the dialog.
- */
- public GUINewNoun() {
- setResizable(false);
- setTitle(LanguageHelper.localize("GUINewNounTitle"));
- setBounds(100, 100, 580, 356);
- GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[]{0, 0};
- gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
- gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
- gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
- getContentPane().setLayout(gridBagLayout);
- JPanel panel_data = new JPanel();
- panel_data.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), LanguageHelper.localize("GUINewNounDataBorderTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
- GridBagConstraints gbc_panel_data = new GridBagConstraints();
- gbc_panel_data.insets = new Insets(0, 0, 5, 0);
- gbc_panel_data.fill = GridBagConstraints.BOTH;
- gbc_panel_data.gridx = 0;
- gbc_panel_data.gridy = 0;
- getContentPane().add(panel_data, gbc_panel_data);
- GridBagLayout gbl_panel_data = new GridBagLayout();
- gbl_panel_data.columnWidths = new int[]{0, 0, 0};
- gbl_panel_data.rowHeights = new int[]{0, 0, 0, 0, 0};
- gbl_panel_data.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
- gbl_panel_data.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
- panel_data.setLayout(gbl_panel_data);
- JLabel lblInputSgNom = new JLabel(LanguageHelper.localize("GUINewNounSingularNominative"));
- GridBagConstraints gbc_lblInputSgNom = new GridBagConstraints();
- gbc_lblInputSgNom.insets = new Insets(0, 0, 5, 5);
- gbc_lblInputSgNom.anchor = GridBagConstraints.EAST;
- gbc_lblInputSgNom.gridx = 0;
- gbc_lblInputSgNom.gridy = 0;
- panel_data.add(lblInputSgNom, gbc_lblInputSgNom);
- tfInputSgNom = new JTextField();
- tfInputSgNom.getDocument().addDocumentListener(tfChangeListener);
- GridBagConstraints gbc_tfInputSgNom = new GridBagConstraints();
- gbc_tfInputSgNom.insets = new Insets(0, 0, 5, 0);
- gbc_tfInputSgNom.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfInputSgNom.gridx = 1;
- gbc_tfInputSgNom.gridy = 0;
- panel_data.add(tfInputSgNom, gbc_tfInputSgNom);
- tfInputSgNom.setColumns(10);
- JLabel lblInputSgGen = new JLabel(LanguageHelper.localize("GUINewNounSingularGenitive"));
- GridBagConstraints gbc_lblInputSgGen = new GridBagConstraints();
- gbc_lblInputSgGen.anchor = GridBagConstraints.EAST;
- gbc_lblInputSgGen.insets = new Insets(0, 0, 5, 5);
- gbc_lblInputSgGen.gridx = 0;
- gbc_lblInputSgGen.gridy = 1;
- panel_data.add(lblInputSgGen, gbc_lblInputSgGen);
- tfInputSgGen = new JTextField();
- tfInputSgGen.getDocument().addDocumentListener(tfChangeListener);
- GridBagConstraints gbc_tfInputSgGen = new GridBagConstraints();
- gbc_tfInputSgGen.insets = new Insets(0, 0, 5, 0);
- gbc_tfInputSgGen.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfInputSgGen.gridx = 1;
- gbc_tfInputSgGen.gridy = 1;
- panel_data.add(tfInputSgGen, gbc_tfInputSgGen);
- tfInputSgGen.setColumns(10);
- JLabel lblGender = new JLabel(LanguageHelper.localize("GUINewNounGender"));
- GridBagConstraints gbc_lblGender = new GridBagConstraints();
- gbc_lblGender.anchor = GridBagConstraints.EAST;
- gbc_lblGender.insets = new Insets(0, 0, 5, 5);
- gbc_lblGender.gridx = 0;
- gbc_lblGender.gridy = 2;
- panel_data.add(lblGender, gbc_lblGender);
- cbGender = new JComboBox<Gender>();
- cbGender.addItem(Gender.MASCULINE);
- cbGender.addItem(Gender.FEMININE);
- cbGender.addItem(Gender.NEUTER);
- cbGender.setSelectedItem(Gender.MASCULINE);
- cbGender.setMaximumRowCount(3);
- GridBagConstraints gbc_cbGender = new GridBagConstraints();
- gbc_cbGender.insets = new Insets(0, 0, 5, 0);
- gbc_cbGender.fill = GridBagConstraints.BOTH;
- gbc_cbGender.gridx = 1;
- gbc_cbGender.gridy = 2;
- panel_data.add(cbGender, gbc_cbGender);
- JLabel lblDeclension = new JLabel(LanguageHelper.localize("GUINewNounDeclension"));
- GridBagConstraints gbc_lblDeclension = new GridBagConstraints();
- gbc_lblDeclension.anchor = GridBagConstraints.EAST;
- gbc_lblDeclension.insets = new Insets(0, 0, 0, 5);
- gbc_lblDeclension.gridx = 0;
- gbc_lblDeclension.gridy = 3;
- panel_data.add(lblDeclension, gbc_lblDeclension);
- cbDeclension = new JComboBox<NounDeclension>();
- cbDeclension.addItem(NounDeclension.O_DECLENSION);
- cbDeclension.addItem(NounDeclension.A_DECLENSION);
- cbDeclension.addItem(NounDeclension.CONSONANTICAL_DECLENSION);
- cbDeclension.addItem(NounDeclension.E_DECLENSION);
- cbDeclension.addItem(NounDeclension.I_DECLENSION);
- cbDeclension.addItem(NounDeclension.U_DECLENSION);
- cbDeclension.addItem(NounDeclension.MIXED_DECLENSION);
- cbDeclension.setSelectedItem(NounDeclension.O_DECLENSION);
- GridBagConstraints gbc_cbDeclension = new GridBagConstraints();
- gbc_cbDeclension.fill = GridBagConstraints.HORIZONTAL;
- gbc_cbDeclension.gridx = 1;
- gbc_cbDeclension.gridy = 3;
- panel_data.add(cbDeclension, gbc_cbDeclension);
- JPanel panel_forms = new JPanel();
- panel_forms.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), LanguageHelper.localize("GUINewNounFormsBorderTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
- GridBagConstraints gbc_panel_forms = new GridBagConstraints();
- gbc_panel_forms.insets = new Insets(0, 0, 5, 0);
- gbc_panel_forms.fill = GridBagConstraints.BOTH;
- gbc_panel_forms.gridx = 0;
- gbc_panel_forms.gridy = 1;
- getContentPane().add(panel_forms, gbc_panel_forms);
- GridBagLayout gbl_panel_forms = new GridBagLayout();
- gbl_panel_forms.columnWidths = new int[]{0, 0, 0, 0, 0};
- gbl_panel_forms.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
- gbl_panel_forms.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
- gbl_panel_forms.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
- panel_forms.setLayout(gbl_panel_forms);
- lblSgNom = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgNom = new GridBagConstraints();
- gbc_lblSgNom.anchor = GridBagConstraints.WEST;
- gbc_lblSgNom.insets = new Insets(0, 0, 5, 5);
- gbc_lblSgNom.gridx = 1;
- gbc_lblSgNom.gridy = 0;
- panel_forms.add(lblSgNom, gbc_lblSgNom);
- tfSgNom = new JTextField();
- GridBagConstraints gbc_tfSgNom = new GridBagConstraints();
- gbc_tfSgNom.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgNom.insets = new Insets(0, 0, 5, 5);
- gbc_tfSgNom.gridx = 1;
- gbc_tfSgNom.gridy = 0;
- tfSgNom.setVisible(false);
- panel_forms.add(tfSgNom, gbc_tfSgNom);
- chckbxSgNom = new JCheckBox();
- chckbxSgNom.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- LogHelper.debug("Click: " + Integer.toString(e.getStateChange()));
- if (e.getStateChange() == ItemEvent.SELECTED) {
- LogHelper.debug("Selected");
- lblSgNom.setVisible(false);
- tfSgNom.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- LogHelper.debug("Deselected");
- tfSgNom.setVisible(false);
- lblSgNom.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgNom = new GridBagConstraints();
- gbc_chckbxSgNom.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxSgNom.gridx = 0;
- gbc_chckbxSgNom.gridy = 0;
- panel_forms.add(chckbxSgNom, gbc_chckbxSgNom);
- chckbxPlNom = new JCheckBox();
- chckbxPlNom.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlNom.setVisible(false);
- tfPlNom.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlNom.setVisible(false);
- lblPlNom.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlNom = new GridBagConstraints();
- gbc_chckbxPlNom.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxPlNom.gridx = 2;
- gbc_chckbxPlNom.gridy = 0;
- panel_forms.add(chckbxPlNom, gbc_chckbxPlNom);
- lblPlNom = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlNom = new GridBagConstraints();
- gbc_lblPlNom.anchor = GridBagConstraints.WEST;
- gbc_lblPlNom.insets = new Insets(0, 0, 5, 0);
- gbc_lblPlNom.gridx = 3;
- gbc_lblPlNom.gridy = 0;
- panel_forms.add(lblPlNom, gbc_lblPlNom);
- tfPlNom = new JTextField();
- GridBagConstraints gbc_tfPlNom = new GridBagConstraints();
- gbc_tfPlNom.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlNom.insets = new Insets(0, 0, 5, 0);
- gbc_tfPlNom.gridx = 3;
- gbc_tfPlNom.gridy = 0;
- tfPlNom.setVisible(false);
- panel_forms.add(tfPlNom, gbc_tfPlNom);
- chckbxSgGen = new JCheckBox();
- chckbxSgGen.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblSgGen.setVisible(false);
- tfSgGen.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfSgGen.setVisible(false);
- lblSgGen.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgGen = new GridBagConstraints();
- gbc_chckbxSgGen.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxSgGen.gridx = 0;
- gbc_chckbxSgGen.gridy = 1;
- panel_forms.add(chckbxSgGen, gbc_chckbxSgGen);
- lblSgGen = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgGen = new GridBagConstraints();
- gbc_lblSgGen.anchor = GridBagConstraints.WEST;
- gbc_lblSgGen.insets = new Insets(0, 0, 5, 5);
- gbc_lblSgGen.gridx = 1;
- gbc_lblSgGen.gridy = 1;
- panel_forms.add(lblSgGen, gbc_lblSgGen);
- tfSgGen = new JTextField();
- GridBagConstraints gbc_tfSgGen = new GridBagConstraints();
- gbc_tfSgGen.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgGen.insets = new Insets(0, 0, 5, 5);
- gbc_tfSgGen.gridx = 1;
- gbc_tfSgGen.gridy = 1;
- tfSgGen.setVisible(false);
- panel_forms.add(tfSgGen, gbc_tfSgGen);
- chckbxPlGen = new JCheckBox();
- chckbxPlGen.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlGen.setVisible(false);
- tfPlGen.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlGen.setVisible(false);
- lblPlGen.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlGen = new GridBagConstraints();
- gbc_chckbxPlGen.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxPlGen.gridx = 2;
- gbc_chckbxPlGen.gridy = 1;
- panel_forms.add(chckbxPlGen, gbc_chckbxPlGen);
- lblPlGen = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlGen = new GridBagConstraints();
- gbc_lblPlGen.anchor = GridBagConstraints.WEST;
- gbc_lblPlGen.insets = new Insets(0, 0, 5, 0);
- gbc_lblPlGen.gridx = 3;
- gbc_lblPlGen.gridy = 1;
- panel_forms.add(lblPlGen, gbc_lblPlGen);
- tfPlGen = new JTextField();
- GridBagConstraints gbc_tfPlGen = new GridBagConstraints();
- gbc_tfPlGen.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlGen.insets = new Insets(0, 0, 5, 0);
- gbc_tfPlGen.gridx = 3;
- gbc_tfPlGen.gridy = 1;
- tfPlGen.setVisible(false);
- panel_forms.add(tfPlGen, gbc_tfPlGen);
- chckbxSgDat = new JCheckBox();
- chckbxSgDat.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblSgDat.setVisible(false);
- tfSgDat.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfSgDat.setVisible(false);
- lblSgDat.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgDat = new GridBagConstraints();
- gbc_chckbxSgDat.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxSgDat.gridx = 0;
- gbc_chckbxSgDat.gridy = 2;
- panel_forms.add(chckbxSgDat, gbc_chckbxSgDat);
- lblSgDat = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgDat = new GridBagConstraints();
- gbc_lblSgDat.anchor = GridBagConstraints.WEST;
- gbc_lblSgDat.insets = new Insets(0, 0, 5, 5);
- gbc_lblSgDat.gridx = 1;
- gbc_lblSgDat.gridy = 2;
- panel_forms.add(lblSgDat, gbc_lblSgDat);
- tfSgDat = new JTextField();
- GridBagConstraints gbc_tfSgDat = new GridBagConstraints();
- gbc_tfSgDat.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgDat.insets = new Insets(0, 0, 5, 5);
- gbc_tfSgDat.gridx = 1;
- gbc_tfSgDat.gridy = 2;
- tfSgDat.setVisible(false);
- panel_forms.add(tfSgDat, gbc_tfSgDat);
- chckbxPlDat = new JCheckBox();
- chckbxPlDat.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlDat.setVisible(false);
- tfPlDat.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlDat.setVisible(false);
- lblPlDat.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlDat = new GridBagConstraints();
- gbc_chckbxPlDat.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxPlDat.gridx = 2;
- gbc_chckbxPlDat.gridy = 2;
- panel_forms.add(chckbxPlDat, gbc_chckbxPlDat);
- lblPlDat = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlDat = new GridBagConstraints();
- gbc_lblPlDat.anchor = GridBagConstraints.WEST;
- gbc_lblPlDat.insets = new Insets(0, 0, 5, 0);
- gbc_lblPlDat.gridx = 3;
- gbc_lblPlDat.gridy = 2;
- panel_forms.add(lblPlDat, gbc_lblPlDat);
- tfPlDat = new JTextField();
- GridBagConstraints gbc_tfPlDat = new GridBagConstraints();
- gbc_tfPlDat.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlDat.insets = new Insets(0, 0, 5, 0);
- gbc_tfPlDat.gridx = 3;
- gbc_tfPlDat.gridy = 2;
- tfPlDat.setVisible(false);
- panel_forms.add(tfPlDat, gbc_tfPlDat);
- chckbxSgAcc = new JCheckBox();
- chckbxSgAcc.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblSgAcc.setVisible(false);
- tfSgAcc.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfSgAcc.setVisible(false);
- lblSgAcc.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgAcc = new GridBagConstraints();
- gbc_chckbxSgAcc.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxSgAcc.gridx = 0;
- gbc_chckbxSgAcc.gridy = 3;
- panel_forms.add(chckbxSgAcc, gbc_chckbxSgAcc);
- lblSgAcc = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgAcc = new GridBagConstraints();
- gbc_lblSgAcc.anchor = GridBagConstraints.WEST;
- gbc_lblSgAcc.insets = new Insets(0, 0, 5, 5);
- gbc_lblSgAcc.gridx = 1;
- gbc_lblSgAcc.gridy = 3;
- panel_forms.add(lblSgAcc, gbc_lblSgAcc);
- tfSgAcc = new JTextField();
- GridBagConstraints gbc_tfSgAcc = new GridBagConstraints();
- gbc_tfSgAcc.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgAcc.insets = new Insets(0, 0, 5, 5);
- gbc_tfSgAcc.gridx = 1;
- gbc_tfSgAcc.gridy = 3;
- tfSgAcc.setVisible(false);
- panel_forms.add(tfSgAcc, gbc_tfSgAcc);
- chckbxPlAcc = new JCheckBox();
- chckbxPlAcc.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlAcc.setVisible(false);
- tfPlAcc.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlAcc.setVisible(false);
- lblPlAcc.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlAcc = new GridBagConstraints();
- gbc_chckbxPlAcc.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxPlAcc.gridx = 2;
- gbc_chckbxPlAcc.gridy = 3;
- panel_forms.add(chckbxPlAcc, gbc_chckbxPlAcc);
- lblPlAcc = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlAcc = new GridBagConstraints();
- gbc_lblPlAcc.anchor = GridBagConstraints.WEST;
- gbc_lblPlAcc.insets = new Insets(0, 0, 5, 0);
- gbc_lblPlAcc.gridx = 3;
- gbc_lblPlAcc.gridy = 3;
- panel_forms.add(lblPlAcc, gbc_lblPlAcc);
- tfPlAcc = new JTextField();
- GridBagConstraints gbc_tfPlAcc = new GridBagConstraints();
- gbc_tfPlAcc.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlAcc.insets = new Insets(0, 0, 5, 0);
- gbc_tfPlAcc.gridx = 3;
- gbc_tfPlAcc.gridy = 3;
- tfPlAcc.setVisible(false);
- panel_forms.add(tfPlAcc, gbc_tfPlAcc);
- chckbxSgAbl = new JCheckBox();
- chckbxSgAbl.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblSgAbl.setVisible(false);
- tfSgAbl.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfSgAbl.setVisible(false);
- lblSgAbl.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgAbl = new GridBagConstraints();
- gbc_chckbxSgAbl.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxSgAbl.gridx = 0;
- gbc_chckbxSgAbl.gridy = 4;
- panel_forms.add(chckbxSgAbl, gbc_chckbxSgAbl);
- lblSgAbl = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgAbl = new GridBagConstraints();
- gbc_lblSgAbl.anchor = GridBagConstraints.WEST;
- gbc_lblSgAbl.insets = new Insets(0, 0, 5, 5);
- gbc_lblSgAbl.gridx = 1;
- gbc_lblSgAbl.gridy = 4;
- panel_forms.add(lblSgAbl, gbc_lblSgAbl);
- tfSgAbl = new JTextField();
- GridBagConstraints gbc_tfSgAbl = new GridBagConstraints();
- gbc_tfSgAbl.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgAbl.insets = new Insets(0, 0, 5, 5);
- gbc_tfSgAbl.gridx = 1;
- gbc_tfSgAbl.gridy = 4;
- tfSgAbl.setVisible(false);
- panel_forms.add(tfSgAbl, gbc_tfSgAbl);
- chckbxPlAbl = new JCheckBox();
- chckbxPlAbl.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlAbl.setVisible(false);
- tfPlAbl.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlAbl.setVisible(false);
- lblPlAbl.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlAbl = new GridBagConstraints();
- gbc_chckbxPlAbl.insets = new Insets(0, 0, 5, 5);
- gbc_chckbxPlAbl.gridx = 2;
- gbc_chckbxPlAbl.gridy = 4;
- panel_forms.add(chckbxPlAbl, gbc_chckbxPlAbl);
- lblPlAbl = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlAbl = new GridBagConstraints();
- gbc_lblPlAbl.anchor = GridBagConstraints.WEST;
- gbc_lblPlAbl.insets = new Insets(0, 0, 5, 0);
- gbc_lblPlAbl.gridx = 3;
- gbc_lblPlAbl.gridy = 4;
- panel_forms.add(lblPlAbl, gbc_lblPlAbl);
- tfPlAbl = new JTextField();
- GridBagConstraints gbc_tfPlAbl = new GridBagConstraints();
- gbc_tfPlAbl.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlAbl.insets = new Insets(0, 0, 5, 0);
- gbc_tfPlAbl.gridx = 3;
- gbc_tfPlAbl.gridy = 4;
- tfPlAbl.setVisible(false);
- panel_forms.add(tfPlAbl, gbc_tfPlAbl);
- chckbxSgVoc = new JCheckBox();
- chckbxSgVoc.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblSgVoc.setVisible(false);
- tfSgVoc.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfSgVoc.setVisible(false);
- lblSgVoc.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxSgVoc = new GridBagConstraints();
- gbc_chckbxSgVoc.insets = new Insets(0, 0, 0, 5);
- gbc_chckbxSgVoc.gridx = 0;
- gbc_chckbxSgVoc.gridy = 5;
- panel_forms.add(chckbxSgVoc, gbc_chckbxSgVoc);
- lblSgVoc = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblSgVoc = new GridBagConstraints();
- gbc_lblSgVoc.anchor = GridBagConstraints.WEST;
- gbc_lblSgVoc.insets = new Insets(0, 0, 0, 5);
- gbc_lblSgVoc.gridx = 1;
- gbc_lblSgVoc.gridy = 5;
- panel_forms.add(lblSgVoc, gbc_lblSgVoc);
- tfSgVoc = new JTextField();
- GridBagConstraints gbc_tfSgVoc = new GridBagConstraints();
- gbc_tfSgVoc.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfSgVoc.insets = new Insets(0, 0, 0, 5);
- gbc_tfSgVoc.gridx = 1;
- gbc_tfSgVoc.gridy = 5;
- tfSgVoc.setVisible(false);
- panel_forms.add(tfSgVoc, gbc_tfSgVoc);
- chckbxPlVoc = new JCheckBox();
- chckbxPlVoc.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- lblPlVoc.setVisible(false);
- tfPlVoc.setVisible(true);
- } else if (e.getStateChange() == ItemEvent.DESELECTED) {
- tfPlVoc.setVisible(false);
- lblPlVoc.setVisible(true);
- }
- }
- });
- GridBagConstraints gbc_chckbxPlVoc = new GridBagConstraints();
- gbc_chckbxPlVoc.insets = new Insets(0, 0, 0, 5);
- gbc_chckbxPlVoc.gridx = 2;
- gbc_chckbxPlVoc.gridy = 5;
- panel_forms.add(chckbxPlVoc, gbc_chckbxPlVoc);
- lblPlVoc = new JLabel(GUIHelper.unknownForm);
- GridBagConstraints gbc_lblPlVoc = new GridBagConstraints();
- gbc_lblPlVoc.anchor = GridBagConstraints.WEST;
- gbc_lblPlVoc.gridx = 3;
- gbc_lblPlVoc.gridy = 5;
- panel_forms.add(lblPlVoc, gbc_lblPlVoc);
- tfPlVoc = new JTextField();
- GridBagConstraints gbc_tfPlVoc = new GridBagConstraints();
- gbc_tfPlVoc.fill = GridBagConstraints.HORIZONTAL;
- gbc_tfPlVoc.gridx = 3;
- gbc_tfPlVoc.gridy = 5;
- tfPlVoc.setVisible(false);
- panel_forms.add(tfPlVoc, gbc_tfPlVoc);
- JPanel panel_buttons = new JPanel();
- GridBagConstraints gbc_panel_buttons = new GridBagConstraints();
- gbc_panel_buttons.fill = GridBagConstraints.BOTH;
- gbc_panel_buttons.gridx = 0;
- gbc_panel_buttons.gridy = 2;
- getContentPane().add(panel_buttons, gbc_panel_buttons);
- GridBagLayout gbl_panel_buttons = new GridBagLayout();
- gbl_panel_buttons.columnWidths = new int[]{0, 0, 0};
- gbl_panel_buttons.rowHeights = new int[]{0, 0};
- gbl_panel_buttons.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
- gbl_panel_buttons.rowWeights = new double[]{1.0, Double.MIN_VALUE};
- panel_buttons.setLayout(gbl_panel_buttons);
- JButton btnSaveExit = new JButton(LanguageHelper.localize("GUINewNounButtonSaveExit"));
- btnSaveExit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- instance().dispose();
- }
- });
- GridBagConstraints gbc_btnSaveExit = new GridBagConstraints();
- gbc_btnSaveExit.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnSaveExit.insets = new Insets(0, 0, 0, 5);
- gbc_btnSaveExit.gridx = 0;
- gbc_btnSaveExit.gridy = 0;
- panel_buttons.add(btnSaveExit, gbc_btnSaveExit);
- JButton btnCancel = new JButton(LanguageHelper.localize("GUINewNounButtonCancel"));
- btnCancel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- instance().dispose();
- }
- });
- GridBagConstraints gbc_btnCancel = new GridBagConstraints();
- gbc_btnCancel.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnCancel.gridx = 1;
- gbc_btnCancel.gridy = 0;
- panel_buttons.add(btnCancel, gbc_btnCancel);
- }
- public JDialog instance() {
- return this;
- }
- public void refresh() {
- LogHelper.debug("Refresh fired!");
- try {
- String nomsg = tfInputSgNom.getText();
- String gensg = tfInputSgGen.getText();
- NounDeclension dec = (NounDeclension) cbDeclension.getSelectedItem();
- Gender g = (Gender) cbGender.getSelectedItem();
- Map<NounFormDescriptor, String> map = NounFormHelper.generateForms(nomsg, gensg, dec, g);
- // map = NounFormHelper.protectNulls(map);
- lblSgNom.setText(map.get(NounFormDescriptor.nomsg));
- lblPlNom.setText(map.get(NounFormDescriptor.nompl));
- lblSgGen.setText(map.get(NounFormDescriptor.gensg));
- lblPlGen.setText(map.get(NounFormDescriptor.genpl));
- lblSgDat.setText(map.get(NounFormDescriptor.datsg));
- lblPlDat.setText(map.get(NounFormDescriptor.datpl));
- lblSgAcc.setText(map.get(NounFormDescriptor.accsg));
- lblPlAcc.setText(map.get(NounFormDescriptor.accpl));
- lblSgAbl.setText(map.get(NounFormDescriptor.ablsg));
- lblPlAbl.setText(map.get(NounFormDescriptor.ablpl));
- lblSgVoc.setText(map.get(NounFormDescriptor.vocsg));
- lblPlVoc.setText(map.get(NounFormDescriptor.vocpl));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement