|
|
@ -1926,15 +1926,15 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
nameField.getDocument().addDocumentListener(new DocumentListener() { |
|
|
|
nameField.getDocument().addDocumentListener(new DocumentListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void changedUpdate(DocumentEvent e) { |
|
|
|
public void changedUpdate(DocumentEvent e) { |
|
|
|
validInput(); |
|
|
|
resetInputChecker(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
validInput(); |
|
|
|
resetInputChecker(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void removeUpdate(DocumentEvent e) { |
|
|
|
public void removeUpdate(DocumentEvent e) { |
|
|
|
validInput(); |
|
|
|
resetInputChecker(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
nameField.selectAll(); |
|
|
|
nameField.selectAll(); |
|
|
@ -1993,7 +1993,9 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void confirmClose() { |
|
|
|
private void confirmClose() { |
|
|
|
|
|
|
|
if (!validInput()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
}; |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
|
|
|
|
|
|
|
|
// 处理不合法的文件夹名称
|
|
|
|
// 处理不合法的文件夹名称
|
|
|
@ -2028,12 +2030,13 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validInput() { |
|
|
|
private boolean validInput() { |
|
|
|
|
|
|
|
boolean valid = true; |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(userInput)) { |
|
|
|
if (StringUtils.isEmpty(userInput)) { |
|
|
|
confirmButton.setEnabled(false); |
|
|
|
confirmButton.setEnabled(false); |
|
|
|
|
|
|
|
valid = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean duplicate = false; |
|
|
|
boolean duplicate = false; |
|
|
@ -2045,7 +2048,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
valid = valid && !duplicate; |
|
|
|
if (duplicate) { |
|
|
|
if (duplicate) { |
|
|
|
nameField.selectAll(); |
|
|
|
nameField.selectAll(); |
|
|
|
// 如果文件名已存在,则灰掉确认按钮
|
|
|
|
// 如果文件名已存在,则灰掉确认按钮
|
|
|
@ -2059,6 +2062,12 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
warnLabel.setVisible(false); |
|
|
|
warnLabel.setVisible(false); |
|
|
|
confirmButton.setEnabled(true); |
|
|
|
confirmButton.setEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return valid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void resetInputChecker() { |
|
|
|
|
|
|
|
warnLabel.setVisible(false); |
|
|
|
|
|
|
|
confirmButton.setEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|