{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/buildship/pulls/comments/42096071","id":42096071,"diff_hunk":"@@ -28,29 +32,30 @@\n \n     @Override\n     public void setEnabled(Object evaluationContext) {\n-        boolean enabled;\n-        TaskView taskView = getTaskView();\n-        if (taskView != null) {\n-            NodeSelection selectionHistory = taskView.getSelection();\n-            enabled = isEnabledFor(selectionHistory);\n-        } else {\n-            enabled = false;\n+        if (evaluationContext instanceof IEvaluationContext) {\n+            IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;\n+            // getting the current ISelection from the IEvaluationContext\n+            // See https://wiki.eclipse.org/Command_Core_Expressions\n+            Object variable = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);\n+            if (variable instanceof ISelection) {\n+                setBaseEnabled(isEnabledFor(NodeSelection.from((IStructuredSelection) variable)));\n+            }\n         }\n-        setBaseEnabled(enabled);\n     }\n \n     protected NodeSelection getSelectionHistory(ExecutionEvent event) {\n         TaskView taskView = getTaskView(event);\n-        if (taskView == null) {\n-            throw new IllegalStateException(String.format(\"Cannot execute command '%s' in current window.\", getCommandName(event)));\n-        }\n-\n-        NodeSelection selectionHistory = taskView.getSelection();\n-        if (!isEnabledFor(selectionHistory)) {\n-            throw new IllegalStateException(String.format(\"Cannot execute command '%s' for current selection.\", getCommandName(event)));\n+        if (taskView != null) {\n+            NodeSelection selectionHistory = taskView.getSelection();\n+            if (!isEnabledFor(selectionHistory)) {\n+                throw new IllegalStateException(\n+                        String.format(\"Cannot execute command '%s' for current selection.\", getCommandName(event)));\n+            }\n+            return selectionHistory;\n+        } else {\n+            ISelection currentSelection = HandlerUtil.getCurrentSelection(event);\n+            return NodeSelection.from(currentSelection);","path":"org.eclipse.buildship.ui/src/main/java/org/eclipse/buildship/ui/view/task/SelectionDependentHandler.java","position":68,"original_position":68,"commit_id":"5c0d16b6d2c0d2e21719477d5534f04054c86490","original_commit_id":"5c0d16b6d2c0d2e21719477d5534f04054c86490","user":{"login":"donat","id":419883,"avatar_url":"https://avatars.githubusercontent.com/u/419883?v=3","gravatar_id":"","url":"https://api.github.com/users/donat","html_url":"https://github.com/donat","followers_url":"https://api.github.com/users/donat/followers","following_url":"https://api.github.com/users/donat/following{/other_user}","gists_url":"https://api.github.com/users/donat/gists{/gist_id}","starred_url":"https://api.github.com/users/donat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donat/subscriptions","organizations_url":"https://api.github.com/users/donat/orgs","repos_url":"https://api.github.com/users/donat/repos","events_url":"https://api.github.com/users/donat/events{/privacy}","received_events_url":"https://api.github.com/users/donat/received_events","type":"User","site_admin":false},"body":"The whole method should contain only the two lines above. The `getTaskView()`, `getTaskView(ExecutionEvent)` and the `getCommandName(ExecutionEvent)` is no longer used and can be deleted.","created_at":"2015-10-15T08:35:32Z","updated_at":"2015-10-15T08:35:32Z","html_url":"https://github.com/eclipse/buildship/pull/179#discussion_r42096071","pull_request_url":"https://api.github.com/repos/eclipse/buildship/pulls/179","_links":{"self":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/comments/42096071"},"html":{"href":"https://github.com/eclipse/buildship/pull/179#discussion_r42096071"},"pull_request":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/179"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/buildship/pulls/179","id":47644938,"html_url":"https://github.com/eclipse/buildship/pull/179","diff_url":"https://github.com/eclipse/buildship/pull/179.diff","patch_url":"https://github.com/eclipse/buildship/pull/179.patch","issue_url":"https://api.github.com/repos/eclipse/buildship/issues/179","number":179,"state":"open","locked":false,"title":"Bug 479243 - Runtasks command not enabled in several Eclipse perspectives","user":{"login":"SimonScholz","id":7559962,"avatar_url":"https://avatars.githubusercontent.com/u/7559962?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonScholz","html_url":"https://github.com/SimonScholz","followers_url":"https://api.github.com/users/SimonScholz/followers","following_url":"https://api.github.com/users/SimonScholz/following{/other_user}","gists_url":"https://api.github.com/users/SimonScholz/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonScholz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonScholz/subscriptions","organizations_url":"https://api.github.com/users/SimonScholz/orgs","repos_url":"https://api.github.com/users/SimonScholz/repos","events_url":"https://api.github.com/users/SimonScholz/events{/privacy}","received_events_url":"https://api.github.com/users/SimonScholz/received_events","type":"User","site_admin":false},"body":"This PR turn the NodeSelection Object into an IStructuredSelection, which is propagated to the Workbench by introducing a NodeSelectionProviderWrapper, which is applied by the TaskView like this:\r\n\r\n```java\r\n this.selectionProvider = new NodeSelectionProviderWrapper(this, getTreeViewer());\r\n getSite().setSelectionProvider(this.selectionProvider);\r\n```\r\n\r\nThis PR not only provides a different approach to handle the enablement of Handlers, but also makes the ISelection, which is propagated to the workbench more detailed and let's NodeSelections behave in a natural Eclipse manner.","created_at":"2015-10-14T11:04:12Z","updated_at":"2015-10-15T08:35:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d044f5d9bc5e21af53152f4847826fb3c497d133","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/buildship/pulls/179/commits","review_comments_url":"https://api.github.com/repos/eclipse/buildship/pulls/179/comments","review_comment_url":"https://api.github.com/repos/eclipse/buildship/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/buildship/issues/179/comments","statuses_url":"https://api.github.com/repos/eclipse/buildship/statuses/5c0d16b6d2c0d2e21719477d5534f04054c86490","head":{"label":"vogellacompany:HandlerEnablementBySelection","ref":"HandlerEnablementBySelection","sha":"5c0d16b6d2c0d2e21719477d5534f04054c86490","user":{"login":"vogellacompany","id":5538152,"avatar_url":"https://avatars.githubusercontent.com/u/5538152?v=3","gravatar_id":"","url":"https://api.github.com/users/vogellacompany","html_url":"https://github.com/vogellacompany","followers_url":"https://api.github.com/users/vogellacompany/followers","following_url":"https://api.github.com/users/vogellacompany/following{/other_user}","gists_url":"https://api.github.com/users/vogellacompany/gists{/gist_id}","starred_url":"https://api.github.com/users/vogellacompany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogellacompany/subscriptions","organizations_url":"https://api.github.com/users/vogellacompany/orgs","repos_url":"https://api.github.com/users/vogellacompany/repos","events_url":"https://api.github.com/users/vogellacompany/events{/privacy}","received_events_url":"https://api.github.com/users/vogellacompany/received_events","type":"Organization","site_admin":false},"repo":{"id":33731511,"name":"buildship","full_name":"vogellacompany/buildship","owner":{"login":"vogellacompany","id":5538152,"avatar_url":"https://avatars.githubusercontent.com/u/5538152?v=3","gravatar_id":"","url":"https://api.github.com/users/vogellacompany","html_url":"https://github.com/vogellacompany","followers_url":"https://api.github.com/users/vogellacompany/followers","following_url":"https://api.github.com/users/vogellacompany/following{/other_user}","gists_url":"https://api.github.com/users/vogellacompany/gists{/gist_id}","starred_url":"https://api.github.com/users/vogellacompany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogellacompany/subscriptions","organizations_url":"https://api.github.com/users/vogellacompany/orgs","repos_url":"https://api.github.com/users/vogellacompany/repos","events_url":"https://api.github.com/users/vogellacompany/events{/privacy}","received_events_url":"https://api.github.com/users/vogellacompany/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vogellacompany/buildship","description":"The Eclipse Plug-ins for Gradle project.","fork":true,"url":"https://api.github.com/repos/vogellacompany/buildship","forks_url":"https://api.github.com/repos/vogellacompany/buildship/forks","keys_url":"https://api.github.com/repos/vogellacompany/buildship/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vogellacompany/buildship/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vogellacompany/buildship/teams","hooks_url":"https://api.github.com/repos/vogellacompany/buildship/hooks","issue_events_url":"https://api.github.com/repos/vogellacompany/buildship/issues/events{/number}","events_url":"https://api.github.com/repos/vogellacompany/buildship/events","assignees_url":"https://api.github.com/repos/vogellacompany/buildship/assignees{/user}","branches_url":"https://api.github.com/repos/vogellacompany/buildship/branches{/branch}","tags_url":"https://api.github.com/repos/vogellacompany/buildship/tags","blobs_url":"https://api.github.com/repos/vogellacompany/buildship/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vogellacompany/buildship/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vogellacompany/buildship/git/refs{/sha}","trees_url":"https://api.github.com/repos/vogellacompany/buildship/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vogellacompany/buildship/statuses/{sha}","languages_url":"https://api.github.com/repos/vogellacompany/buildship/languages","stargazers_url":"https://api.github.com/repos/vogellacompany/buildship/stargazers","contributors_url":"https://api.github.com/repos/vogellacompany/buildship/contributors","subscribers_url":"https://api.github.com/repos/vogellacompany/buildship/subscribers","subscription_url":"https://api.github.com/repos/vogellacompany/buildship/subscription","commits_url":"https://api.github.com/repos/vogellacompany/buildship/commits{/sha}","git_commits_url":"https://api.github.com/repos/vogellacompany/buildship/git/commits{/sha}","comments_url":"https://api.github.com/repos/vogellacompany/buildship/comments{/number}","issue_comment_url":"https://api.github.com/repos/vogellacompany/buildship/issues/comments{/number}","contents_url":"https://api.github.com/repos/vogellacompany/buildship/contents/{+path}","compare_url":"https://api.github.com/repos/vogellacompany/buildship/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vogellacompany/buildship/merges","archive_url":"https://api.github.com/repos/vogellacompany/buildship/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vogellacompany/buildship/downloads","issues_url":"https://api.github.com/repos/vogellacompany/buildship/issues{/number}","pulls_url":"https://api.github.com/repos/vogellacompany/buildship/pulls{/number}","milestones_url":"https://api.github.com/repos/vogellacompany/buildship/milestones{/number}","notifications_url":"https://api.github.com/repos/vogellacompany/buildship/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vogellacompany/buildship/labels{/name}","releases_url":"https://api.github.com/repos/vogellacompany/buildship/releases{/id}","created_at":"2015-04-10T14:02:21Z","updated_at":"2015-04-30T17:39:48Z","pushed_at":"2015-10-14T14:10:56Z","git_url":"git://github.com/vogellacompany/buildship.git","ssh_url":"git@github.com:vogellacompany/buildship.git","clone_url":"https://github.com/vogellacompany/buildship.git","svn_url":"https://github.com/vogellacompany/buildship","homepage":"","size":27008,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"3355a9205dccfaf4c8e8caa8f43576a9d25b964e","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32398083,"name":"buildship","full_name":"eclipse/buildship","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/buildship","description":"The Eclipse Plug-ins for Gradle project.","fork":false,"url":"https://api.github.com/repos/eclipse/buildship","forks_url":"https://api.github.com/repos/eclipse/buildship/forks","keys_url":"https://api.github.com/repos/eclipse/buildship/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/buildship/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/buildship/teams","hooks_url":"https://api.github.com/repos/eclipse/buildship/hooks","issue_events_url":"https://api.github.com/repos/eclipse/buildship/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/buildship/events","assignees_url":"https://api.github.com/repos/eclipse/buildship/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/buildship/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/buildship/tags","blobs_url":"https://api.github.com/repos/eclipse/buildship/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/buildship/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/buildship/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/buildship/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/buildship/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/buildship/languages","stargazers_url":"https://api.github.com/repos/eclipse/buildship/stargazers","contributors_url":"https://api.github.com/repos/eclipse/buildship/contributors","subscribers_url":"https://api.github.com/repos/eclipse/buildship/subscribers","subscription_url":"https://api.github.com/repos/eclipse/buildship/subscription","commits_url":"https://api.github.com/repos/eclipse/buildship/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/buildship/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/buildship/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/buildship/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/buildship/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/buildship/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/buildship/merges","archive_url":"https://api.github.com/repos/eclipse/buildship/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/buildship/downloads","issues_url":"https://api.github.com/repos/eclipse/buildship/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/buildship/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/buildship/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/buildship/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/buildship/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/buildship/releases{/id}","created_at":"2015-03-17T14:25:15Z","updated_at":"2015-10-14T17:25:47Z","pushed_at":"2015-10-14T14:10:56Z","git_url":"git://github.com/eclipse/buildship.git","ssh_url":"git@github.com:eclipse/buildship.git","clone_url":"https://github.com/eclipse/buildship.git","svn_url":"https://github.com/eclipse/buildship","homepage":"","size":33152,"stargazers_count":72,"watchers_count":72,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":18,"forks":19,"open_issues":18,"watchers":72,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/179"},"html":{"href":"https://github.com/eclipse/buildship/pull/179"},"issue":{"href":"https://api.github.com/repos/eclipse/buildship/issues/179"},"comments":{"href":"https://api.github.com/repos/eclipse/buildship/issues/179/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/179/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/buildship/pulls/179/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/buildship/statuses/5c0d16b6d2c0d2e21719477d5534f04054c86490"}}}}