Browse Source

Pull request #4412: REPORT-51678 移植加密组件剪切复制粘贴的逻辑

Merge in DESIGN/design from ~TOMMY/design:feature/10.0 to feature/10.0

* commit '2027e083270800e5604e77b3e2e2f87f5e361ac7':
  REPORT-52819 依赖修改
  REPORT-51678 移植加密组件剪切复制粘贴的逻辑
feature/10.0
Tommy 4 years ago
parent
commit
620a165699
  1. 22
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java
  2. 35
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHandler.java
  3. 1
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  4. 62
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/AbstractCrossClipBoardState.java
  5. 79
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/CrossClipboardHandler.java
  6. 22
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/CrossClipboardState.java
  7. 72
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/RestrictTemplateSet.java
  8. 116
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/TemplateStateListenerProvider.java
  9. 86
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossLayoutClipBoardState.java
  10. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossTemplateClipBoardState.java
  11. 68
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossWidgetClipBoardState.java
  12. 31
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/EncryptSelectionClipboardHandler.java
  13. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/EncryptTransferableClipboardHandler.java
  14. 5
      designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java

22
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java

@ -4,6 +4,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ClipboardHandlerProvider; import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
@ -11,11 +12,25 @@ import java.util.Set;
**/ **/
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public abstract class ClipboardFilter { public abstract class ClipboardFilter {
public static Set<ClipboardHandlerProvider> clipboardHandlerProviders = new HashSet();
public static void registerClipboardHandler(ClipboardHandlerProvider provider) {
if (!clipboardHandlerProviders.contains(provider)) {
clipboardHandlerProviders.add(provider);
}
}
public static void removeClipboardHandler(ClipboardHandlerProvider provider) {
if (clipboardHandlerProviders.contains(provider)) {
clipboardHandlerProviders.remove(provider);
}
}
public static <T> T cut(T selection) { public static <T> T cut(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
providers.addAll(clipboardHandlerProviders);
for (ClipboardHandlerProvider provider : providers) { for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) { if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection); selection = ((ClipboardHandlerProvider<T>) provider).cut(selection);
@ -25,9 +40,9 @@ public abstract class ClipboardFilter {
} }
public static <T> T copy(T selection) { public static <T> T copy(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
providers.addAll(clipboardHandlerProviders);
for (ClipboardHandlerProvider provider : providers) { for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) { if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection); selection = ((ClipboardHandlerProvider<T>) provider).copy(selection);
@ -37,9 +52,10 @@ public abstract class ClipboardFilter {
} }
public static <T> T paste(T selection) { public static <T> T paste(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
providers.addAll(clipboardHandlerProviders);
for (ClipboardHandlerProvider provider : providers) { for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) { if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection); selection = ((ClipboardHandlerProvider<T>) provider).paste(selection);

35
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHandler.java

@ -0,0 +1,35 @@
package com.fr.design.base.clipboard;
public interface ClipboardHandler<T> {
/**
* 剪切
*
* @param selection 选中
* @return 处理后的内容
*/
T cut(T selection);
/**
* 复制
*
* @param selection 选中
* @return 处理后的内容
*/
T copy(T selection);
/**
* 粘贴
*
* @param selection 选中
* @return 处理后的内容
*/
T paste(T selection);
/**
* 支持的类型
*
* @param selection 内容
* @return 是否
*/
boolean support(Object selection);
}

1
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -25,6 +25,7 @@ import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;

62
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/AbstractCrossClipBoardState.java

@ -0,0 +1,62 @@
package com.fr.design.mainframe.share.encrypt.clipboard;
import com.fr.stable.StringUtils;
import java.util.concurrent.atomic.AtomicReference;
/**
* 跨模版禁用
* <p>
* created by Harrison on 2020/05/14
**/
public abstract class AbstractCrossClipBoardState implements CrossClipboardState {
private final AtomicReference<String> sourceId = new AtomicReference<>();
@Override
public synchronized boolean isBan() {
String sourceId = this.sourceId.get();
if (StringUtils.isEmpty(sourceId)) {
return false;
}
//这里只获取新的,不能更新
//因为新的模板可能不是限制模板,然而剪贴板中的内容没有清空。
//所以,直接在新的模板中再一次粘贴,就可以避过限制
String targetId = get();
return isCross(sourceId, targetId) && isRestrict(sourceId);
}
protected boolean isRestrict(String sourceId) {
return true;
}
@Override
public synchronized void mark() {
update();
}
private String get() {
return currentId();
}
private void update() {
String templateId = currentId();
sourceId.set(templateId);
}
private boolean isCross(String sourceId, String targetId) {
//源 id 不等于 null
//如果源 id 等于 null , 两种情况
//1-之前没有
//2-是从其他地方,复制过来,这样的话,直接通过就好了。
return StringUtils.isNotEmpty(sourceId)
&& !StringUtils.equals(sourceId, targetId);
}
protected abstract String currentId();
}

79
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/CrossClipboardHandler.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.share.encrypt.clipboard;
import com.fr.design.fun.impl.AbstractClipboardHandlerProvider;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* created by Harrison on 2020/05/14
**/
public abstract class CrossClipboardHandler<T> extends AbstractClipboardHandlerProvider<T> {
private List<CrossClipboardState> states = new ArrayList<>(8);
public CrossClipboardHandler(CrossClipboardState... states) {
init(states);
}
private void init(CrossClipboardState... states) {
if (states == null) {
return;
}
Collections.addAll(this.states, states);
}
@Override
public T cut(T selection) {
mark();
return cut0(selection);
}
protected T cut0(T selection) {
return selection;
}
@Override
public T copy(T selection) {
mark();
return copy0(selection);
}
protected T copy0(T selection) {
return selection;
}
@Override
public T paste(T selection) {
return isBan() ? null : paste0(selection);
}
protected T paste0(T selection) {
return selection;
}
private void mark() {
for (CrossClipboardState state : states) {
state.mark();
}
}
private boolean isBan() {
boolean isBan = false;
for (CrossClipboardState state : states) {
isBan |= state.isBan();
}
return isBan;
}
}

22
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/CrossClipboardState.java

@ -0,0 +1,22 @@
package com.fr.design.mainframe.share.encrypt.clipboard;
/**
* created by Harrison on 2020/05/18
**/
public interface CrossClipboardState {
/**
* 是否禁用
*
* @return y/n
*/
boolean isBan();
/**
* 标记状态
*/
void mark();
}

72
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/RestrictTemplateSet.java

@ -0,0 +1,72 @@
package com.fr.design.mainframe.share.encrypt.clipboard;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetUtil;
import com.fr.base.iofile.attr.EncryptSharableAttrMark;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.container.WLayout;
import com.fr.stable.fun.IOFileAttrMark;
import java.util.HashMap;
import java.util.Map;
/**
* created by Harrison on 2020/05/14
**/
public abstract class RestrictTemplateSet {
private static Map<String, Boolean> restrictMap = new HashMap<>(8);
public static void monitorGracefully(Form form) {
monitor(form, true);
}
public static void monitorForcefully(Form form) {
monitor(form, false);
}
private static void monitor(Form form, boolean useCache) {
String templateID = form.getTemplateID();
if (useCache) {
if (restrictMap.containsKey(templateID)) {
return;
}
}
//检测 + 缓存
monitor0(form);
}
private static void monitor0(Form form) {
final String templateID = form.getTemplateID();
WLayout container = form.getContainer();
WidgetUtil.bfsTraversalWidget(container, new WidgetUtil.BfsWidgetGather<AbstractBorderStyleWidget>() {
@Override
public boolean dealWith(AbstractBorderStyleWidget widget) {
IOFileAttrMark mark = widget.getWidgetAttrMark(EncryptSharableAttrMark.XML_TAG);
boolean existEncrypt = mark != null;
if (existEncrypt) {
restrictMap.put(templateID, existEncrypt);
}
return existEncrypt;
}
}, AbstractBorderStyleWidget.class);
initIfAbsent(templateID);
}
private static void initIfAbsent(String templateID) {
if (!restrictMap.containsKey(templateID)) {
restrictMap.put(templateID, false);
}
}
public static boolean isRestrict(String templateId) {
Boolean restrict = restrictMap.get(templateId);
return restrict == null ? false : restrict;
}
}

116
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/TemplateStateListenerProvider.java

@ -0,0 +1,116 @@
package com.fr.design.mainframe.share.encrypt.clipboard;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.impl.AbstractDesignerEditListenerProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGatherAdapter;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.editor.SharableEditorProvider;
import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.util.Iterator;
/**
* 创建删除的时候要初始化部分状态
* <p>
* created by Harrison on 2020/05/19
**/
public class TemplateStateListenerProvider extends AbstractDesignerEditListenerProvider {
public static final int CREATOR_ADDED = 1;
public static final int CREATOR_DELETED = 2;
private static final String SEPARATOR = "-";
private String lastAffectedCreatorShareID;
@Override
public void fireCreatorModified(DesignerEvent evt) {
int eventId = evt.getCreatorEventID();
if (eventId == CREATOR_ADDED || eventId == CREATOR_DELETED) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
BaseBook book = template.getTarget();
if (book instanceof Form) {
Form form = (Form) book;
RestrictTemplateSet.monitorForcefully(form);
refreshTableDataTree(form, evt);
}
}
if (eventId == DesignerEvent.CREATOR_SELECTED) {
XCreator lastAffectedCreator = (XCreator) evt.getAffectedCreator();
if (lastAffectedCreator == null) {
return;
}
lastAffectedCreatorShareID = lastAffectedCreator.getShareId();
//做下兼容处理,有标题的老的组件其外层的creator上是没有shareID的,新生成的组件是有的
if (!lastAffectedCreator.acceptType(XWTitleLayout.class) || StringUtils.isNotEmpty(lastAffectedCreatorShareID)) {
return;
}
XCreator body = getBodyCreator((XWTitleLayout) lastAffectedCreator);
if (body != null) {
lastAffectedCreatorShareID = body.getShareId();
}
}
}
private XCreator getBodyCreator(XWTitleLayout titleLayout) {
for (int i = 0; i < titleLayout.getXCreatorCount(); i++) {
XCreator creator = titleLayout.getXCreator(i);
if (creator.hasTitleStyle()) {
return creator;
}
}
return null;
}
private void refreshTableDataTree(Form form, DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED && StringUtils.isNotEmpty(lastAffectedCreatorShareID)) {
if (!needDeleteTableData(form.getContainer(), lastAffectedCreatorShareID)) {
return;
}
//TODO 目前组件没版本号,可以直接遍历,之后可能还是要改的
SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(lastAffectedCreatorShareID);
SharableEditorProvider sharableEditor = ShareUtils.getSharedElCaseEditorById(lastAffectedCreatorShareID);
if (sharableEditor == null || bindInfo == null) {
return;
}
Iterator tdIterator = sharableEditor.getTableDataSource().getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = bindInfo.getName() + SEPARATOR + tdIterator.next();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).removeTableData(tdName);
}
}
}
private boolean needDeleteTableData(WLayout widget, final String shareId) {
final boolean[] needDeleteTableData = {true};
Form.traversalWidget(widget, new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
AbstractBorderStyleWidget borderStyleWidget = (AbstractBorderStyleWidget) widget;
ExtendSharableAttrMark attrMark = borderStyleWidget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (attrMark != null) {
needDeleteTableData[0] &= !ComparatorUtils.equals(shareId, attrMark.getShareId());
}
}
}, AbstractBorderStyleWidget.class);
return needDeleteTableData[0];
}
}

