-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6152 from JabRef/allowReordering
Allow reordering of custom entry types fields
- Loading branch information
Showing
28 changed files
with
491 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.jabref.gui.customentrytypes; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import javafx.beans.property.ObjectProperty; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
|
||
import org.jabref.model.entry.BibEntryType; | ||
|
||
public class CustomEntryTypeViewModel { | ||
|
||
private final ObjectProperty<BibEntryType> entryType = new SimpleObjectProperty<>(); | ||
private final ObservableList<FieldViewModel> fields; | ||
|
||
public CustomEntryTypeViewModel(BibEntryType entryType) { | ||
this.entryType.set(entryType); | ||
|
||
List<FieldViewModel> allFieldsForType = entryType.getAllBibFields().stream().map(bibField -> new FieldViewModel(bibField.getField(), entryType.isRequired(bibField.getField()), bibField.getPriority())).collect(Collectors.toList()); | ||
fields = FXCollections.observableArrayList((allFieldsForType)); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(entryType, fields); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof CustomEntryTypeViewModel)) { | ||
return false; | ||
} | ||
CustomEntryTypeViewModel other = (CustomEntryTypeViewModel) obj; | ||
return Objects.equals(entryType, other.entryType) && Objects.equals(fields, other.fields); | ||
} | ||
|
||
public void addField(FieldViewModel field) { | ||
this.fields.add(field); | ||
} | ||
|
||
public ObservableList<FieldViewModel> fields() { | ||
return this.fields; | ||
} | ||
|
||
public ObjectProperty<BibEntryType> entryType() { | ||
return this.entryType; | ||
} | ||
|
||
public void removeField(FieldViewModel focusedItem) { | ||
this.fields.remove(focusedItem); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CustomEntryTypeViewModel [entryType=" + entryType + ", fields=" + fields + "]"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.