19 package org.turro.contacts.profile;
21 import org.turro.contacts.Contact;
22 import org.turro.i18n.I_;
23 import org.zkoss.zk.ui.event.Events;
24 import org.zkoss.zk.ui.ext.AfterCompose;
25 import org.zkoss.zul.Radio;
26 import org.zkoss.zul.Radiogroup;
32 public class PublishGroup extends Radiogroup implements AfterCompose {
35 private String element;
39 this.contact = contact;
43 this.element = element;
47 this.relation = relation;
55 addEventListener(Events.ON_CHECK, (event) -> {
56 Radio radio = getSelectedItem();
57 ProfilePolicies policies = new ProfilePolicies(contact);
58 PublishPolicy policy = PublishPolicy.valueOf(radio.getValue());
59 policies.setPolicy(relation == null ? contact : relation.getRelation(), element, policy);
65 for(Radio item : getItems()) {
66 if(policy.toString().equals(item.getValue())) {
67 setSelectedItem(item);
72 private void createItems() {
73 appendItem(I_.get(
"Public"), PublishPolicy.PUBLISH_ALL.toString());
74 appendItem(I_.get(
"User"), PublishPolicy.PUBLISH_USERS.toString());
75 appendItem(I_.get(
"Following"), PublishPolicy.PUBLISH_FOLLOWING.toString());
76 appendItem(I_.get(
"Private"), PublishPolicy.PUBLISH_NONE.toString());