zoukankan      html  css  js  c++  java
  • org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy 中一个方法

     1 /**
     2      * Method getCreateElementAndViewCommand.
     3      * 
     4      * @param request
     5      * @return Command Which creates the sematnic and the view command for the
     6      *         given CreateViewAndElementRequest
     7      */
     8     protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
     9         // get the element descriptor
    10         CreateElementRequestAdapter requestAdapter =
    11             request.getViewAndElementDescriptor().getCreateElementRequestAdapter();
    12 
    13         // get the semantic request
    14         CreateElementRequest createElementRequest =
    15             (CreateElementRequest) requestAdapter.getAdapter(
    16                 CreateElementRequest.class);
    17 
    18         if (createElementRequest.getContainer() == null) {
    19             // complete the semantic request by filling in the host's semantic
    20             // element as the context
    21             View view = (View)getHost().getModel();
    22             EObject hostElement = ViewUtil.resolveSemanticElement(view);
    23             
    24             if (hostElement == null && view.getElement() == null) {
    25                 hostElement = view;
    26             }            
    27 
    28             // Returns null if host is unresolvable so that trying to create a
    29             // new element in an unresolved shape will not be allowed.
    30             if (hostElement == null) {
    31                 return null;
    32             }
    33             createElementRequest.setContainer(hostElement);
    34         }
    35 
    36         // get the create element command based on the elementdescriptor's
    37         // request
    38         Command createElementCommand =
    39             getHost().getCommand(
    40                 new EditCommandRequestWrapper(
    41                     (CreateElementRequest)requestAdapter.getAdapter(
    42                         CreateElementRequest.class), request.getExtendedData()));
    43 
    44         if (createElementCommand == null
    45             return UnexecutableCommand.INSTANCE;
    46 
    47         // create the semantic create wrapper command
    48         SemanticCreateCommand semanticCommand =
    49             new SemanticCreateCommand(requestAdapter, createElementCommand);
    50         Command viewCommand = getCreateCommand(request);
    51 
    52         Command refreshConnectionCommand =
    53             getHost().getCommand(
    54                 new RefreshConnectionsRequest(((List)request.getNewObject())));
    55 
    56 
    57         // form the compound command and return
    58         CompositeCommand cc = new CompositeCommand(semanticCommand.getLabel());
    59         cc.compose(semanticCommand);
    60         cc.compose(new CommandProxy(viewCommand));
    61         if ( refreshConnectionCommand != null ) {
    62             cc.compose(new CommandProxy(refreshConnectionCommand));
    63         }
    64 
    65         return new ICommandProxy(cc);
    66     }
  • 相关阅读:
    url中的特殊字符问题
    Gridview中几个Button的应用
    Asp.net中static变量和viewstate的使用方法(谨慎)
    my97DatePicker选择年、季度、月、周、日
    Server.MapPath()
    asp.net(C#)读取文件夹和子文件夹下所有文件,绑定到GRIDVIEW并排序 .
    sql union和union all的用法及效率
    asp.net 字符串替换、截取和从字符串中最后某个字符 开始截取
    ASP.NET
    sql中查询中的when...then 语句
  • 原文地址:https://www.cnblogs.com/youngerbaby/p/434232.html
Copyright © 2011-2022 走看看