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

Add close all/others/... in Database Tab menu #491

Merged
merged 9 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
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