Fix null pointer in case no external program to launch has been set

This commit is contained in:
crschnick 2023-07-09 04:08:24 +00:00
parent 6868f6567b
commit 43b2cde018
2 changed files with 13 additions and 0 deletions

View file

@ -35,6 +35,12 @@ public class EditFileAction implements LeafAction {
return entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.FILE);
}
@Override
public boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
var e = AppPrefs.get().externalEditor().getValue();
return e != null;
}
@Override
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Edit with " + AppPrefs.get().externalEditor().getValue().toTranslatedString();

View file

@ -3,6 +3,7 @@ package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.core.store.FileKind;
import javafx.scene.Node;
@ -53,6 +54,12 @@ public class OpenTerminalAction implements LeafAction {
return entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY);
}
@Override
public boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
var t = AppPrefs.get().terminalType().getValue();
return t != null;
}
@Override
public KeyCombination getShortcut() {
return new KeyCodeCombination(KeyCode.T, KeyCombination.SHORTCUT_DOWN);