Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Integrate BibSonomy Plugin #2157

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8ab73ce
copy bibsonomy-jabref-plugin to jabref
Oct 20, 2015
bf7f11c
update bibsonomy
zesaro Nov 22, 2016
f0c5d46
include localization
zesaro Nov 22, 2016
d3e5d3f
move bibsonomy into jabref package
zesaro Nov 22, 2016
7c6cae1
update imports
zesaro Nov 22, 2016
4676b9f
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Nov 22, 2016
8c84c87
remove duplicates
zesaro Nov 22, 2016
b70ffa6
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Nov 23, 2016
be6fae7
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Nov 27, 2016
15321c5
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Nov 30, 2016
bc8da13
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 3, 2016
5a971d9
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 7, 2016
f073ead
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 9, 2016
705c70e
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 10, 2016
15b0cf1
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 12, 2016
890d54f
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Dec 16, 2016
b91115d
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Jan 4, 2017
47fb6fa
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Jan 20, 2017
ebc88c4
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Feb 7, 2017
88025b9
fix issues after merge
zesaro Feb 7, 2017
b1f6a3e
Merge remote-tracking branch 'upstream/master' into bibsonomy
zesaro Feb 11, 2017
14b7032
Merge remote-tracking branch 'origin/master' into bibsonomy
koppor Feb 16, 2017
022b3f2
Fix usage of Optional.of together with null (by using Optional.ofNull…
koppor Feb 16, 2017
2aa0b6a
Reformat Code using IntelliJ and fix method comments
koppor Feb 16, 2017
4310ad5
Merge remote-tracking branch 'origin/master' into bibsonomy
koppor Feb 16, 2017
047ae2c
Remove obsolete copyright statement
koppor Feb 16, 2017
75a559e
Add bisonomy rest client to external-libraries and update it fromn 3.…
koppor Feb 16, 2017
380e115
Remove "Set file directories" from BibSonomySettingsDialog
koppor Feb 16, 2017
5e0e89e
Streamline comments and reorder methods so that constructors come first
koppor Feb 16, 2017
6a40077
Replace icons by Material Design icons
koppor Feb 16, 2017
3e01613
Remove obsolete @author fields and SVN tags
koppor Feb 16, 2017
1dc98c1
Simplify JabRefFileDirectory and remove BIBSONOMY_FILE_DIRECTORY
koppor Feb 16, 2017
f6c6fd8
Some more comments on WorkerUtil
koppor Feb 16, 2017
8d6dc44
Rewrite BibSonomyToolbarExtender using streams
koppor Feb 16, 2017
cfd64ce
Make settings dialog resizable (it causes trouble on my highres display)
koppor Feb 16, 2017
d035a9a
Merge branch 'master' into bibsonomy
koppor Feb 16, 2017
aa181e5
Prevent ErrorProne to complain
koppor Feb 16, 2017
774cf9d
Move from net.sf.jabref to org.jabref for bibsonomy
koppor Feb 16, 2017
072e6a8
net.sf.jabref -> org.jabref in all texts
koppor Feb 16, 2017
d1047a0
Organize imports for all BibSonomy classes (fixes checkstyle)
koppor Feb 16, 2017
925771b
Integrate settings in JabRef's settings
koppor Feb 17, 2017
79b1850
Beginning to work on late display of bibsonomy properties (to avoid R…
koppor Feb 17, 2017
4743ef3
fix l18n
koppor Feb 17, 2017
5485fca
Merge branch 'master' into bibsonomy
koppor Feb 20, 2017
73456e0
Merge branch 'master' into bibsonomy
koppor Mar 7, 2017
c09b895
Merge branch 'master' into bibsonomy
koppor Mar 28, 2017
183a6f3
fix codacy (1/2)
zesaro Apr 3, 2017
89aef07
Merge master into bibsonomy
zesaro Apr 3, 2017
5ae26b8
Merge branch 'master' into bibsonomy
koppor Apr 16, 2017
0fd3504
Remove EntryEditorTabExteneder as JabRef offers now the tab "Other"
koppor Apr 16, 2017
2741fd5
Remove setting for extra tabs
koppor Apr 16, 2017
d65a1db
Rename GridBagConstraints variables
koppor Apr 16, 2017
8001ecd
Fix inheritance of HyperlinkListener and get rid off WorkerUtil
koppor Apr 16, 2017
aa3bb98
fix more codacy
zesaro Apr 20, 2017
d25ede4
Merge remote-tracking branch 'origin/bibsonomy' into bibsonomy
zesaro Apr 20, 2017
963cc34
refactor some exceptions
zesaro Apr 20, 2017
f5a473c
Add missing break statements (and reformat)
koppor May 11, 2018
ba544bb
Minor stylistic improvements
koppor May 11, 2018
c499265
Move dialog into a warning at the preferences
koppor May 11, 2018
0237a00
Merge remote-tracking branch 'origin/master' into bibsonomy
koppor May 31, 2018
022eb9c
Compile fixes
koppor May 31, 2018
0d09f8e
Remove unused variables
koppor May 31, 2018
0d9eb95
Compile fix
koppor Jun 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,25 @@ install4j {

repositories {
jcenter()

maven {
url 'https://oss.sonatype.org/content/groups/public'
}

maven {
url "http://dev.bibsonomy.org/maven2/"
}
}


configurations {
antlr3
antlr4
}

dependencies {
compile 'org.bibsonomy:bibsonomy-rest-client:3.7.2'

compile 'com.jgoodies:jgoodies-common:1.8.1'
compile 'com.jgoodies:jgoodies-forms:1.9.0'
compile 'com.jgoodies:jgoodies-looks:2.7.0'
Expand Down
5 changes: 5 additions & 0 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Project: Apache Commons Lang
URL: https://commons.apache.org/proper/commons-lang/
License: Apache-2.0

Id: org.bibsonomy:bibsonomy-rest-client
Project: Bibsonomy
URL: https://bitbucket.org/bibsonomy/bibsonomy/wiki/documentation/api/Java%20API%20Examples
License: LGPL-3.0+

Id: com.github.bkromhout:java-diff-utils
Project: java-diff-utils
URL: https://github.com/bkromhout/java-diff-utils
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/jabref/bibsonomy/BibSonomyGlobals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jabref.bibsonomy;

/**
* Provide some default values for configuration of the plugin.
*/
public class BibSonomyGlobals {

public static final String BIBSONOMY_NAME = "BibSonomy";

public static final String API_URL = "http://www.bibsonomy.org/api/";

public static final String API_USERNAME = "jabreftest";

public static final String API_KEY = "4cc8425ab4dfcce2c5d1b5a96d2c7134";

public static final String BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST = "20";

}
224 changes: 224 additions & 0 deletions src/main/java/org/jabref/bibsonomy/BibSonomyProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
package org.jabref.bibsonomy;

import java.util.Optional;
import java.util.Properties;

import org.jabref.preferences.JabRefPreferences;

import org.bibsonomy.common.enums.GroupingEntity;
import org.bibsonomy.model.enums.Order;

/**
* read and write the plugin properties file.
*/
public class BibSonomyProperties extends Properties {

//API properties
private static final String API_URL = "api.url";
private static final String API_USERNAME = "api.username";
private static final String API_KEY = "api.key";

//BibSonomy properties
private static final String BIBSONOMY_SAVE_API_KEY = "bibsonomy.saveapikey";
private static final String BIBSONOMY_DOCUMENTS_IMPORT = "bibsonomy.documents.import";
private static final String BIBSONOMY_DOCUMENTS_EXPORT = "bibsonomy.documents.export";
private static final String BIBSONOMY_TAGS_REFRESH_ON_STARTUP = "bibsonomy.tags.refreshonstartup";
private static final String BIBSONOMY_TAGS_IGNORE_NO_TAGS = "bibsonomy.tags.ignorenotags";
private static final String BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST = "bibsonomy.request.size";
private static final String BIBSONOMY_IGNORE_WARNING_MORE_POSTS = "bibsonomy.request.size.ignorewarning";
private static final String BIBSONOMY_EXTRA_TAB_FIELDS = "bibsonomy.tabs.extra";
private static final String BIBSONOMY_VISIBILITY = "bibsonomy.visibilty";
private static final String BIBSONOMY_TAG_CLOUD_SIZE = "bibsonomy.tagcloud.size";
private static final String BIBSONOMY_SIDE_PANE_VISIBILITY_TYPE = "bibsonomy.sidepane.visibility.type";
private static final String BIBSONOMY_SIDE_PANE_VISIBILITY_NAME = "bibsonomy.sidepane.visibility.name";
private static final String BIBSONOMY_TAG_CLOUD_ORDER = "bibsonomy.tagcloud.order";

//Array containing all property constants
private static final String[] propsArray = {API_URL, API_USERNAME, API_KEY, BIBSONOMY_SAVE_API_KEY, BIBSONOMY_DOCUMENTS_IMPORT, BIBSONOMY_DOCUMENTS_EXPORT, BIBSONOMY_TAGS_REFRESH_ON_STARTUP, BIBSONOMY_TAGS_IGNORE_NO_TAGS, BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST, BIBSONOMY_IGNORE_WARNING_MORE_POSTS, BIBSONOMY_EXTRA_TAB_FIELDS, BIBSONOMY_VISIBILITY, BIBSONOMY_TAG_CLOUD_SIZE, BIBSONOMY_SIDE_PANE_VISIBILITY_TYPE, BIBSONOMY_SIDE_PANE_VISIBILITY_NAME, BIBSONOMY_TAG_CLOUD_ORDER};


private static BibSonomyProperties INSTANCE;

public static BibSonomyProperties getInstance() {
if (INSTANCE == null) {
INSTANCE = loadPropertiesFromJabRefPreferences(JabRefPreferences.getInstance());
}
return INSTANCE;
}

private static BibSonomyProperties loadPropertiesFromJabRefPreferences(JabRefPreferences preferences) {
Optional<String> prefsOpt = Optional.ofNullable(preferences.get(JabRefPreferences.BIBSONOMY_PROPERTIES));

if (!prefsOpt.isPresent()) {
return new BibSonomyProperties();
}

BibSonomyProperties bibSonomyProperties = new BibSonomyProperties();

String prefs = prefsOpt.get();
for (String property : propsArray) {
if (prefs.contains(property)) {
int lastIndexOf = prefs.lastIndexOf(property + "=") + property.length() + 1;
String propertyValue;

if (prefs.indexOf(",", lastIndexOf) >= 0) {
propertyValue = prefs.substring(lastIndexOf, prefs.indexOf(",", lastIndexOf));
} else {
propertyValue = prefs.substring(lastIndexOf, prefs.indexOf("}", lastIndexOf));
}
bibSonomyProperties.setProperty(property, propertyValue);
}
}

return bibSonomyProperties;
}

private BibSonomyProperties() {
}

/**
* Saves the properties and takes care of the "do save API key" option
*/
public static void save() {
String apiKey = getApiKey();
if (!getStoreApiKey()) {
// if the key shoujld not be stored in the preferences, store an empty key in the preferences.
setApiKey("");
}

JabRefPreferences preferences = JabRefPreferences.getInstance();
preferences.clear(JabRefPreferences.BIBSONOMY_PROPERTIES);
preferences.put(JabRefPreferences.BIBSONOMY_PROPERTIES, INSTANCE.toString());

setApiKey(apiKey);
}

public static boolean ignoreNoTagsAssigned() {
return Boolean.valueOf(getInstance().getProperty(BIBSONOMY_TAGS_IGNORE_NO_TAGS, "false"));
}

public static String getUsername() {
return getInstance().getProperty(API_USERNAME, BibSonomyGlobals.API_USERNAME);
}

public static String getApiKey() {
return getInstance().getProperty(API_KEY, BibSonomyGlobals.API_KEY);
}

public static String getApiUrl() {
return getInstance().getProperty(API_URL, BibSonomyGlobals.API_URL);
}

public static boolean getDownloadDocumentsOnImport() {
return Boolean.parseBoolean(getInstance().getProperty(BIBSONOMY_DOCUMENTS_IMPORT, "true"));
}

public static int getNumberOfPostsPerRequest() {
return Integer.parseInt(getInstance().getProperty(BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST, BibSonomyGlobals.BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST));
}

public static boolean getIgnoreMorePostsWarning() {
return Boolean.parseBoolean(getInstance().getProperty(BIBSONOMY_IGNORE_WARNING_MORE_POSTS, "false"));
}

public static String getExtraTabFields() {
return getInstance().getProperty(BIBSONOMY_EXTRA_TAB_FIELDS, "issn;isbn");
}

public static String getDefaultVisibilty() {
return getInstance().getProperty(BIBSONOMY_VISIBILITY, "public");
}

public static boolean getStoreApiKey() {
return Boolean.parseBoolean(getInstance().getProperty(BIBSONOMY_SAVE_API_KEY, "true"));
}

public static boolean getUpdateTagsOnStartUp() {
return Boolean.parseBoolean(getInstance().getProperty(BIBSONOMY_TAGS_REFRESH_ON_STARTUP, "false"));
}

public static boolean getUploadDocumentsOnExport() {
return Boolean.parseBoolean(getInstance().getProperty(BIBSONOMY_DOCUMENTS_EXPORT, "true"));
}

public static int getTagCloudSize() {
return Integer.parseInt(getInstance().getProperty(BIBSONOMY_TAG_CLOUD_SIZE, "100"));
}

public static void setUsername(String text) {
getInstance().setProperty(API_USERNAME, text);
}

public static void setApiKey(String text) {
getInstance().setProperty(API_KEY, text);
}

public static void setStoreApiKey(boolean selected) {
getInstance().setProperty(BIBSONOMY_SAVE_API_KEY, String.valueOf(selected));
}

public static void setNumberOfPostsPerRequest(int value) {
getInstance().setProperty(BIBSONOMY_NUMBER_OF_POSTS_PER_REQUEST, String.valueOf(value));
}

public static void setTagCloudSize(int value) {
getInstance().setProperty(BIBSONOMY_TAG_CLOUD_SIZE, String.valueOf(value));
}

public static void setIgnoreNoTagsAssigned(boolean selected) {
getInstance().setProperty(BIBSONOMY_TAGS_IGNORE_NO_TAGS, String.valueOf(selected));
}

public static void setUpdateTagsOnStartup(boolean selected) {
getInstance().setProperty(BIBSONOMY_TAGS_REFRESH_ON_STARTUP, String.valueOf(selected));
}

public static void setUploadDocumentsOnExport(boolean selected) {
getInstance().setProperty(BIBSONOMY_DOCUMENTS_EXPORT, String.valueOf(selected));
}

public static void setDownloadDocumentsOnImport(boolean selected) {
getInstance().setProperty(BIBSONOMY_DOCUMENTS_IMPORT, String.valueOf(selected));
}

public static void setDefaultVisisbility(String key) {
getInstance().setProperty(BIBSONOMY_VISIBILITY, key);
}

public static void setIgnoreMorePostsWarning(boolean selected) {
getInstance().setProperty(BIBSONOMY_IGNORE_WARNING_MORE_POSTS, String.valueOf(selected));
}

public static void setExtraFields(String text) {
getInstance().setProperty(BIBSONOMY_EXTRA_TAB_FIELDS, text);
}

public static GroupingEntity getSidePaneVisibilityType() {
return GroupingEntity.getGroupingEntity(getInstance().getProperty(BIBSONOMY_SIDE_PANE_VISIBILITY_TYPE, "ALL"));
}

public static String getSidePaneVisibilityName() {
return getInstance().getProperty(BIBSONOMY_SIDE_PANE_VISIBILITY_NAME, "all users");
}

public static void setSidePaneVisibilityType(GroupingEntity entity) {
getInstance().setProperty(BIBSONOMY_SIDE_PANE_VISIBILITY_TYPE, entity.toString());
}

public static void setSidePaneVisibilityName(String value) {
getInstance().setProperty(BIBSONOMY_SIDE_PANE_VISIBILITY_NAME, value);
}

public static Order getTagCloudOrder() {
String order = getInstance().getProperty(BIBSONOMY_TAG_CLOUD_ORDER, "FREQUENCY");
return Order.getOrderByName(order);
}

public static void setTagCloudOrder(Order order) {
getInstance().setProperty(BIBSONOMY_TAG_CLOUD_ORDER, order.toString());
}

public static void setApiUrl(String text) {
getInstance().setProperty(API_URL, text);
}
}
103 changes: 103 additions & 0 deletions src/main/java/org/jabref/bibsonomy/BibSonomySidePaneComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package org.jabref.bibsonomy;

import java.awt.Dimension;

import javax.swing.JMenuItem;

import org.jabref.gui.IconTheme;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.SidePaneComponent;
import org.jabref.gui.SidePaneManager;
import org.jabref.gui.bibsonomy.BibSonomyMenuItem;
import org.jabref.gui.bibsonomy.BibSonomySidePanel;
import org.jabref.gui.bibsonomy.BibSonomyToolBarExtender;
import org.jabref.gui.bibsonomy.EntryEditorTabExtender;
import org.jabref.gui.bibsonomy.listener.BibSonomyDataBaseChangeListener;
import org.jabref.gui.bibsonomy.listener.TabbedPaneChangeListener;
import org.jabref.logic.l10n.Localization;

/**
* Holds the dimension of the {@link BibSonomySidePanel}.
* Additionally it sets the icon and the name.
*/
public class BibSonomySidePaneComponent extends SidePaneComponent {

private SidePaneManager manager;
private JabRefFrame jabRefFrame;

public BibSonomySidePaneComponent(SidePaneManager manager, JabRefFrame jabRefFrame) {
// set the icon and the name
super(manager, IconTheme.JabRefIcon.TAG_TEXT_OUTLINE.getIcon(), Localization.lang("BibSonomy"));

this.manager = manager;
this.jabRefFrame = jabRefFrame;

init();

// add the sidepanel
super.add(new BibSonomySidePanel(jabRefFrame));
}

/**
* get the jabRefFrame
*
* @return The {@link JabRefFrame}
*/
public JabRefFrame getJabRefFrame() {
return jabRefFrame;
}

/**
* get the sidePaneManager
*
* @return The {@link SidePaneManager}
*/
public SidePaneManager getSidePaneManager() {
return manager;
}

@Override
public Dimension getPreferredSize() {
final int SPLIT_PANE_DIVIDER_LOCATION = 145 + 15; // + 15 for possible scrollbar.
return new Dimension(SPLIT_PANE_DIVIDER_LOCATION, 550);
}

@Override
public Dimension getMaximumSize() {
return getPreferredSize();
}

@Override
public int getRescalingWeight() {
return 0;
}

@Override
public ToggleAction getToggleAction() {
return null;
}

public void init() {
// create a ChangeListener to react on newly added entries.
BibSonomyDataBaseChangeListener bibsonomyDataBaseChangeListener = new BibSonomyDataBaseChangeListener(jabRefFrame);

// set a ChangeListener of the Tabbed Pane which registers the databasechangelistener to all database tabs that are added later
jabRefFrame.getTabbedPane().addChangeListener(new TabbedPaneChangeListener(bibsonomyDataBaseChangeListener));
// ...but maybe we were too late: Tabs are created by another (swing)thread so the initial tab change event after tab(and database) creation may be over already.
// Therefore add the listener to the database of the current tab if it is already present.
if (jabRefFrame.getCurrentBasePanel() != null && jabRefFrame.getCurrentBasePanel().getDatabase() != null) {
jabRefFrame.getCurrentBasePanel().getDatabase().registerListener(bibsonomyDataBaseChangeListener);
}

BibSonomyToolBarExtender.extend(jabRefFrame, this);
EntryEditorTabExtender.extend();
}

/**
* Returns a JMenuItem to use Bibsonomy methods
* @return A JMenuItem containing the Menu of Bibsonomy
*/
public JMenuItem getMenuItem() {
return new BibSonomyMenuItem(this);
}
}
Loading