Skip to content

Commit

Permalink
avoid templates from being triggered when reply is used (overwrites t…
Browse files Browse the repository at this point in the history
…he reply content / quote). issue #2326
  • Loading branch information
j-dimension committed Oct 16, 2024
1 parent 4d809b7 commit 2bfd13e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ public void setAzSender(String fileNumber) {

public void addParty(AddressBean addr, PartyTypeBean ptb) {

this.pnlParties.addParty(new PartiesPanelEntry(addr, ptb));
this.pnlParties.addParty(new PartiesPanelEntry(addr, ptb), true);

this.addRecipientCandidate(addr, ptb);

Expand All @@ -1084,7 +1084,7 @@ public void addParty(ArchiveFileAddressesBean aab) {
return;
}

this.pnlParties.addParty(new PartiesPanelEntry(aab));
this.pnlParties.addParty(new PartiesPanelEntry(aab), true);

this.addRecipientCandidate(aab.getAddressKey(), aab.getReferenceType());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ public boolean execute() throws Exception {
if (parties != null) {
ArrayList<ArchiveFileAddressesBean> involved = parties;
for (ArchiveFileAddressesBean aab : involved) {
dlg.addParty(aab);
dlg.addParty(aab, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ public void setData(WizardDataContainer data) {

List<ArchiveFileAddressesBean> involved=locator.lookupArchiveFileServiceRemote().getInvolvementDetailsForCase(caseId);
for(ArchiveFileAddressesBean aab: involved) {
this.partiesPanel.addParty(new PartiesPanelEntry(aab));
this.partiesPanel.addParty(new PartiesPanelEntry(aab), true);
}

this.formPlaceHolders = locator.lookupFormsServiceRemote().getPlaceHoldersForCase(contextArchiveFile.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,7 @@ private void cmdSendEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
// we do not know what role this person has - so put it as all three types
List<PartyTypeBean> allPartyTypes = locator.lookupSystemManagementRemote().getPartyTypes();
for (PartyTypeBean ptb : allPartyTypes) {
dlg.addParty(dto, ptb);
dlg.addParty(dto, ptb, true);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "Fehler beim Ermitteln der Beteiligtentypen: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5057,7 +5057,7 @@ private void mnuSendDocumentActionPerformed(java.awt.event.ActionEvent evt) {//G

dlg.setArchiveFile(dto, caseFolder);
for (ArchiveFileAddressesBean aab : this.pnlInvolvedParties.getInvolvedParties()) {
dlg.addParty(aab);
dlg.addParty(aab, true);
}

try {
Expand Down Expand Up @@ -5119,7 +5119,7 @@ private void mnuSendDocumentPDFActionPerformed(java.awt.event.ActionEvent evt) {

dlg.setArchiveFile(dto, caseFolder);
for (ArchiveFileAddressesBean aab : this.pnlInvolvedParties.getInvolvedParties()) {
dlg.addParty(aab);
dlg.addParty(aab, true);
}

ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ private void mnuSendEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
dlg.setTo(this.a.getEmail());
ArrayList<ArchiveFileAddressesBean> involved = this.container.getInvolvedParties();
for (ArchiveFileAddressesBean aab : involved) {
dlg.addParty(aab);
dlg.addParty(aab, true);
}

FrameUtils.centerDialog(dlg, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ You should also get your employer (if you work as a programmer) or school,
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -810,7 +809,11 @@ public void initialize(List<ArchiveFileAddressesBean> involved) {
}
}

public void addParty(PartiesPanelEntry entry) {
public void addParty(PartiesPanelEntry entry, boolean evaluateTemplates) {
boolean currentIgnoreTableChanges=this.ignoreTableChanges;
if(!evaluateTemplates)
ignoreTableChanges=true;

PartiesPanelTableModel model = (PartiesPanelTableModel) this.tblParties.getModel();
ArrayList row = new ArrayList();
row.add(entry);
Expand All @@ -825,6 +828,7 @@ public void addParty(PartiesPanelEntry entry) {
Object[] rowArray = row.toArray();
model.addRow(rowArray);

ignoreTableChanges=currentIgnoreTableChanges;
}

public PartiesPanelEntry getSelectedParty(PartyTypeBean ptb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ public class SendEmailDialog extends javax.swing.JDialog implements SendCommunic
private AssistantConfig transcribeConfig = null;

private boolean replyOrForward=false;
private boolean initializing=false;

// can be set by code that constructs the SendEmailDialog to "inject" a recently created link to a Nextcloud share
// will be made available as a placeholder
Expand All @@ -793,8 +794,10 @@ public class SendEmailDialog extends javax.swing.JDialog implements SendCommunic
*/
public SendEmailDialog(boolean replyOrForward, JDialog parent, boolean modal) {
super(parent, modal);
this.initializing=true;
this.replyOrForward=replyOrForward;
this.initialize();
this.initializing=false;
}

/**
Expand All @@ -806,8 +809,10 @@ public SendEmailDialog(boolean replyOrForward, JDialog parent, boolean modal) {
*/
public SendEmailDialog(boolean replyOrForward, JFrame parent, boolean modal) {
super(parent, modal);
this.initializing=true;
this.replyOrForward=replyOrForward;
this.initialize();
this.initializing=false;
}

private void initialize() {
Expand Down Expand Up @@ -1107,20 +1112,20 @@ public void setFrom(MailboxSetup ms) {
}
}

public void addParty(AddressBean addr, PartyTypeBean ptb) {
public void addParty(AddressBean addr, PartyTypeBean ptb, boolean evaluateTemplates) {

this.pnlParties.addParty(new PartiesPanelEntry(addr, ptb));
this.pnlParties.addParty(new PartiesPanelEntry(addr, ptb), evaluateTemplates);

this.addRecipientCandidate(addr, ptb);

}

public void addParty(ArchiveFileAddressesBean p) {
public void addParty(ArchiveFileAddressesBean p, boolean evaluateTemplates) {
if (p == null) {
return;
}

this.pnlParties.addParty(new PartiesPanelEntry(p));
this.pnlParties.addParty(new PartiesPanelEntry(p), evaluateTemplates);

this.addRecipientCandidate(p.getAddressKey(), p.getReferenceType());

Expand Down Expand Up @@ -2201,6 +2206,10 @@ private void cmdRecipientsActionPerformed(java.awt.event.ActionEvent evt) {//GEN
}//GEN-LAST:event_cmdRecipientsActionPerformed

private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTemplatesActionPerformed
// when performing a reply, do not evaluate the template
if(this.initializing && this.replyOrForward)
return;

MailboxSetup ms = this.getSelectedMailbox();

Object selected = this.cmbTemplates.getSelectedItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ private void cmdReplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
dlg = EmailUtils.reply(this.outlookMsg, this.content.getBody(), this.content.getContentType());
}
dlg.setArchiveFile(this.contextArchiveFile, this.contextFolder);
this.setPartiesToSendDialog(dlg);
this.setPartiesToSendDialog(dlg, false);
FrameUtils.centerDialog(dlg, null);
dlg.setVisible(true);

Expand All @@ -852,7 +852,7 @@ private void cmdReplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
private void cmdReplyAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdReplyAllActionPerformed
SendEmailDialog dlg = new SendEmailDialog(true, EditorsRegistry.getInstance().getMainWindow(), false);
dlg.setArchiveFile(this.contextArchiveFile, this.contextFolder);
this.setPartiesToSendDialog(dlg);
this.setPartiesToSendDialog(dlg, false);

if (this.emlMsg != null) {
MessageContainer msgC = this.emlMsg;
Expand Down Expand Up @@ -953,15 +953,15 @@ private void cmdReplyAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F

}//GEN-LAST:event_cmdReplyAllActionPerformed

private void setPartiesToSendDialog(SendEmailDialog dlg) {
private void setPartiesToSendDialog(SendEmailDialog dlg, boolean evaluateTemplates) {
if (this.contextArchiveFile != null) {
try {
ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote();
List<ArchiveFileAddressesBean> list = afs.getInvolvementDetailsForCase(this.contextArchiveFile.getId(), false);
for (ArchiveFileAddressesBean aab : list) {
dlg.addParty(aab);
dlg.addParty(aab, evaluateTemplates);
}
} catch (Throwable t) {
log.error("Unable to add recipient candidates", t);
Expand All @@ -972,7 +972,7 @@ private void setPartiesToSendDialog(SendEmailDialog dlg) {
private void cmdForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdForwardActionPerformed
SendEmailDialog dlg = new SendEmailDialog(true, EditorsRegistry.getInstance().getMainWindow(), false);
dlg.setArchiveFile(this.contextArchiveFile, this.contextFolder);
this.setPartiesToSendDialog(dlg);
this.setPartiesToSendDialog(dlg, false);

if (this.emlMsg != null) {
MessageContainer msgC = this.emlMsg;
Expand Down

0 comments on commit 2bfd13e

Please sign in to comment.