Skip to content

Commit

Permalink
added semi-automatic creation of related calendar entry. close #36
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Aug 14, 2024
1 parent 0b300cc commit 7fb1a20
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1899,28 +1899,6 @@ private void cmdSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
log.error("Unable to unarchive case " + this.contextArchiveFile.getFileNumber(), ex);
}

BeaListItem priority=null;
if(this.cmbPriorities.getSelectedItem() instanceof BeaListItem)
// first index is a string (no priority selected)
priority=(BeaListItem)this.cmbPriorities.getSelectedItem();

if (this.chkSaveAsDocument.isSelected()) {
a = new SendBeaMessageAction(dlg, this, messageType, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipients, this.txtSubject.getText(), ed.getText(), priority, this.contextArchiveFile, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), folder);
} else {
a = new SendBeaMessageAction(dlg, this, messageType, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipients, this.txtSubject.getText(), ed.getText(), priority, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString());
}
a.start();


UserSettings uset = UserSettings.getInstance();
if (fromSafeId != null) {
uset.setSetting(UserSettings.CONF_BEA_LASTUSEDMAILBOX, fromSafeId);
}

if (this.cmbTemplates.getSelectedItem() != null) {
uset.setSetting(UserSettings.CONF_BEA_LASTUSEDTEMPLATE, this.cmbTemplates.getSelectedItem().toString());
}

if (!(this.radioReviewTypeNone.isSelected()) && this.contextArchiveFile != null) {
if (this.txtReviewDateField.getText().length() != 10) {
JOptionPane.showMessageDialog(this, "Wiedervorlagedatum ungültig", "beA-Nachricht senden", JOptionPane.INFORMATION_MESSAGE);
Expand Down Expand Up @@ -1948,7 +1926,7 @@ private void cmdSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST

if (CalendarUtils.checkForConflicts(this, reviewDto)) {
try {
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.contextArchiveFile.getId(), (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()));
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.contextArchiveFile, (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()), this);
} catch (Exception ex) {
log.error("Error adding review", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Speichern des Kalendereintrages: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
Expand All @@ -1957,6 +1935,30 @@ private void cmdSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
}

}

BeaListItem priority=null;
if(this.cmbPriorities.getSelectedItem() instanceof BeaListItem)
// first index is a string (no priority selected)
priority=(BeaListItem)this.cmbPriorities.getSelectedItem();

if (this.chkSaveAsDocument.isSelected()) {
a = new SendBeaMessageAction(dlg, this, messageType, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipients, this.txtSubject.getText(), ed.getText(), priority, this.contextArchiveFile, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), folder);
} else {
a = new SendBeaMessageAction(dlg, this, messageType, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipients, this.txtSubject.getText(), ed.getText(), priority, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString());
}
a.start();


UserSettings uset = UserSettings.getInstance();
if (fromSafeId != null) {
uset.setSetting(UserSettings.CONF_BEA_LASTUSEDMAILBOX, fromSafeId);
}

if (this.cmbTemplates.getSelectedItem() != null) {
uset.setSetting(UserSettings.CONF_BEA_LASTUSEDTEMPLATE, this.cmbTemplates.getSelectedItem().toString());
}




}//GEN-LAST:event_cmdSendActionPerformed
Expand Down Expand Up @@ -2291,13 +2293,6 @@ private void cmdSaveDraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
log.error("Unable to unarchive case " + this.contextArchiveFile.getFileNumber(), ex);
}

if (this.chkSaveAsDocument.isSelected()) {
a = new SaveBeaMessageAction(dlg, this, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipient, this.txtSubject.getText(), ed.getText(), this.contextArchiveFile, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), folder, priority);
} else {
a = new SaveBeaMessageAction(dlg, this, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipient, this.txtSubject.getText(), ed.getText(), createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), priority);
}
a.start();

