Browse Source

bug 处理

research/10.0
yaoh.wu 6 years ago
parent
commit
bfc608c6b0
  1. 10
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 15
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  3. 44
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java

10
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -266,14 +266,14 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
tipContent, tipContent,
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
YES_NO_OPTION) YES_NO_OPTION)
== JOptionPane.YES_OPTION) { == JOptionPane.YES_OPTION) {
// 删除所有选中的即可 // 删除所有选中的即可
if (!deleteNodes(Arrays.asList(treeNodes))) { if (!deleteNodes(Arrays.asList(treeNodes))) {
JOptionPane.showConfirmDialog(null, JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
@ -287,14 +287,14 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
tipContent, tipContent,
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
YES_NO_OPTION) YES_NO_OPTION)
== JOptionPane.YES_OPTION) { == JOptionPane.YES_OPTION) {
// 删除其他 // 删除其他
if (!deleteNodes(deletableNodes)) { if (!deleteNodes(deletableNodes)) {
JOptionPane.showConfirmDialog(null, JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
@ -406,7 +406,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (!lockedNodes.isEmpty()) { if (!lockedNodes.isEmpty()) {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"), Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"),
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
return true; return true;
} }

15
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -510,6 +510,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void confirmClose() { private void confirmClose() {
String userInput = nameField.getText().trim(); String userInput = nameField.getText().trim();
// 处理不合法的文件夹名称
userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY);
String path = FilenameUtils.standard(fnf.getPath()); String path = FilenameUtils.standard(fnf.getPath());
@ -527,13 +529,12 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/ // 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix; String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix;
//模版重命名
this.dispose(); this.dispose();
//模版重命名
boolean success = false; boolean success = false;
// 提醒保存文件
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时 // 只有一个文件未保存时
if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
@ -572,6 +573,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (StringUtils.isEmpty(userInput)) { if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false); confirmButton.setEnabled(false);
return;
} }
if (ComparatorUtils.equals(userInput, oldName)) { if (ComparatorUtils.equals(userInput, oldName)) {
@ -724,6 +726,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void confirmClose() { private void confirmClose() {
String userInput = nameField.getText().trim(); String userInput = nameField.getText().trim();
// 处理不合法的文件夹名称
userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY);
if (StringUtils.isEmpty(userInput)) { if (StringUtils.isEmpty(userInput)) {
return; return;
} }
@ -737,7 +742,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (!success) { if (!success) {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Make_Failure"), Toolkit.i18nText("Fine-Design_Basic_Make_Failure"),
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }

44
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -58,6 +58,7 @@ import javax.swing.ListModel;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -1545,25 +1546,34 @@ public class FILEChooserPane extends BasicPane {
String userInput = nameField.getText().trim(); String userInput = nameField.getText().trim();
currentDirectory.createFolder(userInput); // 处理不合法的文件夹名称
userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY);
refreshSubFileListModel();
if (currentDirectory.createFolder(userInput)) {
setSelectedFileName(userInput); refreshSubFileListModel();
// ben:这里处理有些不妥,取文件时没有考虑filefilter,不过效果一样,取的时候应该用subfilelist得data setSelectedFileName(userInput);
FILE[] allFiles = currentDirectory.listFiles(); // ben:这里处理有些不妥,取文件时没有考虑filefilter,不过效果一样,取的时候应该用subfilelist得data
int place = 0; FILE[] allFiles = currentDirectory.listFiles();
for (int i = 0; i < allFiles.length; i++) { int place = 0;
if (ComparatorUtils.equals(allFiles[i].getName(), userInput) && allFiles[i].isDirectory()) { for (int i = 0; i < allFiles.length; i++) {
place = i; if (ComparatorUtils.equals(allFiles[i].getName(), userInput) && allFiles[i].isDirectory()) {
break; place = i;
break;
}
} }
scrollPane.revalidate();
scrollPane.repaint();
int total = scrollPane.getVerticalScrollBar().getMaximum();
int value = total * place / subFileList.getModel().getSize();
scrollPane.getVerticalScrollBar().setValue(value);
} else {
JOptionPane.showConfirmDialog(FILEChooserPane.this,
Toolkit.i18nText("Fine-Design_Basic_Make_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
} }
scrollPane.revalidate();
scrollPane.repaint();
int total = scrollPane.getVerticalScrollBar().getMaximum();
int value = total * place / subFileList.getModel().getSize();
scrollPane.getVerticalScrollBar().setValue(value);
this.dispose(); this.dispose();
} }

Loading…
Cancel
Save