Search in sources :

Example 1 with StringResourceModel

use of org.apache.wicket.model.StringResourceModel in project midpoint by Evolveum.

the class ModelOperationStatusPanel method initLayout.

protected void initLayout() {
    add(new Label(ID_STATE, new StringResourceModel("ModelOperationStatusPanel.state.${}", new PropertyModel<ModelState>(getModel(), ModelOperationStatusDto.F_STATE))));
    //        add(new Label(ID_FOCUS_TYPE, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_TYPE)));
    //        add(new Label(ID_FOCUS_NAME, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_NAME)));
    ScenePanel deltaPanel = new ScenePanel(ID_PRIMARY_DELTA, new PropertyModel<SceneDto>(getModel(), ModelOperationStatusDto.F_PRIMARY_DELTA));
    deltaPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null && getModelObject().getPrimaryDelta() != null;
        }
    });
    add(deltaPanel);
}
Also used : ScenePanel(com.evolveum.midpoint.web.component.prism.show.ScenePanel) SceneDto(com.evolveum.midpoint.web.component.prism.show.SceneDto) Label(org.apache.wicket.markup.html.basic.Label) ModelState(com.evolveum.midpoint.model.api.context.ModelState) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 2 with StringResourceModel

use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.

the class AbstractListPage method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    if (jpaRepository == null) {
        throw new NullJpaRepositoryException();
    }
    if (editPageClass == null) {
        throw new NullEditPageClassException();
    }
    SortableJpaRepositoryDataProvider<T> dataProvider = getProvider();
    dataProvider.setFilterState(newFilterState());
    // add the 'Edit' button
    columns.add(new AbstractColumn<T, String>(new StringResourceModel("actionsColumn", this, null)) {

        private static final long serialVersionUID = -7447601118569862123L;

        @Override
        public void populateItem(final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> model) {
            cellItem.add(getActionPanel(componentId, model));
        }
    });
    dataTable = new AjaxFallbackBootstrapDataTable<>("table", columns, dataProvider, WebConstants.PAGE_SIZE);
    ResettingFilterForm<JpaFilterState<T>> filterForm = new ResettingFilterForm<>("filterForm", dataProvider, dataTable);
    filterForm.add(dataTable);
    add(filterForm);
    if (hasFilteredColumns()) {
        dataTable.addTopToolbar(new FilterToolbar(dataTable, filterForm));
    }
    PageParameters pageParameters = new PageParameters();
    pageParameters.set(WebConstants.PARAM_ID, null);
    editPageLink = new BootstrapBookmarkablePageLink<T>("new", editPageClass, pageParameters, Buttons.Type.Success);
    editPageLink.setIconType(FontAwesomeIconType.plus_circle).setSize(Size.Large).setLabel(new StringResourceModel("new", AbstractListPage.this, null));
    add(editPageLink);
}
Also used : ResettingFilterForm(org.devgateway.toolkit.forms.wicket.components.table.ResettingFilterForm) NullEditPageClassException(org.devgateway.toolkit.forms.exceptions.NullEditPageClassException) NullJpaRepositoryException(org.devgateway.toolkit.forms.exceptions.NullJpaRepositoryException) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) JpaFilterState(org.devgateway.toolkit.forms.wicket.components.table.JpaFilterState) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) StringResourceModel(org.apache.wicket.model.StringResourceModel) FilterToolbar(org.apache.wicket.extensions.markup.html.repeater.data.table.filter.FilterToolbar)

Example 3 with StringResourceModel

use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.

the class EditUserPage method getSaveEditPageButton.

