Search in sources :

Example 6 with IndicatingAjaxLink

use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project oc-explorer by devgateway.

the class FileInputBootstrapFormComponentWrapper method addAlreadyUploadedFilesComponent.

/**
 * already uploaded files section
 */
private void addAlreadyUploadedFilesComponent() {
    alreadyUploadedFiles = new WebMarkupContainer("alreadyUploadedFiles") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onInitialize() {
            super.onInitialize();
            setVisibilityAllowed(isVisibleAlreadyUploadedFiles());
        }
    };
    alreadyUploadedFiles.setOutputMarkupPlaceholderTag(true);
    alreadyUploadedFiles.setOutputMarkupId(true);
    add(alreadyUploadedFiles);
    alreadyUploadedFiles.add(new Label("uploadedFilesTitle", new StringResourceModel("uploadedFilesTitle", this, null)));
    AbstractReadOnlyModel<List<FileMetadata>> alreadyUploadedFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<FileMetadata> getObject() {
            List<FileMetadata> fileObject = new ArrayList<>();
            // get only the already uploaded files
            for (FileMetadata file : filesModel) {
                if (!file.isNew()) {
                    fileObject.add(file);
                }
            }
            return fileObject;
        }
    };
    ListView<FileMetadata> list = new ListView<FileMetadata>("list", alreadyUploadedFilesModel) {

        private static final long serialVersionUID = 1L;

        private List<IndicatingAjaxLink<Void>> deleteButtons = new ArrayList<>();

        @Override
        protected void populateItem(final ListItem<FileMetadata> item) {
            // make file name clickable
            Link<FileMetadata> downloadLink = new Link<FileMetadata>("downloadLink", item.getModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    final FileMetadata modelObject = getModelObject();
                    AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void write(final OutputStream output) throws IOException {
                            output.write(modelObject.getContent().getBytes());
                        }

                        @Override
                        public String getContentType() {
                            return modelObject.getContentType();
                        }
                    };
                    ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, modelObject.getName());
                    handler.setContentDisposition(ContentDisposition.ATTACHMENT);
                    getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
                }
            };
            downloadLink.add(new Label("downloadText", item.getModelObject().getName()));
            downloadLink.add(new TooltipBehavior(new StringResourceModel("downloadUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
            item.add(downloadLink);
            Link<FileMetadata> download = new CustomDownloadLink("download", item.getModel());
            item.add(download);
            IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {

                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void onClick(final AjaxRequestTarget target) {
                    filesModel.remove(item.getModelObject());
                    FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
                    target.add(alreadyUploadedFiles);
                }
            };
            delete.add(new IconBehavior(GlyphIconType.remove));
            delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
            delete.setVisible(true);
            item.add(delete);
            deleteButtons.add(delete);
            // only to admins
            if (visibleOnlyToAdmin) {
                MetaDataRoleAuthorizationStrategy.authorize(delete, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
            }
            if (disableDeleteButton) {
                delete.setVisibilityAllowed(false);
            }
        }

        @Override
        public void onEvent(final IEvent<?> event) {
            /*
                 * disable 'delete' buttons based on the form state
                 */
            if (event.getPayload() instanceof EditingDisabledEvent) {
                for (IndicatingAjaxLink<?> del : deleteButtons) {
                    del.setVisibilityAllowed(false);
                }
            }
            if (event.getPayload() instanceof EditingEnabledEvent) {
                for (IndicatingAjaxLink<?> del : deleteButtons) {
                    del.setVisibilityAllowed(true);
                }
            }
        }
    };
    alreadyUploadedFiles.add(list);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IEvent(org.apache.wicket.event.IEvent) OutputStream(java.io.OutputStream) Label(org.apache.wicket.markup.html.basic.Label) FileMetadata(org.devgateway.toolkit.persistence.dao.FileMetadata) ArrayList(java.util.ArrayList) AbstractResourceStreamWriter(org.apache.wicket.util.resource.AbstractResourceStreamWriter) CustomDownloadLink(org.devgateway.toolkit.forms.wicket.components.util.CustomDownloadLink) IconBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.image.IconBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ResourceStreamRequestHandler(org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler) TooltipBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ArrayList(java.util.ArrayList) List(java.util.List) EditingDisabledEvent(org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent) StringResourceModel(org.apache.wicket.model.StringResourceModel) EditingEnabledEvent(org.devgateway.toolkit.forms.wicket.events.EditingEnabledEvent) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem) CustomDownloadLink(org.devgateway.toolkit.forms.wicket.components.util.CustomDownloadLink) Link(org.apache.wicket.markup.html.link.Link) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)

