|
|
@ -15,6 +15,7 @@ import com.fr.design.file.FileToolbarStateChangeListener; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.MutilTempalteTabPane; |
|
|
|
import com.fr.design.file.MutilTempalteTabPane; |
|
|
|
|
|
|
|
import com.fr.design.file.SaveSomeTemplatePane; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
@ -36,6 +37,7 @@ import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.io.FilenameUtils; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
@ -308,6 +310,16 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileNode node = selectedOperation.getFileNode(); |
|
|
|
FileNode node = selectedOperation.getFileNode(); |
|
|
|
|
|
|
|
String lock = node.getLock(); |
|
|
|
|
|
|
|
if (lock != null && !lock.equals(node.getUserID())) { |
|
|
|
|
|
|
|
// 提醒被锁定模板无法重命名
|
|
|
|
|
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Unable_Rename_Locked_File"), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
|
|
|
WARNING_MESSAGE); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
new FileRenameDialog(node); |
|
|
|
new FileRenameDialog(node); |
|
|
|
MutilTempalteTabPane.getInstance().repaint(); |
|
|
|
MutilTempalteTabPane.getInstance().repaint(); |
|
|
|
} |
|
|
|
} |
|
|
@ -394,8 +406,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
fnf = new FileNodeFILE(node); |
|
|
|
fnf = new FileNodeFILE(node); |
|
|
|
|
|
|
|
|
|
|
|
String oldName = fnf.getName(); |
|
|
|
String oldName = fnf.getName(); |
|
|
|
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
oldName = oldName.replaceAll(suffix, ""); |
|
|
|
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); |
|
|
|
|
|
|
|
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setModal(true); |
|
|
|
this.setModal(true); |
|
|
@ -508,12 +520,14 @@ 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 = fnf.getPath(); |
|
|
|
String path = FilenameUtils.standard(fnf.getPath()); |
|
|
|
|
|
|
|
|
|
|
|
String oldName = fnf.getName(); |
|
|
|
String oldName = fnf.getName(); |
|
|
|
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
oldName = oldName.replaceAll(suffix, ""); |
|
|
|
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); |
|
|
|
|
|
|
|
|
|
|
|
// 输入为空或者没有修改
|
|
|
|
// 输入为空或者没有修改
|
|
|
|
if (ComparatorUtils.equals(userInput, oldName)) { |
|
|
|
if (ComparatorUtils.equals(userInput, oldName)) { |
|
|
@ -521,26 +535,38 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String oldPath = path.replaceAll(CoreConstants.SEPARATOR, "\\\\"); |
|
|
|
String parentPath = FilenameUtils.standard(fnf.getParent().getPath()); |
|
|
|
|
|
|
|
|
|
|
|
String parentPath = fnf.getParent().getPath().replaceAll(CoreConstants.SEPARATOR, "\\\\"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
|
|
|
|
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
|
|
|
|
String newPath = parentPath + "\\" + userInput + suffix; |
|
|
|
String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix; |
|
|
|
|
|
|
|
this.dispose(); |
|
|
|
HistoryTemplateListCache.getInstance().rename(fnf, oldPath, newPath); |
|
|
|
|
|
|
|
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), oldPath, newPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//模版重命名
|
|
|
|
//模版重命名
|
|
|
|
boolean success = selectedOperation.rename(fnf, oldPath, newPath); |
|
|
|
boolean success = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提醒保存文件
|
|
|
|
|
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); |
|
|
|
|
|
|
|
// 只有一个文件未保存时
|
|
|
|
|
|
|
|
if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { |
|
|
|
|
|
|
|
int choose = saveSomeTempaltePane.saveLastOneTemplate(); |
|
|
|
|
|
|
|
if (choose != JOptionPane.CANCEL_OPTION) { |
|
|
|
|
|
|
|
success = selectedOperation.rename(fnf, path, newPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
|
|
|
|
success = selectedOperation.rename(fnf, path, newPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); |
|
|
|
|
|
|
|
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath); |
|
|
|
selectedOperation.refresh(); |
|
|
|
selectedOperation.refresh(); |
|
|
|
DesignerContext.getDesignerFrame().setTitle(); |
|
|
|
DesignerContext.getDesignerFrame().setTitle(); |
|
|
|
this.dispose(); |
|
|
|
} else { |
|
|
|
|
|
|
|
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), |
|
|
|
if (!success) { |
|
|
|
|
|
|
|
JOptionPane.showConfirmDialog(null, |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"), |
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"), |
|
|
|
UIManager.getString("OptionPane.titleText"), |
|
|
|
UIManager.getString("OptionPane.messageDialogTitle"), |
|
|
|
JOptionPane.DEFAULT_OPTION, |
|
|
|
JOptionPane.DEFAULT_OPTION, |
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
@ -552,11 +578,12 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
String userInput = nameField.getText().trim(); |
|
|
|
|
|
|
|
|
|
|
|
String oldName = fnf.getName(); |
|
|
|
String oldName = fnf.getName(); |
|
|
|
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); |
|
|
|
oldName = oldName.replaceAll(suffix, ""); |
|
|
|
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); |
|
|
|
|
|
|
|
|
|
|
|
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)) { |
|
|
@ -665,6 +692,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
confirmClose(); |
|
|
|
confirmClose(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
confirmButton.setEnabled(false); |
|
|
|
|
|
|
|
|
|
|
|
// 取消按钮
|
|
|
|
// 取消按钮
|
|
|
|
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); |
|
|
|
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); |
|
|
@ -701,27 +729,30 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
this.setAlwaysOnTop(true); |
|
|
|
this.setAlwaysOnTop(true); |
|
|
|
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); |
|
|
|
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); |
|
|
|
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
|
|
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
|
|
GUICoreUtils.centerWindow(this); |
|
|
|
GUICoreUtils.setWindowCenter(DesignerContext.getDesignerFrame(), this); |
|
|
|
this.setVisible(true); |
|
|
|
this.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//新建文件夹
|
|
|
|
//新建文件夹
|
|
|
|
boolean success = selectedOperation.mkdir( |
|
|
|
boolean success = selectedOperation.mkdir( |
|
|
|
selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput |
|
|
|
FilenameUtils.standard(selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput) |
|
|
|
); |
|
|
|
); |
|
|
|
selectedOperation.refresh(); |
|
|
|
selectedOperation.refresh(); |
|
|
|
this.dispose(); |
|
|
|
this.dispose(); |
|
|
|
if (!success) { |
|
|
|
if (!success) { |
|
|
|
JOptionPane.showConfirmDialog(null, |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
@ -734,6 +765,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(userInput)) { |
|
|
|
if (StringUtils.isEmpty(userInput)) { |
|
|
|
confirmButton.setEnabled(false); |
|
|
|
confirmButton.setEnabled(false); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (selectedOperation.duplicated(userInput, StringUtils.EMPTY)) { |
|
|
|
if (selectedOperation.duplicated(userInput, StringUtils.EMPTY)) { |
|
|
|