{"action":"created","comment":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/47191566","id":47191566,"diff_hunk":"@@ -48,24 +58,196 @@ public PreviewsView(EventBus eventBus) {\n     }\n \n     @Subscribe\n+    /**\n+     * This function is called when a step moves in the pipeline to adjust the positions of any open previews it has\n+     * to reflect the new order of the pipeline.\n+     */\n+    public synchronized void onPreviewOrderChanged(StepMovedEvent event) {\n+        Platform.runLater(() -> {//Run this function on the main gui thread\n+            final Step movedStep = event.getStep(); //The step whose position in the pipeline has changed\n+            final int distanceMoved = event.getDistance(); //The number of indices (positive or negative) the step has been moved by\n+            final int numberOfSourcePreviews = getNumbOfSourcePreviews();//The number of previews opened that are displaying sources (NOT steps)\n+\n+            final OutputSocket<?>[] socketsMovedArray = movedStep.getOutputSockets();//Grab all the output sockets of the step that has moved\n+\n+            //Find the rightmost and leftmost position in the previews of the previewed sockets of the step that has moved\n+            int rightmostIndex = 0; //Set to minimum possible value so that the first index will overwrite it\n+            int leftmostIndex = this.previewedSockets.size();//Set to maximum possible value so that the first index will overwrite it\n+\n+            Stack<OutputSocket<?>> previewedMovedSockets = new Stack<OutputSocket<?>>();//This will hold the sockets of the step that was moved that are open for preview\n+\n+            for (OutputSocket<?> i : socketsMovedArray) {\n+                if (this.previewedSockets.indexOf(i) != -1) {//If this socket is previewed\n+                    previewedMovedSockets.push(i);\n+                    if (rightmostIndex < this.previewedSockets.indexOf(i))\n+                        rightmostIndex = this.previewedSockets.indexOf(i);\n+                    if (leftmostIndex > this.previewedSockets.indexOf(i))\n+                        leftmostIndex = this.previewedSockets.indexOf(i);\n+                }\n+            }\n+\n+            //Deal with each previewed socket from the step that was moved in turn\n+            while (previewedMovedSockets.size() != 0) { //While there are still sockets to deal with on the stack\n+                OutputSocket<?> current = previewedMovedSockets.pop();//Grab the top socket on the stack\n+                int oldIndex = this.previewedSockets.indexOf(current);//Get the index of this preview so we can remove the correct entry\n+\n+                int newLocation = 0;//This will hold the new index in the list of previewed sockets for this socket\n+\n+                if (distanceMoved < 0) //If the step moved left....\n+                    newLocation = leftmostIndex + distanceMoved; //Calculate the new index from the leftmost previewed socket of this step\n+                else //The step must have moved right....\n+                    newLocation = rightmostIndex + distanceMoved;//So calculate the new index from the rightmost previewed socket of this step","path":"ui/src/main/java/edu/wpi/grip/ui/preview/PreviewsView.java","position":81,"original_position":81,"commit_id":"01b2a7e897db4c22a62e52bec2edccab960b4ab7","original_commit_id":"01b2a7e897db4c22a62e52bec2edccab960b4ab7","user":{"login":"WPIRoboticsProjects-Bot","id":14011429,"avatar_url":"https://avatars.githubusercontent.com/u/14011429?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects-Bot","html_url":"https://github.com/WPIRoboticsProjects-Bot","followers_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/versioned/images/favicon.png) Issue found: [Avoid using if...else statements without curly braces](https://www.codacy.com/app/WPIRoboticsProjects/GRIP/file/1536359806/issues/source?bid=2943107&fileBranchId=3013557#l99)","created_at":"2015-12-10T05:56:59Z","updated_at":"2015-12-10T05:56:59Z","html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/197#discussion_r47191566","pull_request_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197","_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/47191566"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/197#discussion_r47191566"},"pull_request":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197"}}},"pull_request":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197","id":53187203,"html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/197","diff_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/197.diff","patch_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/197.patch","issue_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/197","number":197,"state":"open","locked":false,"title":"Preview order functionality complete","user":{"login":"PaulaRudy","id":3857381,"avatar_url":"https://avatars.githubusercontent.com/u/3857381?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulaRudy","html_url":"https://github.com/PaulaRudy","followers_url":"https://api.github.com/users/PaulaRudy/followers","following_url":"https://api.github.com/users/PaulaRudy/following{/other_user}","gists_url":"https://api.github.com/users/PaulaRudy/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulaRudy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulaRudy/subscriptions","organizations_url":"https://api.github.com/users/PaulaRudy/orgs","repos_url":"https://api.github.com/users/PaulaRudy/repos","events_url":"https://api.github.com/users/PaulaRudy/events{/privacy}","received_events_url":"https://api.github.com/users/PaulaRudy/received_events","type":"User","site_admin":false},"body":"Preview order now reflects position in the pipeline or in the list of sources. Source previews are always displayed at the beginning. Previews now react to steps being moved in the pipeline. ","created_at":"2015-12-09T22:23:35Z","updated_at":"2015-12-10T05:56:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"288121edea73b2c785bf2b9563a95914e460046e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197/commits","review_comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197/comments","review_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/197/comments","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/01b2a7e897db4c22a62e52bec2edccab960b4ab7","head":{"label":"PaulaRudy:previewOrder","ref":"previewOrder","sha":"01b2a7e897db4c22a62e52bec2edccab960b4ab7","user":{"login":"PaulaRudy","id":3857381,"avatar_url":"https://avatars.githubusercontent.com/u/3857381?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulaRudy","html_url":"https://github.com/PaulaRudy","followers_url":"https://api.github.com/users/PaulaRudy/followers","following_url":"https://api.github.com/users/PaulaRudy/following{/other_user}","gists_url":"https://api.github.com/users/PaulaRudy/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulaRudy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulaRudy/subscriptions","organizations_url":"https://api.github.com/users/PaulaRudy/orgs","repos_url":"https://api.github.com/users/PaulaRudy/repos","events_url":"https://api.github.com/users/PaulaRudy/events{/privacy}","received_events_url":"https://api.github.com/users/PaulaRudy/received_events","type":"User","site_admin":false},"repo":{"id":45870695,"name":"GRIP","full_name":"PaulaRudy/GRIP","owner":{"login":"PaulaRudy","id":3857381,"avatar_url":"https://avatars.githubusercontent.com/u/3857381?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulaRudy","html_url":"https://github.com/PaulaRudy","followers_url":"https://api.github.com/users/PaulaRudy/followers","following_url":"https://api.github.com/users/PaulaRudy/following{/other_user}","gists_url":"https://api.github.com/users/PaulaRudy/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulaRudy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulaRudy/subscriptions","organizations_url":"https://api.github.com/users/PaulaRudy/orgs","repos_url":"https://api.github.com/users/PaulaRudy/repos","events_url":"https://api.github.com/users/PaulaRudy/events{/privacy}","received_events_url":"https://api.github.com/users/PaulaRudy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PaulaRudy/GRIP","description":"Program for rapidly developing computer vision applications","fork":true,"url":"https://api.github.com/repos/PaulaRudy/GRIP","forks_url":"https://api.github.com/repos/PaulaRudy/GRIP/forks","keys_url":"https://api.github.com/repos/PaulaRudy/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PaulaRudy/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PaulaRudy/GRIP/teams","hooks_url":"https://api.github.com/repos/PaulaRudy/GRIP/hooks","issue_events_url":"https://api.github.com/repos/PaulaRudy/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/PaulaRudy/GRIP/events","assignees_url":"https://api.github.com/repos/PaulaRudy/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/PaulaRudy/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/PaulaRudy/GRIP/tags","blobs_url":"https://api.github.com/repos/PaulaRudy/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PaulaRudy/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PaulaRudy/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/PaulaRudy/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PaulaRudy/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/PaulaRudy/GRIP/languages","stargazers_url":"https://api.github.com/repos/PaulaRudy/GRIP/stargazers","contributors_url":"https://api.github.com/repos/PaulaRudy/GRIP/contributors","subscribers_url":"https://api.github.com/repos/PaulaRudy/GRIP/subscribers","subscription_url":"https://api.github.com/repos/PaulaRudy/GRIP/subscription","commits_url":"https://api.github.com/repos/PaulaRudy/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/PaulaRudy/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/PaulaRudy/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/PaulaRudy/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/PaulaRudy/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/PaulaRudy/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PaulaRudy/GRIP/merges","archive_url":"https://api.github.com/repos/PaulaRudy/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PaulaRudy/GRIP/downloads","issues_url":"https://api.github.com/repos/PaulaRudy/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/PaulaRudy/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/PaulaRudy/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/PaulaRudy/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PaulaRudy/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/PaulaRudy/GRIP/releases{/id}","created_at":"2015-11-09T22:21:59Z","updated_at":"2015-11-09T22:22:01Z","pushed_at":"2015-12-10T01:51:54Z","git_url":"git://github.com/PaulaRudy/GRIP.git","ssh_url":"git@github.com:PaulaRudy/GRIP.git","clone_url":"https://github.com/PaulaRudy/GRIP.git","svn_url":"https://github.com/PaulaRudy/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":13257,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WPIRoboticsProjects:master","ref":"master","sha":"5db3adf16f606d22b7c1ca33324c91c536cd3c9a","user":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"repo":{"id":41505521,"name":"GRIP","full_name":"WPIRoboticsProjects/GRIP","owner":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WPIRoboticsProjects/GRIP","description":"Program for rapidly developing computer vision applications","fork":false,"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP","forks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/forks","keys_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/teams","hooks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/hooks","issue_events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/events","assignees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/tags","blobs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/languages","stargazers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/stargazers","contributors_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contributors","subscribers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscribers","subscription_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscription","commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/merges","archive_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/downloads","issues_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/releases{/id}","created_at":"2015-08-27T18:59:07Z","updated_at":"2015-11-26T20:27:28Z","pushed_at":"2015-12-10T04:30:35Z","git_url":"git://github.com/WPIRoboticsProjects/GRIP.git","ssh_url":"git@github.com:WPIRoboticsProjects/GRIP.git","clone_url":"https://github.com/WPIRoboticsProjects/GRIP.git","svn_url":"https://github.com/WPIRoboticsProjects/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":19460,"stargazers_count":23,"watchers_count":23,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":31,"forks":7,"open_issues":31,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/197"},"issue":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/197"},"comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/197/comments"},"review_comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197/comments"},"review_comment":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/197/commits"},"statuses":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/01b2a7e897db4c22a62e52bec2edccab960b4ab7"}}}}