Search in sources :

Example 6 with Fragment

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

the class TopologyTogglePanel method getConnectorFragment.

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

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                connectorRestClient.delete(String.class.cast(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.CONNECTOR_DELETE);
    fragment.add(delete);
    AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final ResourceTO modelObject = new ResourceTO();
            modelObject.setConnector(String.class.cast(node.getKey()));
            modelObject.setConnectorDisplayName(node.getDisplayName());
            final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
            modal.setFormModel(model);
            target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
            modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
            modal.show(true);
        }

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

        private static final long serialVersionUID = 3776750333491622263L;

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

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

        private static final long serialVersionUID = -1876519166660008562L;

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

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.CONNECTOR_HISTORY_LIST);
    fragment.add(history);
    return fragment;
}
Also used : HistoryConfList(org.apache.syncope.client.console.panels.HistoryConfList) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IndicatingOnConfirmAjaxLink(org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Fragment(org.apache.wicket.markup.html.panel.Fragment) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConnectorWizardBuilder(org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) ResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO)

Example 7 with Fragment

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

the class TopologyTogglePanel method getLocationFragment.

private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "locationActions", this);
    AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final ConnInstanceTO modelObject = new ConnInstanceTO();
            modelObject.setLocation(node.getKey());
            final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
            modal.setFormModel(model);
            target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
            modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    fragment.add(create);
    MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.CONNECTOR_CREATE);
    return fragment;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ConnectorWizardBuilder(org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 8 with Fragment

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

the class BinaryTextPreviewer method preview.

@Override
public Component preview(final byte[] uploadedBytes) {
    Fragment fragment = new Fragment("preview", "noPreviewFragment", this);
    if (uploadedBytes.length > 0) {
        try {
            fragment = new Fragment("preview", "previewFragment", this);
            InputStream stream = new ByteArrayInputStream(uploadedBytes);
            TextArea<String> jsonEditor = new TextArea<>("jsonEditorInfo", new Model<>(IOUtils.toString(stream)));
            jsonEditor.setOutputMarkupPlaceholderTag(true);
            jsonEditorInfoId = jsonEditor.getMarkupId();
            fragment.add(jsonEditor);
        } catch (IOException e) {
            LOG.error("Error evaluating text file", e);
        }
    }
    WebMarkupContainer previewContainer = new WebMarkupContainer("previewContainer");
    previewContainer.setOutputMarkupId(true);
    previewContainer.add(fragment);
    return this.addOrReplace(previewContainer);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TextArea(org.apache.wicket.markup.html.form.TextArea) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Fragment(org.apache.wicket.markup.html.panel.Fragment) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 9 with Fragment

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

the class AbstractFieldPanel method showExternAction.

public AbstractFieldPanel<T> showExternAction(final Component component) {
    final Fragment fragment = new Fragment("externalAction", "externalActionFragment", AbstractFieldPanel.this);
    addOrReplace(fragment);
    fragment.add(component.setRenderBodyOnly(false));
    return this;
}
Also used : Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 10 with Fragment

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

the class AbstractFieldPanel method removeRequiredLabel.

public AbstractFieldPanel<T> removeRequiredLabel() {
    if (isRequired()) {
        setRequired(false);
    }
    final Fragment fragment = new Fragment("required", "emptyFragment", this);
    replace(fragment);
    this.isRequiredLabelAdded = false;
    return this;
}
Also used : Fragment(org.apache.wicket.markup.html.panel.Fragment)

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