-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
ParseTexResultView.java
51 lines (38 loc) · 1.84 KB
/
ParseTexResultView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.jabref.gui.texparser;
import java.nio.file.Path;
import java.util.Optional;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.texparser.TexParserResult;
import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
public class ParseTexResultView extends BaseDialog<Void> {
private final TexParserResult texParserResult;
private final Path basePath;
@FXML private ListView<ReferenceViewModel> referenceListView;
@FXML private ListView<CitationViewModel> citationListView;
public ParseTexResultView(TexParserResult texParserResult, Path basePath) {
this.texParserResult = texParserResult;
this.basePath = basePath;
setTitle(Localization.lang("LaTeX Citations Search Results"));
ViewLoader.view(this).load().setAsDialogPane(this);
}
@FXML
private void initialize() {
ParseTexResultViewModel viewModel = new ParseTexResultViewModel(texParserResult);
referenceListView.setItems(viewModel.getReferenceList());
referenceListView.getSelectionModel().selectFirst();
new ViewModelListCellFactory<ReferenceViewModel>()
.withText(ReferenceViewModel::getDisplayText)
.install(referenceListView);
citationListView.setItems(viewModel.getCitationListByReference());
new ViewModelListCellFactory<CitationViewModel>()
.withGraphic(citation -> citation.getDisplayGraphic(basePath, Optional.of(citationListView.getWidth() - 50)))
.install(citationListView);
EasyBind.subscribe(referenceListView.getSelectionModel().selectedItemProperty(),
viewModel::activeReferenceChanged);
}
}