-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conversion of Preferences/TableColumnsTab to mvvm (#5185)
* Initial * Added contents of the list and bindings * Initial * Added contents of the list and bindings * Refactored specialFields * Added checking, storing and specialFields * Added add and remove custom column, refactor * Fixes unintentional sorting, added moving columns up and down * Refactoring, added update of MainTable * Refactored to TableView, Added ComboBox * Fixed bug in ui update * Refactor and rewording to clean up * Changed table order reload icon * Refactor to save special fields column order, rewording * Refactor mvvm * Removed now superfluous restart message * l10n * Refactor for order * Added validation, cleanup, and minor fix * Refactored FieldsUtil for reuse * Refactored FieldsUtil for reuse * Fixes and cleanups * Refactor and cleanups * Refactor to streams * l10n * l10n again * Cleanups * Fix sorting bug
- Loading branch information
1 parent
8bb6380
commit 373b9f5
Showing
14 changed files
with
733 additions
and
744 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
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
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
90 changes: 90 additions & 0 deletions
90
src/main/java/org/jabref/gui/preferences/TableColumnsItemModel.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,90 @@ | ||
package org.jabref.gui.preferences; | ||
|
||
import java.util.Objects; | ||
|
||
import javafx.beans.property.BooleanProperty; | ||
import javafx.beans.property.DoubleProperty; | ||
import javafx.beans.property.ObjectProperty; | ||
import javafx.beans.property.ReadOnlyBooleanProperty; | ||
import javafx.beans.property.SimpleBooleanProperty; | ||
import javafx.beans.property.SimpleDoubleProperty; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.beans.value.ObservableValue; | ||
|
||
import org.jabref.gui.maintable.ColumnPreferences; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.entry.field.Field; | ||
import org.jabref.model.entry.field.UnknownField; | ||
|
||
public class TableColumnsItemModel { | ||
|
||
private final ObjectProperty<Field> field; | ||
private final StringProperty name = new SimpleStringProperty(""); | ||
private final DoubleProperty length = new SimpleDoubleProperty(ColumnPreferences.DEFAULT_FIELD_LENGTH); | ||
private final BooleanProperty editableProperty = new SimpleBooleanProperty(true); | ||
|
||
public TableColumnsItemModel() { | ||
this.field = new SimpleObjectProperty<>(new UnknownField(Localization.lang("New column"))); | ||
} | ||
|
||
public TableColumnsItemModel(Field field) { | ||
this.field = new SimpleObjectProperty<>(field); | ||
this.editableProperty.setValue(this.field.get() instanceof UnknownField); | ||
} | ||
|
||
public TableColumnsItemModel(Field field, double length) { | ||
this.field = new SimpleObjectProperty<>(field); | ||
this.length.setValue(length); | ||
this.editableProperty.setValue(this.field.get() instanceof UnknownField); | ||
} | ||
|
||
public void setField(Field field) { | ||
this.field.set(field); | ||
} | ||
|
||
public Field getField() { | ||
return field.get(); | ||
} | ||
|
||
public ObservableValue<Field> fieldProperty() { return this.field; } | ||
|
||
public void setName(String name) { | ||
if (editableProperty.get()) { | ||
field.setValue(new UnknownField(name)); | ||
} | ||
} | ||
|
||
public String getName() { | ||
return field.get().getName(); | ||
} | ||
|
||
public StringProperty nameProperty() { return this.name; } | ||
|
||
public void setLength(double length) { | ||
this.length.set(length); | ||
} | ||
|
||
public double getLength() { | ||
return length.get(); | ||
} | ||
|
||
public DoubleProperty lengthProperty() { return this.length; } | ||
|
||
public ReadOnlyBooleanProperty editableProperty() { return editableProperty; } | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(field); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj instanceof TableColumnsItemModel) { | ||
return Objects.equals(this.field, ((TableColumnsItemModel) obj).field); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.