Browse Source

REPORT-44644 设计器接口开发 fix

feature/big-screen
hades 4 years ago
parent
commit
8ff603736d
  1. 9
      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. 2
      designer-base/src/main/java/com/fr/design/file/TemplateResource.java
  4. 19
      designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java
  5. 6
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  6. 5
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java
  7. 10
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java
  8. 4
      designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java
  9. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 6
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java

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

@ -45,9 +45,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; private JTemplate<?, ?> editingTemplate;
// 插件stop时的已经打开的模板xml byte缓存 插件重新run时 重新加载
private final Map<String, FILE> cacheMap = new LinkedHashMap<>();
public static HistoryTemplateListCache getInstance() { public static HistoryTemplateListCache getInstance() {
return Holder.INSTANCE; return Holder.INSTANCE;
} }
@ -78,11 +75,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
selected.fireJTemplateClosed(); selected.fireJTemplateClosed();
selected.stopEditing(); selected.stopEditing();
try { try {
int index = contains(selected); historyList.remove(contains(selected));
historyList.remove(index);
if (stashFILEMap != null) {
stashFILEMap.remove(index);
}
selected.getEditingFILE().closeTemplate(); selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);

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()) { if (file != null && file.isEnvFile()) {
// release lock // release lock
TemplateFileResourceManager.getOperation().closeTemplate(file.getPath()); TemplateResourceManager.getResource().closeTemplate(file.getPath());
} }
} }

2
designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java → designer-base/src/main/java/com/fr/design/file/TemplateResource.java

@ -13,7 +13,7 @@ import java.io.OutputStream;
* Created by hades on 2020/12/23 * Created by hades on 2020/12/23
*/ */
@Open @Open
public interface TemplateFileResourceOperation { public interface TemplateResource {
/** /**
* 读取模板 * 读取模板

19
designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java → designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java

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

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

@ -193,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override @Override
public boolean mkdir(String path) { public boolean mkdir(String path) {
return TemplateFileResourceManager.getOperation().mkdir(path); return TemplateResourceManager.getResource().mkdir(path);
} }
/** /**
@ -336,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) { if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) { if (nodeFILE.exists()) {
if (TemplateFileResourceManager.getOperation().delete(nodeFILE)) { if (TemplateResourceManager.getResource().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else { } else {
success = false; success = false;
@ -438,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
try { try {
// 接收的是WEB-INF下的路径 // 接收的是WEB-INF下的路径
return TemplateFileResourceManager.getOperation().rename(from, to); return TemplateResourceManager.getResource().rename(from, to);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;

5
designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java → designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java

@ -1,6 +1,7 @@
package com.fr.design.file.impl; package com.fr.design.file.impl;
import com.fr.design.file.TemplateFileResourceOperation;
import com.fr.design.file.TemplateResource;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
@ -13,7 +14,7 @@ import java.io.OutputStream;
* @version 10.0 * @version 10.0
* Created by hades on 2020/12/23 * Created by hades on 2020/12/23
*/ */
public class DefaultTemplateFileResourceOperation implements TemplateFileResourceOperation { public class AbstractTemplateResource implements TemplateResource {
@Override @Override
public InputStream readTemplate(String path) throws Exception { public InputStream readTemplate(String path) throws Exception {

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

@ -0,0 +1,10 @@
package com.fr.design.file.impl;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public class DefaultTemplateResource extends AbstractTemplateResource {
}

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

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

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

@ -23,7 +23,7 @@ import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.InformationWarnPane; import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateFileResourceManager; import com.fr.design.file.TemplateResourceManager;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler; import com.fr.design.fun.MenuHandler;
@ -813,7 +813,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false; return false;
} }
try { try {
this.getTarget().export(TemplateFileResourceManager.getOperation().saveTemplate(editingFILE)); this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);

6
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.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.file.TemplateFileResourceManager; import com.fr.design.file.TemplateResourceManager;
import com.fr.io.FineEncryptUtils; import com.fr.io.FineEncryptUtils;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor; import com.fr.design.file.NodeAuthProcessor;
@ -323,7 +323,7 @@ public class FileNodeFILE implements FILE {
} }
try { try {
return TemplateFileResourceManager.getOperation().exist(node.getEnvPath()); return TemplateResourceManager.getResource().exist(node.getEnvPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
@ -378,7 +378,7 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null; return null;
} }
InputStream in = TemplateFileResourceManager.getOperation().readTemplate( InputStream in = TemplateResourceManager.getResource().readTemplate(
StableUtils.pathJoin( StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME, ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)

Loading…
Cancel
Save