1 *&---------------------------------------------------------------------*
2 *& Report RSDEMO_DRAG_DROP_EDIT_TREE *
3 *& *
4 *&---------------------------------------------------------------------*
5 *& *
6 *& *
7 *&---------------------------------------------------------------------*
8
9 REPORT rsdemo_drag_drop_edit_tree .
10 DATA ok_code TYPE sy-ucomm.
11 DATA node_itab_left LIKE node_str OCCURS 0.
12 DATA node_itab_right LIKE node_str OCCURS 0.
13 DATA node LIKE node_str.
14
15 DATA container TYPE REF TO cl_gui_custom_container.
16 DATA splitter TYPE REF TO cl_gui_easy_splitter_container.
17 DATA right TYPE REF TO cl_gui_container.
18 DATA left TYPE REF TO cl_gui_container.
19
20 DATA tree_right TYPE REF TO cl_gui_simple_tree.
21 DATA tree_left TYPE REF TO cl_gui_simple_tree.
22
23 DATA behaviour_left TYPE REF TO cl_dragdrop.
24 DATA behaviour_right TYPE REF TO cl_dragdrop.
25
26 DATA handle_tree_left TYPE i.
27 DATA handle_tree_right TYPE i.
28
29 *---------------------------------------------------------------------*
30 * CLASS lcl_treeobject DEFINITION
31 *---------------------------------------------------------------------*
32 * Definition of Data Container *
33 *---------------------------------------------------------------------*
34 CLASS lcl_drag_object DEFINITION.
35 PUBLIC SECTION.
36 DATA text TYPE STANDARD TABLE OF mtreesnode-text.
37 ENDCLASS.
38
39
40 *---------------------------------------------------------------------*
41 * CLASS dragdrop_receiver DEFINITION
42 *---------------------------------------------------------------------*
43 * ........ *
44 *---------------------------------------------------------------------*
45 CLASS lcl_dragdrop_receiver DEFINITION.
46 PUBLIC SECTION.
47 METHODS:
48 flavor_select FOR EVENT on_drop_get_flavor OF cl_gui_simple_tree
49 IMPORTING node_key flavors drag_drop_object,
50 left_drag FOR EVENT on_drag_multiple OF cl_gui_simple_tree
51 IMPORTING node_key_table drag_drop_object,
52 right_drop FOR EVENT on_drop OF cl_gui_simple_tree
53 IMPORTING node_key drag_drop_object,
54 drop_complete FOR EVENT on_drop_complete_multiple OF
55 cl_gui_simple_tree
56 IMPORTING node_key_table drag_drop_object.
57
58 ENDCLASS.
59
60 ************************************************************************
61
62
63 ************************************************************************
64
65 START-OF-SELECTION.
66 CALL SCREEN 100.
67 *&---------------------------------------------------------------------*
68 *& Module START OUTPUT
69 *&---------------------------------------------------------------------*
70 * text
71 *----------------------------------------------------------------------*
72 MODULE start OUTPUT.
73 SET PF-STATUS 'BASE'.
74 IF container is initial.
75 CREATE OBJECT container
76 EXPORTING container_name = 'CONTAINER'.
77 CREATE OBJECT splitter
78 EXPORTING parent = container
79 orientation = 1.
80 left = splitter->top_left_container.
81 right = splitter->bottom_right_container.
82 CREATE OBJECT tree_right
83 EXPORTING parent = right
84 node_selection_mode = tree_right->node_sel_mode_multiple.
85 CREATE OBJECT tree_left
86 EXPORTING parent = left
87 node_selection_mode = tree_left->node_sel_mode_multiple.
88
89 * Definition of drag drop behaviour
90 CREATE OBJECT behaviour_left.
91 CALL METHOD behaviour_left->add
92 EXPORTING
93 flavor = 'Tree_move'
94 dragsrc = 'X'
95 droptarget = ' '
96 effect = cl_dragdrop=>copy.
97 CALL METHOD behaviour_left->add
98 EXPORTING
99 flavor = 'Tree_copy'
100 dragsrc = 'X'
101 droptarget = ' '
102 effect = cl_dragdrop=>copy.
103
104 CALL METHOD behaviour_left->get_handle
105 IMPORTING handle = handle_tree_left.
106
107 * Drag Drop behaviour of tree control nodes are defined in the node
108 * structure
109 PERFORM fill_tree CHANGING handle_tree_left node_itab_left.
110 CALL METHOD tree_left->add_nodes
111 EXPORTING node_table = node_itab_left
112 table_structure_name = 'NODE_STR'.
113
114 CREATE OBJECT behaviour_right.
115
116 CALL METHOD behaviour_right->add
117 EXPORTING
118 flavor = 'Tree_copy'
119 dragsrc = ' '
120 droptarget = 'X'
121 effect = cl_dragdrop=>copy.
122 CALL METHOD behaviour_right->add
123 EXPORTING
124 flavor = 'Tree_move'
125 dragsrc = ' '
126 droptarget = 'X'
127 effect = cl_dragdrop=>copy.
128 CALL METHOD behaviour_right->get_handle
129 IMPORTING handle = handle_tree_right.
130
131 PERFORM fill_tree CHANGING handle_tree_right node_itab_right.
132 CALL METHOD tree_right->add_nodes
133 EXPORTING node_table = node_itab_right
134 table_structure_name = 'NODE_STR'.
135
136 * registration of drag and drop events
137 DATA dragdrop TYPE REF TO lcl_dragdrop_receiver.
138 CREATE OBJECT dragdrop.
139 SET HANDLER dragdrop->flavor_select FOR tree_right.
140 SET HANDLER dragdrop->left_drag FOR tree_left.
141 SET HANDLER dragdrop->right_drop FOR tree_right.
142 SET HANDLER dragdrop->drop_complete FOR tree_left.
143
144
145 CALL METHOD tree_left->expand_node
146 EXPORTING node_key = 'Root'.
147 CALL METHOD tree_right->expand_node
148 EXPORTING node_key = 'Root'.
149
150 ENDIF.
151 ENDMODULE. " START OUTPUT
152 *&---------------------------------------------------------------------*
153 *& Module EXIT INPUT
154 *&---------------------------------------------------------------------*
155 * text
156 *----------------------------------------------------------------------*
157 MODULE exit INPUT.
158 LEAVE PROGRAM.
159 ENDMODULE. " EXIT INPUT
160 *&---------------------------------------------------------------------*
161 *& Form fill_tree
162 *&---------------------------------------------------------------------*
163 * text
164 *----------------------------------------------------------------------*
165 * --> p1 text
166 * <-- p2 text
167 *----------------------------------------------------------------------*
168 FORM fill_tree CHANGING handle_tree TYPE i
169 node_itab LIKE node_itab_left.
170 DATA: node LIKE mtreesnode.
171
172 * node table of the left tree
173 CLEAR node.
174 node-node_key = 'Root'.
175 node-isfolder = 'X'.
176 node-text = 'Texte'.
177 node-dragdropid = ' '.
178 APPEND node TO node_itab.
179
180 CLEAR node.
181 node-node_key = 'Child1'.
182 node-relatkey = 'Root'.
183 node-isfolder = 'X'.
184 node-relatship = cl_gui_simple_tree=>relat_last_child.
185 node-text = 'DragDrop Text 1'.
186 node-dragdropid = handle_tree. " handle of behaviour
187 APPEND node TO node_itab.
188
189 CLEAR node.
190 node-node_key = 'Child2'.
191 node-relatkey = 'Root'.
192 node-isfolder = 'X'.
193 node-relatship = cl_gui_simple_tree=>relat_last_child.
194 node-text = 'DragDrop Text 2'.
195 node-dragdropid = handle_tree. " handle of behaviour
196 APPEND node TO node_itab.
197
198
199 ENDFORM. " fill_tree
200 *&---------------------------------------------------------------------*
201 *& Module USER_COMMAND_0100 INPUT
202 *&---------------------------------------------------------------------*
203 * text
204 *----------------------------------------------------------------------*
205 MODULE user_command_0100 INPUT.
206 CALL METHOD cl_gui_cfw=>dispatch.
207 ENDMODULE. " USER_COMMAND_0100 INPUT
208
209
210 *---------------------------------------------------------------------*
211 * CLASS DRAGDROP_RECEIVER IMPLEMENTATION
212 *---------------------------------------------------------------------*
213 * ........ *
214 *---------------------------------------------------------------------*
215 CLASS lcl_dragdrop_receiver IMPLEMENTATION.
216 METHOD flavor_select.
217 IF node_key <> 'Root'.
218 SEARCH flavors FOR 'Tree_move'.
219 IF sy-subrc = 0.
220 CALL METHOD drag_drop_object->set_flavor
221 EXPORTING newflavor = 'Tree_move'.
222 ELSE.
223 CALL METHOD drag_drop_object->abort.
224 ENDIF.
225 ELSE.
226 SEARCH flavors FOR 'Tree_copy'.
227 IF sy-subrc = 0.
228 CALL METHOD drag_drop_object->set_flavor
229 EXPORTING newflavor = 'Tree_copy'.
230 ELSE.
231 CALL METHOD drag_drop_object->abort.
232 ENDIF.
233 ENDIF.
234
235 ENDMETHOD.
236 METHOD left_drag.
237 DATA drag_object TYPE REF TO lcl_drag_object.
238 DATA node_key TYPE node_str-node_key.
239 CREATE OBJECT drag_object.
240 LOOP AT node_key_table INTO node_key.
241 READ TABLE node_itab_left WITH KEY node_key = node_key
242 INTO node.
243
244 APPEND node-text TO drag_object->text.
245 ENDLOOP.
246 drag_drop_object->object = drag_object.
247 ENDMETHOD.
248
249 METHOD right_drop.
250 DATA drag_object TYPE REF TO lcl_drag_object.
251 data new_nodes like node_itab_right.
252 data new_node type node_str.
253 CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
254 drag_object ?= drag_drop_object->object.
255 ENDCATCH.
256 IF sy-subrc = 1.
257 " data object has unexpected class
258 " => cancel Drag & Drop operation
259 CALL METHOD drag_drop_object->abort.
260 EXIT.
261 ENDIF.
262 loop at drag_object->text into new_node-text.
263 perform add_node changing node_key new_node new_nodes
264 node_itab_left.
265 endloop.
266 call method tree_right->add_nodes
267 exporting node_table = new_nodes
268 table_structure_name = 'NODE_STR'.
269 ENDMETHOD.
270 METHOD drop_complete.
271 DATA node_key TYPE node_str-node_key.
272 IF drag_drop_object->flavor = 'Tree_move_to_Edit'.
273 LOOP AT node_key_table INTO node_key.
274 CALL METHOD tree_left->delete_node
275 EXPORTING node_key = node_key.
276 DELETE node_itab_left WHERE node_key = node_key.
277 ENDLOOP.
278 ENDIF.
279
280 ENDMETHOD.
281 ENDCLASS.
282
283 *&---------------------------------------------------------------------*
284 *& Form ADD_NODE
285 *&---------------------------------------------------------------------*
286 * text
287 *----------------------------------------------------------------------*
288 * <--P_NEW_NODE text
289 * <--P_NEW_NODES text
290 * <--P_NODE_ITAB_LEFT text
291 *----------------------------------------------------------------------*
292 FORM ADD_NODE CHANGING node_key
293 NEW_NODE type node_str
294 NEW_NODES like node_itab_left
295 NODE_ITAB_LEFT like node_itab_left.
296 data lines type i.
297 describe table node_itab_left lines lines.
298 new_node-node_key = lines.
299 new_node-isfolder = 'X'.
300 new_node-dragdropid = handle_tree_right.
301 new_node-relatkey = node_key.
302
303 APPEND new_node TO new_nodes.
304 append new_node to node_itab_left.
305
306 ENDFORM. " ADD_NODE

