{"action":"created","comment":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/comments/41608349","id":41608349,"diff_hunk":"@@ -0,0 +1,196 @@\n+/*  Copyright (C) 2015 JabRef contributors.\n+    Copyright (C) 2015 Oscar Gustafsson.\n+    This program is free software; you can redistribute it and/or modify\n+    it under the terms of the GNU General Public License as published by\n+    the Free Software Foundation; either version 2 of the License, or\n+    (at your option) any later version.\n+\n+    This program is distributed in the hope that it will be useful,\n+    but WITHOUT ANY WARRANTY; without even the implied warranty of\n+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+    GNU General Public License for more details.\n+\n+    You should have received a copy of the GNU General Public License along\n+    with this program; if not, write to the Free Software Foundation, Inc.,\n+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+*/\n+package net.sf.jabref.external.push;\n+\n+import java.io.IOException;\n+\n+import javax.swing.*;\n+\n+import net.sf.jabref.*;\n+\n+import com.jgoodies.forms.builder.FormBuilder;\n+import com.jgoodies.forms.layout.FormLayout;\n+import net.sf.jabref.gui.BasePanel;\n+import net.sf.jabref.gui.actions.BrowseAction;\n+import net.sf.jabref.logic.l10n.Localization;\n+import net.sf.jabref.model.database.BibtexDatabase;\n+import net.sf.jabref.model.entry.BibtexEntry;\n+\n+/**\n+ * Abstract class for pushing entries into different editors.\n+ */\n+public abstract class AbstractPushToApplication implements PushToApplication {\n+\n+    protected boolean couldNotCall; // Set to true in case the command could not be executed, e.g., if the file is not found\n+    protected boolean couldNotConnect; // Set to true in case the tunnel to the program (if one is used) does not operate\n+    protected boolean notDefined; // Set to true if the corresponding path is not defined in the preferences\n+    protected JPanel settings;\n+    protected final JTextField Path = new JTextField(30);\n+    protected String commandPath;\n+    protected String commandPathPreferenceKey;\n+    protected String citeCommand = Globals.prefs.get(JabRefPreferences.CITE_COMMAND);\n+    protected FormBuilder builder;\n+\n+\n+    @Override\n+    public String getName() {\n+        return Localization.menuTitle(\"Insert selected citations into %d\", getApplicationName());\n+    }\n+\n+    @Override\n+    public String getTooltip() {\n+        return Localization.lang(\"Push to %0\", getApplicationName());\n+    }\n+\n+    @Override\n+    public String getKeyStrokeName() {\n+        return Localization.lang(\"Push to %0\", getApplicationName());\n+    }\n+\n+    @Override\n+    public void pushEntries(BibtexDatabase database, BibtexEntry[] entries, String keyString, MetaData metaData) {\n+\n+        couldNotConnect = false;\n+        couldNotCall = false;\n+        notDefined = false;\n+\n+        initParameters();\n+        commandPath = Globals.prefs.get(commandPathPreferenceKey);\n+\n+        // Check if a path to the command has been specified\n+        if ((commandPath == null) || commandPath.trim().isEmpty()) {\n+            notDefined = true;\n+            return;\n+        }\n+\n+        // Execute command\n+        try {\n+            Runtime.getRuntime().exec(getCommandLine(keyString));\n+        }\n+\n+        // In case it didn't work\n+        catch (IOException excep) {\n+            couldNotCall = true;\n+            excep.printStackTrace();\n+        }\n+    }\n+\n+    @Override\n+    public void operationCompleted(BasePanel panel) {\n+        if (notDefined) {\n+            // @formatter:off\n+            panel.output(Localization.lang(\"Error\") + \": \" \n+                    + Localization.lang(\"Path to %0 not defined\", getApplicationName()) + \".\");\n+            // @formatter:on\n+        } else if (couldNotCall) {\n+            panel.output(getCouldNotCall());\n+        } else if (couldNotConnect) {\n+            panel.output(getCouldNotConnect());\n+        } else {\n+            panel.output(Localization.lang(\"Pushed citations to %0\", getApplicationName()) + \".\");\n+        }\n+    }\n+\n+    @Override\n+    public boolean requiresBibtexKeys() {\n+        return true;\n+    }\n+\n+    /**\n+     * Function to get the command to be executed for pushing keys to be cited\n+     *\n+     * @param keyString String containing the Bibtex keys to be pushed to the application\n+     * @return String array with the command to call and its arguments\n+     */\n+    protected String[] getCommandLine(String keyString) {","path":"src/main/java/net/sf/jabref/external/push/AbstractPushToApplication.java","position":119,"original_position":119,"commit_id":"4dbd6a2c617d21b70d2d60c091d665eb170ce882","original_commit_id":"4dbd6a2c617d21b70d2d60c091d665eb170ce882","user":{"login":"simonharrer","id":375693,"avatar_url":"https://avatars.githubusercontent.com/u/375693?v=3","gravatar_id":"","url":"https://api.github.com/users/simonharrer","html_url":"https://github.com/simonharrer","followers_url":"https://api.github.com/users/simonharrer/followers","following_url":"https://api.github.com/users/simonharrer/following{/other_user}","gists_url":"https://api.github.com/users/simonharrer/gists{/gist_id}","starred_url":"https://api.github.com/users/simonharrer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonharrer/subscriptions","organizations_url":"https://api.github.com/users/simonharrer/orgs","repos_url":"https://api.github.com/users/simonharrer/repos","events_url":"https://api.github.com/users/simonharrer/events{/privacy}","received_events_url":"https://api.github.com/users/simonharrer/received_events","type":"User","site_admin":false},"body":"It seems this method is overridden in each sub class. Thus, I would make this abstract. This also helps to remove `null` usage, which is a good thing. :)","created_at":"2015-10-09T08:37:56Z","updated_at":"2015-10-09T08:37:56Z","html_url":"https://github.com/JabRef/jabref/pull/218#discussion_r41608349","pull_request_url":"https://api.github.com/repos/JabRef/jabref/pulls/218","_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments/41608349"},"html":{"href":"https://github.com/JabRef/jabref/pull/218#discussion_r41608349"},"pull_request":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/218"}}},"pull_request":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/218","id":47047324,"html_url":"https://github.com/JabRef/jabref/pull/218","diff_url":"https://github.com/JabRef/jabref/pull/218.diff","patch_url":"https://github.com/JabRef/jabref/pull/218.patch","issue_url":"https://api.github.com/repos/JabRef/jabref/issues/218","number":218,"state":"open","locked":false,"title":"[WIP] AbstractPushToApplication","user":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"body":"Here's my go at an AbstractPushToApplication class. So far I've implemented PushToTexmaker.java using the new class. See the last commit, the earlier commit is primarily refactoring all these files to external.push.\r\n\r\nComments so far? I thought it might be a better idea to get some input on the construction of the abstract class before I continue converting the rest.\r\n\r\nThe abstract class will work \"out of the box\" if there's just a single path to be set. In that case one will have to define the four methods in PushToTexmaker: name, icon, command line, and an init, primarily meant to get the preference key (maybe better to have a `getPreferenceKey()`? I was originally thinking that maybe more preference values could be read in here in case of a more complicated configuration dialogue.)\r\n\r\n(I know that I forgot to run auto-format for some files and also noted some other things that can be slightly improved, like in ExternalTab, but those will be sorted out eventually. Comments on AbstractPushToApplication.java and PushToTexmaker.java primarily. :-))","created_at":"2015-10-07T16:04:42Z","updated_at":"2015-10-09T08:37:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00d7423d4a941cf250aeda33acec28af16092518","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JabRef/jabref/pulls/218/commits","review_comments_url":"https://api.github.com/repos/JabRef/jabref/pulls/218/comments","review_comment_url":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JabRef/jabref/issues/218/comments","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/4dbd6a2c617d21b70d2d60c091d665eb170ce882","head":{"label":"oscargus:abstractpusher","ref":"abstractpusher","sha":"4dbd6a2c617d21b70d2d60c091d665eb170ce882","user":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"repo":{"id":43496954,"name":"jabref","full_name":"oscargus/jabref","owner":{"login":"oscargus","id":8114497,"avatar_url":"https://avatars.githubusercontent.com/u/8114497?v=3","gravatar_id":"","url":"https://api.github.com/users/oscargus","html_url":"https://github.com/oscargus","followers_url":"https://api.github.com/users/oscargus/followers","following_url":"https://api.github.com/users/oscargus/following{/other_user}","gists_url":"https://api.github.com/users/oscargus/gists{/gist_id}","starred_url":"https://api.github.com/users/oscargus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscargus/subscriptions","organizations_url":"https://api.github.com/users/oscargus/orgs","repos_url":"https://api.github.com/users/oscargus/repos","events_url":"https://api.github.com/users/oscargus/events{/privacy}","received_events_url":"https://api.github.com/users/oscargus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oscargus/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":true,"url":"https://api.github.com/repos/oscargus/jabref","forks_url":"https://api.github.com/repos/oscargus/jabref/forks","keys_url":"https://api.github.com/repos/oscargus/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oscargus/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oscargus/jabref/teams","hooks_url":"https://api.github.com/repos/oscargus/jabref/hooks","issue_events_url":"https://api.github.com/repos/oscargus/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/oscargus/jabref/events","assignees_url":"https://api.github.com/repos/oscargus/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/oscargus/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/oscargus/jabref/tags","blobs_url":"https://api.github.com/repos/oscargus/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oscargus/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oscargus/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/oscargus/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oscargus/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/oscargus/jabref/languages","stargazers_url":"https://api.github.com/repos/oscargus/jabref/stargazers","contributors_url":"https://api.github.com/repos/oscargus/jabref/contributors","subscribers_url":"https://api.github.com/repos/oscargus/jabref/subscribers","subscription_url":"https://api.github.com/repos/oscargus/jabref/subscription","commits_url":"https://api.github.com/repos/oscargus/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/oscargus/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/oscargus/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/oscargus/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/oscargus/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/oscargus/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oscargus/jabref/merges","archive_url":"https://api.github.com/repos/oscargus/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oscargus/jabref/downloads","issues_url":"https://api.github.com/repos/oscargus/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/oscargus/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/oscargus/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/oscargus/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oscargus/jabref/labels{/name}","releases_url":"https://api.github.com/repos/oscargus/jabref/releases{/id}","created_at":"2015-10-01T13:07:32Z","updated_at":"2015-10-01T13:07:39Z","pushed_at":"2015-10-09T06:38:27Z","git_url":"git://github.com/oscargus/jabref.git","ssh_url":"git@github.com:oscargus/jabref.git","clone_url":"https://github.com/oscargus/jabref.git","svn_url":"https://github.com/oscargus/jabref","homepage":"http://jabref.sourceforge.net/","size":61674,"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":"JabRef:master","ref":"master","sha":"c2773211c2378ba2e5045fb251a3e36c1bc4a942","user":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"repo":{"id":17634071,"name":"jabref","full_name":"JabRef/jabref","owner":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JabRef/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":false,"url":"https://api.github.com/repos/JabRef/jabref","forks_url":"https://api.github.com/repos/JabRef/jabref/forks","keys_url":"https://api.github.com/repos/JabRef/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JabRef/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JabRef/jabref/teams","hooks_url":"https://api.github.com/repos/JabRef/jabref/hooks","issue_events_url":"https://api.github.com/repos/JabRef/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/JabRef/jabref/events","assignees_url":"https://api.github.com/repos/JabRef/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/JabRef/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/JabRef/jabref/tags","blobs_url":"https://api.github.com/repos/JabRef/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JabRef/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JabRef/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/JabRef/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/JabRef/jabref/languages","stargazers_url":"https://api.github.com/repos/JabRef/jabref/stargazers","contributors_url":"https://api.github.com/repos/JabRef/jabref/contributors","subscribers_url":"https://api.github.com/repos/JabRef/jabref/subscribers","subscription_url":"https://api.github.com/repos/JabRef/jabref/subscription","commits_url":"https://api.github.com/repos/JabRef/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/JabRef/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/JabRef/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/JabRef/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/JabRef/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/JabRef/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JabRef/jabref/merges","archive_url":"https://api.github.com/repos/JabRef/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JabRef/jabref/downloads","issues_url":"https://api.github.com/repos/JabRef/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/JabRef/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/JabRef/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/JabRef/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JabRef/jabref/labels{/name}","releases_url":"https://api.github.com/repos/JabRef/jabref/releases{/id}","created_at":"2014-03-11T14:48:42Z","updated_at":"2015-10-08T20:54:24Z","pushed_at":"2015-10-09T08:17:59Z","git_url":"git://github.com/JabRef/jabref.git","ssh_url":"git@github.com:JabRef/jabref.git","clone_url":"https://github.com/JabRef/jabref.git","svn_url":"https://github.com/JabRef/jabref","homepage":"http://jabref.sourceforge.net/","size":72771,"stargazers_count":106,"watchers_count":106,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":106,"mirror_url":null,"open_issues_count":54,"forks":106,"open_issues":54,"watchers":106,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/218"},"html":{"href":"https://github.com/JabRef/jabref/pull/218"},"issue":{"href":"https://api.github.com/repos/JabRef/jabref/issues/218"},"comments":{"href":"https://api.github.com/repos/JabRef/jabref/issues/218/comments"},"review_comments":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/218/comments"},"review_comment":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/218/commits"},"statuses":{"href":"https://api.github.com/repos/JabRef/jabref/statuses/4dbd6a2c617d21b70d2d60c091d665eb170ce882"}}}}