Browse Source

REPORT-44644 fix调整名称

feature/big-screen
hades 4 years ago
parent
commit
c9def50757
  1. 15
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 2
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  3. 24
      designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java
  4. 12
      designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java
  5. 7
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  6. 10
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java
  7. 4
      designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java
  8. 12
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  9. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 4
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java

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

@ -23,6 +23,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.util.LinkedHashMap;
import javax.swing.SwingUtilities;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
@ -44,6 +45,9 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
// 插件stop时的已经打开的模板xml byte缓存 插件重新run时 重新加载
private final Map<String, FILE> cacheMap = new LinkedHashMap<>();
public static HistoryTemplateListCache getInstance() {
return Holder.INSTANCE;
}
@ -74,7 +78,11 @@ public class HistoryTemplateListCache implements CallbackEvent {
selected.fireJTemplateClosed();
selected.stopEditing();
try {
historyList.remove(contains(selected));
int index = contains(selected);
historyList.remove(index);
if (stashFILEMap != null) {
stashFILEMap.remove(index);
}
selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
@ -422,6 +430,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
/**
* 重新载入当前模板刷新数据/对象
*/
@Deprecated
public void reloadCurrentTemplate() {
JTemplate<?, ?> jt = getCurrentEditingTemplate();
boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists();
@ -441,4 +450,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
}
});
}
public void stashByName() {
}
}

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

@ -705,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent {
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
ResourceManager.getInstance().getOperation().closeTpl(file.getPath());
TemplateFileResourceManager.getOperation().closeTemplate(file.getPath());
}
}

24
designer-base/src/main/java/com/fr/design/file/ResourceManager.java → designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java

@ -1,7 +1,7 @@
package com.fr.design.file;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.file.impl.DefaultResourceOperation;
import com.fr.design.file.impl.DefaultTemplateFileResourceOperation;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.ui.util.UIUtil;
@ -21,19 +21,17 @@ import com.fr.workspace.engine.base.FineObjectPool;
* @version 10.0
* Created by hades on 2020/12/23
*/
public class ResourceManager {
public class TemplateFileResourceManager {
private static final ResourceManager INSTANCE = new ResourceManager();
private static TemplateFileResourceOperation OPERATION = new DefaultTemplateFileResourceOperation();
private ResourceOperation operation = new DefaultResourceOperation();
private ResourceManager() {
private TemplateFileResourceManager() {
PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG);
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
registerOperation(new DefaultResourceOperation());
registerOperation(new DefaultTemplateFileResourceOperation());
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes());
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh());
}
@ -52,16 +50,12 @@ public class ResourceManager {
}, filter);
}
public static ResourceManager getInstance() {
return INSTANCE;
}
private void registerOperation(ResourceOperation operation) {
this.operation = operation;
private static void registerOperation(TemplateFileResourceOperation operation) {
OPERATION = operation;
}
public ResourceOperation getOperation() {
return this.operation;
public static TemplateFileResourceOperation getOperation() {
return OPERATION;
}
}

12
designer-base/src/main/java/com/fr/design/file/ResourceOperation.java → designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java

@ -6,12 +6,14 @@ import java.io.InputStream;
import java.io.OutputStream;
/**
* 模板资源操作可操作模板及模板目录
*
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
@Open
public interface ResourceOperation {
public interface TemplateFileResourceOperation {
/**
* 读取模板
@ -19,7 +21,7 @@ public interface ResourceOperation {
* @return
* @throws Exception
*/
InputStream readTpl(String path) throws Exception;
InputStream readTemplate(String path) throws Exception;
/**
* 保存模板
@ -27,7 +29,7 @@ public interface ResourceOperation {
* @return
* @throws Exception
*/
OutputStream saveTpl(FILE file) throws Exception;
OutputStream saveTemplate(FILE file) throws Exception;
/**
* 删除某个目录/某个模板
@ -41,7 +43,7 @@ public interface ResourceOperation {
* @param path
* @return
*/
boolean closeTpl(String path);
boolean closeTemplate(String path);
/**
* 重命名模板/路径
@ -52,7 +54,7 @@ public interface ResourceOperation {
boolean rename(String from, String to);
/**
* 创建工作目录
* 创建目录
* @param path
* @return
*/

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

@ -25,7 +25,6 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -194,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public boolean mkdir(String path) {
return ResourceManager.getInstance().getOperation().mkdir(path);
return TemplateFileResourceManager.getOperation().mkdir(path);
}
/**
@ -337,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
if (ResourceManager.getInstance().getOperation().delete(nodeFILE)) {
if (TemplateFileResourceManager.getOperation().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {
success = false;
@ -439,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
try {
// 接收的是WEB-INF下的路径
return ResourceManager.getInstance().getOperation().rename(from, to);
return TemplateFileResourceManager.getOperation().rename(from, to);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

10
designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java → designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java

@ -1,6 +1,6 @@
package com.fr.design.file.impl;
import com.fr.design.file.ResourceOperation;
import com.fr.design.file.TemplateFileResourceOperation;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
@ -13,20 +13,20 @@ import java.io.OutputStream;
* @version 10.0
* Created by hades on 2020/12/23
*/
public class DefaultResourceOperation implements ResourceOperation {
public class DefaultTemplateFileResourceOperation implements TemplateFileResourceOperation {
@Override
public InputStream readTpl(String path) throws Exception {
public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path));
}
@Override
public OutputStream saveTpl(FILE file) throws Exception {
public OutputStream saveTemplate(FILE file) throws Exception {
return file.asOutputStream();
}
@Override
public boolean closeTpl(String path) {
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
}

4
designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java

@ -1,6 +1,6 @@
package com.fr.design.fun;
import com.fr.design.file.ResourceOperation;
import com.fr.design.file.TemplateFileResourceOperation;
import com.fr.file.filetree.FileNodes;
import com.fr.stable.fun.mark.Immutable;
@ -22,7 +22,7 @@ public interface LocalResourceProvider extends Immutable {
*
* @return 目录/模板的各种操作
*/
ResourceOperation createResourceOperation();
TemplateFileResourceOperation createResourceOperation();
/**
* eg: LocalFileNodes

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

@ -18,7 +18,6 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuHighLight;
@ -34,13 +33,10 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.FileNodes;
import com.fr.file.filetree.LocalFileNodes;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
@ -49,8 +45,6 @@ import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.plugin.observer.PluginListenerRegistration;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -58,17 +52,11 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.resource.FineWorkResource;
import com.fr.workspace.resource.WorkResource;
import com.fr.workspace.server.lock.LocalTplOperator;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;

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

@ -3,7 +3,6 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
@ -24,7 +23,7 @@ import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.ResourceManager;
import com.fr.design.file.TemplateFileResourceManager;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler;
@ -814,7 +813,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
try {
this.getTarget().export(ResourceManager.getInstance().getOperation().saveTpl(editingFILE));
this.getTarget().export(TemplateFileResourceManager.getOperation().saveTemplate(editingFILE));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);

4
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -2,7 +2,7 @@ package com.fr.file;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.file.ResourceManager;
import com.fr.design.file.TemplateFileResourceManager;
import com.fr.io.FineEncryptUtils;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor;
@ -378,7 +378,7 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null;
}
InputStream in = ResourceManager.getInstance().getOperation().readTpl(
InputStream in = TemplateFileResourceManager.getOperation().readTemplate(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)

Loading…
Cancel
Save