mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 15:10:23 +00:00
Add download action
This commit is contained in:
parent
3df5a1f697
commit
82e6b7a035
15 changed files with 84 additions and 2 deletions
|
@ -48,8 +48,13 @@ public final class HumanReadableFormat {
|
|||
bytes /= b;
|
||||
ci.next();
|
||||
}
|
||||
var f = ci.getIndex() >= 2 ? "%.3f" : "%.0f";
|
||||
return String.format(f + " %cB", bytes / (double) b, ci.current());
|
||||
|
||||
var f = ci.getIndex() >= 2 ? "%.3f" : "%.1f";
|
||||
var r = String.format(f + " %cB", bytes / (double) b, ci.current());
|
||||
if (r.endsWith(".0")) {
|
||||
r = r.substring(0, r.length() - 2);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public static String date(LocalDateTime x) {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package io.xpipe.ext.base.browser;
|
||||
|
||||
import io.xpipe.app.browser.BrowserFullSessionModel;
|
||||
import io.xpipe.app.browser.action.BrowserLeafAction;
|
||||
import io.xpipe.app.browser.file.BrowserEntry;
|
||||
import io.xpipe.app.browser.file.BrowserFileSystemTabModel;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.store.FileKind;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DownloadAction implements BrowserLeafAction {
|
||||
|
||||
@Override
|
||||
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
|
||||
var transfer = model.getBrowserModel();
|
||||
if (!(transfer instanceof BrowserFullSessionModel fullSessionModel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fullSessionModel.getLocalTransfersStage().drop(model, entries);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return "download";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getIcon(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
|
||||
return new FontIcon("mdi2d-download");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory() {
|
||||
return Category.MUTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyCombination getShortcut() {
|
||||
return new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> getName(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
|
||||
return AppI18n.observable("download");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
|
||||
var transfer = model.getBrowserModel();
|
||||
if (!(transfer instanceof BrowserFullSessionModel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ open module io.xpipe.ext.base {
|
|||
requires atlantafx.base;
|
||||
|
||||
provides BrowserAction with
|
||||
DownloadAction,
|
||||
RunScriptAction,
|
||||
FollowLinkAction,
|
||||
BackAction,
|
||||
|
|
|
@ -187,3 +187,4 @@ untarDirectory=Untar to $DIR$
|
|||
unzipDirectory=Pak ud til $DIR$
|
||||
unzipHere=Pak ud her
|
||||
requiresRestart=Kræver en genstart for at kunne anvendes.
|
||||
download=Download
|
||||
|
|
|
@ -178,3 +178,4 @@ untarDirectory=Untar zu $DIR$
|
|||
unzipDirectory=Entpacken nach $DIR$
|
||||
unzipHere=Hier entpacken
|
||||
requiresRestart=Erfordert einen Neustart zur Anwendung.
|
||||
download=Herunterladen
|
||||
|
|
|
@ -177,4 +177,5 @@ untarDirectory=Untar to $DIR$
|
|||
unzipDirectory=Unzip to $DIR$
|
||||
unzipHere=Unzip here
|
||||
requiresRestart=Requires a restart to apply.
|
||||
download=Download
|
||||
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Untar a $DIR$
|
|||
unzipDirectory=Descomprimir a $DIR$
|
||||
unzipHere=Descomprimir aquí
|
||||
requiresRestart=Requiere un reinicio para aplicarse.
|
||||
download=Descargar
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Untar to $DIR$
|
|||
unzipDirectory=Décompresser pour $DIR$
|
||||
unzipHere=Décompresse ici
|
||||
requiresRestart=Nécessite un redémarrage pour s'appliquer.
|
||||
download=Télécharger
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Untar a $DIR$
|
|||
unzipDirectory=Decomprimere in $DIR$
|
||||
unzipHere=Decomprimi qui
|
||||
requiresRestart=Richiede un riavvio per essere applicato.
|
||||
download=Scarica
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=未対応$DIR$
|
|||
unzipDirectory=解凍先$DIR$
|
||||
unzipHere=ここで解凍する
|
||||
requiresRestart=適用には再起動が必要である。
|
||||
download=ダウンロード
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Naar $DIR$
|
|||
unzipDirectory=Uitpakken naar $DIR$
|
||||
unzipHere=Hier uitpakken
|
||||
requiresRestart=Vereist een herstart om toe te passen.
|
||||
download=Downloaden
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Untar para $DIR$
|
|||
unzipDirectory=Descompacta para $DIR$
|
||||
unzipHere=Descompacta aqui
|
||||
requiresRestart=Requer um reinício para ser aplicado.
|
||||
download=Descarrega
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Унтар к $DIR$
|
|||
unzipDirectory=Разархивировать в $DIR$
|
||||
unzipHere=Распакуйте здесь
|
||||
requiresRestart=Требует перезапуска для применения.
|
||||
download=Скачать
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=Untar'a $DIR$
|
|||
unzipDirectory=Açmak için $DIR$
|
||||
unzipHere=Buradan açın
|
||||
requiresRestart=Uygulamak için yeniden başlatma gerekir.
|
||||
download=İndir
|
||||
|
|
|
@ -176,3 +176,4 @@ untarDirectory=到$DIR$
|
|||
unzipDirectory=解压缩为$DIR$
|
||||
unzipHere=在此解压缩
|
||||
requiresRestart=需要重新启动才能应用。
|
||||
download=下载
|
||||
|
|
Loading…
Reference in a new issue