forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenConsole, OpenFolder, OpenExternalFile
- Loading branch information
Showing
7 changed files
with
142 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.jabref.gui; | ||
|
||
import java.io.IOException; | ||
|
||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.desktop.JabRefDesktop; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.jabref.gui.actions.ActionHelper.needsDatabase; | ||
|
||
public class OpenConsoleAction extends SimpleCommand { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(OpenConsoleAction.class); | ||
private final StateManager stateManager; | ||
|
||
public OpenConsoleAction(StateManager stateManager) { | ||
this.stateManager = stateManager; | ||
|
||
this.executable.bind(needsDatabase(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
stateManager.getActiveDatabase().flatMap(BibDatabaseContext::getDatabasePath).ifPresent(path -> { | ||
try { | ||
JabRefDesktop.openConsole(path.toFile()); | ||
} catch (IOException e) { | ||
LOGGER.info("Could not open console", e); | ||
} | ||
}); | ||
} | ||
} |
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,53 @@ | ||
package org.jabref.gui; | ||
|
||
import java.util.List; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.externalfiletype.ExternalFileTypes; | ||
import org.jabref.gui.fieldeditors.LinkedFileViewModel; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
import static org.jabref.gui.actions.ActionHelper.needsDatabase; | ||
|
||
public class OpenExternalFileAction extends SimpleCommand { | ||
|
||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
private final PreferencesService preferencesService; | ||
|
||
public OpenExternalFileAction(DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) { | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.preferencesService = preferencesService; | ||
|
||
this.executable.bind(needsDatabase(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
stateManager.getActiveDatabase().ifPresent(databaseContext -> { | ||
final List<BibEntry> selectedEntries = stateManager.getSelectedEntries(); | ||
|
||
if (selectedEntries.size() != 1) { | ||
dialogService.notify(Localization.lang("This operation requires exactly one item to be selected.")); | ||
return; | ||
} | ||
|
||
final BibEntry entry = selectedEntries.get(0); | ||
|
||
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel( | ||
entry.getFiles().get(0), | ||
entry, | ||
databaseContext, | ||
Globals.TASK_EXECUTOR, | ||
dialogService, | ||
preferencesService.getXMPPreferences(), | ||
preferencesService.getFilePreferences(), | ||
ExternalFileTypes.getInstance()); | ||
linkedFileViewModel.open(); | ||
}); | ||
} | ||
} |
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,45 @@ | ||
package org.jabref.gui; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.externalfiletype.ExternalFileTypes; | ||
import org.jabref.gui.fieldeditors.LinkedFileViewModel; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.jabref.gui.actions.ActionHelper.needsDatabase; | ||
|
||
public class OpenFolderAction extends SimpleCommand { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(OpenFolderAction.class); | ||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
private final PreferencesService preferencesService; | ||
|
||
public OpenFolderAction(DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) { | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.preferencesService = preferencesService; | ||
|
||
this.executable.bind(needsDatabase(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
stateManager.getActiveDatabase().ifPresent(databaseContext -> | ||
stateManager.getSelectedEntries().forEach(entry -> { | ||
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel( | ||
entry.getFiles().get(0), | ||
entry, | ||
databaseContext, | ||
Globals.TASK_EXECUTOR, | ||
dialogService, | ||
preferencesService.getXMPPreferences(), | ||
preferencesService.getFilePreferences(), | ||
ExternalFileTypes.getInstance()); | ||
linkedFileViewModel.openFolder(); | ||
})); | ||
} | ||
} |
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