Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Fig. 1 is the schematic flow sheet that the present invention is based on an embodiment of modeling tool command calls method of MVC framework, and as shown in Figure 1, present embodiment comprises the steps:
Step 101, the user interface components in the view layer of MVC framework convert the system event that gets access to into internal event and send to the instruction control unit of the key-course that is arranged in the MVC framework;
Step 102, this instruction control unit are searched with the corresponding order of this internal event according to the pairing application affairs type of this internal event and are carried out this order.
The modeling tool command calls method that the embodiment of the invention provides based on the MVC framework; Through the user interface components in the view layer of MVC framework the system event that acquires is converted into internal event and sends to the instruction control unit that is arranged in key-course; Because incident is divided into internal event and as the system event of external event; Make internal event and system event clear definiton of powers, thereby improved program run efficient; Further; When the number of number of commands and system event is huger; Search and the corresponding order of internal event and this order of execution according to the pairing application affairs type of internal event through instruction control unit; Avoided calling earlier in the prior art corresponding concrete incident, gone to call corresponding order by concrete incident again, thereby improved the validity of call instruction.
Fig. 2 is the schematic flow sheet that the present invention is based on another embodiment of modeling tool command calls method of MVC framework; As shown in Figure 2, the embodiment of the invention comprises:
Whenstep 201, the user interface components initialization in the view layer of MVC framework, the view assistant class in the corresponding view helper module of this user interface components is carried out instantiation, and this view assistant class is registered in the view steady arm.
The system event thatstep 202, the event sniffer monitoring users interface assembly through the view layer acquire.
Step 203, convert this system event into internal event and send to the instruction control unit of key-course through event sniffer;
Step 204, this instruction control unit are searched with the corresponding order of this internal event according to the pairing application affairs type of this internal event and are carried out this order;
Step 205, if the packaged processing logic of this order need communicate with the data source of server end, then in key-course establishment proxy class;
Step 206, from the positioning service device, obtain and the corresponding service of this proxy class type of connection, connect through this service and type communicate to obtain the processing logic relevant data packaged with this order with the data source of server end;
Step 207, after logical process is carried out in this order, in model layer, revise and order corresponding data with this;
Afterstep 208, the data in this model layer are upgraded, notify the user interface components of view layer to carry out display update through data binding mechanism or event notification mechanism.
In above-mentionedsteps 201; When the user interface components to the view layer of MVC framework carries out initialization; Need carry out the instantiation correspondence to the view assistant class in view assistant (ViewHelper) module, and view assistant class is registered in the view steady arm (ViewLocator); Wherein, view steady arm (ViewLocator) makes other order in the calling program can obtain the view Assistant object of any needs as single example class, to realize the operation to the UI assembly.In addition; At view (View) layer; Because the corresponding view helper module of each UI assembly (Component), event sniffer can be arranged in the view helper module, thereby makes the corresponding UI class of UI assembly can be absorbed in the layout of user interface; Avoided in the UI assembly, comprising any logic, made that the UI class is more suitable for realizing through the SGML (MXML) of describing the interface performance; And other order described in the embodiment of the invention specifically can be any order that may change view; For example: the order of the change viewstate of model layer, key-course; For example if the order that other order is the deletion view; Order that then should the deletion view is earlier through the view helper module, remakes to be used for the corresponding view layer, thereby makes the operation to the UI assembly all realize through the view helper module.
In above-mentionedsteps 202~step 204; UI assembly in the view layer receives the system event that the user triggers through mouse or keyboard etc.; Through event sniffer with this system event convert into internal event (this internal event for example can for: create file, newly-built pel etc.) send in the instruction control unit (DesignerControlle); Instruction control unit is searched with the corresponding order of this internal event (Command) according to the type of internal event and is carried out this order, wherein, has encapsulated concrete processing logic in this order; Understand the processing logic described in the embodiment of the invention for clearer; The processing logic of facing in the embodiment of the invention down is illustrated, if order is figure of deletion, then processing logic is meant according to the order of a figure of this deletion the related data of this figure in the model layer is deleted; And with on the painting canvas with by all relevant associated deletions of figure of being deleted, and through the binding relationship renewal view of view layer with model layer; Through internal event and external event are divided, make that the order in calling incident is more efficient.
In above-mentionedsteps 205 andstep 206,, can create agency (Delegate) class at key-course if the packaged processing logic of this order need communicate with the data source of server end; From positioning service device (ServiceLocator), obtain corresponding service and connect type (this service connects type specifically can be HTTPService, RMIService etc.); Communicate through the data source of service connection class, obtain the processing logic relevant data packaged with this order with server end.
In above-mentionedsteps 207 andstep 208; After logical process is carried out in order (Command); If need to revise with this and order the data in corresponding model (Model) layer; Then the data in the model layer are upgraded, informed that through data binding mechanism or event notification mechanism the assembly of view layer carries out display update.
The modeling tool command calls method that the embodiment of the invention provides based on the MVC framework; User interface components through at the view layer converts the system event that acquires internal event into and sends to the instruction control unit that is positioned at key-course; Because incident is divided into internal event and as the system event of external event; Make internal event and system event clear definiton of powers, thereby improved program run efficient; Further; When the number of number of commands and system event is huger; Search and the corresponding order of internal event and this order of execution according to the pairing application affairs type of internal event through instruction control unit; Avoided calling earlier in the prior art corresponding concrete incident, gone to call corresponding order by concrete incident again, thereby improved the validity of call instruction.
Fig. 3 is the structural representation that the present invention is based on an embodiment of modeling tool command calls system of MVC framework, and the embodiment of the invention can realize the method flow of above-mentioned embodiment illustrated in figures 1 and 2; As shown in Figure 3, the embodiment of the invention comprises:user interface components 31,instruction control unit 32;
Wherein,user interface components 31 is arranged in the view layer of MVC framework, converts the system event that gets access to into internal event and sends to theinstruction control unit 32 of the key-course that is arranged in this MVC framework at this view layer;Instruction control unit 32 is searched with the corresponding order of said internal event according to the pairing application affairs type of said internal event and is carried out said order.
The modeling tool command calls system that the embodiment of the invention provides based on the MVC framework; Convert the system event that acquires into internal event and send to theinstruction control unit 32 that is positioned at key-course throughuser interface components 31 at the view layer; Because incident is divided into internal event and as the system event of external event; Make internal event and system event clear definiton of powers, thereby improved program run efficient; Further; When the number of number of commands and system event is huger; Search and the corresponding order of internal event and this order of execution according to the pairing application affairs type of internal event throughinstruction control unit 32; Avoided calling earlier in the prior art corresponding concrete incident, gone to call corresponding order by concrete incident again, thereby improved the validity of call instruction.
Fig. 4 is the structural representation that the present invention is based on modeling tool command calls another embodiment of system of MVC framework, and the embodiment of the invention can realize the method flow of above-mentioned embodiment illustrated in figures 1 and 2; As shown in Figure 4, the embodiment of the invention comprises based on the modeling toolcommand calls system 40 of MVC framework:user interface components 41,instruction control unit 42,event sniffer 43, view steady arm 44,positioning service device 45;
Wherein,user interface components 41 is arranged in the view layer of MVC framework, converts the system event that gets access to into internal event and sends to theinstruction control unit 42 of the key-course that is positioned at the MVC framework at the view layer;Instruction control unit 42 said instruction control units are searched with the corresponding order of said internal event according to the pairing application affairs type of said internal event and are carried out said order.
Further, the event sniffer 43 in the embodiment of the invention is connected withuser interface components 41, is arranged in the view layer;Event sniffer 43 is used for the system event that monitoringusers interface assembly 41 gets access to, and said system event is converted into internal event and sends to theinstruction control unit 42 of key-course.
Further, the view steady arm 44 in the embodiment of the invention is connected withuser interface components 41, is arranged in the view layer; View steady arm 44 is used for whenuser interface components 41 initialization of view layer, and the view assistant class in the view helper module of theseuser interface components 41 correspondences is carried out instantiation, registers said view assistant class class.
Further;Positioning service device 45 in the embodiment of the invention provides and at the corresponding service of proxy class type of connection that said key-course is created, makes said service connect class and communicate to obtain the processing logic relevant data packaged with said order with the data source of server end;
Further, can also comprise modifiedmodule 46 andnotification module 47 in the model layer in the embodiment of the invention; Wherein, after logical process was carried out in this order, modifiedmodule 46 was revised in said model layer and the corresponding data of said order; After data in said model layer were upgraded,notification module 47 notified the user interface components of said view layer to carry out display update through data binding mechanism or event notification mechanism.
The modeling tool command calls system that the embodiment of the invention provides based on the MVC framework; User interface components through at the view layer converts the system event that acquires internal event into and sends to the instruction control unit that is positioned at key-course; Because incident is divided into internal event and as the system event of external event; Make internal event and system event clear definiton of powers, thereby improved program run efficient; Further; When the number of number of commands and system event is huger; Search and the corresponding order of internal event and this order of execution according to the pairing application affairs type of internal event through instruction control unit; Avoided calling earlier in the prior art corresponding concrete incident, gone to call corresponding order by the concrete time again, thereby improved the validity of call instruction.
For the clearer technical scheme of understanding the embodiment of the invention, through Fig. 5 the embodiment of the invention is specifically described below; Fig. 5 is the structural representation of the MVC frame system that the embodiment of the invention was suitable for.
As shown in Figure 5, the MVC frame system that the embodiment of the invention was suitable for can be atview layer 51,model layer 52, key-course 53, service layer's 54 execution graphs 1 and method flow embodiment illustrated in fig. 2.
As shown in Figure 5; At view (View)layer 51; Each user interface components 511 a corresponding view assistant (ViewHelper)module 512;Event sniffer 513 is arranged in theview helper module 512, thereby makes the user interface class in theview layer 51 can be absorbed in the layout at interface and not comprise any logic; And other operation to user interface components 511 all realizes throughview helper module 512; The corresponding view assistant class of the automatic instantiation of meeting when user interface components 511 initialization; And view assistant class is registered in the view steady arm (ViewLocator) 514; Viewsteady arm 514 makes other role in the calling program can obtain the view Assistant object of any needs as a single example class, to realize the operation to user interface components 511; Because the single example class described in the embodiment of the invention is well known to those skilled in the art, and repeats no more at this.
In model (Model)layer 52, exist a plurality of model objects to be registered in the model orientation device (ModelLocator) 521; Because model orientation device 521 also is a single example class, can search required model object through this list example class; Model object can correspond to of Local or Remote, or in a plurality of data object (DataObject); In addition, model object can through data binding mechanism be associated with the corresponding UI assembly of this model in, thereby make that the UI assembly can obtain upgrading after model is modified.
In control (Controller)layer 53; Front controller (FrontController) class is a core classes; Adopt single routine quasi-mode; When realizing, only need to inherit a front controller class establishment concrete instruction control unit (DesignerController) 531 corresponding command controller classes and get final product.In store application affairs (ODEvent) is to the mapping of order (Command) in the front controller class.Command set has encapsulated the service logic of application program; Command set can obtain needed view assistant (ViewHelper) module and model (Model) object through view steady arm (ViewLocator) 532 and model orientation device (ModelLoactor) 521, thereby realizes the modification to view and data.
In service (Server)layer 54; Command set can (for example: services such as HTTPService, WebService) obtain needed Connection Service from the positioning service device (ServiceLocator) 541 theservice layer 54 when the data object of the server end in needs of the service logic in the command set and theservice layer 54 communicates; Make command set need not be concerned about the information of establishment of connection process and server end; Also can be reused with the Connection Service of server end simultaneously by a plurality of command set, thus the overall performance of raising program.
Treatment scheme in embodiment illustrated in fig. 5 is following: at first the user interface components in theview layer 51 511 receives users' system events such as mouse or keyboard, is converted into internal application incident (as creating file, newly-built pel etc.) to send in the instruction control unit (DesignerController); Instruction control unit finds corresponding command and carries out this order according to the application affairs type, has encapsulated concrete processing logic in the command set.If the packaged processing logic of command set need communicate with the data source of server end; Can create an agency (Delegate) class in inside; From positioning service device (ServiceLocator), obtain corresponding service (Service) and connect type (for example: HTTPService, RMIService etc.); Communicate through the data source of service (Service) connection class, obtain relevant data with server end.Order (Command) is carried out needing to revise the data in the corresponding model layer after the logical process, after the data in the model layer are updated, informs that through data binding mechanism or event notification mechanism the assembly of view layer carries out display update again.Simultaneously, after opening collaborative pattern, the order that can work in coordination with (Command) can be sent out and trigger external event, and message is sent to cooperative module, and cooperative module can be collected correlation parameter and send to other client, accomplishes co-operating.
The embodiment of the invention is through being divided into incident internal event and external event, makes that the order (Command) of calling in the incident (Event) at front controller (FrontController) is more efficient.Because calling the order of the order in the incident in the prior art is that front controller (FrontController) calls corresponding concrete incident (Event) earlier; Concrete incident goes to call corresponding order (Command) again; And the embodiment of the invention is through removing to call internal event or external event earlier; Go to call corresponding concrete incident by respective inner incident or external event again; Further call the corresponding order of internal event again, when the number of number of ordering and incident is huge, can improve the efficient of call instruction greatly.
Through above interactive mode; User interface components 511 assemblies and the assembly in themodel layer 52 in theview layer 51 are separate; Realized that data and demonstration are separated; Make the user interface components 511 in theview layer 51 to make amendment and can not have influence on the assembly ofmodel layer 52, simultaneously the processing logic in the program is encapsulated into each and independently orders in (Command) type, be encapsulated in service (Service) class with the logic that is connected of server in theservice layer 54 according to user's preference; The logic that helps in the program is reused, function expansion and maintenance.
The those skilled in the art can be well understood to, for the convenience described with succinct, the concrete course of work of the system of foregoing description, equipment, module and unit can repeat no more at this with reference to the corresponding process among the preceding method embodiment.
One of ordinary skill in the art will appreciate that: all or part of step that realizes the foregoing description can be accomplished through the relevant hardware of programmed instruction; Aforesaid program can be stored in the computer read/write memory medium; This program the step that comprises said method embodiment when carrying out; And aforesaid storage medium comprises: various media that can be program code stored such as ROM, RAM, magnetic disc or CD.
What should explain at last is: above embodiment is only in order to explaining technical scheme of the present invention, but not to its restriction; Although with reference to previous embodiment the present invention has been carried out detailed explanation, those of ordinary skill in the art is to be understood that: it still can be made amendment to the technical scheme that aforementioned each embodiment put down in writing, and perhaps part technical characterictic wherein is equal to replacement; And these are revised or replacement, do not make the spirit and the scope of the essence disengaging various embodiments of the present invention technical scheme of relevant art scheme.