Search in sources :

Example 1 with OpenDocumentDialog

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog in project webanno by webanno.

the class DefaultDocumentNavigatorActionBarExtension method onInitialize.

@Override
public void onInitialize(AnnotationPageBase aPage) {
    ActionBarExtension.super.onInitialize(aPage);
    aPage.getFooterItems().getObject().stream().anyMatch(component -> component instanceof OpenDocumentDialog);
    // Open the dialog if no document has been selected.
    aPage.add(new AutoOpenDialogBehavior());
    // We put the dialog into the page footer since this is presently the only place where we
    // can dynamically add stuff to the page. We cannot add simply to the action bar (i.e.
    // DocumentNavigator) because the action bar only shows *after* a document has been
    // selected. In order to allow the dialog to be rendered *before* a document has been
    // selected (i.e. when the action bar is still not on screen), we need to attach it to the
    // page. The same for the AutoOpenDialogBehavior we add below.
    OpenDocumentDialog openDocumentsModal = createOpenDocumentsDialog("item", aPage);
    aPage.addToFooter(openDocumentsModal);
}
Also used : OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog)

Example 2 with OpenDocumentDialog

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog in project webanno by webanno.

the class AutoOpenDialogBehavior method respond.

@Override
protected void respond(AjaxRequestTarget aTarget) {
    AnnotationPageBase page = (AnnotationPageBase) getComponent().getPage();
    // trying to open it.
    if (page.getModelObject().getDocument() != null) {
        return;
    }
    page.getModelObject().getSelection().clear();
    page.getFooterItems().getObject().stream().filter(component -> component instanceof OpenDocumentDialog).map(component -> (OpenDocumentDialog) component).findFirst().ifPresent(dialog -> dialog.show(aTarget));
}
Also used : OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog) AnnotationPageBase(de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase) Component(org.apache.wicket.Component) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractDefaultAjaxBehavior(org.apache.wicket.ajax.AbstractDefaultAjaxBehavior) OnLoadHeaderItem(org.apache.wicket.markup.head.OnLoadHeaderItem) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog) AnnotationPageBase(de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase)

Aggregations

OpenDocumentDialog (de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.open.OpenDocumentDialog)2 AnnotationPageBase (de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase)1 Component (org.apache.wicket.Component)1 AbstractDefaultAjaxBehavior (org.apache.wicket.ajax.AbstractDefaultAjaxBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)1 OnLoadHeaderItem (org.apache.wicket.markup.head.OnLoadHeaderItem)1