{"action":"created","comment":{"url":"https://api.github.com/repos/sghpjuikit/player/pulls/comments/245482383","pull_request_review_id":189601936,"id":245482383,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NTQ4MjM4Mw==","diff_hunk":"@@ -103,34 +110,53 @@ class ContextMenuItemSuppliers {\n     private val mMany = ClassListMap<ItemsSupply> { fail() }\n \n     @Suppress(\"UNCHECKED_CAST\")\n-    fun <T: Any> add(type: Class<T>, items: (ImprovedContextMenu<*>, T) -> Sequence<MenuItem>) {\n-        mSingle.accumulate(type, items as ItemsSupply)\n+    fun <T: Any> add(type: Class<T>, items: ContextMenuBuilder<T>.() -> Unit) {\n+        mSingle.accumulate(type) { menu, item ->\n+            ContextMenuBuilder(menu, item as T).also { items(it) }.asSequence()\n+        }\n     }\n \n     @Suppress(\"UNCHECKED_CAST\")\n-    fun <T: Any> addMany(type: Class<T>, items: (ImprovedContextMenu<*>, Collection<T>) -> Sequence<MenuItem>) {\n-        mMany.accumulate(type, items as ItemsSupply)\n+    fun <T: Any> addMany(type: Class<T>, items: ContextMenuBuilder<Collection<T>>.() -> Unit) {\n+        mMany.accumulate(type) { menu, item ->\n+            ContextMenuBuilder(menu, item as Collection<T>).also { items(it) }.asSequence()\n+        }\n     }\n \n-    inline fun <reified T: Any> add(noinline items: (ImprovedContextMenu<*>, T) -> Sequence<MenuItem>) {\n+    inline fun <reified T: Any> add(noinline items: ContextMenuBuilder<T>.() -> Unit) {\n         add(T::class.java, items)\n     }\n \n-    inline fun <reified T: Any> addMany(noinline items: (ImprovedContextMenu<*>, Collection<T>) -> Sequence<MenuItem>) {\n+    inline fun <reified T: Any> addMany(noinline items: ContextMenuBuilder<Collection<T>>.() -> Unit) {\n         addMany(T::class.java, items)\n     }\n \n     operator fun get(contextMenu: ImprovedContextMenu<*>, value: Any?): Sequence<MenuItem> {\n+        logger.trace { \"Generating contextmenu for $value\" }\n         val items1 = mSingle.getElementsOfSuperV(value?.javaClass ?: Void::class.java).asSequence()\n-                .map { it(contextMenu, value) }\n-                .flatMap { it }\n+                .flatMap { it(contextMenu, value) }\n         val itemsN = if (value is Collection<*>) {\n             mMany.getElementsOfSuperV(value.getElementType()).asSequence()\n-                    .map { it(contextMenu, contextMenu.value) }\n-                    .flatMap { it }\n+                    .flatMap { it(contextMenu, contextMenu.value) }\n         } else {\n             sequenceOf()\n         }\n         return items1+itemsN\n     }\n+\n+}\n+\n+class ContextMenuBuilder<T>(val contextMenu: ImprovedContextMenu<*>, val selected: T): ArrayList<MenuItem>() {\n+\n+    fun <T: MenuItem> T.add() = also { add(it) }\n+\n+    fun item(text: String, handler: (ActionEvent) -> Unit): MenuItem =\n+            menuItem(text, handler).add()\n+\n+    fun menu(text: String, graphic: Node? = null, items: Menu.() -> Unit) =\n+            sp.it.pl.util.graphics.menu(text, graphic, items).add()\n+\n+    fun menu(text: String, items: Sequence<MenuItem> = seqOf()) =","path":"src/sp/it/pl/gui/objects/contextmenu/ImprovedContextMenu.kt","position":159,"original_position":109,"commit_id":"3a2ec9466dfd0ff784ced5ee1bfee798e68c1e69","original_commit_id":"fd2414575b5fc5c492bca8a693db73f8146c3158","user":{"login":"Xerus2000","id":13354331,"node_id":"MDQ6VXNlcjEzMzU0MzMx","avatar_url":"https://avatars3.githubusercontent.com/u/13354331?v=4","gravatar_id":"","url":"https://api.github.com/users/Xerus2000","html_url":"https://github.com/Xerus2000","followers_url":"https://api.github.com/users/Xerus2000/followers","following_url":"https://api.github.com/users/Xerus2000/following{/other_user}","gists_url":"https://api.github.com/users/Xerus2000/gists{/gist_id}","starred_url":"https://api.github.com/users/Xerus2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xerus2000/subscriptions","organizations_url":"https://api.github.com/users/Xerus2000/orgs","repos_url":"https://api.github.com/users/Xerus2000/repos","events_url":"https://api.github.com/users/Xerus2000/events{/privacy}","received_events_url":"https://api.github.com/users/Xerus2000/received_events","type":"User","site_admin":false},"body":"as extension methods to what?","created_at":"2019-01-05T16:49:58Z","updated_at":"2019-01-05T16:49:59Z","html_url":"https://github.com/sghpjuikit/player/pull/73#discussion_r245482383","pull_request_url":"https://api.github.com/repos/sghpjuikit/player/pulls/73","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/comments/245482383"},"html":{"href":"https://github.com/sghpjuikit/player/pull/73#discussion_r245482383"},"pull_request":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/73"}},"in_reply_to_id":245137921},"pull_request":{"url":"https://api.github.com/repos/sghpjuikit/player/pulls/73","id":184789523,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg0Nzg5NTIz","html_url":"https://github.com/sghpjuikit/player/pull/73","diff_url":"https://github.com/sghpjuikit/player/pull/73.diff","patch_url":"https://github.com/sghpjuikit/player/pull/73.patch","issue_url":"https://api.github.com/repos/sghpjuikit/player/issues/73","number":73,"state":"open","locked":false,"title":"[WIP] Refactor CoreMenus","user":{"login":"Xerus2000","id":13354331,"node_id":"MDQ6VXNlcjEzMzU0MzMx","avatar_url":"https://avatars3.githubusercontent.com/u/13354331?v=4","gravatar_id":"","url":"https://api.github.com/users/Xerus2000","html_url":"https://github.com/Xerus2000","followers_url":"https://api.github.com/users/Xerus2000/followers","following_url":"https://api.github.com/users/Xerus2000/following{/other_user}","gists_url":"https://api.github.com/users/Xerus2000/gists{/gist_id}","starred_url":"https://api.github.com/users/Xerus2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xerus2000/subscriptions","organizations_url":"https://api.github.com/users/Xerus2000/orgs","repos_url":"https://api.github.com/users/Xerus2000/repos","events_url":"https://api.github.com/users/Xerus2000/events{/privacy}","received_events_url":"https://api.github.com/users/Xerus2000/received_events","type":"User","site_admin":false},"body":"WIP - I want to avoid the verbosity and repetitions of the previous syntax and add some items","created_at":"2018-04-28T14:45:03Z","updated_at":"2019-01-05T16:49:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2266ef5f6a567818b9fcbbc8923e4f360cef48cc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sghpjuikit/player/pulls/73/commits","review_comments_url":"https://api.github.com/repos/sghpjuikit/player/pulls/73/comments","review_comment_url":"https://api.github.com/repos/sghpjuikit/player/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sghpjuikit/player/issues/73/comments","statuses_url":"https://api.github.com/repos/sghpjuikit/player/statuses/3a2ec9466dfd0ff784ced5ee1bfee798e68c1e69","head":{"label":"sghpjuikit:contextmenu","ref":"contextmenu","sha":"3a2ec9466dfd0ff784ced5ee1bfee798e68c1e69","user":{"login":"sghpjuikit","id":5527071,"node_id":"MDQ6VXNlcjU1MjcwNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5527071?v=4","gravatar_id":"","url":"https://api.github.com/users/sghpjuikit","html_url":"https://github.com/sghpjuikit","followers_url":"https://api.github.com/users/sghpjuikit/followers","following_url":"https://api.github.com/users/sghpjuikit/following{/other_user}","gists_url":"https://api.github.com/users/sghpjuikit/gists{/gist_id}","starred_url":"https://api.github.com/users/sghpjuikit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghpjuikit/subscriptions","organizations_url":"https://api.github.com/users/sghpjuikit/orgs","repos_url":"https://api.github.com/users/sghpjuikit/repos","events_url":"https://api.github.com/users/sghpjuikit/events{/privacy}","received_events_url":"https://api.github.com/users/sghpjuikit/received_events","type":"User","site_admin":false},"repo":{"id":18862317,"node_id":"MDEwOlJlcG9zaXRvcnkxODg2MjMxNw==","name":"player","full_name":"sghpjuikit/player","private":false,"owner":{"login":"sghpjuikit","id":5527071,"node_id":"MDQ6VXNlcjU1MjcwNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5527071?v=4","gravatar_id":"","url":"https://api.github.com/users/sghpjuikit","html_url":"https://github.com/sghpjuikit","followers_url":"https://api.github.com/users/sghpjuikit/followers","following_url":"https://api.github.com/users/sghpjuikit/following{/other_user}","gists_url":"https://api.github.com/users/sghpjuikit/gists{/gist_id}","starred_url":"https://api.github.com/users/sghpjuikit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghpjuikit/subscriptions","organizations_url":"https://api.github.com/users/sghpjuikit/orgs","repos_url":"https://api.github.com/users/sghpjuikit/repos","events_url":"https://api.github.com/users/sghpjuikit/events{/privacy}","received_events_url":"https://api.github.com/users/sghpjuikit/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sghpjuikit/player","description":"Audio player and management application.","fork":false,"url":"https://api.github.com/repos/sghpjuikit/player","forks_url":"https://api.github.com/repos/sghpjuikit/player/forks","keys_url":"https://api.github.com/repos/sghpjuikit/player/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sghpjuikit/player/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sghpjuikit/player/teams","hooks_url":"https://api.github.com/repos/sghpjuikit/player/hooks","issue_events_url":"https://api.github.com/repos/sghpjuikit/player/issues/events{/number}","events_url":"https://api.github.com/repos/sghpjuikit/player/events","assignees_url":"https://api.github.com/repos/sghpjuikit/player/assignees{/user}","branches_url":"https://api.github.com/repos/sghpjuikit/player/branches{/branch}","tags_url":"https://api.github.com/repos/sghpjuikit/player/tags","blobs_url":"https://api.github.com/repos/sghpjuikit/player/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sghpjuikit/player/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sghpjuikit/player/git/refs{/sha}","trees_url":"https://api.github.com/repos/sghpjuikit/player/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sghpjuikit/player/statuses/{sha}","languages_url":"https://api.github.com/repos/sghpjuikit/player/languages","stargazers_url":"https://api.github.com/repos/sghpjuikit/player/stargazers","contributors_url":"https://api.github.com/repos/sghpjuikit/player/contributors","subscribers_url":"https://api.github.com/repos/sghpjuikit/player/subscribers","subscription_url":"https://api.github.com/repos/sghpjuikit/player/subscription","commits_url":"https://api.github.com/repos/sghpjuikit/player/commits{/sha}","git_commits_url":"https://api.github.com/repos/sghpjuikit/player/git/commits{/sha}","comments_url":"https://api.github.com/repos/sghpjuikit/player/comments{/number}","issue_comment_url":"https://api.github.com/repos/sghpjuikit/player/issues/comments{/number}","contents_url":"https://api.github.com/repos/sghpjuikit/player/contents/{+path}","compare_url":"https://api.github.com/repos/sghpjuikit/player/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sghpjuikit/player/merges","archive_url":"https://api.github.com/repos/sghpjuikit/player/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sghpjuikit/player/downloads","issues_url":"https://api.github.com/repos/sghpjuikit/player/issues{/number}","pulls_url":"https://api.github.com/repos/sghpjuikit/player/pulls{/number}","milestones_url":"https://api.github.com/repos/sghpjuikit/player/milestones{/number}","notifications_url":"https://api.github.com/repos/sghpjuikit/player/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sghpjuikit/player/labels{/name}","releases_url":"https://api.github.com/repos/sghpjuikit/player/releases{/id}","deployments_url":"https://api.github.com/repos/sghpjuikit/player/deployments","created_at":"2014-04-17T01:13:21Z","updated_at":"2019-01-03T14:56:40Z","pushed_at":"2019-01-05T13:27:22Z","git_url":"git://github.com/sghpjuikit/player.git","ssh_url":"git@github.com:sghpjuikit/player.git","clone_url":"https://github.com/sghpjuikit/player.git","svn_url":"https://github.com/sghpjuikit/player","homepage":"","size":172145,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":32,"license":null,"forks":2,"open_issues":32,"watchers":13,"default_branch":"master"}},"base":{"label":"sghpjuikit:master","ref":"master","sha":"a286d0c672e07e01e96e28b316dcfb62670c2ee0","user":{"login":"sghpjuikit","id":5527071,"node_id":"MDQ6VXNlcjU1MjcwNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5527071?v=4","gravatar_id":"","url":"https://api.github.com/users/sghpjuikit","html_url":"https://github.com/sghpjuikit","followers_url":"https://api.github.com/users/sghpjuikit/followers","following_url":"https://api.github.com/users/sghpjuikit/following{/other_user}","gists_url":"https://api.github.com/users/sghpjuikit/gists{/gist_id}","starred_url":"https://api.github.com/users/sghpjuikit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghpjuikit/subscriptions","organizations_url":"https://api.github.com/users/sghpjuikit/orgs","repos_url":"https://api.github.com/users/sghpjuikit/repos","events_url":"https://api.github.com/users/sghpjuikit/events{/privacy}","received_events_url":"https://api.github.com/users/sghpjuikit/received_events","type":"User","site_admin":false},"repo":{"id":18862317,"node_id":"MDEwOlJlcG9zaXRvcnkxODg2MjMxNw==","name":"player","full_name":"sghpjuikit/player","private":false,"owner":{"login":"sghpjuikit","id":5527071,"node_id":"MDQ6VXNlcjU1MjcwNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5527071?v=4","gravatar_id":"","url":"https://api.github.com/users/sghpjuikit","html_url":"https://github.com/sghpjuikit","followers_url":"https://api.github.com/users/sghpjuikit/followers","following_url":"https://api.github.com/users/sghpjuikit/following{/other_user}","gists_url":"https://api.github.com/users/sghpjuikit/gists{/gist_id}","starred_url":"https://api.github.com/users/sghpjuikit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghpjuikit/subscriptions","organizations_url":"https://api.github.com/users/sghpjuikit/orgs","repos_url":"https://api.github.com/users/sghpjuikit/repos","events_url":"https://api.github.com/users/sghpjuikit/events{/privacy}","received_events_url":"https://api.github.com/users/sghpjuikit/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sghpjuikit/player","description":"Audio player and management application.","fork":false,"url":"https://api.github.com/repos/sghpjuikit/player","forks_url":"https://api.github.com/repos/sghpjuikit/player/forks","keys_url":"https://api.github.com/repos/sghpjuikit/player/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sghpjuikit/player/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sghpjuikit/player/teams","hooks_url":"https://api.github.com/repos/sghpjuikit/player/hooks","issue_events_url":"https://api.github.com/repos/sghpjuikit/player/issues/events{/number}","events_url":"https://api.github.com/repos/sghpjuikit/player/events","assignees_url":"https://api.github.com/repos/sghpjuikit/player/assignees{/user}","branches_url":"https://api.github.com/repos/sghpjuikit/player/branches{/branch}","tags_url":"https://api.github.com/repos/sghpjuikit/player/tags","blobs_url":"https://api.github.com/repos/sghpjuikit/player/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sghpjuikit/player/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sghpjuikit/player/git/refs{/sha}","trees_url":"https://api.github.com/repos/sghpjuikit/player/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sghpjuikit/player/statuses/{sha}","languages_url":"https://api.github.com/repos/sghpjuikit/player/languages","stargazers_url":"https://api.github.com/repos/sghpjuikit/player/stargazers","contributors_url":"https://api.github.com/repos/sghpjuikit/player/contributors","subscribers_url":"https://api.github.com/repos/sghpjuikit/player/subscribers","subscription_url":"https://api.github.com/repos/sghpjuikit/player/subscription","commits_url":"https://api.github.com/repos/sghpjuikit/player/commits{/sha}","git_commits_url":"https://api.github.com/repos/sghpjuikit/player/git/commits{/sha}","comments_url":"https://api.github.com/repos/sghpjuikit/player/comments{/number}","issue_comment_url":"https://api.github.com/repos/sghpjuikit/player/issues/comments{/number}","contents_url":"https://api.github.com/repos/sghpjuikit/player/contents/{+path}","compare_url":"https://api.github.com/repos/sghpjuikit/player/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sghpjuikit/player/merges","archive_url":"https://api.github.com/repos/sghpjuikit/player/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sghpjuikit/player/downloads","issues_url":"https://api.github.com/repos/sghpjuikit/player/issues{/number}","pulls_url":"https://api.github.com/repos/sghpjuikit/player/pulls{/number}","milestones_url":"https://api.github.com/repos/sghpjuikit/player/milestones{/number}","notifications_url":"https://api.github.com/repos/sghpjuikit/player/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sghpjuikit/player/labels{/name}","releases_url":"https://api.github.com/repos/sghpjuikit/player/releases{/id}","deployments_url":"https://api.github.com/repos/sghpjuikit/player/deployments","created_at":"2014-04-17T01:13:21Z","updated_at":"2019-01-03T14:56:40Z","pushed_at":"2019-01-05T13:27:22Z","git_url":"git://github.com/sghpjuikit/player.git","ssh_url":"git@github.com:sghpjuikit/player.git","clone_url":"https://github.com/sghpjuikit/player.git","svn_url":"https://github.com/sghpjuikit/player","homepage":"","size":172145,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":32,"license":null,"forks":2,"open_issues":32,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/73"},"html":{"href":"https://github.com/sghpjuikit/player/pull/73"},"issue":{"href":"https://api.github.com/repos/sghpjuikit/player/issues/73"},"comments":{"href":"https://api.github.com/repos/sghpjuikit/player/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sghpjuikit/player/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/sghpjuikit/player/statuses/3a2ec9466dfd0ff784ced5ee1bfee798e68c1e69"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Xerus2000"}}