19 package org.turro.participation;
21 import org.turro.action.MailSenders;
22 import org.turro.assistant.ParticipationInfo;
23 import org.turro.auth.Authentication;
24 import org.turro.entities.Entities;
25 import org.turro.entities.IElephantEntity;
26 import org.turro.i18n.I_;
27 import org.turro.plugin.contacts.IContact;
28 import org.turro.string.Strings;
29 import org.zkoss.zk.ui.event.Events;
30 import org.zkoss.zk.ui.ext.AfterCompose;
31 import org.zkoss.zul.A;
32 import org.zkoss.zul.Html;
40 private final Html html;
42 private Object entity;
44 private String name, description;
64 this.description = description;
69 addEventListener(Events.ON_CLICK, (event) -> {
73 addEventListener(Events.ON_MOUSE_OVER, (event) -> {
76 addEventListener(Events.ON_MOUSE_OUT, (event) -> {
84 case REASON_APPLY -> adjustApply();
90 case REASON_APPLY -> adjustHoverApply();
94 private void adjustApply() {
95 setIconSclass(
"hand point up outline icon");
99 if(!iec.
isEmpty() && !iee.isEmpty()) {
103 setSclass(
"ui green button");
104 html.setContent(
I_.
get(
"Applying"));
106 setSclass(
"ui grey button");
107 html.setContent(I_.get(
"Apply"));
112 private void adjustHoverApply() {
113 IContact contact = Authentication.getIContact();
114 IElephantEntity iec = Entities.
getController(contact.getContact()),
116 if(!iec.isEmpty() && !iee.isEmpty()) {
117 ParticipationInfo info =
new ParticipationInfo(iee.getPath(), iec.getPath(), reason);
118 if(info.isChecked()) {
119 setSclass(
"ui red button");
120 html.setContent(I_.get(
"Stop applying"));
125 private void execute() {
126 IContact contact = Authentication.getIContact();
127 IElephantEntity iec = Entities.getController(contact.getContact()),
128 iee = Entities.getController(entity);
129 if(!iec.isEmpty() && !iee.isEmpty()) {
130 ParticipationInfo info =
new ParticipationInfo(iee.getPath(), iec.getPath(), reason);
131 boolean selected = info.toggle();
133 String subject = iec.getName() +
" " + info.getReasonStr() +
" " + Strings.isBlank(name, iee.getName());
134 MailSenders.getPool()
136 .send(subject, subject +
"\n\n" + Strings.isBlank(description, iee.getDescription()));
138 String subject = iec.getName() +
" NOT " + info.getReasonStr() +
" " + Strings.isBlank(name, iee.getName());
139 MailSenders.getPool()
141 .send(subject, subject +
"\n\n" + Strings.isBlank(description, iee.getDescription()));
static IContact getIContact()
static IElephantEntity getController(String path)
static String get(String msg)
void setDescription(String description)
void setName(String name)
void setReason(String reason)
void setEntity(Object entity)
boolean isMailableOnDeselect()
boolean isMailableOnSelect()
IElephantEntity getController(String entityPath)