Skip to content

Commit

Permalink
Only open files if not already opened
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Aug 4, 2016
1 parent 84e3e6c commit dba0736
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import javax.swing.AbstractAction;
import javax.swing.Action;
Expand Down Expand Up @@ -149,11 +150,10 @@
* The main window of the application.
*/
public class JabRefFrame extends JFrame implements OutputPrinter {
private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class);

// Frame titles.
private static final String FRAME_TITLE = "JabRef";

private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class);
private static final String ELLIPSES = "...";

private final JSplitPane splitPane = new JSplitPane();
Expand Down Expand Up @@ -1379,19 +1379,26 @@ public static JMenu subMenu(String name) {
return res;
}

public void addParserResult(ParserResult pr, boolean raisePanel) {
public void addParserResult(ParserResult pr, boolean focusPanel) {
if (pr.toOpenTab()) {
// Add the entries to the open tab.
BasePanel panel = getCurrentBasePanel();
if (panel == null) {
// There is no open tab to add to, so we create a new tab:
addTab(pr.getDatabaseContext(), raisePanel);
addTab(pr.getDatabaseContext(), focusPanel);
} else {
List<BibEntry> entries = new ArrayList<>(pr.getDatabase().getEntries());
addImportedEntries(panel, entries, false);
}
} else {
addTab(pr.getDatabaseContext(), raisePanel);
// only add tab if DB is not already open
Optional<BasePanel> panel = getBasePanelList().stream().filter(p -> p.getBibDatabaseContext().getDatabaseFile().equals(pr.getFile())).findFirst();

if (panel.isPresent()) {
tabbedPane.setSelectedComponent(panel.get());
} else {
addTab(pr.getDatabaseContext(), focusPanel);
}
}
}

Expand Down Expand Up @@ -1644,6 +1651,7 @@ public void addTab(BasePanel bp, boolean raisePanel) {

public BasePanel addTab(BibDatabaseContext databaseContext, boolean raisePanel) {
Objects.requireNonNull(databaseContext);

BasePanel bp = new BasePanel(JabRefFrame.this, databaseContext);
addTab(bp, raisePanel);
return bp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import org.apache.commons.logging.LogFactory;

public class RemoteListenerServer implements Runnable {
private static final Log LOGGER = LogFactory.getLog(RemoteListenerServer.class);

private static final int BACKLOG = 1;
private static final int ONE_SECOND_TIMEOUT = 1000;

private static final Log LOGGER = LogFactory.getLog(RemoteListenerServer.class);
private static final int ONE_SECOND_TIMEOUT = 1000;

private final MessageHandler messageHandler;
private final ServerSocket serverSocket;
Expand Down

0 comments on commit dba0736

Please sign in to comment.