@Override
public SaveEditPageButton getSaveEditPageButton() {
    return new SaveEditPageButton("save", new StringResourceModel("save", EditUserPage.this, null)) {

        private static final long serialVersionUID = 5214537995514151323L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            Person saveable = editForm.getModelObject();
            StandardPasswordEncoder encoder = new StandardPasswordEncoder("");
            // encode the password
            if (saveable.getChangePass()) {
                saveable.setPassword(encoder.encode(password.getField().getModelObject()));
            } else {
                if (saveable.getPassword() == null || saveable.getPassword().compareTo("") == 0) {
                    feedbackPanel.error(new StringResourceModel("nullPassword", this, null).getString());
                    target.add(feedbackPanel);
                    return;
                }
            }
            // it again next time
            if (isChangePassPage()) {
                saveable.setChangePassword(false);
            }
            saveable = jpaRepository.save(saveable);
            ensureDefaultDashboardIsAlsoAssignedDashboard(saveable);
            if (!SecurityUtil.isCurrentUserAdmin()) {
                setResponsePage(Homepage.class);
            } else {
                setResponsePage(listPageClass);
            }
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) StandardPasswordEncoder(org.springframework.security.crypto.password.StandardPasswordEncoder) Form(org.apache.wicket.markup.html.form.Form) StringResourceModel(org.apache.wicket.model.StringResourceModel) Person(org.devgateway.toolkit.persistence.dao.Person)

Example 4 with StringResourceModel

use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.

the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.

/**
     * pending files section
     */
private void addPendingFilesComponent() {
    pendingFiles = new WebMarkupContainer("pendingFiles") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfigure() {
            if (filesModel != null && filesModel.size() > 0) {
                for (FileMetadata file : filesModel) {
                    if (file.isNew()) {
                        setVisibilityAllowed(true);
                        return;
                    }
                }
            }
            setVisibilityAllowed(false);
        }
    };
    pendingFiles.setOutputMarkupPlaceholderTag(true);
    pendingFiles.setOutputMarkupId(true);
    add(pendingFiles);
    pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
    AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<FileMetadata> getObject() {
            List<FileMetadata> fileObject = new ArrayList<>();
            // upload)
            for (FileMetadata file : filesModel) {
                if (file.isNew()) {
                    fileObject.add(file);
                }
            }
            return fileObject;
        }
    };
    ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FileMetadata> item) {
            item.add(new Label("fileTitle", item.getModelObject().getName()));
            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(pendingFiles);
                }
            };
            delete.add(new IconBehavior(GlyphIconType.remove));
            delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
            delete.setVisible(true);
            item.add(delete);
        }
    };
    pendingFiles.add(list);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) FileMetadata(org.devgateway.toolkit.persistence.dao.FileMetadata) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) IconBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.image.IconBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) 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) ListItem(org.apache.wicket.markup.html.list.ListItem) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 5 with StringResourceModel

use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.

the class FileInputBootstrapFormComponentWrapper method addBootstrapFileInputComponent.

