Skip to content

Commit

Permalink
Fixed #535: Add merge action to right click menu
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Apr 5, 2016
1 parent 084e48e commit 7738f48
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Fixed [#1001](https://github.com/JabRef/jabref/issues/1001): No NPE when exporting a complete database
- Fixed [#991](https://github.com/JabRef/jabref/issues/991): Entry is now correctly removed from the BibDatabase
- Fixed [#1062](https://github.com/JabRef/jabref/issues/1062): Merge entry with DOI information now also applies changes to entry type
- Fixed [#535](https://github.com/JabRef/jabref/issues/535): Add merge action to right click menu


### Removed
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1445,12 +1445,11 @@ private void createToolBar() {
tlb.addAction(makeKeyAction);
tlb.addAction(cleanupEntries);
tlb.addAction(mergeEntries);
tlb.addAction(openConsole);

tlb.addSeparator();
tlb.addAction(mark);
tlb.addAction(unmark);
tlb.addAction(openConsole);
tlb.addSeparator();
if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) {
JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown
Expand Down Expand Up @@ -1479,8 +1478,8 @@ private void createToolBar() {
tlb.add(button);
specialFieldButtons.add(button);
}
tlb.addSeparator();
}
tlb.addSeparator();

fetcherToggle = new JToggleButton(generalFetcher.getAction());
tlb.addJToogleButton(fetcherToggle);
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
this.panel = panel;
JMenu typeMenu = new ChangeEntryTypeMenu().getChangeEntryTypeMenu(panel);
// Are multiple entries selected?
boolean multiple = panel.mainTable.getSelectedRowCount() > 1;
boolean multiple = areMultipleEntriesSelected();

// If only one entry is selected, get a reference to it for adapting the menu.
BibEntry be = null;
Expand Down Expand Up @@ -96,7 +96,6 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
add(new GeneralAction(Actions.MARK_ENTRIES, Localization.lang("Mark entries"), IconTheme.JabRefIcon.MARK_ENTRIES.getSmallIcon()));
add(markSpecific);
add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entries"), IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon()));
addSeparator();
} else if (be != null) {
String marked = be.getField(InternalBibtexFields.MARKED);
// We have to check for "" too as the marked field may be empty
Expand All @@ -107,7 +106,6 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
add(markSpecific);
add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entry"), IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon()));
}
addSeparator();
}

if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) {
Expand Down Expand Up @@ -142,9 +140,10 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
add(readStatusMenu);
}

addSeparator();
}

addSeparator();

add(new GeneralAction(Actions.OPEN_FOLDER, Localization.lang("Open folder")) {
{
if (!isFieldSetForSelectedEntry(Globals.FILE_FIELD)) {
Expand Down Expand Up @@ -186,6 +185,17 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {

add(frame.getMassSetField());
add(frame.getManageKeywords());
add(new GeneralAction(Actions.MERGE_ENTRIES,
Localization.lang("Merge entries") + "...",
IconTheme.JabRefIcon.MERGE_ENTRIES.getSmallIcon()) {

{
if (!(areExactlyTwoEntriesSelected())) {
this.setEnabled(false);
}
}

});

addSeparator(); // for "add/move/remove to/from group" entries (appended here)

Expand All @@ -206,6 +216,14 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
frame.createDisabledIconsForMenuEntries(this);
}

private boolean areMultipleEntriesSelected() {
return panel.mainTable.getSelectedRowCount() > 1;
}

private boolean areExactlyTwoEntriesSelected() {
return panel.mainTable.getSelectedRowCount() == 2;
}

/**
* Remove all types from the menu.
* Then cycle through all available values, and add them.
Expand Down

0 comments on commit 7738f48

Please sign in to comment.