20120212 policy中的command

本文探讨了在GEF框架中通过在policy中创建多个command来实现后退功能的方法。这种方式虽牺牲了一定的效率,但能简便地实现后退操作。文章详细解释了command如何被commonstack执行并存储,以及通过重写undo方法实现后退。

给同事培训的时候有一个问题一直没有解决:在policy中创建了过多的command
    @Override
    protected Command createChangeConstraintCommand(EditPart child,
            Object constraint) {
        SuperChangeConstraintCommand changeConstraint = new SuperChangeConstraintCommand();

......
        return changeConstraint;
    }

以拖拽为例我们调试的时候会发现这里创建了非常多的command,会影响效率的。

这样的设计是为了实现gef的后退功能。那他是怎么实现的呢在policy中最后会返回一个command这个command会被commonstack执行。那么commonstack是什么呢大家可以把它简单地理解为一个栈。被执行的command都会存放到这个站里面。而每一个command都可以重写undo方法。这样就好了,按照栈的规则先进后出,那么我们执行了一个命令后存放到里面,如果后退的话就把最后的一个command提出来然后执行他的undo方法,这样就可以实现了。

虽然牺牲了很多的效率但是可以很方便的实现后退方法。
-- Configuring done CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../fep/lib" This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../fep/lib/usrlib" This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../lib" This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../fep/lib" This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../fep/lib/usrlib" This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) in CMakeLists.txt: Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES target property. Run "cmake --help-policy CMP0081" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating link directories of "portal": "../lib" 报错解析
最新发布
10-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值