-
-
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 #9836 from deybis17/reorganization_library_properties
Reorganized "General tab" (preamble still here) and "String constants…
- Loading branch information
Showing
8 changed files
with
118 additions
and
53 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
11 changes: 11 additions & 0 deletions
11
src/main/java/org/jabref/gui/libraryproperties/preamble/PreambleProperties.fxml
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.layout.VBox?> | ||
<fx:root spacing="10.0" type="VBox" | ||
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" | ||
fx:controller="org.jabref.gui.libraryproperties.preamble.PreamblePropertiesView"> | ||
<Label styleClass="sectionHeader" text="%Preamble"/> | ||
<TextArea fx:id="preamble" minHeight="100" prefHeight="180" VBox.vgrow="ALWAYS"/> | ||
</fx:root> |
38 changes: 38 additions & 0 deletions
38
src/main/java/org/jabref/gui/libraryproperties/preamble/PreamblePropertiesView.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,38 @@ | ||
package org.jabref.gui.libraryproperties.preamble; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.TextArea; | ||
|
||
import org.jabref.gui.libraryproperties.AbstractPropertiesTabView; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
import com.airhacks.afterburner.views.ViewLoader; | ||
import jakarta.inject.Inject; | ||
|
||
public class PreamblePropertiesView extends AbstractPropertiesTabView<PreamblePropertiesViewModel> { | ||
@FXML private TextArea preamble; | ||
|
||
@Inject private UndoManager undoManager; | ||
|
||
public PreamblePropertiesView(BibDatabaseContext databaseContext) { | ||
this.databaseContext = databaseContext; | ||
|
||
ViewLoader.view(this) | ||
.root(this) | ||
.load(); | ||
} | ||
|
||
@Override | ||
public String getTabName() { | ||
return Localization.lang("Preamble"); | ||
} | ||
|
||
public void initialize() { | ||
this.viewModel = new PreamblePropertiesViewModel(databaseContext, undoManager); | ||
|
||
preamble.textProperty().bindBidirectional(viewModel.preambleProperty()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/jabref/gui/libraryproperties/preamble/PreamblePropertiesViewModel.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,40 @@ | ||
package org.jabref.gui.libraryproperties.preamble; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
|
||
import org.jabref.gui.libraryproperties.PropertiesTabViewModel; | ||
import org.jabref.gui.undo.UndoablePreambleChange; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
public class PreamblePropertiesViewModel implements PropertiesTabViewModel { | ||
private final StringProperty preambleProperty = new SimpleStringProperty(""); | ||
|
||
private final BibDatabaseContext databaseContext; | ||
private final UndoManager undoManager; | ||
|
||
PreamblePropertiesViewModel(BibDatabaseContext databaseContext, UndoManager undoManager) { | ||
this.undoManager = undoManager; | ||
this.databaseContext = databaseContext; | ||
} | ||
|
||
@Override | ||
public void setValues() { | ||
preambleProperty.setValue(databaseContext.getDatabase().getPreamble().orElse("")); | ||
} | ||
|
||
@Override | ||
public void storeSettings() { | ||
String newPreamble = preambleProperty.getValue(); | ||
if (!databaseContext.getDatabase().getPreamble().orElse("").equals(newPreamble)) { | ||
undoManager.addEdit(new UndoablePreambleChange(databaseContext.getDatabase(), databaseContext.getDatabase().getPreamble().orElse(null), newPreamble)); | ||
databaseContext.getDatabase().setPreamble(newPreamble); | ||
} | ||
} | ||
|
||
public StringProperty preambleProperty() { | ||
return this.preambleProperty; | ||
} | ||
} |