Skip to content

Commit

Permalink
Merge pull request #491 from JabRef/close-actions
Browse files Browse the repository at this point in the history
Add close all/others/... in Database Tab menu
  • Loading branch information
simonharrer committed Dec 9, 2015
2 parents 0de880b + 4fd2be1 commit 88bae85
Show file tree
Hide file tree
Showing 22 changed files with 182 additions and 150 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
## [Unreleased]

### Changed
- Add options to close other/all databases in tab right-click menu
- Implements #470: Show editor (as an alternative to author) and booktitle (as an alternative to journal) in the main table by default
- Restore focus to last focused tab on start
- Add ability to format/cleanup the date field
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/exporter/AutoSaveManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void run() {
}

for (BasePanel panel : panels) {
if (panel.isBaseChanged()) {
if (panel.isModified()) {
if (panel.getDatabaseFile() != null) {
AutoSaveManager.autoSave(panel);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public String getTabTitle() {
return title;
}

public boolean isBaseChanged() {
public boolean isModified() {
return baseChanged;
}

Expand Down
48 changes: 5 additions & 43 deletions src/main/java/net/sf/jabref/gui/DragDropPopupPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,29 @@

import java.awt.event.MouseEvent;

import javax.swing.AbstractAction;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import net.sf.jabref.logic.l10n.Localization;

/**
* Adds popup functionality to DragDropPane
*
* Code inspired by http://forums.devx.com/showthread.php?t=151270
*/
public class DragDropPopupPane extends DragDropPane {

private JPopupMenu popupMenu;


public DragDropPopupPane(AbstractAction manageSelectorsAction, AbstractAction databasePropertiesAction,
AbstractAction bibtexKeyPatternAction, AbstractAction closeDatabaseAction) {
super();
public DragDropPopupPane(JPopupMenu menu) {
this.popupMenu = menu;

addMouseListener(new java.awt.event.MouseAdapter() {

@Override
public void mouseClicked(MouseEvent e) {
tabClicked(e);
tabRightClick(e);
}
});

initPopupMenu(manageSelectorsAction, databasePropertiesAction, bibtexKeyPatternAction, closeDatabaseAction);
}

private void initPopupMenu(AbstractAction manageSelectorsAction, AbstractAction databasePropertiesAction,
AbstractAction bibtexKeyPatternAction, AbstractAction closeDatabaseAction) {
popupMenu = new JPopupMenu();

JMenuItem databasePropertiesBtn = new JMenuItem(Localization.lang("Database properties"));
databasePropertiesBtn.addActionListener(databasePropertiesAction);
popupMenu.add(databasePropertiesBtn);

JMenuItem bibtexKeyPatternBtn = new JMenuItem(Localization.lang("Bibtex key patterns"));
bibtexKeyPatternBtn.addActionListener(bibtexKeyPatternAction);
popupMenu.add(bibtexKeyPatternBtn);

JMenuItem manageSelectorsBtn = new JMenuItem(Localization.lang("Manage content selectors"));
manageSelectorsBtn.addActionListener(manageSelectorsAction);
popupMenu.add(manageSelectorsBtn);

JMenuItem closeBtn = new JMenuItem(Localization.lang("Close"), IconTheme.JabRefIcon.CLOSE.getSmallIcon());
closeBtn.addActionListener(closeDatabaseAction);
popupMenu.add(closeBtn);
}

private void tabClicked(MouseEvent e) {
if ((e.getButton() != MouseEvent.BUTTON1) && (e.getClickCount() == 1)) { // if is right-click

private void tabRightClick(MouseEvent e) {
if ((e.getButton() != MouseEvent.BUTTON1) && (e.getClickCount() == 1)) {
// display popup near location of mouse click
popupMenu.show(e.getComponent(), e.getX(), e.getY() - 10);
}
}

private void closeSelectedTab() {
// remove selected tab
remove(getSelectedIndex());
}
}
Loading

0 comments on commit 88bae85

Please sign in to comment.