if (!(this.radioReviewTypeNone.isSelected()) && this.contextArchiveFile != null) {
if (this.txtReviewDateField.getText().length() != 10) {
JOptionPane.showMessageDialog(this, "Wiedervorlagedatum ungültig", "beA-Nachricht als Entwurf speichern", JOptionPane.INFORMATION_MESSAGE);
Expand Down Expand Up @@ -2325,14 +2320,23 @@ private void cmdSaveDraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-

if (CalendarUtils.checkForConflicts(this, reviewDto)) {
try {
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.contextArchiveFile.getId(), (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()));
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.contextArchiveFile, (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()), this);
} catch (Exception ex) {
log.error("Error adding review", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Speichern des Kalendereintrages: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
}
}

}

if (this.chkSaveAsDocument.isSelected()) {
a = new SaveBeaMessageAction(dlg, this, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipient, this.txtSubject.getText(), ed.getText(), this.contextArchiveFile, createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), folder, priority);
} else {
a = new SaveBeaMessageAction(dlg, this, fromSafeId, attachmentMetadata, this.cu, this.chkEeb.isSelected(), this.authority, recipient, this.txtSubject.getText(), ed.getText(), createDocumentTag, this.txtAzSender.getText(), this.cmbAzRecipient.getEditor().getItem().toString(), priority);
}
a.start();


}//GEN-LAST:event_cmdSaveDraftActionPerformed

private void tblAttachmentsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblAttachmentsMouseClicked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,16 @@
import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.settings.ServerSettings;
import com.jdimension.jlawyer.client.utils.FrameUtils;
import com.jdimension.jlawyer.persistence.ArchiveFileBean;
import com.jdimension.jlawyer.persistence.ArchiveFileReviewsBean;
import com.jdimension.jlawyer.persistence.CalendarEntryTemplate;
import com.jdimension.jlawyer.services.CalendarServiceRemote;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
import de.costache.calendar.NewEventEntryDialog;
import java.awt.Dialog;
import java.awt.Window;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -901,19 +906,45 @@ public static void populateCalendarEntryTemplatesList(JList list) {
list.setModel(listMod);
}