86
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossLayoutClipBoardState.java

@ -0,0 +1,86 @@
package com.fr.design.mainframe.share.encrypt.clipboard.impl;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.main.Form;
import com.fr.design.mainframe.share.encrypt.clipboard.AbstractCrossClipBoardState;
import com.fr.base.iofile.attr.EncryptSharableAttrMark;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.container.WLayout;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.IOFileAttrMark;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.atomic.AtomicReference;
/**
* 只需要看是否跨布局去粘贴
* <p>
* created by Harrison on 2020/06/04
**/
public class CrossLayoutClipBoardState extends AbstractCrossClipBoardState {
@Override
protected String currentId() {
//默认id
final AtomicReference<String> finalId = new AtomicReference<>(StringUtils.EMPTY);
WidgetPropertyPane pane = WidgetPropertyPane.getInstance();
FormDesigner designer = pane.getEditingFormDesigner();
if (designer == null) {
return null;
}
Form target = designer.getTarget();
BaseBook current = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget();
//如果不是同一个
if (!StringUtils.equals(target.getTemplateID(), current.getTemplateID())) {
return null;
}
SelectionModel selectionModel = designer.getSelectionModel();
if (selectionModel == null) {
return null;
}
FormSelection selection = selectionModel.getSelection();
if (selection == null) {
return null;
}
XCreator[] xCreators = selection.getSelectedCreators();
if (xCreators != null) {
XCreator xCreator = xCreators[0];
if (StringUtils.isEmpty(finalId.get())) {
XLayoutContainer layout = XCreatorUtils.getParentXLayoutContainer(xCreator);
if (layout != null) {
WLayout wLayout = layout.toData();
String encryptWidgetId = findEncryptWidgetId(wLayout);
boolean hasId = StringUtils.isNotEmpty(encryptWidgetId);
if (hasId) {
finalId.set(encryptWidgetId);
}
}
}
}
return finalId.get();
}
@Nullable
private String findEncryptWidgetId(AbstractBorderStyleWidget widget) {
IOFileAttrMark widgetAttrMark = widget.getWidgetAttrMark(EncryptSharableAttrMark.XML_TAG);
boolean isEncrypt = widgetAttrMark != null;
if (isEncrypt) {
ExtendSharableAttrMark sharableAttrMark = widget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (sharableAttrMark != null) {
return (sharableAttrMark.getShareId());
}
}
return null;
}
}

