Skip to content

Commit

Permalink
Changes according to reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshu16095 committed Feb 1, 2025
1 parent 3b250f1 commit 09251a8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;

import static org.jabref.gui.actions.ActionHelper.needsDatabase;

public class ConsistencyCheckAction extends SimpleCommand {

private final DialogService dialogService;
Expand All @@ -26,6 +28,7 @@ public ConsistencyCheckAction(DialogService dialogService, StateManager stateMan
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.executable.bind(needsDatabase(stateManager));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ public void initialize() {
}
}

public void selectEntry() {
@FXML
private void selectEntry() {
selectedEntry.set(entryTypeCombo.getSelectionModel().getSelectedItem());
}

public void exportAsCsv() {
@FXML
private void exportAsCsv() {
viewModel.startExportAsCsv();
}

public void exportAsTxt() {
@FXML
private void exportAsTxt() {
viewModel.startExportAsTxt();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
import org.jabref.logic.quality.consistency.BibliographyConsistencyCheckResultTxtWriter;
import org.jabref.logic.util.StandardFileType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConsistencyCheckDialogViewModel extends AbstractViewModel {

private final Logger LOGGER = LoggerFactory.getLogger(ConsistencyCheckDialogViewModel.class);

private final DialogService dialogService;
private final GuiPreferences preferences;
private final BibliographyConsistencyCheck.Result result;
Expand Down Expand Up @@ -52,23 +58,29 @@ public void startExportAsTxt() {
BibliographyConsistencyCheckResultTxtWriter bibliographyConsistencyCheckResultTxtWriter = new BibliographyConsistencyCheckResultTxtWriter(result, writer);
bibliographyConsistencyCheckResultTxtWriter.writeFindings();
} catch (IOException e) {
dialogService.notify(Localization.lang("Failed to export file!"));
LOGGER.error("Problem when export file", e);
dialogService.showErrorDialogAndWait(Localization.lang("Failed to export file!"));
}
}

public void startExportAsCsv() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(preferences.getFilePreferences().getWorkingDirectory())
.addExtensionFilter(StandardFileType.TXT)
.withDefaultExtension(StandardFileType.TXT)
.addExtensionFilter(StandardFileType.CSV)
.withDefaultExtension(StandardFileType.CSV)
.build();
Optional<Path> exportPath = dialogService.showFileSaveDialog(fileDialogConfiguration);

if (exportPath.isEmpty()) {
return;
}

try (Writer writer = new OutputStreamWriter(Files.newOutputStream(exportPath.get()))) {
BibliographyConsistencyCheckResultCsvWriter bibliographyConsistencyCheckResultTxtWriter = new BibliographyConsistencyCheckResultCsvWriter(result, writer);
bibliographyConsistencyCheckResultTxtWriter.writeFindings();
BibliographyConsistencyCheckResultCsvWriter bibliographyConsistencyCheckResultCsvWriter = new BibliographyConsistencyCheckResultCsvWriter(result, writer);
bibliographyConsistencyCheckResultCsvWriter.writeFindings();
} catch (IOException e) {
dialogService.notify(Localization.lang("Failed to export file!"));
LOGGER.error("Problem when export file", e);
dialogService.showErrorDialogAndWait(Localization.lang("Failed to export file!"));
}
}
}
4 changes: 2 additions & 2 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ Checking\ integrity...=Checking integrity...
Check\ consistency=Check consistency
Select=Select
Entry\ type=Entry type
Export\ as\ csv\ file =Export as csv file
Export\ as\ txt\ file =Export as txt file
Export\ as\ csv\ file=Export as csv file
Export\ as\ txt\ file=Export as txt file
Shows\ results\ for\ the\ selected\ entry\ type.=Shows results for the selected entry type.
Failed\ to\ export\ file!=Failed to export file!

Expand Down

0 comments on commit 09251a8

Please sign in to comment.