Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2246: Document name templates #2545

Merged
merged 11 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.form
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuSearchIndexActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="mnuDocumentNameTemplates">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/edit.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Dateinamen"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuDocumentNameTemplatesActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="mnuDocumentPreview">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
Expand Down
19 changes: 19 additions & 0 deletions j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ private void initComponents() {
mnuDocumentTags = new javax.swing.JMenuItem();
mnuScanOptions = new javax.swing.JMenuItem();
mnuSearchIndex = new javax.swing.JMenuItem();
mnuDocumentNameTemplates = new javax.swing.JMenuItem();
mnuDocumentPreview = new javax.swing.JMenuItem();
mnuCustomLauncherOptions = new javax.swing.JMenuItem();
mnuMappingTables = new javax.swing.JMenuItem();
Expand Down Expand Up @@ -1636,6 +1637,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});
mnuDocumentOptions.add(mnuSearchIndex);

mnuDocumentNameTemplates.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N
mnuDocumentNameTemplates.setText("Dateinamen");
mnuDocumentNameTemplates.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuDocumentNameTemplatesActionPerformed(evt);
}
});
mnuDocumentOptions.add(mnuDocumentNameTemplates);

mnuDocumentPreview.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/baseline_preview_black_48dp.png"))); // NOI18N
mnuDocumentPreview.setText("Dokumentenvorschau");
mnuDocumentPreview.addActionListener(new java.awt.event.ActionListener() {
Expand Down Expand Up @@ -2802,6 +2812,14 @@ private void mnuAssistantPromptsActionPerformed(java.awt.event.ActionEvent evt)
}
}//GEN-LAST:event_mnuAssistantPromptsActionPerformed

private void mnuDocumentNameTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuDocumentNameTemplatesActionPerformed
if (checkAdmin()) {
DocumentNameTemplatesSetupDialog dlg = new DocumentNameTemplatesSetupDialog(this, true);
FrameUtils.centerDialog(dlg, this);
dlg.setVisible(true);
}
}//GEN-LAST:event_mnuDocumentNameTemplatesActionPerformed

/**
* @param args the command line arguments
*/
Expand Down Expand Up @@ -2867,6 +2885,7 @@ public static void main(String args[]) {
private javax.swing.JMenuItem mnuCustomLauncherOptions;
private javax.swing.JMenuItem mnuDocumentFolderTemplates;
private javax.swing.JMenuItem mnuDocumentMonitor;
private javax.swing.JMenuItem mnuDocumentNameTemplates;
private javax.swing.JMenu mnuDocumentOptions;
private javax.swing.JMenuItem mnuDocumentPreview;
private javax.swing.JMenuItem mnuDocumentTags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,6 @@
</Container>
</SubComponents>
</Container>
<Component class="com.jdimension.jlawyer.client.bea.BeaMessageContentUI" name="beaMessageContentUI">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2472,11 +2472,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
dlg.dispose();
}

java.util.Date receivedPrefix = m.getReceptionTime();
if (receivedPrefix == null) {
receivedPrefix = new java.util.Date();
}

// user hit cancel
if (targetCase == null) {
return false;
Expand Down Expand Up @@ -2512,8 +2507,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
}

bulkEntry.setDocumentFilename(attachmentName);
bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName);

bulkSaveDlg.addEntry(bulkEntry);

}
Expand Down Expand Up @@ -2543,8 +2536,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
}

bulkEntry.setDocumentFilename(attachmentName);
bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName);

bulkSaveDlg.addEntry(bulkEntry);
}
}
Expand All @@ -2568,8 +2559,7 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
BulkSaveEntry bulkEntry = new BulkSaveEntry();
bulkEntry.setDocumentDate(m.getReceptionTime());
bulkEntry.setDocumentBytes(data);
bulkEntry.setDocumentFilename(newName);
bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + m.getId() + "_" + newName);
bulkEntry.setDocumentFilename(m.getId() + "_" + newName);
bulkSaveDlg.addEntry(bulkEntry);

}
Expand Down Expand Up @@ -2597,7 +2587,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
bulkEntry.setDocumentDate(m.getReceptionTime());
bulkEntry.setDocumentBytes(attachmentData);
bulkEntry.setDocumentFilename(attachmentName);
bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName);
bulkSaveDlg.addEntry(bulkEntry);

}
Expand Down Expand Up @@ -2627,8 +2616,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea
}

bulkEntry.setDocumentFilename(attachmentName);
bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName);

