forked from fanruan/design
kuangshuai
4 years ago
14 changed files with 660 additions and 3 deletions
@ -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); |
||||
} |
@ -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(); |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
|
||||
|
@ -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.form.share.encrypt.core.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; |
||||
} |
||||
|
||||
} |
@ -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]; |
||||
} |
||||
} |
@ -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.form.share.encrypt.core.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; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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.form.share.encrypt.core.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]; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -1,11 +1,16 @@
|
||||
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.encrypt.clipboard.impl.EncryptSelectionClipboardHandler; |
||||
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler; |
||||
import com.fr.design.mainframe.share.util.SharableXMLUtils; |
||||
|
||||
public class SharableInitManager { |
||||
public static void start() { |
||||
SharableXMLUtils.registerSharableReadHelper(); |
||||
SharableCollectorManager.getInstance().execute(); |
||||
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance()); |
||||
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance()); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue