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

Reimplement custom entry types dialog #5799

Merged
merged 57 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f8202ff
[WIP] Reimplement custom entry types dialog
Siedlerchr Dec 30, 2019
c3d4f31
simplify layout
Siedlerchr Dec 31, 2019
70147eb
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 3, 2020
919fcdb
refactor to display entry types and all fields
Siedlerchr Jan 4, 2020
0c8c8c5
remove logger plugin needed for eclipse
Siedlerchr Jan 5, 2020
7b4bf0e
add data to table when entry type selected
Siedlerchr Jan 6, 2020
5bdd610
some layout improvements
Siedlerchr Jan 6, 2020
f077c08
renaming and replace combobox with textfield
Siedlerchr Jan 6, 2020
ef86a03
add string converter for combobox
Siedlerchr Jan 7, 2020
d36af8b
add icon buttons for adding
Siedlerchr Jan 7, 2020
391aaca
add new entry type to the list
Siedlerchr Jan 8, 2020
7208e0a
use hashmap to associate fields and types
Siedlerchr Jan 8, 2020
607b376
Merge branch 'master' into customizeEntrydlg
Siedlerchr Jan 8, 2020
9850a67
add Delete icons to table colums
Siedlerchr Jan 9, 2020
25350c1
fix issue with empty rows
Siedlerchr Jan 9, 2020
8a9637e
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 10, 2020
dff6163
refactorings
Siedlerchr Jan 10, 2020
f5ba88e
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 18, 2020
02898f1
remove debug outout
Siedlerchr Jan 19, 2020
d18f9d6
implement first part of saving customized entry types
Siedlerchr Jan 19, 2020
5217e2c
mark preferences service as private
Siedlerchr Jan 19, 2020
beec426
remove unused import
Siedlerchr Jan 19, 2020
4dcbf9b
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 25, 2020
11c3b3d
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 26, 2020
a644a3f
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 28, 2020
813a514
add method for completely removing entry types
Siedlerchr Jan 28, 2020
ab86a38
fix checkstyle
Siedlerchr Jan 28, 2020
0f1ff4c
fix l10n
Siedlerchr Jan 28, 2020
eb988b6
Fixes making paths of linked files relative (web urls will not be tou…
systemoperator Jan 29, 2020
f53568b
Replace link to Workspace set-up with new one (#5896)
duelle Jan 29, 2020
4ea90a2
Merge branch 'master' into customizeEntrydlg
Siedlerchr Jan 30, 2020
1d448e9
Merge branch 'customizeEntrydlg' of github.com:JabRef/jabref into cus…
Siedlerchr Jan 30, 2020
3078a47
Merge remote-tracking branch 'upstream/master'
Siedlerchr Jan 31, 2020
7a2f0ef
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Jan 31, 2020
3af0919
Add commit handler
Siedlerchr Jan 31, 2020
368588a
Merge branch 'customizeEntrydlg' of github.com:JabRef/jabref into cus…
Siedlerchr Jan 31, 2020
a702f25
TableView is now properly updated when radio button is toggled
Siedlerchr Feb 1, 2020
365c24a
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Feb 2, 2020
5d673e8
refactor and pass entrytypes manager as ctor param
Siedlerchr Feb 2, 2020
aa27022
add changelog
Siedlerchr Feb 2, 2020
18cde93
fix l10n
Siedlerchr Feb 2, 2020
703f930
add missing l10n
Siedlerchr Feb 2, 2020
8947419
move reloading custom entry types from pref to apply
Siedlerchr Feb 2, 2020
a522f21
increase width
Siedlerchr Feb 2, 2020
6dcc424
Merge remote-tracking branch 'upstream/master'
Siedlerchr Feb 3, 2020
50c054d
Merge branch 'master' into customizeEntrydlg
Siedlerchr Feb 3, 2020
e497e03
bind bidirectional
Siedlerchr Feb 3, 2020
66eee3b
Merge branch 'customizeEntrydlg' of github.com:JabRef/jabref into cus…
Siedlerchr Feb 3, 2020
7802588
merge remote changes
Siedlerchr Feb 3, 2020
c50d20a
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Feb 4, 2020
35472df
rework l1n tooltip
Siedlerchr Feb 4, 2020
7e532ff
fix error in l10n
Siedlerchr Feb 4, 2020
cc32b8f
fix binding
Siedlerchr Feb 4, 2020
f456652
Merge remote-tracking branch 'upstream/master' into customizeEntrydlg
Siedlerchr Feb 8, 2020
f2e377e
Add validation for empty field and type
Siedlerchr Feb 8, 2020
001cf15
fix l10n
Siedlerchr Feb 8, 2020
0fe9edb
Merge branch 'master' into customizeEntrydlg
koppor Feb 19, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Object removeRequiredField(Field focusedItem) {
return null;
}

public Object removeOptionalField(Field focusedItem) {
public Object removeOptionalField(Field focusedItem) {
// TODO Auto-generated method stub
return null;
}
Expand All @@ -49,6 +49,9 @@ public Object removeOptional2Field(Field focusedItem) {
return null;
}



public enum FieldType {
REQUIRED,
PRIMARY_OPTIONAL,
SECONDARY_OPTIONAL
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,20 @@
</HBox>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<VBox prefHeight="200.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<children>
<Label text="Required fields" />
<Label text="Required and optional fields" />
<TableView fx:id="requiredFields" prefHeight="200.0" prefWidth="200.0">
<columns>
<TableColumn fx:id="requiredFieldsNameColumn" prefWidth="75.0" text="Field" />
<TableColumn fx:id="requiredFieldsActionColumn" prefWidth="75.0" />
</columns>
</TableView>
<HBox>
<children>
<ComboBox fx:id="addNewRequiredField" editable="true" prefWidth="150.0" />
<Button mnemonicParsing="false" onAction="#addRequiredFields" text="Button" />
</children>
</HBox>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Optional fields" />
<TableView fx:id="optionalFields" prefHeight="200.0" prefWidth="200.0">
<columns>
<TableColumn fx:id="optionalFieldNameColumn" prefWidth="75.0" text="Field" />
<TableColumn fx:id="optionalFieldActionColumn" prefWidth="75.0" />
</columns>
</TableView>
<HBox>
<children>
<ComboBox fx:id="addOptionalField" editable="true" prefWidth="150.0" />
<Button mnemonicParsing="false" onAction="#addOptionalField" text="add" />
</children>
</HBox>
<Label text="Optional fields 2" />
<TableView fx:id="optionalFields2" prefHeight="200.0" prefWidth="200.0">
<columns>
<TableColumn fx:id="optionalFields2NameColumn" prefWidth="75.0" text="Field" />
<TableColumn fx:id="optionalFields2ActionColumn" prefWidth="75.0" />
<TableColumn fx:id="fieldTypeColumn" prefWidth="75.0" text="Field type" />
<TableColumn fx:id="fieldTypeActionColumn" prefWidth="75.0" />
</columns>
</TableView>
<HBox>
<children>
<ComboBox fx:id="addOptionalFields2" editable="true" prefWidth="150.0" />
<Button mnemonicParsing="false" onAction="#addOptionalField2" text="Button" />
<ComboBox fx:id="addNewField" editable="true" prefWidth="150.0" />
<Button mnemonicParsing="false" onAction="#addNewField" text="Button" />
</children>
</HBox>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;

import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.types.EntryType;
Expand All @@ -25,19 +22,9 @@ public class CustomizeEntryTypeDialogView extends BaseDialog<Void> {
@FXML private ComboBox<EntryType> addNewEntryType;
@FXML private TableView<Field> requiredFields;
@FXML private TableColumn<Field, String> requiredFieldsNameColumn;

@FXML private TableColumn<Field, String> requiredFieldsActionColumn;
@FXML private ComboBox<Field> addNewRequiredField;
@FXML private TableView<Field> optionalFields;
@FXML private TableColumn<Field, String> optionalFieldNameColumn;
@FXML private TableColumn<Field, String> optionalFieldActionColumn;

@FXML private ComboBox<Field> addOptionalField;
@FXML private TableView<Field> optionalFields2;
@FXML private TableColumn<Field, String> optionalFields2NameColumn;
@FXML private TableColumn<Field, String> optionalFields2ActionColumn;

@FXML private ComboBox<Field> addOptionalFields2;
@FXML private TableColumn<Field, String> fieldTypeColumn;
@FXML private TableColumn<Field, String> fieldTypeActionColumn;
@FXML private ComboBox<?> addNewField;
@FXML private ButtonType applyButton;

private final CustomEntryTypeDialogViewModel viewModel;
Expand All @@ -58,53 +45,7 @@ private void initialize() {

private void setupTable() {
Copy link
Member

Choose a reason for hiding this comment

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

inline?

entryTypColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getDisplayName()));
requiredFieldsNameColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getDisplayName()));
optionalFieldNameColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getDisplayName()));
optionalFields2NameColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getDisplayName()));

