Search in sources :

Example 11 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark in project ovirt-engine by oVirt.

the class BookmarkDaoTest method testGetWithInvalidId.

/**
 * Ensures that if the id is invalid then no bookmark is returned.
 */
@Test
public void testGetWithInvalidId() {
    Bookmark result = dao.get(Guid.newGuid());
    assertNull(result);
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Test(org.junit.Test)

Example 12 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark in project ovirt-engine by oVirt.

the class BookmarkDaoTest method testSave.

/**
 * Ensures that saving a bookmark works as expected.
 */
@Test
public void testSave() {
    dao.save(new_bookmark);
    Bookmark result = dao.getByName(new_bookmark.getName());
    assertNotNull(result);
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Test(org.junit.Test)

Example 13 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark in project ovirt-engine by oVirt.

the class EntityDaoImplTest method testGetEntityNameByIdAndTypeForBookmark.

@Test
public void testGetEntityNameByIdAndTypeForBookmark() {
    Bookmark bookmark = bookmarkDao.get(BOOKMARK_ID);
    assertNotNull(bookmark);
    String name = bookmark.getName();
    assertEquals(name, underTest.getEntityNameByIdAndType(BOOKMARK_ID, VdcObjectType.Bookmarks));
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Test(org.junit.Test)

Example 14 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark in project ovirt-engine by oVirt.

the class BookmarkListModel method onSave.

public void onSave() {
    BookmarkModel model = (BookmarkModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    org.ovirt.engine.core.common.businessentities.Bookmark tempVar = new org.ovirt.engine.core.common.businessentities.Bookmark();
    tempVar.setId(model.getIsNew() ? Guid.Empty : ((org.ovirt.engine.core.common.businessentities.Bookmark) getSelectedItem()).getId());
    tempVar.setName(model.getName().getEntity());
    tempVar.setValue(model.getSearchString().getEntity());
    org.ovirt.engine.core.common.businessentities.Bookmark bookmark = tempVar;
    model.startProgress();
    Frontend.getInstance().runAction(model.getIsNew() ? ActionType.AddBookmark : ActionType.UpdateBookmark, new BookmarksOperationParameters(bookmark), result -> {
        BookmarkListModel localModel = (BookmarkListModel) result.getState();
        localModel.postOnSave(result.getReturnValue());
    }, this);
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) BookmarksOperationParameters(org.ovirt.engine.core.common.action.BookmarksOperationParameters)

Example 15 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark 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();
            }));
        });
    }
}
Also used : TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) HasKeyDownHandlers(com.google.gwt.event.dom.client.HasKeyDownHandlers) BookmarkModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.BookmarkModelProvider) EventBus(com.google.gwt.event.shared.EventBus) View(com.gwtplatform.mvp.client.View) Inject(com.google.inject.Inject) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) Collectors(java.util.stream.Collectors) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ArrayList(java.util.ArrayList) MainModelProvider(org.ovirt.engine.ui.common.uicommon.model.MainModelProvider) HasClickHandlers(com.google.gwt.event.dom.client.HasClickHandlers) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) KeyCodes(com.google.gwt.event.dom.client.KeyCodes) PresenterWidget(com.gwtplatform.mvp.client.PresenterWidget) BookmarkListModel(org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) BookmarkListModel(org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel) ArrayList(java.util.ArrayList)

Aggregations

Bookmark (org.ovirt.engine.core.common.businessentities.Bookmark)16 Test (org.junit.Test)8 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Inject (com.google.inject.Inject)2 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BookmarksOperationParameters (org.ovirt.engine.core.common.action.BookmarksOperationParameters)2 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)2 Guid (org.ovirt.engine.core.compat.Guid)2 AsyncCallback (org.ovirt.engine.ui.frontend.AsyncCallback)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)2 BookmarkListModel (org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel)2 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)2 BookmarkModelProvider (org.ovirt.engine.ui.webadmin.uicommon.model.BookmarkModelProvider)2 Scheduler (com.google.gwt.core.client.Scheduler)1 HasClickHandlers (com.google.gwt.event.dom.client.HasClickHandlers)1 HasKeyDownHandlers (com.google.gwt.event.dom.client.HasKeyDownHandlers)1 KeyCodes (com.google.gwt.event.dom.client.KeyCodes)1