Search in sources :

Example 1 with Fragment

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

the class ComponentQueueingTest method fragment_doesNotDequeueAcrossRegion.

@Test
public void fragment_doesNotDequeueAcrossRegion() {
    MarkupContainer a = new A();
    TestPage page = new TestPage();
    page.setPageMarkup("<f wicket:id='fragment'></f><wicket:fragment wicket:id='f'><a wicket:id='a'></a></wicket:fragment>");
    Fragment fragment = new Fragment("fragment", "f", page);
    page.queue(a, fragment);
    assertThat(page, hasPath(new Path(fragment)));
    assertThat(a.getParent(), is(nullValue()));
}
Also used : WicketMatchers.hasPath(org.apache.wicket.queueing.WicketMatchers.hasPath) MarkupContainer(org.apache.wicket.MarkupContainer) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) Fragment(org.apache.wicket.markup.html.panel.Fragment) Test(org.junit.Test)

Example 2 with Fragment

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

the class MarkupFragmentTest method fragments.

/**
 * @throws Exception
 */
@Test
public void fragments() throws Exception {
    Page page = new InlinePanelPage_1();
    Fragment fragment = (Fragment) page.get("myPanel1");
    // Get the associated markup file
    IMarkupFragment markup = fragment.getAssociatedMarkup();
    assertNull(markup);
    // getMarkup() returns the "calling" tags
    markup = fragment.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"myPanel1\">panel</span>");
    // getMarkup(null) returns the markup which is used to find a child component
    markup = fragment.getMarkup(null);
    compareMarkupWithString(markup, "<wicket:fragment wicket:id=\"frag1\">panel 1</wicket:fragment>");
}
Also used : InlinePanelPage_1(org.apache.wicket.markup.html.panel.InlinePanelPage_1) Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Fragment(org.apache.wicket.markup.html.panel.Fragment) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Example 3 with Fragment

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

the class WizardMgtPanel method onEvent.

@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof ExitEvent && modal != null) {
        final AjaxRequestTarget target = ExitEvent.class.cast(event.getPayload()).getTarget();
        // default behaviour: change it catching the event if needed
        modal.close(target);
    } else if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        final AjaxWizard.NewItemEvent<T> newItemEvent = AjaxWizard.NewItemEvent.class.cast(event.getPayload());
        final AjaxRequestTarget target = newItemEvent.getTarget();
        final T item = newItemEvent.getItem();
        final boolean modalPanelAvailable = newItemEvent.getModalPanel() != null || newItemPanelBuilder != null;
        if (event.getPayload() instanceof AjaxWizard.NewItemActionEvent && modalPanelAvailable) {
            final WizardModalPanel<?> modalPanel;
            if (newItemEvent.getModalPanel() == null) {
                newItemPanelBuilder.setItem(item);
                modalPanel = newItemPanelBuilder.build(actualId, ((AjaxWizard.NewItemActionEvent<T>) newItemEvent).getIndex(), item != null ? isReadOnly() ? AjaxWizard.Mode.READONLY : AjaxWizard.Mode.EDIT : AjaxWizard.Mode.CREATE);
            } else {
                modalPanel = newItemEvent.getModalPanel();
            }
            if (wizardInModal) {
                final IModel<T> model = new CompoundPropertyModel<>(item);
                modal.setFormModel(model);
                target.add(modal.setContent(modalPanel));
                modal.header(new StringResourceModel(String.format("any.%s", newItemEvent.getEventDescription()), this, new Model<>(modalPanel.getItem())));
                modal.show(true);
            } else {
                final Fragment fragment = new Fragment("content", "wizard", WizardMgtPanel.this);
                fragment.add(new Label("title", newItemEvent.getResourceModel() == null ? Model.of(StringUtils.EMPTY) : newItemEvent.getResourceModel()));
                fragment.add(Component.class.cast(modalPanel));
                container.addOrReplace(fragment);
            }
            customActionCallback(target);
        } else if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
            if (wizardInModal) {
                modal.close(target);
            } else {
                container.addOrReplace(initialFragment);
            }
            customActionOnCancelCallback(target);
        } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
            if (wizardInModal && showResultPage) {
                modal.setContent(new ResultPage<T>(item, AjaxWizard.NewItemFinishEvent.class.cast(newItemEvent).getResult()) {

                    private static final long serialVersionUID = -2630573849050255233L;

                    @Override
                    protected void closeAction(final AjaxRequestTarget target) {
                        modal.close(target);
                    }

                    @Override
                    protected Panel customResultBody(final String id, final T item, final Serializable result) {
                        return WizardMgtPanel.this.customResultBody(id, item, result);
                    }
                });
                target.add(modal.getForm());
            } else if (wizardInModal) {
                modal.close(target);
            } else {
                container.addOrReplace(initialFragment);
            }
            customActionOnFinishCallback(target);
        }
        if (containerAutoRefresh) {
            target.add(container);
        }
    }
    super.onEvent(event);
}
Also used : IModel(org.apache.wicket.model.IModel) Serializable(java.io.Serializable) Label(org.apache.wicket.markup.html.basic.Label) WizardModalPanel(org.apache.syncope.client.console.panels.WizardModalPanel) Fragment(org.apache.wicket.markup.html.panel.Fragment) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResultPage(org.apache.syncope.client.console.wizards.any.ResultPage) BasePage(org.apache.syncope.client.console.pages.BasePage) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 4 with Fragment

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