new ValueTableCellFactory<EntryType, String>()
.withText(name -> name)
.install(entryTypColumn);

new ValueTableCellFactory<EntryType, String>()
.withGraphic(item -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode())
.withTooltip(name -> Localization.lang("Remove entry type") + " " + name)
.withOnMouseClickedEvent(item -> evt ->
viewModel.removeEntryType(entryTypes.getFocusModel().getFocusedItem()))
.install(entryTypeActionsColumn);

new ValueTableCellFactory<Field, String>()
.withText(name -> name)
.install(requiredFieldsNameColumn);

new ValueTableCellFactory<Field, String>()
.withGraphic(item -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode())
.withTooltip(name -> Localization.lang("Remove required field") + " " + name)
.withOnMouseClickedEvent(item -> evt ->
viewModel.removeRequiredField(requiredFields.getFocusModel().getFocusedItem()))
.install(requiredFieldsActionColumn);

new ValueTableCellFactory<Field, String>()
.withText(name -> name)
.install(optionalFieldNameColumn);

new ValueTableCellFactory<Field, String>()
.withGraphic(item -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode())
.withTooltip(name -> Localization.lang("Remove optional field") + " " + name)
.withOnMouseClickedEvent(item -> evt ->
viewModel.removeOptionalField(optionalFields.getFocusModel().getFocusedItem()))
.install(optionalFieldActionColumn);

