Search in sources :

Example 1 with Bookmark

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

the class BookmarkListModel method onRemove.

public void onRemove() {
    Bookmark selectedBookmark = (Bookmark) getSelectedItem();
    BookmarksParametersBase parameters = new BookmarksParametersBase(selectedBookmark.getId());
    IFrontendActionAsyncCallback async = result -> postOnSave(result.getReturnValue());
    getWindow().startProgress();
    Frontend.getInstance().runAction(ActionType.RemoveBookmark, parameters, async);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) BookmarksOperationParameters(org.ovirt.engine.core.common.action.BookmarksOperationParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) BookmarksParametersBase(org.ovirt.engine.core.common.action.BookmarksParametersBase) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Serializable(java.io.Serializable) List(java.util.List) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) Comparator(java.util.Comparator) Collections(java.util.Collections) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) BookmarksParametersBase(org.ovirt.engine.core.common.action.BookmarksParametersBase)

Example 2 with Bookmark

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

the class BookmarkListModel method edit.

public void edit() {
    org.ovirt.engine.core.common.businessentities.Bookmark bookmark = (org.ovirt.engine.core.common.businessentities.Bookmark) getSelectedItem();
    if (getWindow() != null) {
        return;
    }
    BookmarkModel model = new BookmarkModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().editBookmarkTitle());
    model.setHelpTag(HelpTag.edit_bookmark);
    // $NON-NLS-1$
    model.setHashName("edit_bookmark");
    model.setIsNew(false);
    model.getName().setEntity(bookmark.getName());
    model.getSearchString().setEntity(bookmark.getValue());
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSave", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 3 with Bookmark

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

the class BookmarkListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    Frontend.getInstance().runQuery(QueryType.GetAllBookmarks, new QueryParametersBase(), new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
        List<Bookmark> resultList = returnValue.getReturnValue();
        if (resultList != null) {
            Collections.sort(resultList, COMPARATOR);
        }
        setIsBookmarkInitiated(true);
        setItems(resultList);
        setIsBookmarkInitiated(false);
    }));
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Example 4 with Bookmark

use of org.ovirt.engine.core.common.businessentities.Bookmark 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);
            }
        }
    }
}
Also used : BookmarkModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.BookmarkModelProvider) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) AbstractOverlayPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.AbstractOverlayPresenterWidget) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) Inject(com.google.inject.Inject) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) AbstractMainWithDetailsPresenter(org.ovirt.engine.ui.webadmin.section.main.presenter.AbstractMainWithDetailsPresenter) EventBus(com.google.web.bindery.event.shared.EventBus) BookmarkListModel(org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RevealOverlayContentEvent(org.ovirt.engine.ui.webadmin.section.main.presenter.RevealOverlayContentEvent) RevealOverlayContentEvent(org.ovirt.engine.ui.webadmin.section.main.presenter.RevealOverlayContentEvent) Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) BookmarkListModel(org.ovirt.engine.ui.uicommonweb.models.bookmarks.BookmarkListModel) AbstractMainWithDetailsPresenter(org.ovirt.engine.ui.webadmin.section.main.presenter.AbstractMainWithDetailsPresenter)

Example 5 with Bookmark

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

the class BookmarkDaoTest method testGet.

/**
 * Ensures that, if the id is valid, then retrieving a bookmark works as expected.
 */
@Test
public void testGet() {
    Bookmark result = dao.get(existing_bookmark.getId());
    assertNotNull(result);
    assertEquals(existing_bookmark.getId(), result.getId());
}
Also used : Bookmark(org.ovirt.engine.core.common.businessentities.Bookmark) Test(org.junit.Test)

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