Example 7 with IndicatingAjaxLink

use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project ocvn by devgateway.

the class DateTimeFieldBootstrapFormComponent method onInitialize.

/*
     * (non-Javadoc)
     * 
     * @see org.devgateway.toolkit.forms.wicket.components.form.
     * GenericBootstrapFormComponent#onConfigure()
     */
@Override
protected void onInitialize() {
    super.onInitialize();
    border.add(new AttributeModifier("style", "position:relative;"));
    IndicatingAjaxLink<String> clearDateLink = new IndicatingAjaxLink<String>("clearDate") {

        private static final long serialVersionUID = -1705495886974891511L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            DateTimeFieldBootstrapFormComponent.this.field.setModelObject(null);
            target.add(DateTimeFieldBootstrapFormComponent.this.field);
        }
    };
    border.add(clearDateLink);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 8 with IndicatingAjaxLink

use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project the-app by devops-dojo.

the class ProductDetailPage method addToCartLink.

private AbstractLink addToCartLink() {
    return new IndicatingAjaxLink<Void>("addToCart") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            target.add(feedback);
            send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags()));
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AddToCartEvent(io.github.zutherb.appstash.shop.ui.event.cart.AddToCartEvent) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)

Example 9 with IndicatingAjaxLink

use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project the-app by devops-dojo.

the class ProductItemPanel method addToCartLink.

private IndicatingAjaxLink<Void> addToCartLink() {
    IndicatingAjaxLink<Void> result = new IndicatingAjaxLink<Void>("addToCartIcon") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            // send wicket event for add to cart
            target.add(feedback);
            send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags()));
        }
    };
    result.setVisible(showAddToCartLink());
    return result;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AddToCartEvent(io.github.zutherb.appstash.shop.ui.event.cart.AddToCartEvent) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)

Example 10 with IndicatingAjaxLink

use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project syncope by apache.

the class TopologyTogglePanel method getSyncopeFragment.

private Fragment getSyncopeFragment(final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "syncopeActions", this);
    AjaxLink<String> reload = new IndicatingOnConfirmAjaxLink<String>("reload", "connectors.confirm.reload", true) {

        private static final long serialVersionUID = -2075933173666007020L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                connectorRestClient.reload();
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
            } catch (Exception e) {
                LOG.error("While reloading all connectors", e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    fragment.add(reload);
    MetaDataRoleAuthorizationStrategy.authorize(reload, RENDER, StandardEntitlement.CONNECTOR_RELOAD);
    AjaxLink<String> tasks = new IndicatingAjaxLink<String>("tasks") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(schedTaskModal.setContent(new SchedTasks(schedTaskModal, pageRef)));
            schedTaskModal.header(new ResourceModel("task.custom.list"));
            schedTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    fragment.add(tasks);
    MetaDataRoleAuthorizationStrategy.authorize(tasks, RENDER, StandardEntitlement.TASK_LIST);
    return fragment;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) IndicatingOnConfirmAjaxLink(org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) Fragment(org.apache.wicket.markup.html.panel.Fragment) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SchedTasks(org.apache.syncope.client.console.tasks.SchedTasks)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)13 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 Label (org.apache.wicket.markup.html.basic.Label)5 TooltipBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior)4 IconBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.image.IconBehavior)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4 ListView (org.apache.wicket.markup.html.list.ListView)4 Fragment (org.apache.wicket.markup.html.panel.Fragment)4 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)4 FileMetadata (org.devgateway.toolkit.persistence.dao.FileMetadata)4 IndicatingOnConfirmAjaxLink (org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)3 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)3 AddToCartEvent (io.github.zutherb.appstash.shop.ui.event.cart.AddToCartEvent)2 OutputStream (java.io.OutputStream)2