Merge branch 'master' of https://git.bukova.info/repos/git/isspst
commit
d371cab545
@ -0,0 +1,56 @@
|
|||||||
|
package info.bukova.isspst.filters;
|
||||||
|
|
||||||
|
import static info.bukova.isspst.StringUtils.nullStr;
|
||||||
|
import info.bukova.isspst.data.Workgroup;
|
||||||
|
|
||||||
|
import org.hamcrest.Description;
|
||||||
|
import org.hamcrest.Factory;
|
||||||
|
import org.hamcrest.Matcher;
|
||||||
|
import org.hamcrest.TypeSafeMatcher;
|
||||||
|
|
||||||
|
public class WorkgroupFilter implements Filter<Workgroup> {
|
||||||
|
|
||||||
|
private Workgroup condWorkgroup;
|
||||||
|
|
||||||
|
public WorkgroupFilter(Workgroup condWorkgroup) {
|
||||||
|
this.condWorkgroup = condWorkgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class WorkgroupMatcher extends TypeSafeMatcher<Workgroup> {
|
||||||
|
|
||||||
|
private Workgroup condWorkgroup;
|
||||||
|
|
||||||
|
public WorkgroupMatcher(Workgroup cond) {
|
||||||
|
this.condWorkgroup = cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void describeTo(Description desc) {
|
||||||
|
desc.appendText("material matches");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matchesSafely(Workgroup item) {
|
||||||
|
return nullStr(item.getCode()).toLowerCase().contains(nullStr(condWorkgroup.getCode()).toLowerCase())
|
||||||
|
&& nullStr(item.getName()).toLowerCase().contains(nullStr(condWorkgroup.getName()).toLowerCase())
|
||||||
|
&& item.isCentre() == condWorkgroup.isCentre();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Factory
|
||||||
|
public static Matcher<Workgroup> matchBuilding(Workgroup material) {
|
||||||
|
return new WorkgroupMatcher(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkgroupMatcher matcher() {
|
||||||
|
return new WorkgroupMatcher(condWorkgroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String queryString() {
|
||||||
|
// TODO query string
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package info.bukova.isspst.ui;
|
||||||
|
|
||||||
|
import info.bukova.isspst.StringUtils;
|
||||||
|
|
||||||
|
import org.zkoss.bind.BindContext;
|
||||||
|
import org.zkoss.bind.Converter;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
|
|
||||||
|
public class BoolConverter implements Converter<String, Boolean, Component> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean coerceToBean(String str, Component component, BindContext cx) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String coerceToUi(Boolean val, Component component, BindContext cx) {
|
||||||
|
return StringUtils.localize(val.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue