Browse Source

Merge pull request #465 in DESIGN/design from ~YAOH.WU/design:feature/10.0 to feature/10.0

* commit '21f518ed6c1169c49b8bcd261f2eadfe281f1200':
  多人远程
  多人远程
  bug 处理
  无任务,自测bug修复
  新建文件夹 交互修订
  REPORT-10896 多人远程设计
research/10.0
yaoh.wu 6 years ago
parent
commit
db21f75849
  1. 32
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 10
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  3. 93
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  4. 82
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  5. 44
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  6. 23
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

32
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -26,6 +26,7 @@ import com.fr.general.xml.GeneralXMLTools;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap; import com.fr.stable.ListMap;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -38,6 +39,7 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
@ -850,10 +852,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径 * @param filePath 文件路径
*/ */
public void addRecentOpenedFilePath(String filePath) { public void addRecentOpenedFilePath(String filePath) {
filePath = FilenameUtils.standard(filePath);
// 先删除. // 先删除.
if (getRecentOpenedFilePathList().contains(filePath)) { getRecentOpenedFilePathList().remove(filePath);
getRecentOpenedFilePathList().remove(filePath);
}
getRecentOpenedFilePathList().add(0, filePath); getRecentOpenedFilePathList().add(0, filePath);
checkRecentOpenedFileNum(); checkRecentOpenedFileNum();
@ -862,8 +863,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 替换近期打开的文件路径 * 替换近期打开的文件路径
* *
* @param oldPath 旧的路径 * @param oldPath path 使用 unix 分隔符
* @param newPath 新的路径 * @param newPath path 使用 unix 分隔符
*/ */
public void replaceRecentOpenedFilePath(String oldPath, String newPath) { public void replaceRecentOpenedFilePath(String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList(); List<String> list = getRecentOpenedFilePathList();
@ -872,28 +873,22 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
list.remove(oldPath); list.remove(oldPath);
list.add(index, newPath); list.add(index, newPath);
} }
oldPath = oldPath.replaceAll("\\\\", "/");
if (list.contains(oldPath)) {
int index = list.indexOf(oldPath);
list.remove(oldPath);
list.add(index, newPath);
}
} }
/** /**
* 替换近期打开的文件路径 * 替换近期打开的文件路径
* *
* @param type 文件类型,文件夹true,文件false * @param type 文件类型,文件夹true,文件false
* @param oldPath 旧的路径 使用反斜杠分割 * @param oldPath path 使用 unix 分隔符
* @param newPath 新的路径 使用反斜杠分割 * @param newPath path 使用 unix 分隔符
*/ */
public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) { public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList(); List<String> list = getRecentOpenedFilePathList();
ListIterator<String> iterator = list.listIterator(); ListIterator<String> iterator = list.listIterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String s = iterator.next().replaceAll("/", "\\\\"); String s = FilenameUtils.standard(iterator.next());
if (type ? s.contains(oldPath + "\\") : s.equals(oldPath)) { if (type ? s.contains(oldPath + CoreConstants.SEPARATOR) : s.equals(oldPath)) {
s = s.replace(oldPath, newPath); s = s.replace(oldPath, newPath);
iterator.set(s); iterator.set(s);
} }
@ -916,9 +911,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径 * @param filePath 文件路径
*/ */
public void removeRecentOpenedFilePath(String filePath) { public void removeRecentOpenedFilePath(String filePath) {
if (getRecentOpenedFilePathList().contains(filePath)) { filePath = FilenameUtils.standard(filePath);
getRecentOpenedFilePathList().remove(filePath); getRecentOpenedFilePathList().remove(filePath);
}
} }
@ -1637,7 +1631,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String n = reader.getTagName(); String n = reader.getTagName();
if ("Path".equals(n)) { if ("Path".equals(n)) {
String path = reader.getElementValue(); String path = FilenameUtils.standard(reader.getElementValue());
if (StringUtils.isNotEmpty(path)) { if (StringUtils.isNotEmpty(path)) {
recentOpenedFileList.add(path); recentOpenedFileList.add(path);
} }

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

@ -11,7 +11,9 @@ import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
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 java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -270,8 +272,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
template = this.getCurrentEditingTemplate(); template = this.getCurrentEditingTemplate();
if (template != null) { if (template != null) {
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\"); String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) { if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE(); FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to)); renameFile.setPath(editingPath.replace(from, to));
} }
@ -279,8 +281,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
for (int i = 0; i < this.getHistoryCount(); i++) { for (int i = 0; i < this.getHistoryCount(); i++) {
template = this.get(i); template = this.get(i);
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\"); String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) { if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE(); FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to)); renameFile.setPath(editingPath.replace(from, to));
} }

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

@ -44,6 +44,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION; import static javax.swing.JOptionPane.YES_NO_OPTION;
public class TemplateTreePane extends JPanel implements FileOperations { public class TemplateTreePane extends JPanel implements FileOperations {
@ -186,6 +187,17 @@ public class TemplateTreePane extends JPanel implements FileOperations {
*/ */
@Override @Override
public void openFile() { public void openFile() {
// 判断是否是远程设计的锁定文件
if (!WorkContext.getCurrent().isLocal()) {
FileNode node = reportletsTree.getSelectedFileNode();
if (node == null) {
return;
}
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
return;
}
}
String reportPath = reportletsTree.getSelectedTemplatePath(); String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
@ -226,11 +238,6 @@ public class TemplateTreePane extends JPanel implements FileOperations {
public void deleteFile() { public void deleteFile() {
String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File");
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes(); ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes();
// 筛选可以删除的文件 // 筛选可以删除的文件
ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>(); ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>();
@ -238,40 +245,59 @@ public class TemplateTreePane extends JPanel implements FileOperations {
for (ExpandMutableTreeNode treeNode : treeNodes) { for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, deletableNodes, lockedNodes); checkFreeOrLock(treeNode, deletableNodes, lockedNodes);
} }
boolean success = false;
if (lockedNodes.isEmpty()) { if (lockedNodes.isEmpty()) {
String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File");
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.OK_OPTION) { == JOptionPane.YES_OPTION) {
// 删除所有选中的即可 // 删除所有选中的即可
success = deleteNodes(Arrays.asList(treeNodes)); if (!deleteNodes(Arrays.asList(treeNodes))) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
} }
} else { } else {
String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File_And_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File");
if (deletableNodes.isEmpty()) {
// 提醒被锁定模板无法删除
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Unable_Delete_Locked_File"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"), tipContent,
UIManager.getString("OptionPane.titleText"), UIManager.getString("OptionPane.messageDialogTitle"),
YES_NO_OPTION) YES_NO_OPTION)
== JOptionPane.YES_OPTION) { == JOptionPane.YES_OPTION) {
// 删除其他 // 删除其他
success = deleteNodes(deletableNodes); if (!deleteNodes(deletableNodes)) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
} }
} }
if (!success) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.titleText"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
reportletsTree.refresh(); reportletsTree.refresh();
} }
@ -283,8 +309,11 @@ public class TemplateTreePane extends JPanel implements FileOperations {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) { if (nodeFILE.exists()) {
FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class); FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class);
success = fileAssistUtils.moveToTrash(nodeFILE.getPath()) && success; if (fileAssistUtils.moveToTrash(nodeFILE.getPath())) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {
success = false;
}
} }
} }
} }
@ -314,15 +343,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
boolean childrenEmptyLock = true; boolean childrenEmptyLock = true;
for (ExpandMutableTreeNode child : children) { for (ExpandMutableTreeNode child : children) {
childrenEmptyLock = checkFreeOrLock(child, dNodes, lNodes) && childrenEmptyLock;
boolean childEmptyLock = checkFreeOrLock(child, dNodes, lNodes);
if (childEmptyLock) {
dNodes.add(child);
} else {
lNodes.add(child);
}
childrenEmptyLock = childrenEmptyLock && childEmptyLock;
} }
boolean emptyLock = childrenEmptyLock && selfEmptyLock; boolean emptyLock = childrenEmptyLock && selfEmptyLock;
@ -383,7 +404,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;
} }

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

