{"action":"created","comment":{"url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/comments/54347175","id":54347175,"diff_hunk":"@@ -0,0 +1,277 @@\n+/*******************************************************************************\n+ * Copyright (c) 2015 - 2016\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"),\n+ * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n+ * DEALINGS IN THE SOFTWARE.\n+ *******************************************************************************/\n+package jsettlers.main.swing.foldertree;\n+\n+import java.io.File;\n+import java.util.ArrayList;\n+import java.util.Collections;\n+import java.util.Comparator;\n+import java.util.Enumeration;\n+import java.util.Iterator;\n+import java.util.List;\n+\n+import javax.swing.tree.TreeNode;\n+\n+import jsettlers.graphics.swing.resources.SettlerFolderChecker;\n+\n+/**\n+ * Node to display file / folders\n+ * \n+ * @author Andreas Butti\n+ */\n+public class FilesystemTreeNode implements TreeNode {\n+\n+\t/**\n+\t * If the children are already loaded\n+\t */\n+\tprotected boolean loaded = false;\n+\n+\t/**\n+\t * If this is a settler folder\n+\t */\n+\tprivate boolean settlerFolder = false;\n+\n+\t/**\n+\t * To expand the node on the first selection\n+\t */\n+\tprivate boolean wasExpanded = false;\n+\n+\t/**\n+\t * Tmp loaded child list\n+\t */\n+\tprivate final List<FilesystemTreeNode> list = new ArrayList<>();\n+\n+\t/**\n+\t * Current child list\n+\t */\n+\tprivate List<FilesystemTreeNode> children = new ArrayList<>();\n+\n+\t/**\n+\t * Parent node\n+\t */\n+\tprivate TreeNode parent;\n+\n+\t/**\n+\t * The file represented by this node\n+\t */\n+\tprivate final File file;\n+\n+\t/**\n+\t * Constructor\n+\t * \n+\t * @param file\n+\t *            The file to represent\n+\t */\n+\tpublic FilesystemTreeNode(File file) {\n+\t\tthis.file = file;\n+\t}\n+\n+\t/**\n+\t * @return The file\n+\t */\n+\tpublic File getFile() {\n+\t\treturn file;\n+\t}\n+\n+\t/**\n+\t * @return Root node\n+\t */\n+\tprivate RootTreeNode findRoot() {\n+\t\tTreeNode node = getParent();\n+\t\twhile (true) {\n+\t\t\tif (node == null) {\n+\t\t\t\treturn null;\n+\t\t\t}\n+\t\t\tif (node instanceof RootTreeNode) {\n+\t\t\t\treturn (RootTreeNode) node;\n+\t\t\t}\n+\t\t\tnode = node.getParent();\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * Load the children of this folder, if a folder\n+\t */\n+\tprivate void loadChildren() {\n+\t\tRootTreeNode root = findRoot();\n+\t\tif (root == null) {\n+\t\t\tloadChildren1();\n+\t\t\tapplyLoadedChildren();\n+\t\t} else {\n+\t\t\troot.loadAsynchron(this);\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * @return true if this node already was expanded\n+\t */\n+\tpublic boolean wasExpanded() {\n+\t\treturn wasExpanded;\n+\t}\n+\n+\t/**\n+\t * @param wasExpanded\n+\t *            true if this node already was expanded\n+\t */\n+\tpublic void setWasExpanded(boolean wasExpanded) {\n+\t\tthis.wasExpanded = wasExpanded;\n+\t}\n+\n+\t/**\n+\t * @return if this is a settler folder\n+\t */\n+\tpublic boolean isSettlerFolder() {\n+\t\treturn settlerFolder;\n+\t}\n+\n+\t/**\n+\t * Load children if not loaded\n+\t */\n+\tprivate synchronized void loadIfNotLoaded() {\n+\t\tif (!loaded) {\n+\t\t\tloaded = true;\n+\n+\t\t\tloadChildren();\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tpublic boolean isLeaf() {\n+\t\tloadIfNotLoaded();\n+\t\tif (children != null) {\n+\t\t\treturn children.isEmpty();\n+\t\t}\n+\t\treturn true;\n+\t}\n+\n+\t@Override\n+\tpublic int getChildCount() {\n+\t\tloadIfNotLoaded();\n+\t\treturn children.size();\n+\t}\n+\n+\t/**\n+\t * Add a node\n+\t * \n+\t * @param node\n+\t *            Node\n+\t */\n+\tpublic void add(FilesystemTreeNode node) {\n+\t\tchildren.add(node);\n+\t}\n+\n+\t/**\n+\t * Load the children to a tmp attribute, **this is the only one method which is called from another thread**","path":"jsettlers.main.swing/src/jsettlers/main/swing/foldertree/FilesystemTreeNode.java","position":176,"original_position":176,"commit_id":"e4af9d03cc7dcec252a771b8efa4677157293c07","original_commit_id":"e4af9d03cc7dcec252a771b8efa4677157293c07","user":{"login":"andreas-eberle","id":9267365,"avatar_url":"https://avatars.githubusercontent.com/u/9267365?v=3","gravatar_id":"","url":"https://api.github.com/users/andreas-eberle","html_url":"https://github.com/andreas-eberle","followers_url":"https://api.github.com/users/andreas-eberle/followers","following_url":"https://api.github.com/users/andreas-eberle/following{/other_user}","gists_url":"https://api.github.com/users/andreas-eberle/gists{/gist_id}","starred_url":"https://api.github.com/users/andreas-eberle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreas-eberle/subscriptions","organizations_url":"https://api.github.com/users/andreas-eberle/orgs","repos_url":"https://api.github.com/users/andreas-eberle/repos","events_url":"https://api.github.com/users/andreas-eberle/events{/privacy}","received_events_url":"https://api.github.com/users/andreas-eberle/received_events","type":"User","site_admin":false},"body":"From which Thread is this method called? And on which Thread is the rest of the class running?","created_at":"2016-02-28T10:10:20Z","updated_at":"2016-02-28T10:10:20Z","html_url":"https://github.com/jsettlers/settlers-remake/pull/306#discussion_r54347175","pull_request_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306","_links":{"self":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/comments/54347175"},"html":{"href":"https://github.com/jsettlers/settlers-remake/pull/306#discussion_r54347175"},"pull_request":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306"}}},"pull_request":{"url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306","id":60984944,"html_url":"https://github.com/jsettlers/settlers-remake/pull/306","diff_url":"https://github.com/jsettlers/settlers-remake/pull/306.diff","patch_url":"https://github.com/jsettlers/settlers-remake/pull/306.patch","issue_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/306","number":306,"state":"open","locked":false,"title":"New Settler 3 folder selection dialog (Startup of the Game)","user":{"login":"andreas-eberle","id":9267365,"avatar_url":"https://avatars.githubusercontent.com/u/9267365?v=3","gravatar_id":"","url":"https://api.github.com/users/andreas-eberle","html_url":"https://github.com/andreas-eberle","followers_url":"https://api.github.com/users/andreas-eberle/followers","following_url":"https://api.github.com/users/andreas-eberle/following{/other_user}","gists_url":"https://api.github.com/users/andreas-eberle/gists{/gist_id}","starred_url":"https://api.github.com/users/andreas-eberle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreas-eberle/subscriptions","organizations_url":"https://api.github.com/users/andreas-eberle/orgs","repos_url":"https://api.github.com/users/andreas-eberle/repos","events_url":"https://api.github.com/users/andreas-eberle/events{/privacy}","received_events_url":"https://api.github.com/users/andreas-eberle/received_events","type":"User","site_admin":false},"body":"This is the follow up of #299. ","created_at":"2016-02-28T09:16:49Z","updated_at":"2016-02-28T10:10:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab52a805689cb47fc8aef9b4fd26f703a277a328","assignee":{"login":"andreas-eberle","id":9267365,"avatar_url":"https://avatars.githubusercontent.com/u/9267365?v=3","gravatar_id":"","url":"https://api.github.com/users/andreas-eberle","html_url":"https://github.com/andreas-eberle","followers_url":"https://api.github.com/users/andreas-eberle/followers","following_url":"https://api.github.com/users/andreas-eberle/following{/other_user}","gists_url":"https://api.github.com/users/andreas-eberle/gists{/gist_id}","starred_url":"https://api.github.com/users/andreas-eberle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreas-eberle/subscriptions","organizations_url":"https://api.github.com/users/andreas-eberle/orgs","repos_url":"https://api.github.com/users/andreas-eberle/repos","events_url":"https://api.github.com/users/andreas-eberle/events{/privacy}","received_events_url":"https://api.github.com/users/andreas-eberle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306/commits","review_comments_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306/comments","review_comment_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/306/comments","statuses_url":"https://api.github.com/repos/jsettlers/settlers-remake/statuses/e4af9d03cc7dcec252a771b8efa4677157293c07","head":{"label":"jsettlers:enhancement_new_folder_selection","ref":"enhancement_new_folder_selection","sha":"e4af9d03cc7dcec252a771b8efa4677157293c07","user":{"login":"jsettlers","id":10380489,"avatar_url":"https://avatars.githubusercontent.com/u/10380489?v=3","gravatar_id":"","url":"https://api.github.com/users/jsettlers","html_url":"https://github.com/jsettlers","followers_url":"https://api.github.com/users/jsettlers/followers","following_url":"https://api.github.com/users/jsettlers/following{/other_user}","gists_url":"https://api.github.com/users/jsettlers/gists{/gist_id}","starred_url":"https://api.github.com/users/jsettlers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsettlers/subscriptions","organizations_url":"https://api.github.com/users/jsettlers/orgs","repos_url":"https://api.github.com/users/jsettlers/repos","events_url":"https://api.github.com/users/jsettlers/events{/privacy}","received_events_url":"https://api.github.com/users/jsettlers/received_events","type":"Organization","site_admin":false},"repo":{"id":25301488,"name":"settlers-remake","full_name":"jsettlers/settlers-remake","owner":{"login":"jsettlers","id":10380489,"avatar_url":"https://avatars.githubusercontent.com/u/10380489?v=3","gravatar_id":"","url":"https://api.github.com/users/jsettlers","html_url":"https://github.com/jsettlers","followers_url":"https://api.github.com/users/jsettlers/followers","following_url":"https://api.github.com/users/jsettlers/following{/other_user}","gists_url":"https://api.github.com/users/jsettlers/gists{/gist_id}","starred_url":"https://api.github.com/users/jsettlers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsettlers/subscriptions","organizations_url":"https://api.github.com/users/jsettlers/orgs","repos_url":"https://api.github.com/users/jsettlers/repos","events_url":"https://api.github.com/users/jsettlers/events{/privacy}","received_events_url":"https://api.github.com/users/jsettlers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jsettlers/settlers-remake","description":"A Remake of \"The Settlers III\" for Windows, Linux, Mac and Android","fork":false,"url":"https://api.github.com/repos/jsettlers/settlers-remake","forks_url":"https://api.github.com/repos/jsettlers/settlers-remake/forks","keys_url":"https://api.github.com/repos/jsettlers/settlers-remake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jsettlers/settlers-remake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jsettlers/settlers-remake/teams","hooks_url":"https://api.github.com/repos/jsettlers/settlers-remake/hooks","issue_events_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/events{/number}","events_url":"https://api.github.com/repos/jsettlers/settlers-remake/events","assignees_url":"https://api.github.com/repos/jsettlers/settlers-remake/assignees{/user}","branches_url":"https://api.github.com/repos/jsettlers/settlers-remake/branches{/branch}","tags_url":"https://api.github.com/repos/jsettlers/settlers-remake/tags","blobs_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/refs{/sha}","trees_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jsettlers/settlers-remake/statuses/{sha}","languages_url":"https://api.github.com/repos/jsettlers/settlers-remake/languages","stargazers_url":"https://api.github.com/repos/jsettlers/settlers-remake/stargazers","contributors_url":"https://api.github.com/repos/jsettlers/settlers-remake/contributors","subscribers_url":"https://api.github.com/repos/jsettlers/settlers-remake/subscribers","subscription_url":"https://api.github.com/repos/jsettlers/settlers-remake/subscription","commits_url":"https://api.github.com/repos/jsettlers/settlers-remake/commits{/sha}","git_commits_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/commits{/sha}","comments_url":"https://api.github.com/repos/jsettlers/settlers-remake/comments{/number}","issue_comment_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/comments{/number}","contents_url":"https://api.github.com/repos/jsettlers/settlers-remake/contents/{+path}","compare_url":"https://api.github.com/repos/jsettlers/settlers-remake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jsettlers/settlers-remake/merges","archive_url":"https://api.github.com/repos/jsettlers/settlers-remake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jsettlers/settlers-remake/downloads","issues_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues{/number}","pulls_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls{/number}","milestones_url":"https://api.github.com/repos/jsettlers/settlers-remake/milestones{/number}","notifications_url":"https://api.github.com/repos/jsettlers/settlers-remake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jsettlers/settlers-remake/labels{/name}","releases_url":"https://api.github.com/repos/jsettlers/settlers-remake/releases{/id}","deployments_url":"https://api.github.com/repos/jsettlers/settlers-remake/deployments","created_at":"2014-10-16T12:41:40Z","updated_at":"2016-02-19T12:39:45Z","pushed_at":"2016-02-28T09:57:35Z","git_url":"git://github.com/jsettlers/settlers-remake.git","ssh_url":"git@github.com:jsettlers/settlers-remake.git","clone_url":"https://github.com/jsettlers/settlers-remake.git","svn_url":"https://github.com/jsettlers/settlers-remake","homepage":"http://www.settlers-android-clone.com","size":276705,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":71,"forks":32,"open_issues":71,"watchers":81,"default_branch":"master"}},"base":{"label":"jsettlers:master","ref":"master","sha":"7af690e80095a73feaf5cf60064dee5818a86406","user":{"login":"jsettlers","id":10380489,"avatar_url":"https://avatars.githubusercontent.com/u/10380489?v=3","gravatar_id":"","url":"https://api.github.com/users/jsettlers","html_url":"https://github.com/jsettlers","followers_url":"https://api.github.com/users/jsettlers/followers","following_url":"https://api.github.com/users/jsettlers/following{/other_user}","gists_url":"https://api.github.com/users/jsettlers/gists{/gist_id}","starred_url":"https://api.github.com/users/jsettlers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsettlers/subscriptions","organizations_url":"https://api.github.com/users/jsettlers/orgs","repos_url":"https://api.github.com/users/jsettlers/repos","events_url":"https://api.github.com/users/jsettlers/events{/privacy}","received_events_url":"https://api.github.com/users/jsettlers/received_events","type":"Organization","site_admin":false},"repo":{"id":25301488,"name":"settlers-remake","full_name":"jsettlers/settlers-remake","owner":{"login":"jsettlers","id":10380489,"avatar_url":"https://avatars.githubusercontent.com/u/10380489?v=3","gravatar_id":"","url":"https://api.github.com/users/jsettlers","html_url":"https://github.com/jsettlers","followers_url":"https://api.github.com/users/jsettlers/followers","following_url":"https://api.github.com/users/jsettlers/following{/other_user}","gists_url":"https://api.github.com/users/jsettlers/gists{/gist_id}","starred_url":"https://api.github.com/users/jsettlers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsettlers/subscriptions","organizations_url":"https://api.github.com/users/jsettlers/orgs","repos_url":"https://api.github.com/users/jsettlers/repos","events_url":"https://api.github.com/users/jsettlers/events{/privacy}","received_events_url":"https://api.github.com/users/jsettlers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jsettlers/settlers-remake","description":"A Remake of \"The Settlers III\" for Windows, Linux, Mac and Android","fork":false,"url":"https://api.github.com/repos/jsettlers/settlers-remake","forks_url":"https://api.github.com/repos/jsettlers/settlers-remake/forks","keys_url":"https://api.github.com/repos/jsettlers/settlers-remake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jsettlers/settlers-remake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jsettlers/settlers-remake/teams","hooks_url":"https://api.github.com/repos/jsettlers/settlers-remake/hooks","issue_events_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/events{/number}","events_url":"https://api.github.com/repos/jsettlers/settlers-remake/events","assignees_url":"https://api.github.com/repos/jsettlers/settlers-remake/assignees{/user}","branches_url":"https://api.github.com/repos/jsettlers/settlers-remake/branches{/branch}","tags_url":"https://api.github.com/repos/jsettlers/settlers-remake/tags","blobs_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/refs{/sha}","trees_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jsettlers/settlers-remake/statuses/{sha}","languages_url":"https://api.github.com/repos/jsettlers/settlers-remake/languages","stargazers_url":"https://api.github.com/repos/jsettlers/settlers-remake/stargazers","contributors_url":"https://api.github.com/repos/jsettlers/settlers-remake/contributors","subscribers_url":"https://api.github.com/repos/jsettlers/settlers-remake/subscribers","subscription_url":"https://api.github.com/repos/jsettlers/settlers-remake/subscription","commits_url":"https://api.github.com/repos/jsettlers/settlers-remake/commits{/sha}","git_commits_url":"https://api.github.com/repos/jsettlers/settlers-remake/git/commits{/sha}","comments_url":"https://api.github.com/repos/jsettlers/settlers-remake/comments{/number}","issue_comment_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues/comments{/number}","contents_url":"https://api.github.com/repos/jsettlers/settlers-remake/contents/{+path}","compare_url":"https://api.github.com/repos/jsettlers/settlers-remake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jsettlers/settlers-remake/merges","archive_url":"https://api.github.com/repos/jsettlers/settlers-remake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jsettlers/settlers-remake/downloads","issues_url":"https://api.github.com/repos/jsettlers/settlers-remake/issues{/number}","pulls_url":"https://api.github.com/repos/jsettlers/settlers-remake/pulls{/number}","milestones_url":"https://api.github.com/repos/jsettlers/settlers-remake/milestones{/number}","notifications_url":"https://api.github.com/repos/jsettlers/settlers-remake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jsettlers/settlers-remake/labels{/name}","releases_url":"https://api.github.com/repos/jsettlers/settlers-remake/releases{/id}","deployments_url":"https://api.github.com/repos/jsettlers/settlers-remake/deployments","created_at":"2014-10-16T12:41:40Z","updated_at":"2016-02-19T12:39:45Z","pushed_at":"2016-02-28T09:57:35Z","git_url":"git://github.com/jsettlers/settlers-remake.git","ssh_url":"git@github.com:jsettlers/settlers-remake.git","clone_url":"https://github.com/jsettlers/settlers-remake.git","svn_url":"https://github.com/jsettlers/settlers-remake","homepage":"http://www.settlers-android-clone.com","size":276705,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":71,"forks":32,"open_issues":71,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306"},"html":{"href":"https://github.com/jsettlers/settlers-remake/pull/306"},"issue":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/issues/306"},"comments":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/issues/306/comments"},"review_comments":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306/comments"},"review_comment":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/pulls/306/commits"},"statuses":{"href":"https://api.github.com/repos/jsettlers/settlers-remake/statuses/e4af9d03cc7dcec252a771b8efa4677157293c07"}}}}