-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use AtomicFileWriter - and introduce constant Crawler.FILENAME_STUDY_RESULT_BIB * Editing of the SLR data works * Update CHANGELOG.md * fix checkstyle * fix l10n * Improve SLR feature - SLR main branch is now "main" (instead of "master") - SLR git initalization now has the .gitignore in the initial commit - Localization - Change from "Perform search for existing systematic literature review" to "Update study search results" - Group together saving localization - Refine localization for LyX - Fix typo "case-insensitive" (source https://en.wikipedia.org/wiki/Case_sensitivity) * Remove obsolete link * Update CHANGELOG.md * Fix checkstyle * Fix localization test * Fix typo * Update src/main/java/org/jabref/gui/slr/EditExistingStudyAction.java Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
- Loading branch information
1 parent
98ce1b5
commit b06e4dc
Showing
26 changed files
with
454 additions
and
222 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
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
63 changes: 63 additions & 0 deletions
63
src/main/java/org/jabref/gui/slr/EditExistingStudyAction.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,63 @@ | ||
package org.jabref.gui.slr; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.actions.ActionHelper; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.logic.crawler.StudyRepository; | ||
import org.jabref.logic.crawler.StudyYamlParser; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.study.Study; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class EditExistingStudyAction extends SimpleCommand { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(EditExistingStudyAction.class); | ||
|
||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
|
||
public EditExistingStudyAction(DialogService dialogService, StateManager stateManager) { | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.executable.bind(ActionHelper.needsStudyDatabase(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
// The action works on the current library | ||
// This library has to be determined | ||
if (stateManager.getActiveDatabase().isEmpty() || !stateManager.getActiveDatabase().get().isStudy()) { | ||
return; | ||
} | ||
BibDatabaseContext bibDatabaseContext = stateManager.getActiveDatabase().get(); | ||
|
||
// The action can only be called on an existing AND saved study library | ||
// The saving is ensured at creation of a study library | ||
// Thus, this check is only existing to check this assumption | ||
if (bibDatabaseContext.getDatabasePath().isEmpty()) { | ||
LOGGER.error("Library path is not available"); | ||
return; | ||
} | ||
|
||
Path databasePath = bibDatabaseContext.getDatabasePath().get(); | ||
|
||
Path studyDirectory = databasePath.getParent(); | ||
|
||
Study study; | ||
try { | ||
study = new StudyYamlParser().parseStudyYamlFile(studyDirectory.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME)); | ||
} catch (IOException e) { | ||
dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), e); | ||
return; | ||
} | ||
|
||
// When the dialog returns, the study.yml file is updated (or kept unmodified at Cancel) | ||
dialogService.showCustomDialogAndWait(new ManageStudyDefinitionView(study, studyDirectory)); | ||
} | ||
} |
Oops, something went wrong.