Search in sources :

Example 1 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class OperationResultPanel method initParams.

private void initParams(WebMarkupContainer operationContent, final IModel<OpResult> model, Page parentPage) {
    Label paramsLabel = new Label("paramsLabel", parentPage.getString("FeedbackAlertMessageDetails.params"));
    paramsLabel.setOutputMarkupId(true);
    paramsLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getParams());
        }
    });
    operationContent.add(paramsLabel);
    ListView<Param> params = new ListView<Param>(ID_PARAMS, createParamsModel(model)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Param> item) {
            item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name")));
            item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value")));
        }
    };
    params.setOutputMarkupId(true);
    params.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getParams());
        }
    });
    operationContent.add(params);
    ListView<OpResult> subresults = new ListView<OpResult>("subresults", createSubresultsModel(model)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<OpResult> item) {
            Panel subresult = new OperationResultPanel("subresult", item.getModel(), getPage());
            subresult.setOutputMarkupId(true);
            item.add(subresult);
        }
    };
    subresults.setOutputMarkupId(true);
    subresults.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getSubresults());
        }
    });
    operationContent.add(subresults);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 2 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout(final PageBase page) {
    final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
    shadows.setOutputMarkupId(true);
    add(shadows);
    InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
    accountMenu.setVisible(!getObjectWrapper().isReadonly());
    shadows.add(accountMenu);
    final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
            PackageResourceReference packageRef;
            final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
            final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
            final Panel shadowPanel;
            if (dto.isLoadedOK()) {
                packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
                shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
            } else {
                shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onShowMorePerformed(AjaxRequestTarget target) {
                        OperationResult fetchResult = dto.getResult();
                        if (fetchResult != null) {
                            showResult(fetchResult);
                            target.add(page.getFeedbackPanel());
                        }
                    }
                };
            }
            shadowPanel.setOutputMarkupId(true);
            shadowPanel.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
                    ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
                    return !shadowWrapper.isMinimalized();
                }
            });
            item.add(shadowPanel);
            CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClickPerformed(AjaxRequestTarget target) {
                    super.onClickPerformed(target);
                    onExpandCollapse(target, item.getModel());
                    target.add(shadows);
                }
            };
            if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
                shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
            }
            item.add(shadowHeader);
        }
    };
    AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
                if (dto.isLoadedOK()) {
                    ObjectWrapper<ShadowType> accModel = dto.getObject();
                    accModel.setSelected(getModelObject());
                }
            }
            target.add(shadows);
        }
    };
    shadows.add(accountCheckAll);
    shadows.add(projectionList);
}
Also used : Serializable(java.io.Serializable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ImgResources(com.evolveum.midpoint.web.resource.img.ImgResources) ListView(org.apache.wicket.markup.html.list.ListView) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 3 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class PrismValuePanel method initLayout.

private void initLayout(IModel<String> labelModel, Form form, String valueCssClass, String inputCssClass) {
    //container
    WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
    valueContainer.setOutputMarkupId(true);
    valueContainer.add(new AttributeModifier("class", valueCssClass));
    add(valueContainer);
    //feedback
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    add(feedback);
    //input
    Panel input = createInputComponent(ID_INPUT, labelModel, form);
    input.add(new AttributeModifier("class", inputCssClass));
    if (input instanceof InputPanel) {
        initAccessBehaviour((InputPanel) input);
        feedback.setFilter(new ComponentFeedbackMessageFilter(((InputPanel) input).getBaseFormComponent()));
    } else if (input instanceof LockoutStatusPanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof ValueChoosePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof AssociationValueChoicePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(((AssociationValueChoicePanel) input).getTextComponent()));
    }
    valueContainer.add(input);
    //buttons
    AjaxLink addButton = new AjaxLink(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValue(target);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible();
        }
    });
    valueContainer.add(addButton);
    AjaxLink removeButton = new AjaxLink(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValue(target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    valueContainer.add(removeButton);
}
Also used : LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 4 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project wicket by apache.

the class ComponentQueueingTest method nestedPanels.

/**
 * test with inner panels
 */
@Test
public void nestedPanels() {
    MarkupContainer r = new R(), s = new S();
    Panel innerPanel = new InnerPanel("inner");
    innerPanel.queue(s);
    Panel outerPanel = new OuterPanel("outer");
    outerPanel.queue(r, innerPanel);
    TestPage p = new TestPage();
    p.setPageMarkup("<html><head></head><body><p wicket:id='outer'></p></body></html>");
    p.queue(outerPanel);
    tester.startPage(p);
    assertThat(p, hasPath(new Path(outerPanel, r)));
    assertThat(p, hasPath(new Path(outerPanel, innerPanel, s)));
    // contributed by <wicket:head> in outer
    tester.assertContains("<meta/>");
    // contributed by <wicket:head> in inner
    tester.assertContains("<meta2/>");
}
Also used : WicketMatchers.hasPath(org.apache.wicket.queueing.WicketMatchers.hasPath) OuterPanel(org.apache.wicket.queueing.nestedpanels.OuterPanel) InnerPanel(org.apache.wicket.queueing.nestedpanels.InnerPanel) Panel(org.apache.wicket.markup.html.panel.Panel) LoginPanel(org.apache.wicket.queueing.bodyisachild.LoginPanel) MarkupContainer(org.apache.wicket.MarkupContainer) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) OuterPanel(org.apache.wicket.queueing.nestedpanels.OuterPanel) InnerPanel(org.apache.wicket.queueing.nestedpanels.InnerPanel) Test(org.junit.Test)

Example 5 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project wicket by apache.

the class MarkupFragmentTest method panelWithAutoComponent.

/**
 * @see href http://issues.apache.org/jira/browse/WICKET-3111
 *
 * @throws Exception
 */
@Test
public void panelWithAutoComponent() throws Exception {
    Page page = new MyPage();
    Panel panel = new MyPanelWithAutoComponent("panel");
    page.add(panel);
    // Get the associated markup file
    IMarkupFragment markup = panel.getAssociatedMarkup();
    compareMarkupWithFile(markup, "MyPanelWithAutoComponent_ExpectedResult.html", MyPage.class);
    // The Page is missing the tag to "call" the panel
    assertNull(panel.getMarkup());
    // Create a Page with proper markup for the panel
    page = new MyPanelWithAutoComponentPage();
    panel = (Panel) page.get("panel");
    // getMarkup() returns the "calling" tags
    markup = panel.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"panel\">test</span>");
    // getMarkup(null) returns the markup which is used to find a child component
    markup = panel.getMarkup(null);
    compareMarkupWithString(markup, "<wicket:panel><a href=\"something\"><span wicket:id=\"label\">text</span></a></wicket:panel>");
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Aggregations

Panel (org.apache.wicket.markup.html.panel.Panel)76 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)27 ArrayList (java.util.ArrayList)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)16 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)16 Before (org.junit.Before)16 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)15 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)12 ResourceModel (org.apache.wicket.model.ResourceModel)11 DivTestPanel (org.odlabs.wiquery.ui.DivTestPanel)11 ItemPanelSettingsBuilder (com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 List (java.util.List)9 Test (org.junit.Test)9 IModel (org.apache.wicket.model.IModel)8 Model (org.apache.wicket.model.Model)6 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)5 Label (org.apache.wicket.markup.html.basic.Label)5