Skip to content

Commit

Permalink
[26039] fix send mail doSend logic, reset task descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Dec 20, 2023
1 parent 73d446b commit dbd7dbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class SendMailDialog extends TitleAreaDialog {
private String documentsString;
private boolean disableOutbox;
private ComboViewer templatesViewer;
private boolean doSend;
private boolean doSend = true;
private LocalDateTime sentTime;

public SendMailDialog(Shell parentShell) {
Expand Down Expand Up @@ -270,7 +270,7 @@ public void selectionChanged(SelectionChangedEvent event) {
updateLayout();
}
});
if (Boolean.valueOf(doSend)) {
if (!doSend) {
lbl.setVisible(false);
templatesViewer.getCombo().setVisible(false);
attachments.setVisible(false);
Expand Down Expand Up @@ -393,9 +393,9 @@ protected void createButtonsForButtonBar(Composite parent) {
if (getButton(IDialogConstants.OK_ID) != null) {
Button okButton = getButton(IDialogConstants.OK_ID);
if (doSend) {
okButton.setText(IDialogConstants.OK_LABEL);
} else {
okButton.setText("Senden");
} else {
okButton.setText(IDialogConstants.OK_LABEL);
}
if (sentTime != null) {
setTitle("E-Mail Anzeige");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
Expand Down Expand Up @@ -81,9 +82,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
sendMailDialog.setText(text);
}

Boolean doSend = Boolean.TRUE;
String doSendString = event.getParameter("ch.elexis.core.mail.ui.sendMail.doSend");
if (doSendString != null) {
Boolean doSend = Boolean.valueOf(doSendString);
if (StringUtils.isNotBlank(doSendString)) {
doSend = Boolean.valueOf(doSendString);
sendMailDialog.doSend(doSend);
}
if (sendMailDialog.open() == Dialog.OK) {
Expand All @@ -93,11 +95,14 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
message.setDocuments(sendMailDialog.getDocumentsString());
taskDescriptor = TaskUtil
.createSendMailTaskDescriptor(sendMailDialog.getAccount().getId(), message);
ContextServiceHolder.get().getRootContext().setNamed("sendMailDialog.taskDescriptor", taskDescriptor.get());
if (!Boolean.valueOf(doSendString) && taskDescriptor.isPresent()) {
if (doSend && taskDescriptor.isPresent()) {
ContextServiceHolder.get().getRootContext().setNamed("sendMailDialog.taskDescriptor", null);
ITask task = new SendMailTaskWithProgress().execute(HandlerUtil.getActiveShell(event),
taskDescriptor.get());
return task.getState() == TaskState.COMPLETED;
} else if (!doSend) {
ContextServiceHolder.get().getRootContext().setNamed("sendMailDialog.taskDescriptor",
taskDescriptor.get());
}
}
return false;
Expand Down

0 comments on commit dbd7dbf

Please sign in to comment.