开发者

reflect a set of changes by making corresponding function calls on apply

I am developing a java swing application which has the functionality of adding,editing and deleting nodes to a tree, and there are two controls apply and cancel.

when user performs any operation on tree say for eg. adds a new node, it will be immediately reflected in the UI, but the corresponding call to a function for making it persistent will be made only when user chooses Apply else the changes will be reverted to previous stable state.

I have handled the UI part of applying and cancelling, but I am wondering how to efficiently perform a set of procedure calls on apply.

I thought of adding the procedure calls as a string to an arraylist and iterating this arraylist in order (as this ensures order of user operations,which is an important requirement) and execute them as java statements.

Another way is to have a double map for mapping the sequence of user operation to the procedure sequence, and procedure sequence to the list of parameters.

开发者_JAVA百科But I feel there could be a better way to achieve this and would like to hear your answers.


The only time that I think you would want to map the UI and procedure actions together is if you were going to implement an "Undo" function. Otherwise, it is simplest to just store the list of operations and preform them in order as you describe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