Browse Source

REPORT-10896 多人远程设计

research/10.0
yaoh.wu 6 years ago
parent
commit
8ba6629390
  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. 82
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  4. 29
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  5. 13
      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.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap;
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.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
@ -850,10 +852,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径
*/
public void addRecentOpenedFilePath(String filePath) {
filePath = FilenameUtils.standard(filePath);
// 先删除.
if (getRecentOpenedFilePathList().contains(filePath)) {
getRecentOpenedFilePathList().remove(filePath);
}
getRecentOpenedFilePathList().remove(filePath);
getRecentOpenedFilePathList().add(0, filePath);
checkRecentOpenedFileNum();
@ -862,8 +863,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/**
* 替换近期打开的文件路径
*
* @param oldPath 旧的路径
* @param newPath 新的路径
* @param oldPath path 使用 unix 分隔符
* @param newPath path 使用 unix 分隔符
*/
public void replaceRecentOpenedFilePath(String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList();
@ -872,28 +873,22 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
list.remove(oldPath);
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 oldPath 旧的路径 使用反斜杠分割
* @param newPath 新的路径 使用反斜杠分割
* @param oldPath path 使用 unix 分隔符
* @param newPath path 使用 unix 分隔符
*/
public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList();
ListIterator<String> iterator = list.listIterator();
while (iterator.hasNext()) {
String s = iterator.next().replaceAll("/", "\\\\");
if (type ? s.contains(oldPath + "\\") : s.equals(oldPath)) {
String s = FilenameUtils.standard(iterator.next());
if (type ? s.contains(oldPath + CoreConstants.SEPARATOR) : s.equals(oldPath)) {
s = s.replace(oldPath, newPath);
iterator.set(s);
}
@ -916,9 +911,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径
*/
public void removeRecentOpenedFilePath(String filePath) {
if (getRecentOpenedFilePathList().contains(filePath)) {
getRecentOpenedFilePathList().remove(filePath);
}
filePath = FilenameUtils.standard(filePath);
getRecentOpenedFilePathList().remove(filePath);
}
@ -1637,7 +1631,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (reader.isChildNode()) {
String n = reader.getTagName();
if ("Path".equals(n)) {
String path = reader.getElementValue();
String path = FilenameUtils.standard(reader.getElementValue());
if (StringUtils.isNotEmpty(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.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.util.ArrayList;
import java.util.Collections;
@ -270,8 +272,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
template = this.getCurrentEditingTemplate();
if (template != null) {
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\");
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) {
String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}
@ -279,8 +281,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
for (int i = 0; i < this.getHistoryCount(); i++) {
template = this.get(i);
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\");
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) {
String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}

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

@ -5,6 +5,8 @@ package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtilsOperator;
import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
@ -20,8 +22,10 @@ import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnection;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -186,6 +190,26 @@ public class TemplateTreePane extends JPanel implements FileOperations {
*/
@Override
public void openFile() {
// 判断是否是远程设计的锁定文件
if (!WorkContext.getCurrent().isLocal()) {
FileNode node = reportletsTree.getSelectedFileNode();
if (node == null) {
return;
}
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
String username = null;
if (info != null) {
WorkspaceConnection connection = info.getConnection();
username = connection == null ? StringUtils.EMPTY : connection.getUserName();
}
String lock = node.getLock();
if (lock != null && !lock.equals(username)) {
return;
}
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
@ -226,11 +250,6 @@ public class TemplateTreePane extends JPanel implements FileOperations {
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();
// 筛选可以删除的文件
ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>();
@ -238,40 +257,49 @@ public class TemplateTreePane extends JPanel implements FileOperations {
for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, deletableNodes, lockedNodes);
}
boolean success = false;
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(),
tipContent,
UIManager.getString("OptionPane.titleText"),
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.titleText"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
}
} 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 (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"),
tipContent,
UIManager.getString("OptionPane.titleText"),
YES_NO_OPTION)
== JOptionPane.YES_OPTION) {
// 删除其他
success = deleteNodes(deletableNodes);
if (!deleteNodes(deletableNodes)) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.titleText"),
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();
}
@ -314,15 +342,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
boolean childrenEmptyLock = true;
for (ExpandMutableTreeNode child : children) {
boolean childEmptyLock = checkFreeOrLock(child, dNodes, lNodes);
if (childEmptyLock) {
dNodes.add(child);
} else {
lNodes.add(child);
}
childrenEmptyLock = childrenEmptyLock && childEmptyLock;
childrenEmptyLock = checkFreeOrLock(child, dNodes, lNodes) && childrenEmptyLock;
}
boolean emptyLock = childrenEmptyLock && selfEmptyLock;

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

@ -36,6 +36,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
@ -394,8 +395,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
fnf = new FileNodeFILE(node);
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
this.setLayout(new BorderLayout());
this.setModal(true);
@ -509,11 +510,11 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String userInput = nameField.getText().trim();
String path = fnf.getPath();
String path = FilenameUtils.standard(fnf.getPath());
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
// 输入为空或者没有修改
if (ComparatorUtils.equals(userInput, oldName)) {
@ -521,18 +522,16 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
return;
}
String oldPath = path.replaceAll(CoreConstants.SEPARATOR, "\\\\");
String parentPath = fnf.getParent().getPath().replaceAll(CoreConstants.SEPARATOR, "\\\\");
String parentPath = FilenameUtils.standard(fnf.getParent().getPath());
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
String newPath = parentPath + "\\" + userInput + suffix;
String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix;
HistoryTemplateListCache.getInstance().rename(fnf, oldPath, newPath);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), oldPath, newPath);
HistoryTemplateListCache.getInstance().rename(fnf, path, newPath);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath);
//模版重命名
boolean success = selectedOperation.rename(fnf, oldPath, newPath);
boolean success = selectedOperation.rename(fnf, path, newPath);
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle();
this.dispose();
@ -552,8 +551,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String userInput = nameField.getText().trim();
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false);
@ -714,7 +713,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
//新建文件夹
boolean success = selectedOperation.mkdir(
selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput
FilenameUtils.standard(selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput)
);
selectedOperation.refresh();
this.dispose();

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

@ -2,8 +2,9 @@ package com.fr.design.mainframe.socketio;
import com.fr.config.RemoteConfigEvent;
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.TemplatePane;
import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory;
@ -84,9 +85,13 @@ public class DesignerSocketIO {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
TemplatePane.getInstance().editItems();
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
EnvChangeEntrance.getInstance().chooseEnv();
}
});
} catch (Exception e) {

Loading…
Cancel
Save