Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void updateWidgetPositions()
protected void onConfirm()
{
this.consumer.accept(this.getListWidget().getSelectedEntries());
this.closeScreenOrShowParent();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be done here, as it would cause any screen the Consumer had already opened to be closed again immediately. The Consumer should be left to close it if needed, or in some cases it would have probably opened some other screen already at this point (like with the Material List screen in Litematica: https://github.com/maruohon/litematica/blob/644dc94978b3900eaa39964097cac092402df6b0/src/main/java/fi/dy/masa/litematica/materials/MaterialListUtils.java#L164-L183).

}

public List<String> getStrings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public void refreshFilteredEntries()
{
this.reAddFilteredEntries();
this.onEntriesRefreshed();
this.selectEntries();
this.notifyListWidgetFactory();
this.reCreateListEntryWidgets();
}
Expand All @@ -689,6 +690,10 @@ protected void reAddFilteredEntries()
{
}

protected void selectEntries()
{
}

protected void notifyListWidgetFactory()
{
if (this.listEntryWidgetFactory != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class DataListEntrySelectionHandler<DATATYPE>
protected final Supplier<List<DATATYPE>> dataListSupplier;

@Nullable protected Set<DATATYPE> selectedEntries;
@Nullable protected Collection<DATATYPE> selectedEntriesOnCreate;
@Nullable protected SelectionListener<DATATYPE> selectionListener;
@Nullable protected DATATYPE lastSelectedEntry;
protected boolean allowMultiSelection;
Expand Down Expand Up @@ -338,4 +339,18 @@ protected Set<DATATYPE> rebuildSelectedEntries()

return selectedEntries;
}

protected void selectEntries()
{
if (this.selectedEntriesOnCreate != null)
{
this.setSelectedEntries(this.selectedEntriesOnCreate);
this.selectedEntriesOnCreate = null;
}
}

public void setEntriesOnCreate(Collection<DATATYPE> entries)
{
this.selectedEntriesOnCreate = entries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ protected void reAddFilteredEntries()
}
}

protected void selectEntries()
{
if (this.selectionHandler != null)
{
this.selectionHandler.selectEntries();
}
}

protected void addNonFilteredContents(List<DATATYPE> entries)
{
this.filteredDataList.addAll(entries);
Expand Down