the class BinaryFieldPanel method changePreviewer.

private void changePreviewer(final Component panelPreview) {
    final Fragment fragment = new Fragment("panelPreview", "previewFragment", container);
    fragment.add(panelPreview);
    container.addOrReplace(fragment);
    uploadForm.addOrReplace(container);
}
Also used : Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 5 with Fragment

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

the class TopologyTogglePanel method getResourceFragment.

private Fragment getResourceFragment(final TopologyNode node, final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "resourceActions", this);
    AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                resourceRestClient.delete(node.getKey());
                target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                toggle(target, false);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting resource {}", node.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.RESOURCE_DELETE);
    fragment.add(delete);
    AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
            IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
            modal.setFormModel(model);
            target.add(modal.setContent(new ResourceWizardBuilder(resource, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
            modal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
    fragment.add(edit);
    AjaxLink<String> status = new IndicatingAjaxLink<String>("status") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO modelObject = resourceRestClient.read(node.getKey());
            target.add(propTaskModal.setContent(new ResourceStatusModal(propTaskModal, pageRef, modelObject)));
            propTaskModal.header(new Model<>(MessageFormat.format(getString("resource.provisioning.status"), node.getKey())));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(status, RENDER, StandardEntitlement.USER_UPDATE);
    fragment.add(status);
    AjaxLink<String> provision = new IndicatingAjaxLink<String>("provision") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
            if (SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm())) {
                provisionModal.addSubmitButton();
            } else {
                provisionModal.removeSubmitButton();
            }
            IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
            provisionModal.setFormModel(model);
            target.add(provisionModal.setContent(new ResourceProvisionPanel(provisionModal, resource, connInstance.getAdminRealm(), pageRef)));
            provisionModal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
            provisionModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
    fragment.add(provision);
    AjaxLink<String> explore = new IndicatingAjaxLink<String>("explore") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            target.add(propTaskModal.setContent(new ConnObjects(resource, pageRef)));
            propTaskModal.header(new StringResourceModel("resource.explore.list", Model.of(node)));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(explore, RENDER, StandardEntitlement.RESOURCE_LIST_CONNOBJECT);
    fragment.add(explore);
    AjaxLink<String> propagation = new IndicatingAjaxLink<String>("propagation") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        @SuppressWarnings("unchecked")
        public void onClick(final AjaxRequestTarget target) {
            target.add(propTaskModal.setContent(new PropagationTasks(propTaskModal, node.getKey(), pageRef)));
            propTaskModal.header(new Model<>(MessageFormat.format(getString("task.propagation.list"), node.getKey())));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(propagation, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(propagation);
    AjaxLink<String> pull = new IndicatingAjaxLink<String>("pull") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(schedTaskModal.setContent(new PullTasks(schedTaskModal, pageRef, node.getKey())));
            schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.pull.list"), node.getKey())));
            schedTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(pull, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(pull);
    AjaxLink<String> push = new IndicatingAjaxLink<String>("push") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(schedTaskModal.setContent(new PushTasks(schedTaskModal, pageRef, node.getKey())));
            schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.push.list"), node.getKey())));
            schedTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(push, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(push);
    AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {

        private static final long serialVersionUID = -1876519166660008562L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            String resourceKey = String.class.cast(node.getKey());
            final ResourceTO modelObject = resourceRestClient.read(String.class.cast(node.getKey()));
            target.add(historyModal.setContent(new HistoryConfList<>(historyModal, resourceKey, pageRef, modelObject)));
            historyModal.header(new Model<>(MessageFormat.format(getString("resource.menu.history"), node.getDisplayName())));
            historyModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.RESOURCE_HISTORY_LIST);
    fragment.add(history);
    // [SYNCOPE-1161] - Option to clone a resource
    AjaxLink<String> clone = new IndicatingOnConfirmAjaxLink<String>("clone", "confirmClone", true) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                ResourceTO resource = resourceRestClient.read(node.getKey());
                resource.setKey("Copy of " + resource.getKey());
                // reset some resource objects keys
                if (resource.getOrgUnit() != null) {
                    resource.getOrgUnit().setKey(null);
                    for (ItemTO item : resource.getOrgUnit().getItems()) {
                        item.setKey(null);
                    }
                }
                for (ProvisionTO provision : resource.getProvisions()) {
                    provision.setKey(null);
                    if (provision.getMapping() != null) {
                        for (ItemTO item : provision.getMapping().getItems()) {
                            item.setKey(null);
                        }
                        provision.getMapping().getLinkingItems().clear();
                    }
                    provision.getVirSchemas().clear();
                }
                resourceRestClient.create(resource);
                // refresh Topology
                send(pageRef.getPage(), Broadcast.DEPTH, new AbstractResourceWizardBuilder.CreateEvent(resource.getKey(), resource.getKey(), TopologyNode.Kind.RESOURCE, resource.getConnector(), target));
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                toggle(target, false);
            } catch (SyncopeClientException e) {
                LOG.error("While cloning resource {}", node.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(clone, RENDER, StandardEntitlement.RESOURCE_CREATE);
    fragment.add(clone);
    return fragment;
}
Also used : ConnObjects(org.apache.syncope.client.console.panels.ConnObjects) ResourceProvisionPanel(org.apache.syncope.client.console.wizards.resources.ResourceProvisionPanel) HistoryConfList(org.apache.syncope.client.console.panels.HistoryConfList) ResourceStatusModal(org.apache.syncope.client.console.status.ResourceStatusModal) PushTasks(org.apache.syncope.client.console.tasks.PushTasks) Fragment(org.apache.wicket.markup.html.panel.Fragment) ItemTO(org.apache.syncope.common.lib.to.ItemTO) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) ResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder) StringResourceModel(org.apache.wicket.model.StringResourceModel) PropagationTasks(org.apache.syncope.client.console.tasks.PropagationTasks) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IndicatingOnConfirmAjaxLink(org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PullTasks(org.apache.syncope.client.console.tasks.PullTasks) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO)

Aggregations

Fragment (org.apache.wicket.markup.html.panel.Fragment)51 Label (org.apache.wicket.markup.html.basic.Label)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 ArrayList (java.util.ArrayList)9 LinkPanel (com.gitblit.wicket.panels.LinkPanel)6 Component (org.apache.wicket.Component)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 RepositoryModel (com.gitblit.models.RepositoryModel)5 UserModel (com.gitblit.models.UserModel)5 Item (org.apache.wicket.markup.repeater.Item)5 DataView (org.apache.wicket.markup.repeater.data.DataView)5 ListDataProvider (org.apache.wicket.markup.repeater.data.ListDataProvider)5 ResourceModel (org.apache.wicket.model.ResourceModel)4 TicketLabel (com.gitblit.tickets.TicketLabel)3 List (java.util.List)3 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)3 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)3 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)3 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2