public ArchiveFileReviewsBean storeCalendarEntry(ArchiveFileReviewsBean entry, String caseId, CalendarEntryTemplate template) throws Exception {
public ArchiveFileReviewsBean storeCalendarEntry(ArchiveFileReviewsBean entry, ArchiveFileBean entryCase, CalendarEntryTemplate template, Window parent) throws Exception {
EditorsRegistry.getInstance().updateStatus("Wiedervorlage/Frist wird gespeichert...");
try {
ClientSettings settings = ClientSettings.getInstance();

JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
CalendarServiceRemote calService = locator.lookupCalendarServiceRemote();

entry = calService.addReview(caseId, entry);
entry = calService.addReview(entryCase.getId(), entry);

EventBroker eb = EventBroker.getInstance();
eb.publishEvent(new ReviewAddedEvent(entry));
eb.publishEvent(new CasesChangedEvent());

if(template!=null && template.isRelated()) {
NewEventEntryDialog relatedEventDlg = new NewEventEntryDialog(null, parent, Dialog.ModalityType.APPLICATION_MODAL, entryCase, true);
relatedEventDlg.setTitle("weiterer Eintrag mit " + template.getRelatedOffsetDays() + " Tagen Versatz");
relatedEventDlg.setEventType(entry.getEventType());
relatedEventDlg.setSummary(template.getRelatedName());
relatedEventDlg.setDescription(template.getRelatedDescription());
relatedEventDlg.setReviewAssignee(entry.getAssignee());

Calendar c = Calendar.getInstance();
c.setTime(entry.getBeginDate());
c.add(Calendar.DAY_OF_YEAR, template.getRelatedOffsetDays());
relatedEventDlg.setBeginDate(c.getTime());

Calendar c2=Calendar.getInstance();
c2.setTime(entry.getEndDate());
c2.add(Calendar.DAY_OF_YEAR, template.getRelatedOffsetDays());
relatedEventDlg.setEndDate(c2.getTime());

relatedEventDlg.setEndDate(c2.getTime());

FrameUtils.centerDialog(relatedEventDlg, parent);
relatedEventDlg.setVisible(true);
}


return entry;
} finally {
EditorsRegistry.getInstance().clearStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ private void addAndOpen(boolean openAfterAdd) {

if (CalendarUtils.checkForConflicts(this, reviewDto)) {
try {
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.aFile.getId(), (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()));
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.aFile, (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()), this);
} catch (Exception ex) {
log.error("Error adding review", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Speichern des Kalendereintrages: " + 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 @@ -1145,7 +1145,7 @@ private void cmdAddDocumentActionPerformed(java.awt.event.ActionEvent evt) {//GE

if (CalendarUtils.checkForConflicts(this, reviewDto)) {
try {
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.aFile.getId(), (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()));
CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.aFile, (CalendarEntryTemplate) this.cmbReviewReason.getItemAt(this.cmbReviewReason.getSelectedIndex()), this);
} catch (Exception ex) {
log.error("Error adding review", ex);
JOptionPane.showMessageDialog(this, "Fehler beim Speichern des Kalendereintrages: " + 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 @@ -1054,7 +1054,6 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
ingo.populateMenu(this.mnuAssistant, capabilities2, (AssistantInputAdapter)this);
} catch (Exception ex) {
log.error(ex);
JOptionPane.showMessageDialog(this, "Assistent Ingo aktuell nicht erreichbar: " + ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
}

EventBroker b = EventBroker.getInstance();
Expand Down Expand Up @@ -4216,7 +4215,7 @@ public void addReview(CalendarEntryTemplate template, int eventType, String reas
reviewDto.setLocation(location);
reviewDto.setCalendarSetup(calSetup);

reviewDto = CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.dto.getId(), template);
reviewDto = CalendarUtils.getInstance().storeCalendarEntry(reviewDto, this.dto, template, EditorsRegistry.getInstance().getMainWindow());

if (this.chkArchived.isSelected()) {
this.chkArchived.setSelected(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ private void cmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
CalendarServiceRemote calService = locator.lookupCalendarServiceRemote();
if (this.mode == MODE_DUPLICATE) {
// when duplicating, do not pass in the template because we do not want to handle adding related events
targetReview = CalendarUtils.getInstance().storeCalendarEntry(targetReview, this.caseDto.getId(), null);
targetReview = CalendarUtils.getInstance().storeCalendarEntry(targetReview, this.caseDto, null, this);
} else if (this.mode == MODE_EDIT) {
targetReview = calService.updateReview(this.caseDto.getId(), targetReview);
EventBroker eb = EventBroker.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,18 +724,22 @@ public void mouseClicked(MouseEvent event) {
list.repaint(list.getCellBounds(index, index));

int selectionCount = 0;
String selectedItemText = "";
String selectedItemSummary = "";
String selectedItemDescription = "";
for (int i = 0; i < list.getModel().getSize(); i++) {
CalendarEntryTemplateListItem cli = (CalendarEntryTemplateListItem) list.getModel().getElementAt(i);
if (cli.isSelected()) {
selectionCount++;
selectedItemText = cli.toString();
selectedItemSummary = cli.toString();
selectedItemDescription = cli.getEntry().getDescription();
}
}
if (selectionCount == 1) {
txtReviewReason.setText(selectedItemText);
txtReviewReason.setText(selectedItemSummary);
taEventDescription.setText(selectedItemDescription);
} else {
txtReviewReason.setText("");
taEventDescription.setText("");
}
}
});
Expand Down Expand Up @@ -1272,7 +1276,7 @@ public void setReviewAssignee(String assignee) {
}
}
}

public void setBeginDate(Date d) {

this.txtEventBeginDateField.setText(dateFormat.format(d));
Expand All @@ -1286,6 +1290,14 @@ public void setEndDate(Date d) {

this.cmbEventEndTime.setSelectedItem(timeFormat.format(d));
}

public void setSummary(String summary) {
this.txtReviewReason.setText(summary);
}

public void setDescription(String description) {
this.taEventDescription.setText(description);
}

public void setEventType(int eventType) {
this.radioEventTypeFollowUp.setSelected(true);
Expand Down
Loading

0 comments on commit 7fb1a20

Please sign in to comment.