Skip to content
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

Code: Tex --> Latex (in the context of ParseLatex) #6019

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
import org.jabref.gui.search.GlobalSearchBar;
import org.jabref.gui.shared.ConnectToSharedDatabaseCommand;
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
import org.jabref.gui.texparser.ParseTexAction;
import org.jabref.gui.texparser.ParseLatexAction;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
Expand Down Expand Up @@ -770,7 +770,7 @@ private MenuBar createMenu() {
pushToApplicationsManager.setMenuItem(pushToApplicationMenuItem);

tools.getItems().addAll(
factory.createMenuItem(StandardActions.PARSE_TEX, new ParseTexAction(stateManager)),
factory.createMenuItem(StandardActions.PARSE_LATEX, new ParseLatexAction(stateManager)),
factory.createMenuItem(StandardActions.NEW_SUB_LIBRARY_FROM_AUX, new NewSubLibraryAction(this, stateManager)),

new SeparatorMenuItem(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public enum StandardActions implements Action {
TOOGLE_OO(Localization.lang("OpenOffice/LibreOffice"), IconTheme.JabRefIcons.FILE_OPENOFFICE, KeyBinding.OPEN_OPEN_OFFICE_LIBRE_OFFICE_CONNECTION),
TOGGLE_WEB_SEARCH(Localization.lang("Web search"), Localization.lang("Toggle web search interface"), IconTheme.JabRefIcons.WWW, KeyBinding.WEB_SEARCH),

PARSE_TEX(Localization.lang("Search for citations in LaTeX files..."), IconTheme.JabRefIcons.LATEX_CITATIONS),
PARSE_LATEX(Localization.lang("Search for citations in LaTeX files..."), IconTheme.JabRefIcons.LATEX_CITATIONS),
NEW_SUB_LIBRARY_FROM_AUX(Localization.lang("New sublibrary based on AUX file") + "...", Localization.lang("New BibTeX sublibrary") + Localization.lang("This feature generates a new library based on which entries are needed in an existing LaTeX document."), IconTheme.JabRefIcons.NEW),
WRITE_XMP(Localization.lang("Write XMP metadata to PDFs"), Localization.lang("Will write XMP metadata to the PDFs linked from selected entries."), KeyBinding.WRITE_XMP),
OPEN_FOLDER(Localization.lang("Open folder"), Localization.lang("Open folder"), KeyBinding.OPEN_FOLDER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.texparser.DefaultTexParser;
import org.jabref.logic.texparser.DefaultLatexParser;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.texparser.Citation;
import org.jabref.model.texparser.TexParserResult;
import org.jabref.model.texparser.LatexParserResult;
import org.jabref.preferences.PreferencesService;

import org.slf4j.Logger;
Expand All @@ -56,7 +56,7 @@ enum Status {
private final ObjectProperty<Status> status;
private final StringProperty searchError;
private Future<?> searchTask;
private TexParserResult texParserResult;
private LatexParserResult latexParserResult;
private BibEntry currentEntry;

public LatexCitationsTabViewModel(BibDatabaseContext databaseContext, PreferencesService preferencesService,
Expand Down Expand Up @@ -129,18 +129,18 @@ private Collection<Citation> searchAndParse(String citeKey) throws IOException {
Path newDirectory = databaseContext.getMetaData().getLatexFileDirectory(preferencesService.getUser())
.orElseGet(preferencesService::getWorkingDir);

if (texParserResult == null || !newDirectory.equals(directory.get())) {
if (latexParserResult == null || !newDirectory.equals(directory.get())) {
directory.set(newDirectory);

if (!newDirectory.toFile().exists()) {
throw new IOException(String.format("Current search directory does not exist: %s", newDirectory));
}

List<Path> texFiles = searchDirectory(newDirectory, new ArrayList<>());
texParserResult = new DefaultTexParser().parse(texFiles);
latexParserResult = new DefaultLatexParser().parse(texFiles);
}

return texParserResult.getCitationsByKey(citeKey);
return latexParserResult.getCitationsByKey(citeKey);
}

private List<Path> searchDirectory(Path directory, List<Path> texFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.model.database.BibDatabaseContext;

public class ParseTexAction extends SimpleCommand {
public class ParseLatexAction extends SimpleCommand {

private final StateManager stateManager;

public ParseTexAction(StateManager stateManager) {
public ParseLatexAction(StateManager stateManager) {
this.stateManager = stateManager;
executable.bind(ActionHelper.needsDatabase(stateManager));
}

@Override
public void execute() {
BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(NullPointerException::new);
ParseTexDialogView dialog = new ParseTexDialogView(database);
ParseLatexDialogView dialog = new ParseLatexDialogView(database);
dialog.showAndWait();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<?import javafx.scene.layout.VBox?>
<?import org.controlsfx.control.CheckTreeView?>
<DialogPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.jabref.gui.texparser.ParseTexDialogView"
fx:controller="org.jabref.gui.texparser.ParseLatexDialogView"
prefWidth="500.0" prefHeight="650.0">
<content>
<VBox spacing="10.0">
<VBox spacing="5.0">
<Label text="%LaTeX files directory:"/>
<HBox spacing="10.0">
<TextField fx:id="texDirectoryField" HBox.hgrow="ALWAYS"/>
<TextField fx:id="latexDirectoryField" HBox.hgrow="ALWAYS"/>
<Button fx:id="browseButton" onAction="#browseButtonClicked" text="%Browse"/>
<Button fx:id="searchButton" defaultButton="true" onAction="#searchButtonClicked" text="%Search"/>
</HBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.controlsfx.control.CheckTreeView;
import org.fxmisc.easybind.EasyBind;

public class ParseTexDialogView extends BaseDialog<Void> {
public class ParseLatexDialogView extends BaseDialog<Void> {

private final BibDatabaseContext databaseContext;
private final ControlsFxVisualizer validationVisualizer;
@FXML private TextField texDirectoryField;
@FXML private TextField latexDirectoryField;
@FXML private Button browseButton;
@FXML private Button searchButton;
@FXML private ProgressIndicator progressIndicator;
Expand All @@ -44,9 +44,9 @@ public class ParseTexDialogView extends BaseDialog<Void> {
@Inject private TaskExecutor taskExecutor;
@Inject private PreferencesService preferencesService;
@Inject private FileUpdateMonitor fileMonitor;
private ParseTexDialogViewModel viewModel;
private ParseLatexDialogViewModel viewModel;

public ParseTexDialogView(BibDatabaseContext databaseContext) {
public ParseLatexDialogView(BibDatabaseContext databaseContext) {
this.databaseContext = databaseContext;
this.validationVisualizer = new ControlsFxVisualizer();

Expand All @@ -62,7 +62,7 @@ public ParseTexDialogView(BibDatabaseContext databaseContext) {

@FXML
private void initialize() {
viewModel = new ParseTexDialogViewModel(databaseContext, dialogService, taskExecutor, preferencesService, fileMonitor);
viewModel = new ParseLatexDialogViewModel(databaseContext, dialogService, taskExecutor, preferencesService, fileMonitor);

fileTreeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
fileTreeView.showRootProperty().bindBidirectional(viewModel.successfulSearchProperty());
Expand All @@ -79,11 +79,11 @@ private void initialize() {
EasyBind.listBind(viewModel.getCheckedFileList(), fileTreeView.getCheckModel().getCheckedItems());
});

texDirectoryField.textProperty().bindBidirectional(viewModel.texDirectoryProperty());
latexDirectoryField.textProperty().bindBidirectional(viewModel.latexFileDirectoryProperty());
validationVisualizer.setDecoration(new IconValidationDecorator());
validationVisualizer.initVisualization(viewModel.texDirectoryValidation(), texDirectoryField);
validationVisualizer.initVisualization(viewModel.latexDirectoryValidation(), latexDirectoryField);
browseButton.disableProperty().bindBidirectional(viewModel.searchInProgressProperty());
searchButton.disableProperty().bind(viewModel.texDirectoryValidation().validProperty().not());
searchButton.disableProperty().bind(viewModel.latexDirectoryValidation().validProperty().not());
selectAllButton.disableProperty().bindBidirectional(viewModel.noFilesFoundProperty());
unselectAllButton.disableProperty().bindBidirectional(viewModel.noFilesFoundProperty());
progressIndicator.visibleProperty().bindBidirectional(viewModel.searchInProgressProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.texparser.DefaultTexParser;
import org.jabref.logic.texparser.DefaultLatexParser;
import org.jabref.logic.texparser.TexBibEntriesResolver;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.util.FileUpdateMonitor;
Expand All @@ -41,51 +41,51 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ParseTexDialogViewModel extends AbstractViewModel {
public class ParseLatexDialogViewModel extends AbstractViewModel {

private static final Logger LOGGER = LoggerFactory.getLogger(ParseTexDialogViewModel.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ParseLatexDialogViewModel.class);
private static final String TEX_EXT = ".tex";
private final BibDatabaseContext databaseContext;
private final DialogService dialogService;
private final TaskExecutor taskExecutor;
private final PreferencesService preferencesService;
private final FileUpdateMonitor fileMonitor;
private final StringProperty texDirectory;
private final Validator texDirectoryValidator;
private final StringProperty latexFileDirectory;
private final Validator latexDirectoryValidator;
private final ObjectProperty<FileNodeViewModel> root;
private final ObservableList<TreeItem<FileNodeViewModel>> checkedFileList;
private final BooleanProperty noFilesFound;
private final BooleanProperty searchInProgress;
private final BooleanProperty successfulSearch;

public ParseTexDialogViewModel(BibDatabaseContext databaseContext, DialogService dialogService,
TaskExecutor taskExecutor, PreferencesService preferencesService,
FileUpdateMonitor fileMonitor) {
public ParseLatexDialogViewModel(BibDatabaseContext databaseContext, DialogService dialogService,
TaskExecutor taskExecutor, PreferencesService preferencesService,
FileUpdateMonitor fileMonitor) {
this.databaseContext = databaseContext;
this.dialogService = dialogService;
this.taskExecutor = taskExecutor;
this.preferencesService = preferencesService;
this.fileMonitor = fileMonitor;
this.texDirectory = new SimpleStringProperty(databaseContext.getMetaData().getLatexFileDirectory(preferencesService.getUser())
.orElseGet(preferencesService::getWorkingDir)
.toAbsolutePath().toString());
this.latexFileDirectory = new SimpleStringProperty(databaseContext.getMetaData().getLatexFileDirectory(preferencesService.getUser())
.orElseGet(preferencesService::getWorkingDir)
.toAbsolutePath().toString());
this.root = new SimpleObjectProperty<>();
this.checkedFileList = FXCollections.observableArrayList();
this.noFilesFound = new SimpleBooleanProperty(true);
this.searchInProgress = new SimpleBooleanProperty(false);
this.successfulSearch = new SimpleBooleanProperty(false);

Predicate<String> isDirectory = path -> Paths.get(path).toFile().isDirectory();
texDirectoryValidator = new FunctionBasedValidator<>(texDirectory, isDirectory,
latexDirectoryValidator = new FunctionBasedValidator<>(latexFileDirectory, isDirectory,
ValidationMessage.error(Localization.lang("Please enter a valid file path.")));
}

public StringProperty texDirectoryProperty() {
return texDirectory;
public StringProperty latexFileDirectoryProperty() {
return latexFileDirectory;
}

public ValidationStatus texDirectoryValidation() {
return texDirectoryValidator.getValidationStatus();
public ValidationStatus latexDirectoryValidation() {
return latexDirectoryValidator.getValidationStatus();
}

public ObjectProperty<FileNodeViewModel> rootProperty() {
Expand All @@ -110,10 +110,10 @@ public BooleanProperty successfulSearchProperty() {

public void browseButtonClicked() {
DirectoryDialogConfiguration directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder()
.withInitialDirectory(Paths.get(texDirectory.get())).build();
.withInitialDirectory(Paths.get(latexFileDirectory.get())).build();

dialogService.showDirectorySelectionDialog(directoryDialogConfiguration).ifPresent(selectedDirectory -> {
texDirectory.set(selectedDirectory.toAbsolutePath().toString());
latexFileDirectory.set(selectedDirectory.toAbsolutePath().toString());
preferencesService.setWorkingDir(selectedDirectory.toAbsolutePath());
});
}
Expand All @@ -122,7 +122,7 @@ public void browseButtonClicked() {
* Run a recursive search in a background task.
*/
public void searchButtonClicked() {
BackgroundTask.wrap(() -> searchDirectory(Paths.get(texDirectory.get())))
BackgroundTask.wrap(() -> searchDirectory(Paths.get(latexFileDirectory.get())))
.onRunning(() -> {
root.set(null);
noFilesFound.set(true);
Expand Down Expand Up @@ -202,10 +202,10 @@ public void parseButtonClicked() {
TexBibEntriesResolver entriesResolver = new TexBibEntriesResolver(databaseContext.getDatabase(),
preferencesService.getImportFormatPreferences(), fileMonitor);

BackgroundTask.wrap(() -> entriesResolver.resolve(new DefaultTexParser().parse(fileList)))
BackgroundTask.wrap(() -> entriesResolver.resolve(new DefaultLatexParser().parse(fileList)))
.onRunning(() -> searchInProgress.set(true))
.onFinished(() -> searchInProgress.set(false))
.onSuccess(result -> new ParseTexResultView(result, databaseContext, Paths.get(texDirectory.get())).showAndWait())
.onSuccess(result -> new ParseLatexResultView(result, databaseContext, Paths.get(latexFileDirectory.get())).showAndWait())
.onFailure(dialogService::showErrorDialogAndWait)
.executeWith(taskExecutor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?import javafx.scene.control.SplitPane?>

<DialogPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.jabref.gui.texparser.ParseTexResultView"
fx:controller="org.jabref.gui.texparser.ParseLatexResultView"
prefWidth="900.0" prefHeight="600.0">
<content>
<SplitPane dividerPositions="0.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.texparser.TexBibEntriesResolverResult;
import org.jabref.model.texparser.LatexBibEntriesResolverResult;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;

public class ParseTexResultView extends BaseDialog<Void> {
public class ParseLatexResultView extends BaseDialog<Void> {

private final TexBibEntriesResolverResult resolverResult;
private final LatexBibEntriesResolverResult resolverResult;
private final BibDatabaseContext databaseContext;
private final Path basePath;
@FXML private ListView<ReferenceViewModel> referenceListView;
@FXML private CitationsDisplay citationsDisplay;
@FXML private ButtonType importButtonType;
private ParseTexResultViewModel viewModel;
private ParseLatexResultViewModel viewModel;

public ParseTexResultView(TexBibEntriesResolverResult resolverResult, BibDatabaseContext databaseContext, Path basePath) {
public ParseLatexResultView(LatexBibEntriesResolverResult resolverResult, BibDatabaseContext databaseContext, Path basePath) {
this.resolverResult = resolverResult;
this.databaseContext = databaseContext;
this.basePath = basePath;
Expand All @@ -47,7 +47,7 @@ public ParseTexResultView(TexBibEntriesResolverResult resolverResult, BibDatabas

@FXML
private void initialize() {
viewModel = new ParseTexResultViewModel(resolverResult, databaseContext);
viewModel = new ParseLatexResultViewModel(resolverResult, databaseContext);

referenceListView.setItems(viewModel.getReferenceList());
referenceListView.getSelectionModel().selectFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.texparser.Citation;
import org.jabref.model.texparser.TexBibEntriesResolverResult;
import org.jabref.model.texparser.LatexBibEntriesResolverResult;

public class ParseTexResultViewModel extends AbstractViewModel {
public class ParseLatexResultViewModel extends AbstractViewModel {

private final TexBibEntriesResolverResult resolverResult;
private final LatexBibEntriesResolverResult resolverResult;
private final BibDatabaseContext databaseContext;
private final ObservableList<ReferenceViewModel> referenceList;
private final ObservableList<Citation> citationList;
private final BooleanProperty importButtonDisabled;

public ParseTexResultViewModel(TexBibEntriesResolverResult resolverResult, BibDatabaseContext databaseContext) {
public ParseLatexResultViewModel(LatexBibEntriesResolverResult resolverResult, BibDatabaseContext databaseContext) {
this.resolverResult = resolverResult;
this.databaseContext = databaseContext;
this.referenceList = FXCollections.observableArrayList();
Expand Down
Loading