/************************************************************************** OmegaT - Computer Assisted Translation (CAT) tool with fuzzy matching, translation memory, keyword search, glossaries, and translation leveraging into updated projects. Copyright (C) 2000-2006 Keith Godfrey and Maxym Mykhalchuk 2010 Didier Briel Home page: http://www.omegat.org/ Support center: http://groups.yahoo.com/group/OmegaT/ This file is part of OmegaT. OmegaT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OmegaT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. **************************************************************************/ package org.omegat.gui.dialogs; import java.awt.Frame; import java.awt.event.KeyEvent; import javax.swing.JDialog; import javax.swing.JLabel; import org.omegat.util.OStrings; import org.omegat.util.gui.StaticUIUtils; /** * * @author Maxym Mykhalchuk * @author Didier Briel */ @SuppressWarnings("serial") public class CreateGlossaryEntry extends JDialog { /** A return status code - returned if Cancel button has been pressed */ public static final int RET_CANCEL = 0; /** A return status code - returned if OK button has been pressed */ public static final int RET_OK = 1; /** Creates new form CreateGlossaryEntry */ public CreateGlossaryEntry(Frame parent) { super(parent, false); StaticUIUtils.setEscapeClosable(this); initComponents(); getRootPane().setDefaultButton(okButton); // initializing options invalidate(); pack(); setLocationRelativeTo(parent); } /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */ public int getReturnStatus() { return returnStatus; } /** * @return the source text component of the dialog */ public javax.swing.JTextField getSourceText() { return sourceText; } /** * @return the target text component of the dialog */ public javax.swing.JTextField getTargetText() { return targetText; } /** * @return the comment text component of the dialog */ public javax.swing.JTextArea getCommentText() { return commentText; } /** * @return the glossary file text component of the dialog */ public javax.swing.JTextArea getGlossaryFileText() { return glossaryFileText; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; sourceTermLabel = new javax.swing.JLabel(); descriptionTextArea = new javax.swing.JTextArea(); targetTermLabel = new javax.swing.JLabel(); sourceText = new javax.swing.JTextField(); targetText = new javax.swing.JTextField(); commentLabel = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); commentText = new javax.swing.JTextArea(); glossaryFileText = new javax.swing.JTextArea(); jPanel1 = new javax.swing.JPanel(); okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); setTitle(OStrings.getString("CREATE_GLOSSARY_TITLE")); // NOI18N addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); getContentPane().setLayout(new java.awt.GridBagLayout()); org.openide.awt.Mnemonics.setLocalizedText(sourceTermLabel, OStrings.getString("CREATE_GLOSSARY_SOURCE")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 16, 4, 4); getContentPane().add(sourceTermLabel, gridBagConstraints); descriptionTextArea.setEditable(false); descriptionTextArea.setFont(targetTermLabel.getFont()); descriptionTextArea.setLineWrap(true); descriptionTextArea.setText(OStrings.getString("CREATE_GLOSSARY_DESCRIPTION")); // NOI18N descriptionTextArea.setWrapStyleWord(true); descriptionTextArea.setDragEnabled(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setOpaque(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(descriptionTextArea, gridBagConstraints); targetTermLabel.setLabelFor(sourceText); org.openide.awt.Mnemonics.setLocalizedText(targetTermLabel, OStrings.getString("CREATE_GLOSSARY_TARGET")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 16, 4, 4); getContentPane().add(targetTermLabel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 50; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(sourceText, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 50; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(targetText, gridBagConstraints); commentLabel.setLabelFor(sourceText); org.openide.awt.Mnemonics.setLocalizedText(commentLabel, OStrings.getString("CREATE_GLOSSARY_COMMENT")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 16, 4, 4); getContentPane().add(commentLabel, gridBagConstraints); commentText.setColumns(20); commentText.setFont(sourceText.getFont()); commentText.setLineWrap(true); commentText.setRows(5); commentText.setWrapStyleWord(true); commentText.setMinimumSize(new java.awt.Dimension(104, 18)); commentText.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { commentTextKeyPressed(evt); } }); jScrollPane1.setViewportView(commentText); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 50; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 0.5; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(jScrollPane1, gridBagConstraints); glossaryFileText.setEditable(false); glossaryFileText.setFont(new JLabel().getFont()); glossaryFileText.setLineWrap(true); glossaryFileText.setText(OStrings.getString("CREATE_GLOSSARY_FILE")); // NOI18N glossaryFileText.setWrapStyleWord(true); glossaryFileText.setOpaque(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(glossaryFileText, gridBagConstraints); org.openide.awt.Mnemonics.setLocalizedText(okButton, OStrings.getString("BUTTON_OK")); // NOI18N okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); jPanel1.add(okButton); org.openide.awt.Mnemonics.setLocalizedText(cancelButton, OStrings.getString("BUTTON_CANCEL")); // NOI18N cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); jPanel1.add(cancelButton); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; getContentPane().add(jPanel1, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void commentTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_commentTextKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { evt.consume(); okButton.doClick(); } else if (evt.getKeyCode() == KeyEvent.VK_TAB) { if (evt.isShiftDown()) { targetText.requestFocusInWindow(); // Is it Shift+Tab? } else { evt.consume(); // Otherwise, the tab is entered in the component okButton.requestFocusInWindow(); } } }//GEN-LAST:event_commentTextKeyPressed private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed doClose(RET_OK); }//GEN-LAST:event_okButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed doClose(RET_CANCEL); }//GEN-LAST:event_cancelButtonActionPerformed private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog doClose(RET_CANCEL); }//GEN-LAST:event_closeDialog private void doClose(int retStatus) { returnStatus = retStatus; setVisible(false); dispose(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JLabel commentLabel; private javax.swing.JTextArea commentText; private javax.swing.JTextArea descriptionTextArea; private javax.swing.JTextArea glossaryFileText; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton okButton; private javax.swing.JLabel sourceTermLabel; private javax.swing.JTextField sourceText; private javax.swing.JLabel targetTermLabel; private javax.swing.JTextField targetText; // End of variables declaration//GEN-END:variables private int returnStatus = RET_CANCEL; }