32
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossTemplateClipBoardState.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.share.encrypt.clipboard.impl;
import com.fr.base.io.BaseBook;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.share.encrypt.clipboard.AbstractCrossClipBoardState;
import com.fr.design.mainframe.share.encrypt.clipboard.RestrictTemplateSet;
import com.fr.form.main.Form;
/**
* created by Harrison on 2020/05/18
**/
public class CrossTemplateClipBoardState extends AbstractCrossClipBoardState {
@Override
protected String currentId() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
BaseBook book = template.getTarget();
if (book instanceof Form) {
Form form = (Form) book;
RestrictTemplateSet.monitorGracefully(form);
}
return book.getTemplateID();
}
@Override
protected boolean isRestrict(String sourceId) {
return RestrictTemplateSet.isRestrict(sourceId);
}
}

68
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/CrossWidgetClipBoardState.java

@ -0,0 +1,68 @@
package com.fr.design.mainframe.share.encrypt.clipboard.impl;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.share.encrypt.clipboard.AbstractCrossClipBoardState;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetUtil;
import com.fr.base.iofile.attr.EncryptSharableAttrMark;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.IOFileAttrMark;
/**
* created by Harrison on 2020/05/18
**/
public class CrossWidgetClipBoardState extends AbstractCrossClipBoardState {
@Override
protected String currentId() {
final String[] finalIds = new String[]{null};
WidgetPropertyPane pane = WidgetPropertyPane.getInstance();
FormDesigner designer = pane.getEditingFormDesigner();
if (designer == null) {
return null;
}
Form target = designer.getTarget();
BaseBook current = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget();
//如果不是同一个
if (!StringUtils.equals(target.getTemplateID(), current.getTemplateID())) {
return null;
}
SelectionModel selectionModel = designer.getSelectionModel();
if (selectionModel == null) {
return null;
}
FormSelection selection = selectionModel.getSelection();
if (selection == null) {
return null;
}
Widget[] selectedWidgets = selection.getSelectedWidgets();
if (selectedWidgets != null && selectedWidgets.length == 1) {
final Widget selectedWidget = selectedWidgets[0];
WidgetUtil.bfsTraversalWidget(selectedWidget, new WidgetUtil.BfsWidgetGather<AbstractBorderStyleWidget>() {
@Override
public boolean dealWith(AbstractBorderStyleWidget widget) {
IOFileAttrMark widgetAttrMark = widget.getWidgetAttrMark(EncryptSharableAttrMark.XML_TAG);
boolean isEncrypt = widgetAttrMark != null;
if (isEncrypt) {
ExtendSharableAttrMark sharableAttrMark = widget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (sharableAttrMark != null) {
finalIds[0] = sharableAttrMark.getShareId();
}
}
return isEncrypt;
}
}, AbstractBorderStyleWidget.class);
}
return finalIds[0];
}
}

