Search in sources :

Example 6 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project wicket by apache.

the class SimplePanel1 method addXXX.

private MarkupContainer addXXX(final String id, final MarkupContainer parent) {
    MarkupContainer container = new WebMarkupContainer(id);
    parent.add(container);
    container.add(new Behavior() {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            response.render(CssHeaderItem.forUrl(id + ".css"));
        }
    });
    return container;
}
Also used : WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MarkupContainer(org.apache.wicket.MarkupContainer) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) Behavior(org.apache.wicket.behavior.Behavior) Component(org.apache.wicket.Component) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 7 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project wicket by apache.

the class FilteringHeaderResponseTest method footerDependsOnHeadItem.

@Test
public void footerDependsOnHeadItem() throws Exception {
    tester.getApplication().setHeaderResponseDecorator(new IHeaderResponseDecorator() {

        @Override
        public IHeaderResponse decorate(IHeaderResponse response) {
            // footer (after </body>)
            return new ResourceAggregator(new JavaScriptFilteredIntoFooterHeaderResponse(response, "footerJS"));
        }
    });
    executeTest(FilteredHeaderPage.class, "FilteredHeaderPageExpected.html");
}
Also used : IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) ResourceAggregator(org.apache.wicket.markup.head.ResourceAggregator) IHeaderResponseDecorator(org.apache.wicket.markup.html.IHeaderResponseDecorator) Test(org.junit.Test)

Example 8 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project midpoint by Evolveum.

the class OrgTreePanel method initLayout.

private void initLayout(ModelServiceLocator serviceLocator) {
    WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER);
    treeHeader.setOutputMarkupId(true);
    add(treeHeader);
    String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey;
    Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title));
    treeHeader.add(treeTitle);
    List<InlineMenuItem> actions = createTreeMenu();
    DropdownButtonDto model = new DropdownButtonDto(null, "fa fa-cog", null, actions);
    DropdownButtonPanel treeMenu = new DropdownButtonPanel(ID_TREE_MENU, model) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String getSpecialButtonClass() {
            return "btn-default";
        }

        @Override
        protected boolean visibleCaret() {
            return false;
        }
    };
    treeMenu.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !actions.isEmpty();
        }
    });
    treeMenu.setOutputMarkupId(true);
    treeMenu.setOutputMarkupPlaceholderTag(true);
    treeHeader.add(treeMenu);
    ISortableTreeProvider provider = new OrgTreeProvider(this, getModel(), preselecteOrgsList) {

        @Override
        protected ObjectFilter getCustomFilter() {
            return OrgTreePanel.this.getCustomFilter();
        }
    };
    WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(IHeaderResponse response) {
            super.renderHead(response);
            // method computes height based on document.innerHeight() -
            // screen height;
            Component form = OrgTreePanel.this.getParent().get("memberPanel");
            if (form != null) {
            // TODO fix
            // response.render(OnDomReadyHeaderItem.forScript(
            // "updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#"
            // + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
            }
        }
    };
    add(treeContainer);
    TreeStateModel treeStateMode = new TreeStateModel(this, provider, getOrgTreeStateStorage()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Set<TreeSelectableBean<OrgType>> getExpandedItems() {
            return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
        }

        @Override
        public Set<TreeSelectableBean<OrgType>> getCollapsedItems() {
            return OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
        }

        @Override
        public void setCollapsedItems(TreeStateSet items) {
            OrgTreePanel.this.setCollapsedItems(null, getOrgTreeStateStorage());
        }
    };
    contentPannels = new ArrayList<OrgTreeFolderContent>();
    MidpointNestedTree tree = new MidpointNestedTree(ID_TREE, provider, treeStateMode) {

        @Override
        protected Component newContentComponent(String id, IModel<TreeSelectableBean<OrgType>> model) {
            OrgTreeFolderContent contentPannel = new OrgTreeFolderContent(id, model, selectable, selected, this, getOrgTreeStateStorage()) {

                @Override
                protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
                    OrgTreePanel.this.selectTreeItemPerformed(selected, target);
                }

                @Override
                protected IModel<Boolean> getCheckboxModel(IModel<TreeSelectableBean<OrgType>> org) {
                    return OrgTreePanel.this.getCheckBoxValueModel(org);
                }

                @Override
                protected void onUpdateCheckbox(AjaxRequestTarget target) {
                    selected = getModel();
                    onOrgTreeCheckBoxSelectionPerformed(target, selected);
                }

                @Override
                protected IModel<List<InlineMenuItem>> createInlineMenuItemsModel() {
                    return new ReadOnlyModel<>(() -> createTreeChildrenMenuInternal(model.getObject(), serviceLocator.getCompiledGuiProfile()));
                }
            };
            contentPannels.add(contentPannel);
            return contentPannel;
        }

        @Override
        public void collapse(TreeSelectableBean<OrgType> collapsedItem) {
            super.collapse(collapsedItem);
            Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
            if (items != null && items.contains(collapsedItem)) {
                items.remove(collapsedItem);
            }
            OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage());
            OrgTreePanel.this.addCollapsedItem(collapsedItem, getOrgTreeStateStorage());
        }

        @Override
        public void expand(TreeSelectableBean<OrgType> expandedItem) {
            super.expand(expandedItem);
            Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
            if (items != null && items.contains(expandedItem)) {
                items.remove(expandedItem);
            }
            OrgTreePanel.this.setCollapsedItems((TreeStateSet) items, getOrgTreeStateStorage());
            OrgTreePanel.this.addExpandedItem(expandedItem, getOrgTreeStateStorage());
        }
    };
    tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
    tree.setOutputMarkupId(true);
    tree.add(new WindowsTheme());
    treeContainer.add(tree);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WindowsTheme(org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ReuseIfModelsEqualStrategy(org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) OrgTreeProvider(com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) TreeStateSet(com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ISortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Example 9 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project midpoint by Evolveum.

the class PageBase method createModalWindow.

protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
    final ModalWindow modal = new ModalWindow(id);
    add(modal);
    modal.setResizable(false);
    modal.setTitle(title);
    modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100)));
    modal.setInitialWidth(width);
    modal.setWidthUnit("px");
    modal.setInitialHeight(height);
    modal.setHeightUnit("px");
    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {

        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            return true;
        }
    });
    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        @Override
        public void onClose(AjaxRequestTarget target) {
            modal.close(target);
        }
    });
    modal.add(new AbstractDefaultAjaxBehavior() {

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
            response.render(JavaScriptHeaderItem.forScript("$(document).ready(function() {\n" + "  $(document).bind('keyup', function(evt) {\n" + "    if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + "        evt.preventDefault();\n" + "    }\n" + "  });\n" + "});", id));
        }

        @Override
        protected void respond(AjaxRequestTarget target) {
            modal.close(target);
        }
    });
    return modal;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractDefaultAjaxBehavior(org.apache.wicket.ajax.AbstractDefaultAjaxBehavior) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow)

