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 231730748..a483c4db6 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
@@ -81,6 +81,9 @@
+
+
+
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 fdcfabbf2..46ff3bf24 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
@@ -683,6 +683,7 @@
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JMenuItem;
+import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
/**
@@ -694,8 +695,8 @@ 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;
+
+ private DocumentNameTemplate nameTemplate = null;
// caching for data that is required to build the file name if it contains place holders
private List allPartyTypes = null;
@@ -706,22 +707,22 @@ public class NewFilenameOptionPanel extends javax.swing.JPanel {
private List parties = new ArrayList<>();
private ArchiveFileBean selectedCase = null;
- private Date documentDate=null;
- private String documentFilename=null;
- private String documentFilenameNew=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;
@@ -765,7 +766,7 @@ public NewFilenameOptionPanel(ArchiveFileBean selectedCase) {
}
}
}
-
+
private void initializeOptions() {
try {
ClientSettings settings = ClientSettings.getInstance();
@@ -783,33 +784,32 @@ private void initializeOptions() {
popNameTemplates.add(mi);
}
- this.nameTemplate=defaultNameTemplate;
+ 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);
-
+ 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, "");
-
+ docName = docName.replace("." + extension, "");
+
// add back extension
- docName=FileUtils.preserveExtension(this.documentFilename, docName);
-
-
+ docName = FileUtils.preserveExtension(this.documentFilename, docName);
+
this.setDocumentFilenameNew(docName);
} catch (Exception ex) {
@@ -823,53 +823,58 @@ private void setDocumentFilenameNew(String 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.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)
+ 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();
+ 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.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)
+
+ if (documentDate == null) {
+ this.documentDate = new Date();
+ } else {
+ this.documentDate = documentDate;
+ }
+
+ this.documentFilename = name;
+ if (applyNameTemplate) {
this.setNameTemplate(this.nameTemplate);
- else
+ } else {
this.setDocumentFilenameNew(name);
-
+ }
+
this.lblIcon.setIcon(FileUtils.getInstance().getFileTypeIcon(name));
}
public String getFilename() {
- if(StringUtils.isEmpty(this.txtNewName.getText()))
+ if (StringUtils.isEmpty(this.txtNewName.getText())) {
return null;
- else
+ } else {
return FileUtils.preserveExtension(this.documentFilename, this.txtNewName.getText());
+ }
}
/**
@@ -894,6 +899,12 @@ private void initComponents() {
jLabel1.setText("neuer Dateiname:");
+ txtNewName.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ txtNewNameFocusGained(evt);
+ }
+ });
+
cmdCancel.setText("Abbrechen");
cmdCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -953,6 +964,15 @@ private void cmdNameTemplateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-
this.popNameTemplates.show(this.cmdNameTemplate, evt.getX(), evt.getY());
}//GEN-LAST:event_cmdNameTemplateMouseReleased
+ private void txtNewNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNewNameFocusGained
+ int dotPos = this.txtNewName.getText().lastIndexOf(".");
+ this.txtNewName.requestFocusInWindow();
+ if (dotPos > -1) {
+ this.txtNewName.setSelectionStart(0);
+ this.txtNewName.setSelectionEnd(dotPos);
+ }
+ }//GEN-LAST:event_txtNewNameFocusGained
+
private Container findDialog(Container c) {
while (!(c.getParent() instanceof JDialog) && c.getParent() != null) {
c = c.getParent();