Skip to content

Commit

Permalink
Merge branch 'master' into gerTrans
Browse files Browse the repository at this point in the history
* master:
  Some more Swedish translations (#1836)
  Updated Menu_tr.properties
  Updated jabref_tr.properties
  Add check for obsolete database structure. Add help popup. (#1818)
  Updated dependencies (#1831)
  Removed one Globals call from MetaData (#1782)
  • Loading branch information
Siedlerchr committed Aug 24, 2016
2 parents 0406741 + fa44fdf commit daee318
Show file tree
Hide file tree
Showing 41 changed files with 471 additions and 212 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
compile 'org.apache.pdfbox:jempbox:1.8.12'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.54'
compile 'org.bouncycastle:bcprov-jdk15on:1.55'

compile 'commons-cli:commons-cli:1.3.1'

Expand Down Expand Up @@ -120,7 +120,7 @@ dependencies {

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'com.github.tomakehurst:wiremock:2.1.10'
testCompile 'com.github.tomakehurst:wiremock:2.1.11'
testCompile 'org.assertj:assertj-swing-junit:3.4.0'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void setUp() throws ClassNotFoundException, SQLException {
connection = TestConnector.getTestConnection(dbmsType);
}
dbmsProcessor = DBMSProcessor.getProcessorInstance(connection, dbmsType);
dbmsProcessor.setUpSharedDatabase();
dbmsProcessor.setupSharedDatabase();
}

@Parameters(name = "Test with {0} database system")
Expand All @@ -58,7 +58,7 @@ public void testCheckBaseIntegrity() throws SQLException {
@Test
public void testSetUpSharedDatabase() throws SQLException {
clear();
dbmsProcessor.setUpSharedDatabase();
dbmsProcessor.setupSharedDatabase();
Assert.assertTrue(dbmsProcessor.checkBaseIntegrity());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.shared.exception.DatabaseNotSupportedException;
import net.sf.jabref.shared.exception.OfflineLockException;
import net.sf.jabref.shared.exception.SharedEntryNotPresentException;

Expand All @@ -40,7 +41,7 @@ public class DBMSSynchronizerTest {


@Before
public void setUp() throws ClassNotFoundException, SQLException {
public void setUp() throws ClassNotFoundException, SQLException, DatabaseNotSupportedException {

Globals.prefs = JabRefPreferences.getInstance();

Expand Down Expand Up @@ -130,7 +131,7 @@ public void testMetaDataChangedEventListener() {
}

@Test
public void testInitializeDatabases() throws SQLException {
public void testInitializeDatabases() throws SQLException, DatabaseNotSupportedException {
clear();
dbmsSynchronizer.initializeDatabases();
Assert.assertTrue(dbmsProcessor.checkBaseIntegrity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.sf.jabref.model.database.DatabaseLocation;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.shared.exception.DatabaseNotSupportedException;

import org.junit.After;
import org.junit.Assert;
Expand All @@ -36,7 +37,7 @@ public class SynchronizationTestSimulator {


@Before
public void setUp() throws ClassNotFoundException, SQLException {
public void setUp() throws ClassNotFoundException, SQLException, DatabaseNotSupportedException {
// Get only one connection for each parameter
if (TestConnector.currentConnectionType != dbmsType) {
connection = TestConnector.getTestConnection(dbmsType);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern;
import net.sf.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern;
import net.sf.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.entry.FieldName;

Expand Down Expand Up @@ -236,12 +237,12 @@ private static Optional<String> getNextUnit(Reader reader) throws IOException {
/**
* @return the stored label patterns
*/
public AbstractBibtexKeyPattern getBibtexKeyPattern() {
public AbstractBibtexKeyPattern getBibtexKeyPattern(GlobalBibtexKeyPattern globalPattern) {
if (bibtexKeyPattern != null) {
return bibtexKeyPattern;
}

bibtexKeyPattern = new DatabaseBibtexKeyPattern(Globals.prefs);
bibtexKeyPattern = new DatabaseBibtexKeyPattern(globalPattern);

// read the data from the metadata and store it into the bibtexKeyPattern
for (String key : this) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/BibtexKeyPatternDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import net.sf.jabref.Globals;
import net.sf.jabref.MetaData;
import net.sf.jabref.gui.bibtexkeypattern.BibtexKeyPatternPanel;
import net.sf.jabref.gui.keyboard.KeyBinder;
Expand Down Expand Up @@ -43,7 +44,7 @@ public BibtexKeyPatternDialog(JabRefFrame parent, BasePanel panel) {
public void setPanel(BasePanel panel) {
this.panel = panel;
this.metaData = panel.getBibDatabaseContext().getMetaData();
AbstractBibtexKeyPattern keypatterns = metaData.getBibtexKeyPattern();
AbstractBibtexKeyPattern keypatterns = metaData.getBibtexKeyPattern(Globals.prefs.getKeyPattern());
bibtexKeyPatternPanel.setValues(keypatterns);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected GlobalBibtexKeyPattern getKeyPatternAsGlobalBibtexKeyPattern() {
}

public DatabaseBibtexKeyPattern getKeyPatternAsDatabaseBibtexKeyPattern() {
DatabaseBibtexKeyPattern res = new DatabaseBibtexKeyPattern(Globals.prefs);
DatabaseBibtexKeyPattern res = new DatabaseBibtexKeyPattern(Globals.prefs.getKeyPattern());
fillPatternUsingPanelData(res);
return res;
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/net/sf/jabref/gui/help/HelpAction.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package net.sf.jabref.gui.help;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.KeyStroke;

import net.sf.jabref.Globals;
Expand Down Expand Up @@ -57,12 +62,29 @@ public JButton getHelpButton() {
return button;
}

public JLabel getHelpLabel(String labelText) {
JLabel helpLabel = new JLabel("<html><u>" + labelText + "</u></html>");
helpLabel.setForeground(Color.BLUE);
helpLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
helpLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
openHelpPage();
}
});
return helpLabel;
}

public void setHelpFile(HelpFile urlPart) {
this.helpPage = urlPart;
}

@Override
public void actionPerformed(ActionEvent e) {
openHelpPage();
}

private void openHelpPage() {
String url = "https://help.jabref.org/" + Globals.prefs.get(JabRefPreferences.LANGUAGE) + "/" + helpPage.getPageName();
JabRefDesktop.openBrowserShowPopup(url);
}
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/net/sf/jabref/gui/shared/MigrationHelpDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package net.sf.jabref.gui.shared;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.border.EmptyBorder;

import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;

public class MigrationHelpDialog extends JDialog {

public MigrationHelpDialog(OpenSharedDatabaseDialog openSharedDatabaseDialog) {
super(openSharedDatabaseDialog, Localization.lang("Migration help information"));
setModal(true);

String migrationMessage = Localization
.lang("Entered database has obsolete structure and is no longer supported.");
JLabel migrationLabel = new JLabel(migrationMessage);
migrationLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

String helpMessage = Localization.lang("Click here to learn about the migration of pre-3.6 databases.");
JLabel helpLabel = new HelpAction(HelpFile.SQL_DATABASE_MIGRATION).getHelpLabel(helpMessage);
helpLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

String informationMessage = Localization.lang("However, a new database was created alongside the pre-3.6 one.");
JLabel informationLabel = new JLabel(informationMessage);
informationLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

Action openAction = new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
openSharedDatabaseDialog.openSharedDatabase();
}
};

JButton okButton = new JButton(Localization.lang("OK"));
okButton.addActionListener(openAction);
okButton.setAlignmentX(Component.CENTER_ALIGNMENT);
okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
"Enter_pressed");
okButton.getActionMap().put("Enter_pressed", openAction);

JPanel buttonPanel = new JPanel();
buttonPanel.add(okButton, BorderLayout.CENTER);

JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(9, 9, 9, 9));
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));

contentPanel.add(migrationLabel);
contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
contentPanel.add(helpLabel);
contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
contentPanel.add(informationLabel);
contentPanel.add(Box.createRigidArea(new Dimension(0, 20)));
contentPanel.add(buttonPanel);

add(contentPanel);

setResizable(false);
pack();
setLocationRelativeTo(openSharedDatabaseDialog);
}
}
Loading

0 comments on commit daee318

Please sign in to comment.