Skip to content

Commit

Permalink
added implementation for rename actions. issue #2246
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Aug 26, 2024
1 parent ca6d2a0 commit 2a7b6be
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 114 deletions.
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 @@ -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";
}
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 @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public boolean execute() throws Exception {
HashMap<String, CaseFolderSettings> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1303,6 +1303,11 @@ public void setNameTemplate(DocumentNameTemplate nameTemplate) {
HashMap<String, Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,18 +689,18 @@ 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;
private Invoice invoice = null;

private List<File> files;

public UploadDocumentsAction(ProgressIndicator i, Component owner, String archiveFileKey, CaseFolderPanel docTarget, List<File> files, CaseFolder targetFolder, Invoice invoice) {
public UploadDocumentsAction(ProgressIndicator i, Component owner, ArchiveFileBean archiveFile, CaseFolderPanel docTarget, List<File> files, CaseFolder targetFolder, Invoice invoice) {
super(i, false);

this.archiveFileKey = archiveFileKey;
this.archiveFile = archiveFile;
this.owner = owner;
this.docTarget = docTarget;
this.files = files;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@
</Container>
<Component class="javax.swing.JComboBox" name="cmbPlaceHolderTarget">
<Properties>
<Property name="maximumRowCount" type="int" value="15"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 2a7b6be

Please sign in to comment.