private void addBootstrapFileInputComponent() {
    // this is where the newly uploaded files are saved
    final IModel<List<FileUpload>> internalUploadModel = new ListModel<>();
    /*
         * some customization of the BootstrapFileInput Component
         */
    FileInputConfig fileInputConfig = new FileInputConfig();
    fileInputConfig.put(new Key<String>("browseLabel"), new StringResourceModel("browseLabel", FileInputBootstrapFormComponentWrapper.this, null).getString());
    fileInputConfig.put(new Key<String>("uploadClass"), "btn btn-blue");
    fileInputConfig.put(new Key<String>("browseClass"), "btn btn-blue");
    bootstrapFileInput = new BootstrapFileInput("bootstrapFileInput", internalUploadModel, fileInputConfig) {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override
        protected void onSubmit(final AjaxRequestTarget target) {
            super.onSubmit(target);
            List<FileUpload> fileUploads = internalUploadModel.getObject();
            if (fileUploads != null) {
                // check if we uploaded too many files
                if (maxFiles > 0 && filesModel.size() + fileUploads.size() > maxFiles) {
                    if (maxFiles == 1) {
                        FileInputBootstrapFormComponentWrapper.this.fatal(new StringResourceModel("OneUpload", FileInputBootstrapFormComponentWrapper.this, null).getString());
                    } else {
                        FileInputBootstrapFormComponentWrapper.this.fatal(new StringResourceModel("tooManyFiles", FileInputBootstrapFormComponentWrapper.this, Model.of(maxFiles)).getString());
                    }
                    FileInputBootstrapFormComponentWrapper.this.invalid();
                } else {
                    // and update the model
                    for (FileUpload upload : fileUploads) {
                        FileMetadata fileMetadata = new FileMetadata();
                        fileMetadata.setName(upload.getClientFileName());
                        fileMetadata.setContentType(upload.getContentType());
                        fileMetadata.setSize(upload.getSize());
                        FileContent fileContent = new FileContent();
                        fileContent.setBytes(upload.getBytes());
                        fileMetadata.setContent(fileContent);
                        filesModel.add(fileMetadata);
                    // don't display the success notification
                    // FileInputBootstrapFormComponentWrapper.this.success(new
                    // StringResourceModel("successUpload",
                    // FileInputBootstrapFormComponentWrapper.this,
                    // null, new
                    // Model(upload.getClientFileName())).getString());
                    }
                }
            }
            FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
            target.add(fileUploadFeedback);
            target.add(pendingFiles);
        }
    };
    add(bootstrapFileInput);
    /**
         * due to an upgrade of FormGroup in wicket7/wicket-bootrap-0.10, the
         * visitor that finds inner FormComponentS, will now find two instead of
         * one: the FileInputBootstrapFormComponentWrapper and also the
         * BootstrapFileInputField. This is the RIGHT result, previously in
         * wicket 6.x it only got the first level of children, hence only one
         * FormComponent (the FileInputBootstrapFormComponentWrapper). It would
         * then read the label from FileInputBootstrapFormComponentWrapper and
         * use it for displaying the label of the FormGroup. In
         * wicket7/wicket-bootstrap-0.10 this will result in reading the label
         * of BootstrapFileInputField which is null. So you will notice no
         * labels for FormGroupS. We fix this by forcing the label of the
         * underlying fileInput element to the same model as the label used by
         * FileInputBootstrapFormComponentWrapper
         */
    FormComponent<?> fileInput = (FormComponent<?>) bootstrapFileInput.get("fileInputForm").get("fileInput");
    fileInput.setLabel(this.getLabel());
    // only to admins
    if (visibleOnlyToAdmin) {
        MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
    }
    // want to read only
    if (disableDeleteButton) {
        MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, MetaDataRoleAuthorizationStrategy.NO_ROLE);
    }
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) FileMetadata(org.devgateway.toolkit.persistence.dao.FileMetadata) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FileContent(org.devgateway.toolkit.persistence.dao.FileContent) ListModel(org.apache.wicket.model.util.ListModel) BootstrapFileInput(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.fileinput.BootstrapFileInput) ArrayList(java.util.ArrayList) List(java.util.List) FileInputConfig(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.fileinput.FileInputConfig) StringResourceModel(org.apache.wicket.model.StringResourceModel) FileUpload(org.apache.wicket.markup.html.form.upload.FileUpload)

Aggregations

StringResourceModel (org.apache.wicket.model.StringResourceModel)19 Label (org.apache.wicket.markup.html.basic.Label)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 ArrayList (java.util.ArrayList)6 List (java.util.List)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 TooltipBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 ListView (org.apache.wicket.markup.html.list.ListView)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 IconBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.image.IconBehavior)2 NavbarDropDownButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton)2 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)2 Form (org.apache.wicket.markup.html.form.Form)2 AbstractLink (org.apache.wicket.markup.html.link.AbstractLink)2 LogoutPage (org.devgateway.toolkit.forms.wicket.page.user.LogoutPage)2 FileMetadata (org.devgateway.toolkit.persistence.dao.FileMetadata)2 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)1 ModelState (com.evolveum.midpoint.model.api.context.ModelState)1