Example 10 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project syncope by apache.

the class Topology method topologyNodePanel.

private TopologyNodePanel topologyNodePanel(final String id, final TopologyNode node) {
    final TopologyNodePanel panel = new TopologyNodePanel(id, node);
    panel.setMarkupId(String.valueOf(node.getKey()));
    panel.setOutputMarkupId(true);
    final List<Behavior> behaviors = new ArrayList<>();
    behaviors.add(new Behavior() {

        private static final long serialVersionUID = 2661717818979056044L;

        @Override
        public void renderHead(final Component component, final IHeaderResponse response) {
            response.render(OnDomReadyHeaderItem.forScript(String.format("setPosition('%s', %d, %d)", node.getKey(), node.getX(), node.getY())));
        }
    });
    behaviors.add(new AjaxEventBehavior(Constants.ON_CLICK) {

        private static final long serialVersionUID = -9027652037484739586L;

        @Override
        protected String findIndicatorId() {
            return StringUtils.EMPTY;
        }

        @Override
        protected void onEvent(final AjaxRequestTarget target) {
            togglePanel.toggleWithContent(target, node);
            target.appendJavaScript(String.format("$('.window').removeClass(\"active-window\").addClass(\"inactive-window\"); " + "$(document.getElementById('%s'))." + "removeClass(\"inactive-window\").addClass(\"active-window\");", node.getKey()));
        }
    });
    panel.add(behaviors.toArray(new Behavior[] {}));
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ArrayList(java.util.ArrayList) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) Behavior(org.apache.wicket.behavior.Behavior) AbstractAjaxTimerBehavior(org.apache.wicket.ajax.AbstractAjaxTimerBehavior) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Component(org.apache.wicket.Component)

Aggregations

IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)17 Component (org.apache.wicket.Component)9 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 Behavior (org.apache.wicket.behavior.Behavior)5 StringResponse (org.apache.wicket.response.StringResponse)5 Response (org.apache.wicket.request.Response)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)2 OrgTreeProvider (com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider)2 TreeStateSet (com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 ArrayList (java.util.ArrayList)2 MarkupContainer (org.apache.wicket.MarkupContainer)2 AbstractDefaultAjaxBehavior (org.apache.wicket.ajax.AbstractDefaultAjaxBehavior)2 ISortableTreeProvider (org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider)2 WindowsTheme (org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme)2 HeaderItem (org.apache.wicket.markup.head.HeaderItem)2 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)2 Label (org.apache.wicket.markup.html.basic.Label)2 ReuseIfModelsEqualStrategy (org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy)2