{"action":"created","comment":{"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments/48025081","id":48025081,"diff_hunk":"@@ -289,18 +295,63 @@ public static boolean isSingleSelection(ISelection selection) {\n \t * </ul>\n \t * @return the project selected in package-, project-explorer or navigator (in this order of prescedence).\n \t */\n-\tpublic static IProject getFirstSelectedProject() {\n-\t\tIProject project = getFirstSelectedElement(PACKAGE_EXPLORER_ID, IProject.class);\n-\t\tif (project == null) {\n-\t\t\tproject = getFirstSelectedElement(PROJECT_EXPLORER_ID, IProject.class);\n-\t\t\tif (project == null) {\n-\t\t\t\tproject = getFirstSelectedElement(RESOURCE_NAVIGATOR_ID, IProject.class);\n-\t\t\t}\n+\tpublic static IProject getFirstSelectedWorkbenchProject() {\n+\t\tIViewPart part = getVisibleProjectsView();\n+\t\tif (part == null) {\n+\t\t\treturn null;\n \t\t}\n-\t\treturn project;\n+\t\treturn getFirstSelectedElement(part.getSite().getId(), IProject.class);\n+\t}\n \n+\t/**\n+\t * Returns the 1st visible part among the following ones:\n+\t * <ul>\n+\t * <li>package explorer</li>\n+\t * <li>project explorer</li>\n+\t * <li>resource navigator</li>\n+\t * </ul>\n+\t * @return\n+\t */\n+\tpublic static IViewPart getVisibleProjectsView() {\n+\t\tList<IViewPart> parts = getVisibleViewParts(PACKAGE_EXPLORER_ID, PROJECT_EXPLORER_ID, RESOURCE_NAVIGATOR_ID);\n+\t\tif (parts.isEmpty()) {\n+\t\t\treturn null;\n+\t\t}\n+\t\treturn parts.get(0);\n \t}\n \t\n+\t/**\n+\t * Returns the visible workbench parts which match the given ids. If no ids\n+\t * are given all visible parts are returned.\n+\t * \n+\t * @param partIds\n+\t * @return\n+\t * \n+\t * @see IWorkbenchPart\n+\t */\n+\tpublic static List<IViewPart> getVisibleViewParts(String... partIds) {\n+\t\tIWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n+\t\tIWorkbenchPage page = workbenchWindow.getActivePage();\n+\t\tList<IViewPart> parts = new ArrayList<>();","path":"plugins/org.jboss.tools.openshift.common.ui/src/org/jboss/tools/openshift/internal/common/ui/utils/UIUtils.java","position":70,"original_position":70,"commit_id":"7e61969085eb8a7e3480c0d0d8afbe432f2e4b2a","original_commit_id":"7e61969085eb8a7e3480c0d0d8afbe432f2e4b2a","user":{"login":"fbricon","id":148698,"avatar_url":"https://avatars.githubusercontent.com/u/148698?v=3","gravatar_id":"","url":"https://api.github.com/users/fbricon","html_url":"https://github.com/fbricon","followers_url":"https://api.github.com/users/fbricon/followers","following_url":"https://api.github.com/users/fbricon/following{/other_user}","gists_url":"https://api.github.com/users/fbricon/gists{/gist_id}","starred_url":"https://api.github.com/users/fbricon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fbricon/subscriptions","organizations_url":"https://api.github.com/users/fbricon/orgs","repos_url":"https://api.github.com/users/fbricon/repos","events_url":"https://api.github.com/users/fbricon/events{/privacy}","received_events_url":"https://api.github.com/users/fbricon/received_events","type":"User","site_admin":false},"body":"List<IViewPart> parts = new ArrayList<>(partIds.length); //list size will be at most == to params length","created_at":"2015-12-18T13:37:06Z","updated_at":"2015-12-18T13:37:06Z","html_url":"https://github.com/jbosstools/jbosstools-openshift/pull/864#discussion_r48025081","pull_request_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864","_links":{"self":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments/48025081"},"html":{"href":"https://github.com/jbosstools/jbosstools-openshift/pull/864#discussion_r48025081"},"pull_request":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864"}}},"pull_request":{"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864","id":54101398,"html_url":"https://github.com/jbosstools/jbosstools-openshift/pull/864","diff_url":"https://github.com/jbosstools/jbosstools-openshift/pull/864.diff","patch_url":"https://github.com/jbosstools/jbosstools-openshift/pull/864.patch","issue_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/864","number":864,"state":"open","locked":false,"title":"[JBIDE-21352] server adapter wiz: using the selected project in the visible project view","user":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-18T13:18:22Z","updated_at":"2015-12-18T13:37:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c501caa101faf0c418593312bc15cdbaf3d46931","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864/commits","review_comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864/comments","review_comment_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/864/comments","statuses_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/7e61969085eb8a7e3480c0d0d8afbe432f2e4b2a","head":{"label":"adietish:JBIDE-21352","ref":"JBIDE-21352","sha":"7e61969085eb8a7e3480c0d0d8afbe432f2e4b2a","user":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"repo":{"id":6351407,"name":"jbosstools-openshift","full_name":"adietish/jbosstools-openshift","owner":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adietish/jbosstools-openshift","description":"JBoss Tools :: OpenShift { openshift }","fork":true,"url":"https://api.github.com/repos/adietish/jbosstools-openshift","forks_url":"https://api.github.com/repos/adietish/jbosstools-openshift/forks","keys_url":"https://api.github.com/repos/adietish/jbosstools-openshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adietish/jbosstools-openshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adietish/jbosstools-openshift/teams","hooks_url":"https://api.github.com/repos/adietish/jbosstools-openshift/hooks","issue_events_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues/events{/number}","events_url":"https://api.github.com/repos/adietish/jbosstools-openshift/events","assignees_url":"https://api.github.com/repos/adietish/jbosstools-openshift/assignees{/user}","branches_url":"https://api.github.com/repos/adietish/jbosstools-openshift/branches{/branch}","tags_url":"https://api.github.com/repos/adietish/jbosstools-openshift/tags","blobs_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adietish/jbosstools-openshift/statuses/{sha}","languages_url":"https://api.github.com/repos/adietish/jbosstools-openshift/languages","stargazers_url":"https://api.github.com/repos/adietish/jbosstools-openshift/stargazers","contributors_url":"https://api.github.com/repos/adietish/jbosstools-openshift/contributors","subscribers_url":"https://api.github.com/repos/adietish/jbosstools-openshift/subscribers","subscription_url":"https://api.github.com/repos/adietish/jbosstools-openshift/subscription","commits_url":"https://api.github.com/repos/adietish/jbosstools-openshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/adietish/jbosstools-openshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/adietish/jbosstools-openshift/contents/{+path}","compare_url":"https://api.github.com/repos/adietish/jbosstools-openshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adietish/jbosstools-openshift/merges","archive_url":"https://api.github.com/repos/adietish/jbosstools-openshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adietish/jbosstools-openshift/downloads","issues_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues{/number}","pulls_url":"https://api.github.com/repos/adietish/jbosstools-openshift/pulls{/number}","milestones_url":"https://api.github.com/repos/adietish/jbosstools-openshift/milestones{/number}","notifications_url":"https://api.github.com/repos/adietish/jbosstools-openshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adietish/jbosstools-openshift/labels{/name}","releases_url":"https://api.github.com/repos/adietish/jbosstools-openshift/releases{/id}","created_at":"2012-10-23T11:48:16Z","updated_at":"2015-05-05T14:50:36Z","pushed_at":"2015-12-18T13:17:18Z","git_url":"git://github.com/adietish/jbosstools-openshift.git","ssh_url":"git@github.com:adietish/jbosstools-openshift.git","clone_url":"https://github.com/adietish/jbosstools-openshift.git","svn_url":"https://github.com/adietish/jbosstools-openshift","homepage":"","size":14619,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jbosstools:jbosstools-4.3.x","ref":"jbosstools-4.3.x","sha":"26a1d1e7d918014a1f69d451baddebbbbaa3f749","user":{"login":"jbosstools","id":619871,"avatar_url":"https://avatars.githubusercontent.com/u/619871?v=3","gravatar_id":"","url":"https://api.github.com/users/jbosstools","html_url":"https://github.com/jbosstools","followers_url":"https://api.github.com/users/jbosstools/followers","following_url":"https://api.github.com/users/jbosstools/following{/other_user}","gists_url":"https://api.github.com/users/jbosstools/gists{/gist_id}","starred_url":"https://api.github.com/users/jbosstools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbosstools/subscriptions","organizations_url":"https://api.github.com/users/jbosstools/orgs","repos_url":"https://api.github.com/users/jbosstools/repos","events_url":"https://api.github.com/users/jbosstools/events{/privacy}","received_events_url":"https://api.github.com/users/jbosstools/received_events","type":"Organization","site_admin":false},"repo":{"id":6308288,"name":"jbosstools-openshift","full_name":"jbosstools/jbosstools-openshift","owner":{"login":"jbosstools","id":619871,"avatar_url":"https://avatars.githubusercontent.com/u/619871?v=3","gravatar_id":"","url":"https://api.github.com/users/jbosstools","html_url":"https://github.com/jbosstools","followers_url":"https://api.github.com/users/jbosstools/followers","following_url":"https://api.github.com/users/jbosstools/following{/other_user}","gists_url":"https://api.github.com/users/jbosstools/gists{/gist_id}","starred_url":"https://api.github.com/users/jbosstools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbosstools/subscriptions","organizations_url":"https://api.github.com/users/jbosstools/orgs","repos_url":"https://api.github.com/users/jbosstools/repos","events_url":"https://api.github.com/users/jbosstools/events{/privacy}","received_events_url":"https://api.github.com/users/jbosstools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jbosstools/jbosstools-openshift","description":"JBoss Tools :: OpenShift { openshift }","fork":false,"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift","forks_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/forks","keys_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/teams","hooks_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/hooks","issue_events_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/events{/number}","events_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/events","assignees_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/assignees{/user}","branches_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/branches{/branch}","tags_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/tags","blobs_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/{sha}","languages_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/languages","stargazers_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/stargazers","contributors_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/contributors","subscribers_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/subscribers","subscription_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/subscription","commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/contents/{+path}","compare_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/merges","archive_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/downloads","issues_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues{/number}","pulls_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls{/number}","milestones_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/milestones{/number}","notifications_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/labels{/name}","releases_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/releases{/id}","created_at":"2012-10-20T11:23:01Z","updated_at":"2015-08-11T20:47:08Z","pushed_at":"2015-12-18T13:18:22Z","git_url":"git://github.com/jbosstools/jbosstools-openshift.git","ssh_url":"git@github.com:jbosstools/jbosstools-openshift.git","clone_url":"https://github.com/jbosstools/jbosstools-openshift.git","svn_url":"https://github.com/jbosstools/jbosstools-openshift","homepage":"","size":15414,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":6,"forks":36,"open_issues":6,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864"},"html":{"href":"https://github.com/jbosstools/jbosstools-openshift/pull/864"},"issue":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/864"},"comments":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/864/comments"},"review_comments":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864/comments"},"review_comment":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/864/commits"},"statuses":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/7e61969085eb8a7e3480c0d0d8afbe432f2e4b2a"}}}}