Browse Source

Merge pull request #3172 in DESIGN/design from release/10.0 to bugfix/10.0

* commit '2a7acadc73f52939ef6210a5982ee42ad88f4551':
  REPORT-44644 设计器接口开放 fix实现层级
  REPORT-44644 fix无用import
  REPORT-44644 设计器接口开发 fix
  REPORT-44644 添加判断是否存在接口
  REPORT-44644 fix调整名称
  REPORT-44644 设计器接口开放
  REPORT-44644 设计器接口开放
bugfix/10.0
superman 4 years ago
parent
commit
7e6769ee61
  1. 3
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  3. 71
      designer-base/src/main/java/com/fr/design/file/TemplateResource.java
  4. 66
      designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java
  5. 21
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  6. 19
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java
  7. 52
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java
  8. 34
      designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java
  9. 19
      designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java
  10. 23
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java
  11. 24
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java
  12. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  13. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  14. 18
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java

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

@ -2,7 +2,6 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.io.BaseBook;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager;
@ -23,7 +22,6 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import javax.swing.SwingUtilities;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collections;
@ -441,4 +439,5 @@ public class HistoryTemplateListCache implements CallbackEvent {
}
});
}
}

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

@ -18,8 +18,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.third.javax.annotation.Nonnull;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.ButtonModel;
@ -707,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent {
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
TemplateResourceManager.getResource().closeTemplate(file.getPath());
}
}

71
designer-base/src/main/java/com/fr/design/file/TemplateResource.java

@ -0,0 +1,71 @@
package com.fr.design.file;
import com.fr.common.annotations.Open;
import com.fr.file.FILE;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 模板资源操作可操作模板及模板目录
*
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
@Open
public interface TemplateResource {
/**
* 读取模板
* @param path
* @return
* @throws Exception
*/
InputStream readTemplate(String path) throws Exception;
/**
* 保存模板
* @param file
* @return
* @throws Exception
*/
OutputStream saveTemplate(FILE file) throws Exception;
/**
* 删除某个目录/某个模板
* @param file
* @return
*/
boolean delete(FILE file);
/**
* 关闭模板
* @param path
* @return
*/
boolean closeTemplate(String path);
/**
* 重命名模板/目录
* @param from
* @param to
* @return
*/
boolean rename(String from, String to);
/**
* 模板/目录是否存在
* @param path
* @return
*/
boolean exist(String path);
/**
* 创建目录
* @param path
* @return
*/
boolean mkdir(String path);
}

66
designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java

@ -0,0 +1,66 @@
package com.fr.design.file;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.file.impl.DefaultTemplateResource;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.file.filetree.FileNodes;
import com.fr.file.filetree.LocalFileNodes;
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.workspace.WorkContext;
import com.fr.workspace.engine.base.FineObjectPool;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public class TemplateResourceManager {
private static final TemplateResource DEFAULT_OPERATION = new DefaultTemplateResource();
private static TemplateResource OPERATION = DEFAULT_OPERATION;
static {
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 DefaultTemplateResource());
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes());
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh());
}
}, filter);
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG);
if (provider != null && WorkContext.getCurrent().isLocal()) {
registerOperation(provider.createResourceOperation());
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes());
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh());
}
}
}, filter);
}
private static void registerOperation(TemplateResource operation) {
OPERATION = operation;
}
public static TemplateResource getResource() {
if (OPERATION == null) {
return DEFAULT_OPERATION;
}
return OPERATION;
}
}

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

@ -4,7 +4,9 @@
package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.TemplateTreeDefineProcessor;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
@ -23,12 +25,11 @@ 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;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
@ -87,6 +88,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
TemplateTreeDefineProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TemplateTreeDefineProcessor.XML_TAG);
if (processor != null) {
processor.rightClickAction(e);
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (toolBarStateChangeListener != null) {
@ -182,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
return TemplateResourceManager.getResource().mkdir(path);
}
/**
@ -325,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
if (WorkContext.getCurrent().get(TplOperator.class).delete(nodeFILE.getPath())) {
if (TemplateResourceManager.getResource().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {
success = false;
@ -427,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
try {
// 接收的是WEB-INF下的路径
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
return TemplateResourceManager.getResource().rename(from, to);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

19
designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java

@ -0,0 +1,19 @@
package com.fr.design.file.impl;
import com.fr.design.file.TemplateResource;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public abstract class AbstractTemplateResource implements TemplateResource {
}

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

@ -0,0 +1,52 @@
package com.fr.design.file.impl;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public class DefaultTemplateResource extends AbstractTemplateResource {
@Override
public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path));
}
@Override
public OutputStream saveTemplate(FILE file) throws Exception {
return file.asOutputStream();
}
@Override
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
}
@Override
public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath());
}
@Override
public boolean rename(String from, String to) {
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
}
@Override
public boolean exist(String path) {
return WorkContext.getWorkResource().exist(path);
}
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
}

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

@ -0,0 +1,34 @@
package com.fr.design.fun;
import com.fr.design.file.TemplateResource;
import com.fr.file.filetree.FileNodes;
import com.fr.stable.fun.mark.Immutable;
/**
* 本地资源操作插件接口
*
* @author hades
* @version 10.0
* Created by hades on 2020/12/22
*/
public interface LocalResourceProvider extends Immutable {
String XML_TAG = "LocalResourceProvider";
int CURRENT_LEVEL = 1;
/**
* eg: DefaultResourceOperation
*
* @return 目录/模板的各种操作
*/
TemplateResource createResourceOperation();
/**
* eg: LocalFileNodes
*
* @return 构建目录树的方式
*/
FileNodes createFileNodes();
}

19
designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java

@ -0,0 +1,19 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Immutable;
import java.awt.event.MouseEvent;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/14
*/
public interface TemplateTreeDefineProcessor extends Immutable {
String XML_TAG = "TemplateTreeDefineProcessor";
int CURRENT_LEVEL = 1;
void rightClickAction(MouseEvent mouseEvent);
}

23
designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java

@ -0,0 +1,23 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/22
*/
@API(level = LocalResourceProvider.CURRENT_LEVEL)
public abstract class AbstractLocalResourceProvider implements LocalResourceProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

24
designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java

@ -0,0 +1,24 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.TemplateTreeDefineProcessor;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/21
*/
@API(level = TemplateTreeDefineProcessor.CURRENT_LEVEL)
public abstract class AbstractTemplateTreeDefineProcessor implements TemplateTreeDefineProcessor {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

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

@ -17,7 +17,6 @@ import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
@ -58,7 +57,6 @@ 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;

4
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,6 +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.TemplateResourceManager;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler;
@ -813,7 +813,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
try {
this.getTarget().export(editingFILE.asOutputStream());
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);

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

@ -2,6 +2,7 @@ package com.fr.file;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.file.TemplateResourceManager;
import com.fr.io.FineEncryptUtils;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor;
@ -22,10 +23,8 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.resource.WorkResourceTempRenameStream;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
@ -324,7 +323,7 @@ public class FileNodeFILE implements FILE {
}
try {
return WorkContext.getWorkResource().exist(node.getEnvPath());
return TemplateResourceManager.getResource().exist(node.getEnvPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
@ -379,14 +378,11 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null;
}
InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)
)
)
);
InputStream in = TemplateResourceManager.getResource().readTemplate(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)
));
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in;

Loading…
Cancel
Save