SAP Drag or drop tree的更多相关文章

  1. 20 Best Drag and Drop jQuery Plugins--reference

    reference from:http://dizyne.net/20-best-drag-drop-jquery-plugins/ jQuery has done a great job repla ...

  2. delphi Drag and Drop sample 鼠标拖放操作实例

    Drag and Drop is a common operation that makes the interface user friendly: a user can drag/drop inf ...

  3. HTML5 之拖放(drag与drop)

    拖放(Drag 和 drop)是 HTML5 标准的组成部分. 拖放是一种常见的特性,即抓取对象以后拖到另一个位置. 在 HTML5 中,拖放是标准的一部分,任何元素都能够拖放. HTML5 拖放实例 ...

  4. 通过HTML5的Drag and Drop生成拓扑图片Base64信息

    HTML5 原生的 Drag and Drop是很不错的功能,网上使用例子较多如 http://html5demos.com/drag ,但这些例子大部分没实际用途,本文将搞个有点使用价值的例子,通过 ...

  5. 基于HTML5的Drag and Drop生成图片Base64信息

    HTML5的Drag and Drop是很不错的功能,网上使用例子较多如 http://html5demos.com/drag ,但这些例子大部分没实际用途,本文将搞个有点使用价值的例子,通过Drag ...

  6. Android 用户界面---拖放(Drag and Drop)(三)

      设计拖放操作 本节主要内容如下: 1.  如何开始拖拽: 2.  在拖拽期间如何响应事件: 3.  如何响应落下事件: 4.  如何结束拖放操作. 开始拖拽 用户使用一个拖拽手势开始拖拽,通常是在 ...

  7. Android 用户界面---拖放(Drag and Drop)(二)

      拖拽事件监听器和回调方法 View对象既可以用实现View.OnDragListener接口的拖放事件监听器,也可以用View对象的onDragEvent(DragEvent)回调方法来接收拖拽事 ...

  8. Android 用户界面---拖放(Drag and Drop)(一)

    用Android的拖放框架,能够允许用户使用图形化的拖放手势,把数据从当前布局中的一个View对象中移到另一个View对象中.这个框架包括:拖拽事件类.拖拽监听器.以及辅助的方法和类. 尽管这个框架主 ...

  9. [Javascript + rxjs] Simple drag and drop with Observables

    Armed with the map and concatAll functions, we can create fairly complex interactions in a simple wa ...