new ValueTableCellFactory<Field, String>()
.withText(name -> name)
.install(optionalFields2NameColumn);

new ValueTableCellFactory<Field, String>()
.withGraphic(item -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode())
.withTooltip(name -> Localization.lang("Remove optional2 field") + " " + name)
.withOnMouseClickedEvent(item -> evt ->
viewModel.removeOptional2Field(optionalFields2.getFocusModel().getFocusedItem()))
.install(optionalFields2ActionColumn);

}

@FXML
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/org/jabref/gui/customentrytypes/RadioButtonCell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.jabref.gui.customentrytypes;
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved

import java.util.EnumSet;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableCell;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;

public class RadioButtonCell<S, T extends Enum<T>> extends TableCell<S, T> {

private final EnumSet<T> enumeration;

public RadioButtonCell(EnumSet<T> enumeration) {
this.enumeration = enumeration;
}

@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
// gui setup
HBox hb = new HBox(7);
hb.setAlignment(Pos.CENTER);
final ToggleGroup group = new ToggleGroup();

// create a radio button for each 'element' of the enumeration
for (Enum<T> enumElement : enumeration) {
RadioButton radioButton = new RadioButton(enumElement.toString());
radioButton.setUserData(enumElement);
radioButton.setToggleGroup(group);
hb.getChildren().add(radioButton);
if (enumElement.equals(item)) {
radioButton.setSelected(true);
}
}

// issue events on change of the selected radio button
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

@SuppressWarnings("unchecked")
@Override
public void changed(ObservableValue<? extends Toggle> observable,
Toggle oldValue, Toggle newValue) {
getTableView().edit(getIndex(), getTableColumn());
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
RadioButtonCell.this.commitEdit((T) newValue.getUserData());
}
});
setGraphic(hb);
}
}
}