diff --git a/src/main/java/cz/webstones/words/Main.java b/src/main/java/cz/webstones/words/Main.java index 9bca52b..4f49979 100644 --- a/src/main/java/cz/webstones/words/Main.java +++ b/src/main/java/cz/webstones/words/Main.java @@ -902,16 +902,22 @@ private void addWord() { if ((wOld = dict.findDuplicity(w)) != null) { wordExistsDialog.showDialog(w, wOld); + if (!wordExistsDialog.isCancelled()) + play(w); return; } if ((wOld = dict.findDuplicity(w.getCz())) != null) { wordExistsDialog.showDialog(w, wOld); + if (!wordExistsDialog.isCancelled()) + play(w); return; } if ((wOld = dict.findDuplicity(w.getEn())) != null) { wordExistsDialog.showDialog(w, wOld); + if (!wordExistsDialog.isCancelled()) + play(w); return; } diff --git a/src/main/java/cz/webstones/words/WordExistsDialog.java b/src/main/java/cz/webstones/words/WordExistsDialog.java index 3269cff..b6e2bdf 100644 --- a/src/main/java/cz/webstones/words/WordExistsDialog.java +++ b/src/main/java/cz/webstones/words/WordExistsDialog.java @@ -20,6 +20,7 @@ public class WordExistsDialog extends JEscapeableDialog { private IDictionary dict; private WordDto newWord; private WordDto oldWord; + private boolean cancelled; /** * Creates new form WordExistsDialog */ @@ -33,6 +34,7 @@ public WordExistsDialog(java.awt.Frame parent, boolean modal, IDictionary dictio public void showDialog(WordDto newWord, WordDto oldWord) { this.newWord = newWord; this.oldWord = oldWord; + this.cancelled = false; this.jLabel3.setText(oldWord.getCz()); this.jLabel5.setText(oldWord.getEn()); @@ -194,6 +196,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // cancel + cancelled = true; this.setVisible(false); }//GEN-LAST:event_jButton3ActionPerformed @@ -228,4 +231,11 @@ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; // End of variables declaration//GEN-END:variables + + /** + * @return the play + */ + public boolean isCancelled() { + return cancelled; + } }