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

DB properties layout and save order config changed #999

Merged
merged 1 commit into from
Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Integrity check now also checks broken file links, abbreviations in journal and booktitle, and incorrect use of proceedings with page numbers
- PdfContentImporter does not write the content of the first page into the review field any more
- Implemented [#462](https://github.com/JabRef/jabref/issues/462): Add new action to open console where opened database file is located. New button, menu entry and shortcut (CTRL+SHIFT+J) for this action have also been added.
- [#957](https://github.com/JabRef/jabref/issues/957) Improved usability of Export save order selection in Preferences and Database Properties
- [#958](https://github.com/JabRef/jabref/issues/958) Adjusted size and changed layout of database dialog

- [#1023](https://github.com/JabRef/jabref/issues/492) ArXiv fetcher now also fetches based on eprint id

### Fixed
Expand Down
47 changes: 37 additions & 10 deletions src/integrationTest/java/net/sf/jabref/gui/GUITest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.sf.jabref.gui;

import net.sf.jabref.JabRefMain;
import net.sf.jabref.gui.dbproperties.DatabasePropertiesDialog;
import net.sf.jabref.gui.preftabs.PreferencesDialog;
import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.dependency.jsr305.Nonnull;
Expand All @@ -20,6 +21,7 @@ public class GUITest extends AssertJSwingJUnitTestCase {

private AWTExceptionHandler awtExceptionHandler;


@Override
protected void onSetUp() {
awtExceptionHandler = new AWTExceptionHandler();
Expand Down Expand Up @@ -64,12 +66,14 @@ public void testCreateBibtexEntry() {
newDatabase(mainFrame);

mainFrame.menuItemWithPath("BibTeX", "New entry...").click();
findDialog(EntryTypeDialog.class).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {
findDialog(EntryTypeDialog.class).withTimeout(10_000).using(robot())
.button(new GenericTypeMatcher<JButton>(JButton.class) {

@Override protected boolean isMatching(@Nonnull JButton jButton) {
return "Book".equals(jButton.getText());
}
}).click();
@Override
protected boolean isMatching(@Nonnull JButton jButton) {
return "Book".equals(jButton.getText());
}
}).click();

exitJabRef(mainFrame);
}
Expand All @@ -82,12 +86,14 @@ public void testOpenAndSavePreferences() {

robot().waitForIdle();

findDialog(PreferencesDialog.class).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {
findDialog(PreferencesDialog.class).withTimeout(10_000).using(robot())
.button(new GenericTypeMatcher<JButton>(JButton.class) {

@Override protected boolean isMatching(@Nonnull JButton jButton) {
return "OK".equals(jButton.getText());
}
}).click();
@Override
protected boolean isMatching(@Nonnull JButton jButton) {
return "OK".equals(jButton.getText());
}
}).click();

exitJabRef(mainFrame);
}
Expand All @@ -112,4 +118,25 @@ public void testViewChanges() {
exitJabRef(mainFrame);
}

@Test
public void testDatabasePropertiesDialog() {

FrameFixture mainFrame = findFrame(JabRefFrame.class).withTimeout(10_000).using(robot());
newDatabase(mainFrame);

mainFrame.menuItemWithPath("File", "Database properties").click();

robot().waitForIdle();

findDialog(DatabasePropertiesDialog.class).withTimeout(10_000).using(robot())
.button(new GenericTypeMatcher<JButton>(JButton.class) {

@Override
protected boolean isMatching(@Nonnull JButton jButton) {
return "OK".equals(jButton.getText());
}
}).click();

exitJabRef(mainFrame);
}
}
72 changes: 18 additions & 54 deletions src/main/java/net/sf/jabref/gui/SaveOrderConfigDisplay.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2012-2015 JabRef contributors.
/* Copyright (C) 2012-2016 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
Expand All @@ -25,8 +25,6 @@
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;

Expand All @@ -40,13 +38,11 @@ public class SaveOrderConfigDisplay {
private JComboBox<String> savePriSort;
private JComboBox<String> saveSecSort;
private JComboBox<String> saveTerSort;
private JTextField savePriField;
private JTextField saveSecField;
private JTextField saveTerField;
private JCheckBox savePriDesc;
private JCheckBox saveSecDesc;
private JCheckBox saveTerDesc;


public SaveOrderConfigDisplay() {
init();
}
Expand All @@ -57,58 +53,30 @@ private void init() {
Collections.sort(fieldNames);
String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]);
savePriSort = new JComboBox<>(allPlusKey);
savePriSort.setEditable(true);
saveSecSort = new JComboBox<>(allPlusKey);
saveSecSort.setEditable(true);
saveTerSort = new JComboBox<>(allPlusKey);

savePriSort.insertItemAt(Localization.lang("<select>"), 0);
saveSecSort.insertItemAt(Localization.lang("<select>"), 0);
saveTerSort.insertItemAt(Localization.lang("<select>"), 0);

savePriField = new JTextField(10);
saveSecField = new JTextField(10);
saveTerField = new JTextField(10);

savePriSort.addActionListener(e -> {
if (savePriSort.getSelectedIndex() > 0) {
savePriField.setText(savePriSort.getSelectedItem().toString());
savePriSort.setSelectedIndex(0);
}
});
saveSecSort.addActionListener(e -> {
if (saveSecSort.getSelectedIndex() > 0) {
saveSecField.setText(saveSecSort.getSelectedItem().toString());
saveSecSort.setSelectedIndex(0);
}
});
saveTerSort.addActionListener(e -> {
if (saveTerSort.getSelectedIndex() > 0) {
saveTerField.setText(saveTerSort.getSelectedItem().toString());
saveTerSort.setSelectedIndex(0);
}
});
saveTerSort.setEditable(true);

savePriDesc = new JCheckBox(Localization.lang("Descending"));
saveSecDesc = new JCheckBox(Localization.lang("Descending"));
saveTerDesc = new JCheckBox(Localization.lang("Descending"));


FormLayout layout = new FormLayout("right:pref, 8dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, left:pref",
"pref, 2dlu, pref, 2dlu, pref");
FormBuilder builder = FormBuilder.create().layout(layout);
builder.add(Localization.lang("Primary sort criterion")).xy(1, 1);
builder.add(savePriSort).xy(3, 1);
builder.add(savePriField).xy(5, 1);
builder.add(savePriDesc).xy(7, 1);
builder.add(savePriDesc).xy(5, 1);

builder.add(Localization.lang("Secondary sort criterion")).xy(1, 3);
builder.add(saveSecSort).xy(3, 3);
builder.add(saveSecField).xy(5, 3);
builder.add(saveSecDesc).xy(7, 3);
builder.add(saveSecDesc).xy(5, 3);

builder.add(Localization.lang("Tertiary sort criterion")).xy(1, 5);
builder.add(saveTerSort).xy(3, 5);
builder.add(saveTerField).xy(5, 5);
builder.add(saveTerDesc).xy(7, 5);
builder.add(saveTerDesc).xy(5, 5);

panel = builder.build();
}
Expand All @@ -117,43 +85,39 @@ public Component getPanel() {
return panel;
}


public void setEnabled(boolean enabled) {
savePriSort.setEnabled(enabled);
savePriField.setEnabled(enabled);
savePriDesc.setEnabled(enabled);
saveSecSort.setEnabled(enabled);
saveSecField.setEnabled(enabled);
saveSecDesc.setEnabled(enabled);
saveTerSort.setEnabled(enabled);
saveTerField.setEnabled(enabled);
saveTerDesc.setEnabled(enabled);
}


public void setSaveOrderConfig(SaveOrderConfig saveOrderConfig) {
Objects.requireNonNull(saveOrderConfig);

savePriField.setText(saveOrderConfig.sortCriteria[0].field);
savePriSort.setSelectedItem(saveOrderConfig.sortCriteria[0].field);
savePriDesc.setSelected(saveOrderConfig.sortCriteria[0].descending);
saveSecField.setText(saveOrderConfig.sortCriteria[1].field);
saveSecSort.setSelectedItem(saveOrderConfig.sortCriteria[1].field);
saveSecDesc.setSelected(saveOrderConfig.sortCriteria[1].descending);
saveTerField.setText(saveOrderConfig.sortCriteria[2].field);
saveTerSort.setSelectedItem(saveOrderConfig.sortCriteria[2].field);
saveTerDesc.setSelected(saveOrderConfig.sortCriteria[2].descending);

savePriSort.setSelectedIndex(0);
saveSecSort.setSelectedIndex(0);
saveTerSort.setSelectedIndex(0);
}

public SaveOrderConfig getSaveOrderConfig() {
SaveOrderConfig saveOrderConfig = new SaveOrderConfig();
saveOrderConfig.sortCriteria[0].field = savePriField.getText().toLowerCase().trim();
saveOrderConfig.sortCriteria[0].field = getSelectedItemAsLowerCaseTrim(savePriSort);
saveOrderConfig.sortCriteria[0].descending = savePriDesc.isSelected();
saveOrderConfig.sortCriteria[1].field = saveSecField.getText().toLowerCase().trim();
saveOrderConfig.sortCriteria[1].field = getSelectedItemAsLowerCaseTrim(saveSecSort);
saveOrderConfig.sortCriteria[1].descending = saveSecDesc.isSelected();
saveOrderConfig.sortCriteria[2].field = saveTerField.getText().toLowerCase().trim();
saveOrderConfig.sortCriteria[2].field = getSelectedItemAsLowerCaseTrim(saveTerSort);
saveOrderConfig.sortCriteria[2].descending = saveTerDesc.isSelected();
return saveOrderConfig;
}

private String getSelectedItemAsLowerCaseTrim(JComboBox<String> sortBox) {
return sortBox.getSelectedItem().toString().toLowerCase().trim();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2003-2015 JabRef contributors.
/* Copyright (C) 2003-2016 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
Expand Down Expand Up @@ -35,7 +35,6 @@
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import net.sf.jabref.exporter.FieldFormatterCleanups;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.SaveOrderConfigDisplay;
Expand Down Expand Up @@ -77,7 +76,8 @@ public class DatabasePropertiesDialog extends JDialog {
private JRadioButton saveInOriginalOrder;
private JRadioButton saveInSpecifiedOrder;

private final JCheckBox protect = new JCheckBox(Localization.lang("Refuse to save the database before external changes have been reviewed."));
private final JCheckBox protect = new JCheckBox(
Localization.lang("Refuse to save the database before external changes have been reviewed."));
private boolean oldProtectVal;
private SaveOrderConfigDisplay saveOrderPanel;

Expand Down Expand Up @@ -106,9 +106,9 @@ private void init(JFrame parent) {
browseFileIndv.addActionListener(BrowseAction.buildForDir(parent, fileDirIndv));

setupSortOrderConfiguration();

FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, left:pref, 4dlu, pref:grow",
"pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 140dlu, pref,"));
FormLayout form = new FormLayout("left:pref, 4dlu, pref:grow, 4dlu, pref:grow, 4dlu, pref",
"pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 160dlu, pref,");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add fill/grow to the row corresponding to the save action panel. Makes sense that it is expanded if the dialog is resized.

FormBuilder builder = FormBuilder.create().layout(form);
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

builder.add(Localization.lang("Database encoding")).xy(1, 1);
Expand Down Expand Up @@ -142,6 +142,7 @@ private void init(JFrame parent) {
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
Expand Down Expand Up @@ -326,8 +327,7 @@ private void storeSettings() {
}

boolean changed = saveOrderConfigChanged || !newEncoding.equals(oldEncoding)
|| !oldFileVal.equals(fileDir.getText())
|| !oldFileIndvVal.equals(fileDirIndv.getText())
|| !oldFileVal.equals(fileDir.getText()) || !oldFileIndvVal.equals(fileDirIndv.getText())
|| (oldProtectVal != protect.isSelected()) || saveActionsChanged;
// ... if so, mark base changed. Prevent the Undo button from removing
// change marking:
Expand Down
Loading