-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 #5755
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca4e025
Travail sur l'issue #4183 et #550 pour implémenter un bouton qui ouvr…
CarodePourtales 038911d
Merge pull request #1 from CarodePourtales/issue4183
CarodePourtales b38d442
avancée issue 4183 : reste travail sur pattern, beauté affichage
CarodePourtales b30c3de
Merge pull request #2 from CarodePourtales/issue+4183
CarodePourtales File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.*?> | ||
<?import java.util.*?> | ||
<?import javafx.scene.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<?import javafx.scene.control.ButtonType?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.control.ComboBox?> | ||
<?import javafx.scene.control.DialogPane?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.control.TitledPane?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.FlowPane?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
|
||
<?import javafx.geometry.Insets?> | ||
<DialogPane xmlns:fx="http://javafx.com/fxml/1" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.171" fx:controller="org.jabref.gui.EntryFromIDView"> | ||
|
||
<buttonTypes> | ||
<ButtonType fx:id="lookupButton" buttonData="OK_DONE" text="%LookUp"/> | ||
<ButtonType fx:id="generateButton" buttonData="OK_DONE" text="%Generate"/> | ||
<ButtonType fx:constant="CANCEL"/> | ||
</buttonTypes> | ||
|
||
<content> | ||
<VBox prefHeight="400.0" prefWidth="850.0"> | ||
<children> | ||
<GridPane alignment="CENTER"> | ||
<children> | ||
<Label text="%FromID" GridPane.rowIndex="1" /> | ||
<TextField fx:id="idTextField" onAction="#runFetcherWorker" prefHeight="30.0" prefWidth="400.0" | ||
GridPane.rowIndex="2"/> | ||
|
||
<Label text="%LookUp" GridPane.rowIndex="3" /> | ||
|
||
<Label fx:id="lookUpField" | ||
GridPane.rowIndex="4"/> | ||
|
||
</children> | ||
|
||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="850.0" minWidth="10.0" prefWidth="850.0" /> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="200.0" minWidth="10.0" prefWidth="150.0" /> | ||
</columnConstraints> | ||
<opaqueInsets> | ||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" /> | ||
</opaqueInsets> | ||
<rowConstraints> | ||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> | ||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/> | ||
</rowConstraints> | ||
|
||
</GridPane> | ||
</children> | ||
</VBox> | ||
</content> | ||
</DialogPane> | ||
|
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,98 @@ | ||
package org.jabref.gui; | ||
|
||
import com.airhacks.afterburner.views.ViewLoader; | ||
import javafx.application.Platform; | ||
import javafx.event.Event; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.*; | ||
import javafx.scene.layout.FlowPane; | ||
import org.fxmisc.easybind.EasyBind; | ||
import org.jabref.Globals; | ||
import org.jabref.gui.util.BaseDialog; | ||
import org.jabref.gui.util.ControlHelper; | ||
import org.jabref.gui.util.ViewModelListCellFactory; | ||
import org.jabref.logic.importer.IdBasedFetcher; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseMode; | ||
import org.jabref.model.entry.BibEntryType; | ||
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions; | ||
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions; | ||
import org.jabref.model.entry.types.EntryType; | ||
import org.jabref.model.entry.types.IEEETranEntryTypeDefinitions; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
/** | ||
* Dialog that prompts the user to enter an id for an entry. | ||
* Returns null if canceled. | ||
*/ | ||
public class EntryFromIDView extends BaseDialog<EntryType> { | ||
|
||
@FXML private ButtonType generateButton; | ||
@FXML private ButtonType lookupButton; | ||
@FXML private TextField idTextField; | ||
@FXML private Label lookUpField; | ||
|
||
private final BasePanel basePanel; | ||
private final DialogService dialogService; | ||
private final JabRefPreferences prefs; | ||
|
||
private EntryType type; | ||
private EntryFromIDViewModel viewModel; | ||
|
||
public EntryFromIDView(BasePanel basePanel, DialogService dialogService, JabRefPreferences preferences) { | ||
this.basePanel = basePanel; | ||
this.dialogService = dialogService; | ||
this.prefs = preferences; | ||
|
||
this.setTitle(Localization.lang("Select entry type from ID")); | ||
ViewLoader.view(this) | ||
.load() | ||
.setAsDialogPane(this); | ||
|
||
setResultConverter(button -> { | ||
//The buttonType will always be cancel, even if we pressed one of the entry type buttons | ||
return type; | ||
}); | ||
|
||
ControlHelper.setAction(lookupButton, this.getDialogPane(), event -> viewModel.runFetcherWorkerForLookUp(lookUpField)); | ||
|
||
Button btnLookUp = (Button) this.getDialogPane().lookupButton(lookupButton); | ||
btnLookUp.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> (searching) ? Localization.lang("Searching...") : Localization.lang("LookUp"))); | ||
btnLookUp.disableProperty().bind(viewModel.searchingProperty()); | ||
|
||
ControlHelper.setAction(generateButton, this.getDialogPane(), event -> viewModel.runFetcherWorker()); | ||
|
||
Button btnGenerate = (Button) this.getDialogPane().lookupButton(generateButton); | ||
btnGenerate.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> (searching) ? Localization.lang("Adding...") : Localization.lang("Generate"))); | ||
btnGenerate.disableProperty().bind(viewModel.searchingProperty()); | ||
|
||
} | ||
|
||
@FXML | ||
public void initialize() { | ||
viewModel = new EntryFromIDViewModel(prefs, basePanel, dialogService); | ||
|
||
idTextField.textProperty().bindBidirectional(viewModel.idTextProperty()); | ||
|
||
EasyBind.subscribe(viewModel.getFocusAndSelectAllProperty(), evt -> { | ||
if (evt) { | ||
idTextField.requestFocus(); | ||
idTextField.selectAll(); | ||
} | ||
}); | ||
|
||
Platform.runLater(() -> idTextField.requestFocus()); | ||
} | ||
|
||
@FXML | ||
private void runFetcherWorker(Event event) { | ||
viewModel.runFetcherWorker(); | ||
} | ||
|
||
@FXML | ||
private void focusTextField(Event event) { | ||
idTextField.requestFocus(); | ||
idTextField.selectAll(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not two empty lines between statements.