2
0

Fix initialization of text consumers & action handlers on sites list.

This commit is contained in:
Maarten Billemont 2018-09-13 22:37:28 -04:00
parent ec9c55ec4d
commit 9a04c28054
2 changed files with 9 additions and 4 deletions

View File

@ -87,8 +87,11 @@ public class DocumentModel implements Selectable<String, DocumentModel> {
@Override
public DocumentModel selection(@Nullable final String selectedItem, @Nullable final Consumer<String> selectionConsumer) {
selection( selectionConsumer );
setText( selectedItem );
selection( selectionConsumer );
if (selectionConsumer != null)
selectionConsumer.accept( selectedItem );
return this;
}

View File

@ -542,6 +542,10 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
add( Components.scrollPane( sitesList = Components.list(
sitesModel = new CollectionListModel<MPQuery.Result<? extends MPSite<?>>>().selection( this::showSiteItem ),
this::getSiteDescription ) ) );
sitesList.registerKeyboardAction( this::useSite, KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, 0 ),
JComponent.WHEN_FOCUSED );
sitesList.registerKeyboardAction( this::useSite, KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK ),
JComponent.WHEN_FOCUSED );
add( Components.strut() );
add( Components.label( strf(
@ -1015,9 +1019,7 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
if (siteItems.stream().noneMatch( MPQuery.Result::isExact ))
siteItems.add( MPQuery.Result.allOf( new MPNewSite( user, query.getQuery() ), query.getQuery() ) );
Res.ui( () -> {
sitesModel.set( siteItems );
} );
Res.ui( () -> sitesModel.set( siteItems ) );
} );
}