随机推荐

  1. 制作Unity中的单位血条

    本文章用于记录Unity的学习过程,如有疑问,欢迎交流. 1.血条的显示 在Unity场景中创建空物体,然后新建两个Image(图片),当然只用一个也行,一个作为填充来显示血量,一个作为血条的外框. ...

  2. Math内置对象 常用的方法

    属性: Math.Pi 方法: Math.max()   最大值 Math.min()  最小值 Math.ceil()  向上取整 Math.floor() 向下取整 Math.random()   ...

  3. mongodb 数据块的迁移流程介绍

    1. 基本概念 1.1 Chunk(数据块) 表示特定服务器上面,连续范围的分片键值所包含的一组数据,是一个逻辑概念. 例如,某数据块记录如下: { "_id" : "c ...

  4. 攻防世界-MISC:掀桌子

    这是攻防世界新手练习区的第八题,题目如下: 就给了一串16进制的字符串.哎,又是不懂,看了一下官方WP,说是将每两位16进制数转换为10进制,再减去128再转换为ASCII码.直接上脚本 str1 = ...

  5. 微服务生态组件之Spring Cloud LoadBalancer详解和源码分析

    Spring Cloud LoadBalancer 概述 Spring Cloud LoadBalancer目前Spring官方是放在spring-cloud-commons里,Spring Clou ...

  6. CRM项目的整理---第一篇

    CRM:cunstomer relationship management  客户管理系统 1.项目的使用者:销售  班主任    讲师  助教 2.项目的需求分析 2.1.注册 2.2.登录 2.3 ...

  7. 拯救一切强迫症 - 读《编写可维护的 JavaScript》(一)

    拯救一切强迫症 - 读<编写可维护的 JavaScript>(一) 本文写于 2020 年 4 月 24 日 我在小学的时候就有接触过编程,所以读大一的时候 C 语言还算是轻车熟路.自然会 ...

  8. 《Mybatis 手撸专栏》第8章:把反射用到出神入化

    作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言 为什么,读不懂框架源码? 我们都知道作为一个程序员,如果想学习到更深层次的技术,就需 ...

  9. 【动态UAC权限】无盾程序(win32&cmd)

    可以看到两种不同的提权方式,注意是动态,用代码提权,而不是用清单文件提前处理. 函数都写好了,这里不多做解释. win32程序: 首先需要这俩头文件,第二个我忘了啥函数要用了,总之出问题加上就对了:( ...

  10. VS.NET启动显示ID为XXXX的进程当前未运行

    解决办法:在启动项目根目录下用文本编辑器打开Web项目下的{X}.csproj文件,然后查找 <WebProjectProperties>,将这一对标签之间的内容全部删除,然后再打开项目就 ...