31
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/EncryptSelectionClipboardHandler.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.share.encrypt.clipboard.impl;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.share.encrypt.clipboard.CrossClipboardHandler;
/**
* 组件选择
* <p>
* created by Harrison on 2020/05/18
**/
public class EncryptSelectionClipboardHandler extends CrossClipboardHandler<FormSelection> {
private static EncryptSelectionClipboardHandler selectionClipboardHandler;
public static EncryptSelectionClipboardHandler getInstance() {
if (selectionClipboardHandler == null) {
selectionClipboardHandler = new EncryptSelectionClipboardHandler();
}
return selectionClipboardHandler;
}
public EncryptSelectionClipboardHandler() {
super(new CrossTemplateClipBoardState(), new CrossLayoutClipBoardState());
}
@Override
public boolean support(Object selection) {
return selection instanceof FormSelection;
}
}

32
designer-form/src/main/java/com/fr/design/mainframe/share/encrypt/clipboard/impl/EncryptTransferableClipboardHandler.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.share.encrypt.clipboard.impl;
import com.fr.design.mainframe.share.encrypt.clipboard.CrossClipboardHandler;
import java.awt.datatransfer.Transferable;
/**
* 单元格
* <p>
* created by Harrison on 2020/05/18
**/
public class EncryptTransferableClipboardHandler extends CrossClipboardHandler<Transferable> {
private static EncryptTransferableClipboardHandler transferableClipboardHandler;
public static EncryptTransferableClipboardHandler getInstance() {
if (transferableClipboardHandler == null) {
transferableClipboardHandler = new EncryptTransferableClipboardHandler();
}
return transferableClipboardHandler;
}
public EncryptTransferableClipboardHandler() {
super(new CrossTemplateClipBoardState(), new CrossWidgetClipBoardState());
}
@Override
public boolean support(Object selection) {
return selection instanceof Transferable;
}
}

5
designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java

@ -1,11 +1,16 @@
package com.fr.design.share; package com.fr.design.share;
import com.fr.design.base.clipboard.ClipboardFilter;
import com.fr.design.mainframe.share.collect.SharableCollectorManager; import com.fr.design.mainframe.share.collect.SharableCollectorManager;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler;
import com.fr.design.mainframe.share.util.SharableXMLUtils; import com.fr.design.mainframe.share.util.SharableXMLUtils;
public class SharableInitManager { public class SharableInitManager {
public static void start() { public static void start() {
SharableXMLUtils.registerSharableReadHelper(); SharableXMLUtils.registerSharableReadHelper();
SharableCollectorManager.getInstance().execute(); SharableCollectorManager.getInstance().execute();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
} }
} }

Loading…
Cancel
Save