From 2a7b6be959a1468387dfab26573023f1afce8966 Mon Sep 17 00:00:00 2001 From: j-dimension Date: Mon, 26 Aug 2024 18:30:52 +0200 Subject: [PATCH] added implementation for rename actions. issue #2246 --- .../jlawyer/client/bea/BeaInboxPanel.form | 7 - .../jlawyer/client/bea/BeaInboxPanel.java | 2 +- .../client/bea/BeaMessageContentUI.java | 2 +- .../client/bea/SaveBeaMessageAction.java | 2 +- .../client/bea/SendBeaMessageAction.java | 4 +- .../client/drebis/DrebisInboxPanel.java | 6 - .../drebis/freetext/FreeTextReceiptStep.java | 6 +- .../editors/documents/ScannerPanel.java | 2 +- .../files/ArchiveFileDetailLoadAction.java | 2 +- .../editors/files/ArchiveFilePanel.java | 18 +- .../client/editors/files/BulkSaveEntry.java | 7 +- .../editors/files/ExportAsPdfMergeStep.java | 2 +- .../editors/files/UploadDocumentsAction.java | 14 +- .../client/mail/EmailTemplatesPanel.form | 1 - .../client/mail/EmailTemplatesPanel.java | 4 +- .../jlawyer/client/mail/MailContentUI.java | 2 +- .../jlawyer/client/mail/SendAction.java | 4 +- .../client/mail/SendEncryptedAction.java | 4 +- .../client/templates/TemplatesTreePanel.java | 2 +- .../jlawyer/client/utils/FileUtils.java | 32 ++- .../client/utils/NewFilenameOptionPanel.form | 43 ++- .../client/utils/NewFilenameOptionPanel.java | 248 ++++++++++++++++-- .../client/voip/EpostLetterSendStatus.java | 10 +- .../client/voip/MailingStatusPanel.java | 8 +- .../jlawyer/ui/folders/CaseFolderPanel.java | 11 +- .../jlawyer/ui/folders/FolderListCell.java | 4 +- .../jlawyer/documents/PlaceHolders.java | 3 +- .../jlawyer/server/utils/ServerFileUtils.java | 8 + .../V2_7_0_9__AddDocumentNameTpls.sql | 4 + 29 files changed, 348 insertions(+), 114 deletions(-) create mode 100644 j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form index 3948147b1..6efd5e11b 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form @@ -448,13 +448,6 @@ - - - - - - - diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java index 53459249b..626771caf 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java @@ -2849,7 +2849,7 @@ private void saveEebResponse(Message m, MessageHeader originalMessage, String re ArchiveFileServiceRemote remote = locator.lookupArchiveFileServiceRemote(); MessageExport mex = BeaAccess.exportMessage(m); - String newName = FileUtils.getNewFileName(m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea", false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "eEb-Antwort speichern"); + String newName = FileUtils.getNewFileName(targetCase, m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea", false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "eEb-Antwort speichern"); if (newName == null || "".equals(newName)) { newName=m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea"; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java index 7048fa6a0..b13ac4399 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java @@ -1501,7 +1501,7 @@ private void mnuSearchSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN byte[] data = ((Attachment) selected).getContent(); - String newName = FileUtils.getNewFileName(selected.toString(), true); + String newName = FileUtils.getNewFileName(sel, selected.toString(), true, true); if (newName == null) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java index 50f0c679d..09f56d6d2 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java @@ -820,7 +820,7 @@ public boolean execute() throws Exception { if (receivedPrefix == null) { receivedPrefix = new java.util.Date(); } - String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(mex.getFileName(), true, receivedPrefix, this.indicator); + String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, mex.getFileName(), true, receivedPrefix, true, this.indicator); if (newName == null) { return false; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java index f8ed03c2e..2645c3d3f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java @@ -862,7 +862,7 @@ public boolean execute() throws Exception { if (receivedPrefix == null) { receivedPrefix = new java.util.Date(); } - String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(mex.getFileName(), true, receivedPrefix, this.indicator, "Datei benennen"); + String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, mex.getFileName(), true, receivedPrefix, true, this.indicator, "Datei benennen"); if (newName == null) { return false; } @@ -880,7 +880,7 @@ public boolean execute() throws Exception { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(newName, true, receivedPrefix, this.indicator, "Datei benennen"); + newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, newName, true, receivedPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java index 50e742393..c3d9ae901 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java @@ -776,12 +776,6 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { } - public String getNewFileName(String currentFileName) { - - return FileUtils.getNewFileName(currentFileName, false); - - } - public void clear() { this.txtClaimNumber.setText(""); this.txtFileName.setText(""); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java index 802d10a8a..3161c1ee2 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java @@ -740,7 +740,7 @@ public void finishedEvent() { log.error("Unable to unarchive case " + sel.getFileNumber(), ex); } - String newName = this.getNewFileName(attachment.getName() + "." + attachment.getSuffix()); + String newName = this.getNewFileName(sel, attachment.getName() + "." + attachment.getSuffix()); if (newName == null) { newName = attachment.getName() + "." + attachment.getSuffix(); } @@ -864,8 +864,8 @@ public String getStepName() { return this.getName(); } - public String getNewFileName(String currentFileName) { - return FileUtils.getNewFileName(currentFileName, false, new Date(), this, "Datei benennen"); + public String getNewFileName(ArchiveFileBean selectedCase, String currentFileName) { + return FileUtils.getNewFileName(selectedCase, currentFileName, false, new Date(), true, this, "Datei benennen"); } @Override diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java index 1a611e870..1839f515f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java @@ -1529,7 +1529,7 @@ public boolean renameCallback() { for (int r : selRow) { String fileName = this.tblDirContent.getValueAt(r, 2).toString(); - String toFileName = FileUtils.getNewFileName(fileName, false); + String toFileName = FileUtils.getNewFileName(null, fileName, false, false); if (toFileName == null) { // user cancelled continue; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java index ea44752f3..0b757ae80 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java @@ -935,7 +935,7 @@ public boolean execute() throws Exception { HashMap folderSettings = fileService.getCaseFolderSettings(folderIds); caseFolders.setReadOnly(readOnly || this.caseDto.isArchived()); caseFolders.setRootFolder(this.caseDto.getRootFolder(), folderSettings); - caseFolders.setCaseId(archiveFileKey); + caseFolders.setCase(this.caseDto); caseFolders.setDocuments(new ArrayList<>(documents), docToInvoice); caseFolders.sort(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index 4c1fa0dff..301c6e290 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -4723,13 +4723,13 @@ public void uploadDocument(Invoice invoice) { ThreadUtils.setWaitCursor(this); ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto.getId(), this.caseFolderPanel1, files, null, invoice); + UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto, this.caseFolderPanel1, files, null, invoice); a.start(); } else { ThreadUtils.setWaitCursor(this); ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto.getId(), this.caseFolderPanel1, files, null, invoice); + UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto, this.caseFolderPanel1, files, null, invoice); a.execute(); } @@ -4791,7 +4791,7 @@ private void mnuDuplicateDocumentActionPerformed(java.awt.event.ActionEvent evt) byte[] content = remote.getDocumentContent(doc.getId()); ArchiveFileDocumentsBean orgDoc = remote.getDocument(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument duplizieren"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Dokument duplizieren"); if (newName == null || "".equals(newName)) { return; @@ -4929,7 +4929,7 @@ private void mnuRenameDocumentActionPerformed(java.awt.event.ActionEvent evt) {/ return; } ArchiveFileDocumentsBean doc = selectedDocs.get(0); - String newName = FileUtils.getNewFileName(doc.getName(), false, null, this, "Dokument umbenennen"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, null, false, this, "Dokument umbenennen"); this.lastPopupClosed = System.currentTimeMillis(); if (newName == null) { return; @@ -5494,7 +5494,7 @@ private void mnuCopyDocumentToOtherCaseActionPerformed(java.awt.event.ActionEven try { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument kopieren"); + String newName = FileUtils.getNewFileName(sel, doc.getName(), false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Dokument kopieren"); if (newName == null || "".equalsIgnoreCase(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -5557,7 +5557,7 @@ public void convertDocumentToPdf(ArchiveFileDocumentsBean doc) throws Exception int response = JOptionPane.showOptionDialog(EditorsRegistry.getInstance().getMainWindow(), "Eine Datei mit dem Namen '" + newName + "' existiert bereits, soll diese ersetzt werden?", "Datei ersetzen?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{"Ja", "Nein"}, "Nein"); replaceDocument = response == JOptionPane.YES_OPTION; if (!replaceDocument) { - newName = FileUtils.getNewFileName(newName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für PDF-Dokument"); + newName = FileUtils.getNewFileName(dto, newName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für PDF-Dokument"); if (newName == null || "".equals(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -5964,7 +5964,7 @@ private void mnuUseDocumentAsTemplateActionPerformed(java.awt.event.ActionEvent for (ArchiveFileDocumentsBean doc : selectedDocs) { if (doc.getName().toLowerCase().endsWith(".ods") || doc.getName().toLowerCase().endsWith(".odt") || doc.getName().toLowerCase().endsWith(".docx")) { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), this, "Dokument als Vorlage speichern"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, new Date(), false, this, "Dokument als Vorlage speichern"); if (newName == null || "".equals(newName)) { this.lastPopupClosed = System.currentTimeMillis(); @@ -6800,7 +6800,7 @@ private void mnuMoveDocumentToOtherCaseActionPerformed(java.awt.event.ActionEven try { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument verschieben"); + String newName = FileUtils.getNewFileName(sel, doc.getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Dokument verschieben"); if (newName == null || "".equalsIgnoreCase(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -7440,7 +7440,7 @@ public void drop(DropTargetDropEvent dtde) { ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, p, dto.getId(), caseFolderPanel1, files, caseFolderPanel1.getFoldersListPanel().getRootFolder(), null); + UploadDocumentsAction a = new UploadDocumentsAction(pi, p, dto, caseFolderPanel1, files, caseFolderPanel1.getFoldersListPanel().getRootFolder(), null); a.start(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java index ade7fdc26..ba3234917 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java @@ -1293,7 +1293,7 @@ public void setNameTemplate(DocumentNameTemplate nameTemplate) { this.documentDate=new Date(); - + String extension=FileUtils.getExtension(this.documentFilename); String docName=locator.lookupArchiveFileServiceRemote().getNewDocumentName(this.documentFilename, this.documentDate, nameTemplate); ArchiveFileBean selectedCase=null; @@ -1303,6 +1303,11 @@ public void setNameTemplate(DocumentNameTemplate nameTemplate) { HashMap placeHolders=TemplatesUtil.getPlaceHolderValues(docName, selectedCase, this.parties, null, this.allPartyTypes, this.formPlaceHolders, this.formPlaceHolderValues, this.caseLawyer, this.caseAssistant); docName=TemplatesUtil.replacePlaceHolders(docName, placeHolders); docName=FileUtils.sanitizeFileName(docName); + + // remove any extension, because of the template it might be somewhere in the middle of the new name + docName=docName.replace("." + extension, ""); + + // add back extension docName=FileUtils.preserveExtension(this.documentFilename, docName); this.setDocumentFilenameNew(docName); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java index eb533fa55..b772f6af9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java @@ -794,7 +794,7 @@ public void finishedEvent() { try { ArchiveFileBean exportCase=(ArchiveFileBean)this.data.get("export.case"); byte[] content = FileUtils.readFile(new File(resultFile)); - String newName = FileUtils.getNewFileName(new File(resultFile).getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "PDF-Export zur Akte speichern"); + String newName = FileUtils.getNewFileName(exportCase, new File(resultFile).getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "PDF-Export zur Akte speichern"); if (newName == null || "".equalsIgnoreCase(newName)) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java index 206c9eb90..8937197c3 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java @@ -689,7 +689,7 @@ public class UploadDocumentsAction extends ProgressableAction { private static final Logger log = Logger.getLogger(UploadDocumentsAction.class.getName()); - private String archiveFileKey; + private ArchiveFileBean archiveFile; private Component owner; private CaseFolderPanel docTarget; private CaseFolder targetFolder = null; @@ -697,10 +697,10 @@ public class UploadDocumentsAction extends ProgressableAction { private List files; - public UploadDocumentsAction(ProgressIndicator i, Component owner, String archiveFileKey, CaseFolderPanel docTarget, List files, CaseFolder targetFolder, Invoice invoice) { + public UploadDocumentsAction(ProgressIndicator i, Component owner, ArchiveFileBean archiveFile, CaseFolderPanel docTarget, List files, CaseFolder targetFolder, Invoice invoice) { super(i, false); - this.archiveFileKey = archiveFileKey; + this.archiveFile = archiveFile; this.owner = owner; this.docTarget = docTarget; this.files = files; @@ -761,20 +761,20 @@ private boolean processFile(File f, CaseFolder folder, ArchiveFileServiceRemote byte[] data = FileUtils.readFile(f); String newName = f.getName(); - boolean documentExists = afs.doesDocumentExist(this.archiveFileKey, newName); + boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, false, new Date(), this.indicator, "neuer Dateiname"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, false, new Date(), true, this.indicator, "neuer Dateiname"); if (newName == null || "".equals(newName)) { EditorsRegistry.getInstance().clearStatus(true); ThreadUtils.setDefaultCursor(this.owner); return false; } - documentExists = afs.doesDocumentExist(this.archiveFileKey, newName); + documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); } - final ArchiveFileDocumentsBean doc = afs.addDocument(this.archiveFileKey, newName, data, null, null); + final ArchiveFileDocumentsBean doc = afs.addDocument(this.archiveFile.getId(), newName, data, null, null); if (this.invoice != null) { afs.linkInvoiceDocument(doc.getId(), invoice.getId()); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form index 9cdddaf81..6056b8f8f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form @@ -432,7 +432,6 @@ - diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java index 38baa671e..be13dd124 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java @@ -1258,7 +1258,7 @@ private void cmdRenameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR String oldName = selectedValue.toString(); - String newName = FileUtils.getNewFileName(oldName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Vorlage umbenennen"); + String newName = FileUtils.getNewFileName(null, oldName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Vorlage umbenennen"); if (newName==null || newName.isEmpty()) { JOptionPane.showMessageDialog(this, "Name darf nicht leer sein.", CommonStrings.HINT, JOptionPane.INFORMATION_MESSAGE); return; @@ -1291,7 +1291,7 @@ private void cmdDuplicateActionPerformed(java.awt.event.ActionEvent evt) {//GEN- String oldName = selectedValue.toString(); - String newName = FileUtils.getNewFileName(oldName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Vorlage duplizieren"); + String newName = FileUtils.getNewFileName(null, oldName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Vorlage duplizieren"); if (newName==null || newName.isEmpty()) { JOptionPane.showMessageDialog(this, "Name darf nicht leer sein.", CommonStrings.HINT, JOptionPane.INFORMATION_MESSAGE); return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java index 39d2e7137..43d5e946e 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java @@ -1971,7 +1971,7 @@ private void mnuSearchSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN } } - String newName = FileUtils.getNewFileName(selected.toString(), true); + String newName = FileUtils.getNewFileName(sel, selected.toString(), true, true); if (newName == null) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java index c4eb3e1d5..032c4ee9d 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java @@ -936,7 +936,7 @@ public PasswordAuthentication getPasswordAuthentication() { newName = newName + ".eml"; newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { newName = "E-Mail"; @@ -948,7 +948,7 @@ public PasswordAuthentication getPasswordAuthentication() { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java index bd76c7de2..c942874aa 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java @@ -963,7 +963,7 @@ public PasswordAuthentication getPasswordAuthentication() { newName = newName + ".eml"; newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { @@ -976,7 +976,7 @@ public PasswordAuthentication getPasswordAuthentication() { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java index 44b69e8fd..a744ae5f0 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java @@ -1371,7 +1371,7 @@ private void mnuRenameTemplateActionPerformed(java.awt.event.ActionEvent evt) {/ } DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) tp.getLastPathComponent(); GenericNode folder = (GenericNode) selNode.getUserObject(); - String newName=FileUtils.getNewFileName(this.lstTemplates.getSelectedValue().toString(), false, null, this, "Vorlage umbenennen"); + String newName=FileUtils.getNewFileName(null, this.lstTemplates.getSelectedValue().toString(), false, null, false, this, "Vorlage umbenennen"); if(newName==null) return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java index 11ac84324..c97795dca 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java @@ -666,6 +666,7 @@ import com.jdimension.jlawyer.client.editors.EditorsRegistry; import com.jdimension.jlawyer.client.launcher.LauncherFactory; import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.server.utils.ServerFileUtils; import java.awt.Component; import java.awt.Toolkit; @@ -721,14 +722,6 @@ private FileUtils() { } - public static String getExtension(String fileName) { - int index = fileName.lastIndexOf('.'); - if (index > -1 && index < fileName.length()) { - return fileName.substring(index + 1); - } - return "url-with-no-extension"; - } - public Icon getFileTypeIcon(String fileName) { if (fileName == null) { @@ -841,19 +834,19 @@ public static String getFileSizeHumanReadable(long size) { } } - public static String getNewFileName(String currentFileName, boolean datetimePrefix) { - return getNewFileName(currentFileName, datetimePrefix, new java.util.Date()); + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, boolean applyNameTemplate) { + return getNewFileName(selectedCase, currentFileName, datetimePrefix, new java.util.Date(), applyNameTemplate); } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate) { - return getNewFileName(currentFileName, datetimePrefix, d, EditorsRegistry.getInstance().getMainWindow(), "Datei benennen"); + return getNewFileName(selectedCase, currentFileName, datetimePrefix, d, applyNameTemplate, EditorsRegistry.getInstance().getMainWindow(), "Datei benennen"); } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d, Component parent) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate, Component parent) { - return getNewFileName(currentFileName, datetimePrefix, d, parent, "Datei benennen"); + return getNewFileName(selectedCase, currentFileName, datetimePrefix, d, applyNameTemplate, parent, "Datei benennen"); } @@ -1058,7 +1051,7 @@ public static void cleanupTempFile(String url) { } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d, Component parent, String title) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate, Component parent, String title) { String dtPrefix = ""; if (datetimePrefix) { @@ -1069,8 +1062,13 @@ public static String getNewFileName(String currentFileName, boolean datetimePref parent = EditorsRegistry.getInstance().getMainWindow(); } - NewFilenameOptionPanel p = new NewFilenameOptionPanel(); - p.setFilename(dtPrefix + currentFileName); + NewFilenameOptionPanel p = null; + if(selectedCase==null) + p = new NewFilenameOptionPanel(); + else + p = new NewFilenameOptionPanel(selectedCase); + + p.setFilename(currentFileName, d, applyNameTemplate); JOptionPane pane = new JOptionPane(p, JOptionPane.QUESTION_MESSAGE); JDialog dialog = pane.createDialog(parent, title); dialog.doLayout(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form index ce5297ee2..231730748 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form @@ -1,6 +1,14 @@
+ + + + + + + + @@ -27,15 +35,21 @@ - + + + + + + + + + + + + - - - - - @@ -46,9 +60,10 @@ + - + @@ -67,12 +82,22 @@ - + - + + + + + + + + + + + diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java index fa7a769c2..4c76456a9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java @@ -663,8 +663,27 @@ */ package com.jdimension.jlawyer.client.utils; +import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.settings.UserSettings; +import com.jdimension.jlawyer.persistence.AppOptionGroupBean; +import com.jdimension.jlawyer.persistence.AppUserBean; +import com.jdimension.jlawyer.persistence.ArchiveFileAddressesBean; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; +import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; +import com.jdimension.jlawyer.persistence.PartyTypeBean; +import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import com.jdimension.jlawyer.services.PartiesTriplet; import java.awt.Container; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; import javax.swing.JDialog; +import javax.swing.JMenuItem; +import org.apache.log4j.Logger; /** * @@ -672,21 +691,185 @@ */ public class NewFilenameOptionPanel extends javax.swing.JPanel { + private static final Logger log = Logger.getLogger(NewFilenameOptionPanel.class.getName()); + + private ArrayList existingFileNames = new ArrayList<>(); + + private DocumentNameTemplate nameTemplate=null; + + // caching for data that is required to build the file name if it contains place holders + private List allPartyTypes = null; + private Collection formPlaceHolders = null; + private HashMap formPlaceHolderValues = null; + private AppUserBean caseLawyer = null; + private AppUserBean caseAssistant = null; + private List parties = new ArrayList<>(); + + private ArchiveFileBean selectedCase = null; + private Date documentDate=null; + private String documentFilename=null; + private String documentFilenameNew=null; + /** * Creates new form NewFilenameOptionPanel */ public NewFilenameOptionPanel() { initComponents(); + + initializeOptions(); + } + + public NewFilenameOptionPanel(ArchiveFileBean selectedCase) { + initComponents(); + + initializeOptions(); + + this.selectedCase = selectedCase; + if (this.selectedCase != null) { + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + Collection docs = locator.lookupArchiveFileServiceRemote().getDocuments(selectedCase.getId()); + for (ArchiveFileDocumentsBean d : docs) { + existingFileNames.add(d.getName().toLowerCase()); + } + + // cached and passed to BulkSaveEntry to avoid loading for each entry + this.allPartyTypes = locator.lookupSystemManagementRemote().getPartyTypes(); + if (this.selectedCase != null) { + try { + this.caseAssistant = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getAssistant()); + } catch (Exception ex) { + } + try { + this.caseLawyer = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getLawyer()); + } catch (Exception ex) { + } + this.formPlaceHolders = locator.lookupFormsServiceRemote().getPlaceHoldersForCase(this.selectedCase.getId()); + this.formPlaceHolderValues = locator.lookupFormsServiceRemote().getPlaceHolderValuesForCase(this.selectedCase.getId()); + + try { + List involved = locator.lookupArchiveFileServiceRemote().getInvolvementDetailsForCase(this.selectedCase.getId(), false); + for (ArchiveFileAddressesBean aab : involved) { + parties.add(new PartiesTriplet(aab.getAddressKey(), aab.getReferenceType(), aab)); + } + } catch (Exception ex) { + log.error("Could not load involvements for case " + this.selectedCase.getId(), ex); + } + } + + } catch (Exception ex) { + log.error("Error getting docments for case " + selectedCase.getId(), ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Dokumente der Akte", "Dokumente speichern"); + } + } } - public void setFilename(String name) { - this.txtNewName.setText(name); - this.lblIcon.setIcon(FileUtils.getInstance().getFileTypeIcon(name)); + private void initializeOptions() { + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + List allNameTemplates = locator.lookupSystemManagementRemote().getDocumentNameTemplates(); + DocumentNameTemplate defaultNameTemplate = locator.lookupSystemManagementRemote().getDefaultDocumentNameTemplate(); + + this.popNameTemplates.removeAll(); + + for (DocumentNameTemplate t : allNameTemplates) { + JMenuItem mi = new JMenuItem(t.getDisplayName()); + mi.addActionListener((ActionEvent e) -> { + setNameTemplate(t); + }); + popNameTemplates.add(mi); + + } + this.nameTemplate=defaultNameTemplate; + } catch (Exception ex) { + log.error("Error connecting to server", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Dateinamenvorlagen", "Dateinamen"); + } + } + + public void setNameTemplate(DocumentNameTemplate nameTemplate) { + this.nameTemplate = nameTemplate; + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + String extension=FileUtils.getExtension(this.documentFilename); + String docName=locator.lookupArchiveFileServiceRemote().getNewDocumentName(this.documentFilename, this.documentDate, this.nameTemplate); + + HashMap placeHolders=TemplatesUtil.getPlaceHolderValues(docName, selectedCase, this.parties, null, this.allPartyTypes, this.formPlaceHolders, this.formPlaceHolderValues, this.caseLawyer, this.caseAssistant); + docName=TemplatesUtil.replacePlaceHolders(docName, placeHolders); + docName=FileUtils.sanitizeFileName(docName); + + // remove any extension, because of the template it might be somewhere in the middle of the new name + docName=docName.replace("." + extension, ""); + + // add back extension + docName=FileUtils.preserveExtension(this.documentFilename, docName); + + + this.setDocumentFilenameNew(docName); + + } catch (Exception ex) { + log.error("Error getting new document name", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Anwenden der Dateinamensvorschrift", "Dateinamen"); + } + } + + private void setDocumentFilenameNew(String documentFilenameNew) { + this.documentFilenameNew = documentFilenameNew; + this.txtNewName.setText(documentFilenameNew); + this.fileNameChanged(); + } + + private void fileNameChanged() { + this.documentFilenameNew=this.txtNewName.getText(); + String oldExt=FileUtils.getExtension(this.documentFilename); + String newExt=FileUtils.getExtension(this.documentFilenameNew); + if(!oldExt.equalsIgnoreCase(newExt)) { + int caretPosition=this.txtNewName.getCaretPosition(); + this.documentFilenameNew=FileUtils.preserveExtension(this.documentFilename, this.documentFilenameNew); + this.txtNewName.setText(this.documentFilenameNew); + if(this.txtNewName.getText().length()>=caretPosition) + this.txtNewName.setCaretPosition(caretPosition); + } + + // use may have typed invalid characters + String checkedName=FileUtils.sanitizeFileName(this.documentFilenameNew); + if(!checkedName.equals(this.txtNewName.getText())) { + int caretPosition=this.txtNewName.getCaretPosition(); + this.txtNewName.setText(checkedName); + this.documentFilenameNew=checkedName; + if(this.txtNewName.getText().length()>=caretPosition) + this.txtNewName.setCaretPosition(caretPosition); + } } + public void setFilename(String name, Date documentDate, boolean applyNameTemplate) { + + if(documentDate==null) + this.documentDate=new Date(); + else + this.documentDate=documentDate; + + this.documentFilename=name; + if(applyNameTemplate) + this.setNameTemplate(this.nameTemplate); + else + this.setDocumentFilenameNew(name); + + this.lblIcon.setIcon(FileUtils.getInstance().getFileTypeIcon(name)); + + } + public String getFilename() { - return this.txtNewName.getText(); + if(StringUtils.isEmpty(this.txtNewName.getText())) + return null; + else + return FileUtils.preserveExtension(this.documentFilename, this.txtNewName.getText()); } /** @@ -698,10 +881,12 @@ public String getFilename() { // //GEN-BEGIN:initComponents private void initComponents() { + popNameTemplates = new javax.swing.JPopupMenu(); lblIcon = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); txtNewName = new javax.swing.JTextField(); - lblCancel = new javax.swing.JButton(); + cmdCancel = new javax.swing.JButton(); + cmdNameTemplate = new javax.swing.JButton(); setPreferredSize(new java.awt.Dimension(600, 81)); @@ -709,10 +894,17 @@ private void initComponents() { jLabel1.setText("neuer Dateiname:"); - lblCancel.setText("Abbrechen"); - lblCancel.addActionListener(new java.awt.event.ActionListener() { + cmdCancel.setText("Abbrechen"); + cmdCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - lblCancelActionPerformed(evt); + cmdCancelActionPerformed(evt); + } + }); + + cmdNameTemplate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N + cmdNameTemplate.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(java.awt.event.MouseEvent evt) { + cmdNameTemplateMouseReleased(evt); } }); @@ -726,11 +918,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) - .addGap(0, 480, Short.MAX_VALUE)) - .addComponent(txtNewName))) - .addGroup(layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) - .addComponent(lblCancel)) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 534, Short.MAX_VALUE) + .addComponent(cmdCancel)) + .addComponent(txtNewName)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdNameTemplate)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -739,30 +935,38 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtNewName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblIcon)) + .addComponent(lblIcon) + .addComponent(cmdNameTemplate)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lblCancel) + .addComponent(cmdCancel) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents - private void lblCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lblCancelActionPerformed + private void cmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCancelActionPerformed this.txtNewName.setText(""); - Container dialog=this.findDialog(this); + Container dialog = this.findDialog(this); dialog.setVisible(false); - }//GEN-LAST:event_lblCancelActionPerformed + }//GEN-LAST:event_cmdCancelActionPerformed + + private void cmdNameTemplateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdNameTemplateMouseReleased + this.popNameTemplates.show(this.cmdNameTemplate, evt.getX(), evt.getY()); + }//GEN-LAST:event_cmdNameTemplateMouseReleased private Container findDialog(Container c) { - while(!(c.getParent() instanceof JDialog) && c.getParent()!=null) - c=c.getParent(); - + while (!(c.getParent() instanceof JDialog) && c.getParent() != null) { + c = c.getParent(); + } + return c.getParent(); } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cmdCancel; + private javax.swing.JButton cmdNameTemplate; private javax.swing.JLabel jLabel1; - private javax.swing.JButton lblCancel; private javax.swing.JLabel lblIcon; + private javax.swing.JPopupMenu popNameTemplates; private javax.swing.JTextField txtNewName; // End of variables declaration//GEN-END:variables } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java index d22967b28..35824cbac 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java @@ -670,6 +670,7 @@ import com.jdimension.jlawyer.client.utils.StringUtils; import com.jdimension.jlawyer.client.wizard.*; import com.jdimension.jlawyer.epost.EpostLetter; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.ArchiveFileHistoryBean; import com.jdimension.jlawyer.services.ArchiveFileServiceRemote; @@ -882,6 +883,8 @@ public void display() { try { + ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); + ArchiveFileBean selectedCase=afs.getArchiveFile(this.data.get("epost.letter.caseid").toString()); String newName = "E-POST-Brief_" + l.getFileName(); if (newName.length() > 228) { @@ -889,7 +892,7 @@ public void display() { } newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this, "Datei benennen"); + newName = FileUtils.getNewFileName(selectedCase, newName, true, sentPrefix, true, this, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { newName = "E-POST-Brief"; @@ -898,11 +901,10 @@ public void display() { if (!newName.toLowerCase().endsWith(".pdf")) { newName = newName + ".pdf"; } - ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); boolean documentExists = afs.doesDocumentExist(this.data.get("epost.letter.caseid").toString(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this, "Datei benennen"); + newName = FileUtils.getNewFileName(selectedCase, newName, true, sentPrefix, true, this, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } @@ -912,7 +914,7 @@ public void display() { } if (newName != null) { - ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); + ArchiveFileDocumentsBean newDoc = afs.addDocument(this.data.get("epost.letter.caseid").toString(), newName, (byte[]) this.data.get("pdf.bytes"), "", null); ArchiveFileHistoryBean historyDto = new ArchiveFileHistoryBean(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java index 7098cccd8..23fbca6b3 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java @@ -1259,7 +1259,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN for (String id : faxEntriesIds) { String defaultName = locator.lookupVoipServiceRemote().getNewFaxReportFileName(id); - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); + defaultName = FileUtils.getNewFileName(faxEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); if(defaultName==null) { this.clearDetails(); return; @@ -1267,7 +1267,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN boolean documentExists = locator.lookupArchiveFileServiceRemote().doesDocumentExist(faxEntries.get(id).getCase().getId(), defaultName); while (documentExists) { - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); + defaultName = FileUtils.getNewFileName(faxEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); if (defaultName == null || "".equals(defaultName)) { this.clearDetails(); return; @@ -1280,7 +1280,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN for (int id : epostEntriesIds) { String defaultName = locator.lookupVoipServiceRemote().getNewEpostReportFileName(id); - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); + defaultName = FileUtils.getNewFileName(epostEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); if(defaultName==null) { this.clearDetails(); return; @@ -1288,7 +1288,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN boolean documentExists = locator.lookupArchiveFileServiceRemote().doesDocumentExist(epostEntries.get(id).getCase().getId(), defaultName); while (documentExists) { - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); + defaultName = FileUtils.getNewFileName(epostEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); if (defaultName == null || "".equals(defaultName)) { this.clearDetails(); return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java index 035113b45..2b496276a 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java @@ -673,6 +673,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.settings.UserSettings; import com.jdimension.jlawyer.client.utils.FileUtils; import com.jdimension.jlawyer.client.utils.StringUtils; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.CaseFolder; import com.jdimension.jlawyer.persistence.CaseFolderSettings; @@ -727,7 +728,7 @@ public class CaseFolderPanel extends javax.swing.JPanel implements EventConsumer private HashMap linkedInvoices=new HashMap<>(); private ArchiveFilePanel caseContainer = null; private JPopupMenu documentsPopup = null; - private String caseId = null; + private ArchiveFileBean selectedCase = null; /** * Creates new form CaseFolderPanel @@ -769,12 +770,12 @@ public FoldersListPanel getFoldersListPanel() { return this.foldersListPanel; } - public String getCaseId() { - return this.caseId; + public ArchiveFileBean getCase() { + return this.selectedCase; } - public void setCaseId(String caseId) { - this.caseId = caseId; + public void setCase(ArchiveFileBean afb) { + this.selectedCase = afb; } public CaseFolderPanel() { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java index b63d110a5..56495aaa7 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java @@ -1123,7 +1123,7 @@ public void drop(DropTargetDropEvent dtde) { dtde.rejectDrop(); } - if (this.parent.getCaseFolderPanel().getCaseId() == null) { + if (this.parent.getCaseFolderPanel().getCase() == null) { dtde.rejectDrop(); } @@ -1150,7 +1150,7 @@ public void drop(DropTargetDropEvent dtde) { ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, EditorsRegistry.getInstance().getMainEditorsPane(), this.parent.getCaseFolderPanel().getCaseId(), this.parent.getCaseFolderPanel(), files, this.folder, null); + UploadDocumentsAction a = new UploadDocumentsAction(pi, EditorsRegistry.getInstance().getMainEditorsPane(), this.parent.getCaseFolderPanel().getCase(), this.parent.getCaseFolderPanel(), files, this.folder, null); a.start(); diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java index d8a24acc5..05c5aa5d3 100755 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java @@ -835,7 +835,8 @@ public static ArrayList getAllPlaceHolders(List allPartyTypesPla ArrayList ALLPLACEHOLDERS = new ArrayList<>(); - ALLPLACEHOLDERS.addAll(formsPlaceHolders); + if(formsPlaceHolders!=null) + ALLPLACEHOLDERS.addAll(formsPlaceHolders); ALLPLACEHOLDERS.add(PROFIL_FIRMA); ALLPLACEHOLDERS.add(PROFIL_STRASSE); diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java index 552eba2e7..d036fff96 100755 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java @@ -699,6 +699,14 @@ protected ServerFileUtils() { } + public static String getExtension(String fileName) { + int index = fileName.lastIndexOf('.'); + if (index > -1 && index < fileName.length()) { + return fileName.substring(index + 1); + } + return "url-with-no-extension"; + } + public static String sanitizeFileName(String fileName) { String name = fileName; name = name.replace(",", " "); diff --git a/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql new file mode 100644 index 000000000..4930383ad --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql @@ -0,0 +1,4 @@ +insert into document_name_tpls (id, display_name, schema_syntax, default_tpl) values ('dateiname-tpl','ursprünglicher Name','DATEINAME',0); + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','2.7.0.9') ON DUPLICATE KEY UPDATE settingValue = '2.7.0.9'; +commit; \ No newline at end of file