mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Ordering fixes
This commit is contained in:
parent
ae02fb3791
commit
bc9b962be9
14 changed files with 85 additions and 34 deletions
|
@ -428,7 +428,7 @@ public abstract class StoreEntryComp extends SimpleComp {
|
||||||
}
|
}
|
||||||
|
|
||||||
var order = new Menu(AppI18n.get("order"), new FontIcon("mdal-bookmarks"));
|
var order = new Menu(AppI18n.get("order"), new FontIcon("mdal-bookmarks"));
|
||||||
var noOrder = new MenuItem("None");
|
var noOrder = new MenuItem(AppI18n.get("none"), new FontIcon("mdi2r-reorder-horizontal"));
|
||||||
noOrder.setOnAction(event -> {
|
noOrder.setOnAction(event -> {
|
||||||
DataStorage.get().orderBefore(wrapper.getEntry(), null);
|
DataStorage.get().orderBefore(wrapper.getEntry(), null);
|
||||||
event.consume();
|
event.consume();
|
||||||
|
@ -437,7 +437,8 @@ public abstract class StoreEntryComp extends SimpleComp {
|
||||||
noOrder.setDisable(true);
|
noOrder.setDisable(true);
|
||||||
}
|
}
|
||||||
order.getItems().add(noOrder);
|
order.getItems().add(noOrder);
|
||||||
var stick = new MenuItem(AppI18n.get("stickToTop"));
|
order.getItems().add(new SeparatorMenuItem());
|
||||||
|
var stick = new MenuItem(AppI18n.get("stickToTop"), new FontIcon("mdi2o-order-bool-descending"));
|
||||||
stick.setOnAction(event -> {
|
stick.setOnAction(event -> {
|
||||||
DataStorage.get().orderBefore(wrapper.getEntry(), wrapper.getEntry());
|
DataStorage.get().orderBefore(wrapper.getEntry(), wrapper.getEntry());
|
||||||
event.consume();
|
event.consume();
|
||||||
|
@ -447,22 +448,27 @@ public abstract class StoreEntryComp extends SimpleComp {
|
||||||
}
|
}
|
||||||
order.getItems().add(stick);
|
order.getItems().add(stick);
|
||||||
order.getItems().add(new SeparatorMenuItem());
|
order.getItems().add(new SeparatorMenuItem());
|
||||||
|
var desc = new MenuItem(AppI18n.get("orderAheadOf"), new FontIcon("mdi2o-order-bool-descending-variant"));
|
||||||
|
desc.setDisable(true);
|
||||||
|
order.getItems().add(desc);
|
||||||
var section = StoreViewState.get().getParentSectionForWrapper(wrapper);
|
var section = StoreViewState.get().getParentSectionForWrapper(wrapper);
|
||||||
section.get().getAllChildren().getList().forEach(other -> {
|
if (section.isPresent()) {
|
||||||
var ow = other.getWrapper();
|
section.get().getAllChildren().getList().forEach(other -> {
|
||||||
var op = ow.getEntry().getProvider();
|
var ow = other.getWrapper();
|
||||||
MenuItem m = new MenuItem(ow.getName().getValue(),
|
var op = ow.getEntry().getProvider();
|
||||||
op != null ? PrettyImageHelper.ofFixedSizeSquare(op.getDisplayIconFileName(ow.getEntry().getStore()),
|
MenuItem m = new MenuItem(ow.getName().getValue(),
|
||||||
16).createRegion() : null);
|
op != null ? PrettyImageHelper.ofFixedSizeSquare(op.getDisplayIconFileName(ow.getEntry().getStore()),
|
||||||
if (ow.getEntry().getUuid().equals(wrapper.getEntry().getOrderBefore())) {
|
16).createRegion() : null);
|
||||||
m.setDisable(true);
|
if (other.getWrapper().equals(wrapper) || ow.getEntry().getUuid().equals(wrapper.getEntry().getOrderBefore())) {
|
||||||
}
|
m.setDisable(true);
|
||||||
m.setOnAction(event -> {
|
}
|
||||||
wrapper.orderBefore(ow);
|
m.setOnAction(event -> {
|
||||||
event.consume();
|
wrapper.orderBefore(ow);
|
||||||
|
event.consume();
|
||||||
|
});
|
||||||
|
order.getItems().add(m);
|
||||||
});
|
});
|
||||||
order.getItems().add(m);
|
}
|
||||||
});
|
|
||||||
contextMenu.getItems().add(order);
|
contextMenu.getItems().add(order);
|
||||||
|
|
||||||
contextMenu.getItems().add(new SeparatorMenuItem());
|
contextMenu.getItems().add(new SeparatorMenuItem());
|
||||||
|
|
|
@ -15,7 +15,10 @@ import javafx.collections.FXCollections;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.ToIntFunction;
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public class StoreSection {
|
public class StoreSection {
|
||||||
|
@ -62,29 +65,36 @@ public class StoreSection {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
var explicitOrderComp = new Comparator<StoreSection>() {
|
var explicitOrderComp = Comparator.<StoreSection>comparingInt(new ToIntFunction<>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(StoreSection o1, StoreSection o2) {
|
public int applyAsInt(StoreSection value) {
|
||||||
var explicit1 = o1.getWrapper().getEntry().getOrderBefore();
|
var explicit = value.getWrapper().getEntry().getOrderBefore();
|
||||||
var explicit2 = o2.getWrapper().getEntry().getOrderBefore();
|
if (explicit == null) {
|
||||||
if (explicit1 == null && explicit2 == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (explicit1 != null && explicit2 == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (explicit2 != null && explicit1 == null) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (explicit1.equals(o2.getWrapper().getEntry().getUuid())) {
|
|
||||||
return -1;
|
if (explicit.equals(value.getWrapper().getEntry().getUuid())) {
|
||||||
|
return Integer.MIN_VALUE;
|
||||||
}
|
}
|
||||||
if (explicit2.equals(o1.getWrapper().getEntry().getUuid())) {
|
|
||||||
return -1;
|
return -count(value.getWrapper(), new HashSet<>());
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
private int count(StoreEntryWrapper wrapper, Set<StoreEntryWrapper> seen) {
|
||||||
|
if (seen.contains(wrapper)) {
|
||||||
|
// Loop!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
seen.add(wrapper);
|
||||||
|
|
||||||
|
var found = list.getList().stream().filter(section -> wrapper.getEntry().getOrderBefore().equals(section.getWrapper().getEntry().getUuid())).findFirst();
|
||||||
|
if (found.isPresent()) {
|
||||||
|
return count(found.get().getWrapper(), seen);
|
||||||
|
} else {
|
||||||
|
return seen.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
var usableComp = Comparator.<StoreSection>comparingInt(
|
var usableComp = Comparator.<StoreSection>comparingInt(
|
||||||
value -> value.getWrapper().getEntry().getValidity().isUsable() ? -1 : 1);
|
value -> value.getWrapper().getEntry().getValidity().isUsable() ? -1 : 1);
|
||||||
var comp = explicitOrderComp.thenComparing(usableComp);
|
var comp = explicitOrderComp.thenComparing(usableComp);
|
||||||
|
|
|
@ -457,3 +457,6 @@ history=Browsing-historik
|
||||||
skipAll=Spring alle over
|
skipAll=Spring alle over
|
||||||
notes=Bemærkninger
|
notes=Bemærkninger
|
||||||
addNotes=Tilføj noter
|
addNotes=Tilføj noter
|
||||||
|
order=Bestille ...
|
||||||
|
stickToTop=Hold dig på toppen
|
||||||
|
orderAheadOf=Bestil på forhånd ...
|
||||||
|
|
|
@ -451,3 +451,6 @@ history=Browsing-Verlauf
|
||||||
skipAll=Alles überspringen
|
skipAll=Alles überspringen
|
||||||
notes=Anmerkungen
|
notes=Anmerkungen
|
||||||
addNotes=Notizen hinzufügen
|
addNotes=Notizen hinzufügen
|
||||||
|
order=Bestellen ...
|
||||||
|
stickToTop=Oben bleiben
|
||||||
|
orderAheadOf=Vorbestellen ...
|
||||||
|
|
|
@ -456,3 +456,5 @@ notes=Notes
|
||||||
addNotes=Add notes
|
addNotes=Add notes
|
||||||
#context: verb
|
#context: verb
|
||||||
order=Order ...
|
order=Order ...
|
||||||
|
stickToTop=Keep on top
|
||||||
|
orderAheadOf=Order ahead of ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=Historial de navegación
|
||||||
skipAll=Saltar todo
|
skipAll=Saltar todo
|
||||||
notes=Notas
|
notes=Notas
|
||||||
addNotes=Añadir notas
|
addNotes=Añadir notas
|
||||||
|
order=Ordenar ...
|
||||||
|
stickToTop=Mantener arriba
|
||||||
|
orderAheadOf=Haz tu pedido antes de ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=Historique de navigation
|
||||||
skipAll=Sauter tout
|
skipAll=Sauter tout
|
||||||
notes=Notes
|
notes=Notes
|
||||||
addNotes=Ajouter des notes
|
addNotes=Ajouter des notes
|
||||||
|
order=Commander...
|
||||||
|
stickToTop=Garde le dessus
|
||||||
|
orderAheadOf=Commande en avance...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=Cronologia di navigazione
|
||||||
skipAll=Salta tutto
|
skipAll=Salta tutto
|
||||||
notes=Note
|
notes=Note
|
||||||
addNotes=Aggiungi note
|
addNotes=Aggiungi note
|
||||||
|
order=Ordinare ...
|
||||||
|
stickToTop=Continua a essere in cima
|
||||||
|
orderAheadOf=Ordina prima di ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=閲覧履歴
|
||||||
skipAll=すべてスキップする
|
skipAll=すべてスキップする
|
||||||
notes=備考
|
notes=備考
|
||||||
addNotes=メモを追加する
|
addNotes=メモを追加する
|
||||||
|
order=注文する
|
||||||
|
stickToTop=トップをキープする
|
||||||
|
orderAheadOf=先に注文する
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=Browsegeschiedenis
|
||||||
skipAll=Alles overslaan
|
skipAll=Alles overslaan
|
||||||
notes=Opmerkingen
|
notes=Opmerkingen
|
||||||
addNotes=Opmerkingen toevoegen
|
addNotes=Opmerkingen toevoegen
|
||||||
|
order=Bestellen ...
|
||||||
|
stickToTop=Bovenaan houden
|
||||||
|
orderAheadOf=Vooruitbestellen ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=Histórico de navegação
|
||||||
skipAll=Salta tudo
|
skipAll=Salta tudo
|
||||||
notes=Nota
|
notes=Nota
|
||||||
addNotes=Adiciona notas
|
addNotes=Adiciona notas
|
||||||
|
order=Encomenda ...
|
||||||
|
stickToTop=Mantém-te no topo
|
||||||
|
orderAheadOf=Encomenda antes de ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=История просмотров
|
||||||
skipAll=Пропустить все
|
skipAll=Пропустить все
|
||||||
notes=Заметки
|
notes=Заметки
|
||||||
addNotes=Добавляй заметки
|
addNotes=Добавляй заметки
|
||||||
|
order=Заказать ...
|
||||||
|
stickToTop=Держись на высоте
|
||||||
|
orderAheadOf=Заказать заранее ...
|
||||||
|
|
|
@ -439,3 +439,6 @@ history=Tarama geçmişi
|
||||||
skipAll=Tümünü atla
|
skipAll=Tümünü atla
|
||||||
notes=Notlar
|
notes=Notlar
|
||||||
addNotes=Notlar ekleyin
|
addNotes=Notlar ekleyin
|
||||||
|
order=Sipariş ...
|
||||||
|
stickToTop=Zirvede kal
|
||||||
|
orderAheadOf=Önceden sipariş verin ...
|
||||||
|
|
|
@ -438,3 +438,6 @@ history=浏览历史
|
||||||
skipAll=全部跳过
|
skipAll=全部跳过
|
||||||
notes=说明
|
notes=说明
|
||||||
addNotes=添加注释
|
addNotes=添加注释
|
||||||
|
order=订购 ...
|
||||||
|
stickToTop=保持在顶部
|
||||||
|
orderAheadOf=提前订购...
|
||||||
|
|
Loading…
Reference in a new issue