Browse Source

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

* commit 'fa38f5327954c87da6e0d1a73a76864de0b9fb2f':
  REPORT-12916 另存为时的文件锁逻辑
  不是工程内的文件不进行解锁操作
  REPORT-12916 另存文件选择对话框被另存文件icon显示锁定问题
bugfix/10.0
yaoh.wu 6 years ago
parent
commit
bf4d23d36e
  1. 16
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  2. 4
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  3. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  4. 29
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

16
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -206,8 +206,7 @@ public class MutilTempalteTabPane extends JComponent {
openedTemplate.remove(jTemplate);
closeFormat(jTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath());
closeAndFreeLock(jTemplate);
}
}
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -221,7 +220,6 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) {
closeOther.setEnabled(false);
}
return closeOther;
}
@ -698,11 +696,19 @@ public class MutilTempalteTabPane extends JComponent {
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate, @Nonnull String fileName) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
closeAndFreeLock(specifiedTemplate);
activeTemplate(fileName);
}
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) {
FILE file = template.getEditingFILE();
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
}
}
/**
* 关闭模板
*

4
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -69,10 +69,8 @@ public class EnvFileTree extends RefreshableJTree {
if (treeNode.hasFullAuthority()) {
if (lock != null && !node.getUserID().equals(lock)) {
name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")");
this.setIcon(FileTreeIcon.getIcon(node));
} else {
this.setIcon(FileTreeIcon.getIcon(node, false));
}
this.setIcon(FileTreeIcon.getIcon(node));
} else {
this.setIcon(FileTreeIcon.getFolderHalfImageIcon());
}

11
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -3,6 +3,7 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils;
import com.fr.design.icon.LockIcon;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
@ -125,8 +126,16 @@ public class FileTreeIcon {
return FOLDER_HALF_IMAGE_ICON;
}
/**
* 获取文件节点对应的图标
*
* @param node 文件节点
* @return 文件节点的图标
*/
public static Icon getIcon(FileNode node) {
return getIcon(node, node.getLock() != null);
// 如果文件节点锁不为空且不是当前用户锁定的该模板,那么模板ICON 提示用户当前文件节点被锁
boolean showLock = node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock());
return getIcon(node, showLock);
}
public static Icon getIcon(FileNode node, boolean isShowLock) {

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

@ -32,6 +32,7 @@ import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
@ -56,6 +57,8 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -587,6 +590,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (isCancelOperation(chooseResult)) {
return false;
}
// 源文件
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) {
boolean access = false;
@ -596,13 +601,33 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false;
}
// 目标文件
editingFILE = fileChooser.getSelectedFILE();
}
return saveNewFile(editingFILE, oldName);
boolean lockedTarget = WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
if (lockedTarget) {
boolean saved = saveNewFile(editingFILE, oldName);
// 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉
if (saved && !ComparatorUtils.equals(editingFILE.getPath(), sourceFile.getPath())) {
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(sourceFile.getPath());
}
return saved;
} else {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false;
}
}
protected boolean saveNewFile(FILE editingFILE, String oldName) {

Loading…
Cancel
Save