bulkSaveDlg.addEntry(bulkEntry);
}

Expand Down Expand Up @@ -2862,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";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@
*/
package com.jdimension.jlawyer.client.bea;

import com.jdimension.jlawyer.client.utils.TemplatesUtil;
import com.jdimension.jlawyer.client.calendar.CalendarUtils;
import com.jdimension.jlawyer.client.components.MultiCalDialog;
import com.jdimension.jlawyer.client.configuration.UserListCellRenderer;
Expand Down Expand Up @@ -2041,7 +2042,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
EmailTemplate tpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(tplName);

List<PartiesPanelEntry> selectedParties = this.pnlParties.getSelectedParties(new ArrayList(allPartyTypes));
ArrayList<String> placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders,new ArrayList<>());
ArrayList<String> placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders,new ArrayList<>());
HashMap<String, Object> ht = new HashMap<>();
for (String ph : placeHolderNames) {
ht.put(ph, "");
Expand Down Expand Up @@ -2069,17 +2070,17 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
partiesTriplets.add(triplet);
}
HashMap<String, Object> htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, this.contextArchiveFile, partiesTriplets, this.contextDictateSign, null, new HashMap<>(), caseLawyer, caseAssistant, author, null, null, null, null);
this.txtSubject.setText(EmailTemplateAccess.replacePlaceHolders(tpl.getSubject(), htValues));
this.txtSubject.setText(TemplatesUtil.replacePlaceHolders(tpl.getSubject(), htValues));

placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders,new ArrayList<>());
placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders,new ArrayList<>());
ht = new HashMap<>();
for (String ph : placeHolderNames) {
ht.put(ph, "");
}

htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, this.contextArchiveFile, partiesTriplets, this.contextDictateSign, null, new HashMap<>(), caseLawyer, caseAssistant, author, null, null, null, null);

String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator");
String t = TemplatesUtil.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator");
int cursorIndex = t.indexOf(PLACEHOLDER_CURSOR);
if (cursorIndex > -1) {
t = t.replace(PLACEHOLDER_CURSOR, "");
Expand Down
60 changes: 31 additions & 29 deletions ...wyer/client/mail/EmailTemplateAccess.java → ...ocumentNameTemplateTableCellRenderer.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -661,44 +661,46 @@
* For more information on this, and how to apply and follow the GNU AGPL, see
* <https://www.gnu.org/licenses/>.
*/
package com.jdimension.jlawyer.client.mail;
package com.jdimension.jlawyer.client.configuration;

import com.jdimension.jlawyer.documents.PlaceHolders;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import com.jdimension.jlawyer.persistence.DocumentNameTemplate;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import themes.colors.DefaultColorTheme;

/**
*
* @author jens
*/
public class EmailTemplateAccess {

public static ArrayList<String> getPlaceHoldersInTemplate(String templateText, List<String> allPartyTypesPlaceHolders, Collection<String> formPlaceHolders) {
ArrayList<String> result=new ArrayList<>();
if(templateText==null)
templateText="";
for (String r : PlaceHolders.getAllPlaceHolders(allPartyTypesPlaceHolders, formPlaceHolders)) {
if(templateText.contains(r))
result.add(r);

public class DocumentNameTemplateTableCellRenderer extends DefaultTableCellRenderer {

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {

DocumentNameTemplate tpl = (DocumentNameTemplate) table.getValueAt(row, 0);

Object returnRenderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

if (column == 0) {
((JLabel) ((Component) returnRenderer)).setText(tpl.getDisplayName());
}
return result;
}

public static String replacePlaceHolders(String content, HashMap<String,Object> values) {
for (String key: values.keySet()) {
String keyRegX = "\\{\\{" + key.substring(2, key.length() - 2) + "\\}\\}";
String value = (String) values.get(key);
if (value == null) {
value = "";
}

content = content.replaceAll(keyRegX, value);
if (isSelected) {
((JLabel) ((Component) returnRenderer)).setForeground(Color.WHITE);
if (column != 1) {
((JLabel) ((Component) returnRenderer)).setBackground(DefaultColorTheme.COLOR_LOGO_BLUE);
}
} else {
((JLabel) ((Component) returnRenderer)).setForeground(Color.BLACK);
if (column != 1) {
((JLabel) ((Component) returnRenderer)).setBackground(Color.WHITE);
}
}

return content;
return (Component) returnRenderer;
}

}
Loading