use of org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel in project ovirt-engine by oVirt.
the class SearchPanelPresenterWidget method onBind.
@Override
protected void onBind() {
super.onBind();
registerHandler(getView().getBookmarkButton().addClickHandler(event -> {
BookmarkListModel bookmarkListModel = bookmarkModelProvider.getModel();
bookmarkListModel.setSearchString(getView().getSearchString());
bookmarkListModel.getNewCommand().execute();
}));
registerHandler(getView().getClearButton().addClickHandler(event -> {
getView().setSearchString("");
model.setSearchString("");
updateViewSearchString();
updateModelSearchString();
}));
registerHandler(getView().getSearchButton().addClickHandler(event -> updateModelSearchString()));
registerHandler(getView().getSearchInputHandlers().addKeyDownHandler(event -> {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
updateModelSearchString();
} else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
getView().hideSuggestionBox();
}
}));
BookmarkListModel bookmarkListModel = bookmarkModelProvider.getModel();
bookmarkListModel.getItemsChangedEvent().addListener((ev, sender, args) -> bookmarkItemsChanged());
if (bookmarkListModel.getItems() == null) {
bookmarkListModel.search();
}
// Have to call this to initially populate the values.
bookmarkItemsChanged();
}
use of org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel in project ovirt-engine by oVirt.
the class BookmarkPresenterWidget method updateBookmarks.
private void updateBookmarks() {
BookmarkListModel model = bookmarkModelProvider.getModel();
Collection<Bookmark> items = model.getItems();
AbstractMainWithDetailsPresenter<?, ?, ?, ?> presenter = null;
if (getCurrentPlaceWidget() instanceof AbstractMainWithDetailsPresenter) {
presenter = (AbstractMainWithDetailsPresenter<?, ?, ?, ?>) getCurrentPlaceWidget();
}
final AbstractMainWithDetailsPresenter<?, ?, ?, ?> mainPresenter = presenter;
getView().clearBookmarks();
if (items != null && !items.isEmpty()) {
for (Bookmark bookmark : items) {
if (mainPresenter != null && isBookmarkForCurrentPlace(bookmark, mainPresenter)) {
registerHandler(getView().addBookmark(bookmark, model, event -> {
mainPresenter.applySearchString(bookmark.getValue());
// Close the overlay.
RevealOverlayContentEvent.fire(this, new RevealOverlayContentEvent(null));
event.preventDefault();
}));
} else {
getView().addBookmark(bookmark, model, null);
}
}
}
}
use of org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel in project ovirt-engine by oVirt.
the class SearchPanelPresenterWidget method bookmarkItemsChanged.
private void bookmarkItemsChanged() {
BookmarkListModel bookmarkListModel = bookmarkModelProvider.getModel();
if (bookmarkListModel.getItems() != null) {
getView().clearBookmarks();
List<Bookmark> items = new ArrayList<>(bookmarkListModel.getItems());
final String filterString = model.getDefaultSearchString();
List<Bookmark> result = items.stream().filter(bookmark -> bookmark.getValue().startsWith(filterString)).collect(Collectors.toList());
result.forEach(bookmark -> {
registerHandler(getView().addAvailableBookmarks(bookmark, e -> {
model.setSearchString(bookmark.getValue());
model.search();
}));
});
}
}
Aggregations