www.gusucode.com > appdesigner工具箱matlab源码程序 > appdesigner/+appdesigner/+internal/+model/DesignTimeProperties.m

    classdef DesignTimeProperties < handle
    %DESIGNTIMEPROPERTIES This is a class that handles
    % AppDesigner specific design time properties for the component,
    % such as generating code, CodeName or GroupId.
    
    % Copyright 2015-2016 The MathWorks, Inc.
    
    properties (GetAccess = 'public', SetAccess = {...
            ?appdesigner.internal.controller.DesignTimeController})
        % AppDesigner specific design time properties for the
        % component
        % CodeName of the component
        CodeName = '';
        
        % GroupId of the component belongs to
        GroupId = '';
        
        % AppDesigner specific design time properties for the
        % component code generation
        ComponentCode = {};
    end
    
    properties (Constant, Transient)
        % Design time propery names for client side view
        PropertyNamesForView = {'CodeName', 'GroupId', 'ComponentCode'};
        
        % Class responsible for using the adapter to create code for a
        % component.  This object will be shared by all components.
        ComponentCodeGenerator = appdesigner.internal.codegeneration.ComponentCodeGenerator(...
            {'DesignTimeProperties'});
    end
    
    
    methods(Access = {...
            ?appdesigner.internal.controller.DesignTimeController})
        
        function updateProperties(obj, model, adapter, proxyView)  
            % Update CodeName and groupId
            obj.CodeName = proxyView.getProperty('CodeName');
            obj.GroupId = proxyView.getProperty('GroupId');
        end
        
        function updateCode(obj, model, adapter, proxyView)
            
            code = proxyView.getProperty('ComponentCode');
            if (~isempty(code))
                obj.ComponentCode = cell(code);                
            end
            
            % Generate component code using the code generator class
            obj.ComponentCode = obj.ComponentCodeGenerator.getComponentGenerationCode(model, adapter);
            hashMap = appdesservices.internal.peermodel.convertPvPairsToJavaMap({'ComponentCode', obj.ComponentCode});
            proxyView.PeerNode.setProperties(hashMap);
        end
    end
end