19 package org.turro.synonyms;
21 import java.util.List;
23 import org.turro.string.Strings;
24 import org.turro.command.Context;
25 import org.turro.elephant.db.ElephantPU;
26 import org.turro.elephant.entities.db.Synonyms;
27 import org.turro.i18n.I_;
28 import org.turro.jpa.Dao;
29 import org.turro.zkoss.dialog.InputDialog;
30 import org.turro.zul.frame.Framework;
31 import org.zkoss.bind.BindUtils;
32 import org.zkoss.bind.annotation.BindingParam;
33 import org.zkoss.bind.annotation.Command;
34 import org.zkoss.bind.annotation.NotifyChange;
43 private String searchValue;
53 this.selected = selected;
61 this.searchValue = searchValue;
65 return selected !=
null && synonyms !=
null &&
66 selected.
getId() !=
null && synonyms.
getId() !=
null &&
70 @NotifyChange(
"model")
81 @NotifyChange({
"wordModel",
"model"})
83 if(selected !=
null) {
91 if(selected !=
null) {
93 I_.
get(
"Synonyms"),
"Word",
94 "",
null, 0, (Context context) -> {
95 String value = (String) context.get(
"value");
96 if(!Strings.isBlank(value)) {
97 selected.getWords().add(value);
98 selected = getDao().saveObject(selected);
99 BindUtils.postNotifyChange(null, null, SynonymsVM.this,
"model");
100 BindUtils.postNotifyChange(null, null, SynonymsVM.this,
"wordModel");
108 @NotifyChange({
"wordModel",
"model"})
110 if(selected !=
null) {
111 if(selected.
getWords().remove(word)) {
113 getDao().deleteObject(selected);
116 selected = getDao().saveObject(selected);
123 @NotifyChange({
"wordModel",
"model"})
125 this.selected = selected;
129 if(selected ==
null)
return null;
134 if(!Strings.isBlank(searchValue)) {
137 return getDao().getResultList(
"select s from Synonyms s");
145 private Dao getDao() {
static List< Synonyms > getSynonyms(String word)
static String get(String msg)
void deleteObject(Object obj)
void selectSynonyms(@BindingParam("selected") Synonyms selected)
void setSelected(Synonyms selected)
Set< String > getWordModel()
List< Synonyms > getModel()
boolean isSelected(Synonyms synonyms)
void setSearchValue(String searchValue)
void deleteWord(@BindingParam("word") String word)
static Framework getCurrent()