@ -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;
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); // 提醒保存文件
this.dispose(); 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) { if (success) {
JOptionPane.showConfirmDialog(null, HistoryTemplateListCache.getInstance().rename(fnf, path, newPath);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath);
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle();
} else {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
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)) {

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();
} }

23
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -2,11 +2,13 @@ package com.fr.design.mainframe.socketio;
import com.fr.config.RemoteConfigEvent; import com.fr.config.RemoteConfigEvent;
import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.TemplatePane;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.RemoteDesignConstants;
import com.fr.serialization.SerializerHelper; import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
@ -15,6 +17,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import com.fr.workspace.server.WorkspaceConnection;
import com.fr.workspace.server.socket.SocketInfoOperator; import com.fr.workspace.server.socket.SocketInfoOperator;
import io.socket.client.IO; import io.socket.client.IO;
import io.socket.client.Socket; import io.socket.client.Socket;
@ -84,9 +87,13 @@ public class DesignerSocketIO {
try { try {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
public void run() { public void run() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), JOptionPane.showMessageDialog(
null, 0, UIManager.getIcon("OptionPane.errorIcon")); DesignerContext.getDesignerFrame(),
TemplatePane.getInstance().editItems(); Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
EnvChangeEntrance.getInstance().chooseEnv();
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -106,12 +113,16 @@ public class DesignerSocketIO {
private static String getSocketUri(Workspace current) throws IOException { private static String getSocketUri(Workspace current) throws IOException {
URL url = new URL(current.getPath()); URL url = new URL(current.getPath());
int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort();
return String.format("%s://%s:%s%s?%s=%s", WorkspaceConnection connection = RemoteCallClient.getInstance().getConnection();
return String.format("%s://%s:%s%s?%s=%s&%s=%s",
url.getProtocol(), url.getProtocol(),
url.getHost(), url.getHost(),
port, port,
WorkspaceConstants.WS_NAMESPACE, WorkspaceConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
RemoteCallClient.getInstance().getConnection().getToken()); connection.getToken(),
RemoteDesignConstants.USER_LOCK_ID,
connection.getId()
);
} }
} }

Loading…
Cancel
Save