Search in sources :

Example 1 with ResourceModel

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

the class PasswordPanel method initLayout.

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
    setOutputMarkupId(true);
    final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {

        @Override
        public boolean isVisible() {
            return passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    add(inputContainer);
    final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
    password1.setRequired(false);
    password1.setResetPassword(false);
    password1.setOutputMarkupId(true);
    password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password1);
    final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
    password2.setRequired(false);
    password2.setResetPassword(false);
    password2.setOutputMarkupId(true);
    password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password2);
    password1.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
            password2.setRequired(required);
        //fix of MID-2463
        //				target.add(password2);
        //				target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
        }
    });
    password2.add(new PasswordValidator(password1, password2));
    final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    linkContainer.setOutputMarkupId(true);
    add(linkContainer);
    final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
    linkContainer.add(passwordSetLabel);
    final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel"));
    passwordRemoveLabel.setVisible(false);
    linkContainer.add(passwordRemoveLabel);
    AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onLinkClick(target);
        }

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    link.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
    link.setBody(new ResourceModel("passwordPanel.passwordChange"));
    link.setOutputMarkupId(true);
    linkContainer.add(link);
    final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
    AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onRemovePassword(model, target);
        }
    };
    removePassword.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageBase pageBase = (PageBase) getPage();
            if (pageBase == null) {
                return false;
            }
            if (pageBase instanceof PageSelfProfile) {
                return false;
            }
            if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
                return true;
            }
            return false;
        }
    });
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) PageSelfProfile(com.evolveum.midpoint.web.page.self.PageSelfProfile) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceModel(org.apache.wicket.model.ResourceModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with ResourceModel

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

the class TaskSubtasksAndThreadsTabPanel method initLayout.

private void initLayout(final IModel<TaskDto> taskDtoModel) {
    WebMarkupContainer threadsConfigurationPanel = new WebMarkupContainer(ID_THREADS_CONFIGURATION_PANEL);
    add(threadsConfigurationPanel);
    threadsConfigurationPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return taskDtoModel.getObject().configuresWorkerThreads();
        }
    });
    final TextField<Integer> workerThreads = new TextField<>(ID_WORKER_THREADS, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_WORKER_THREADS));
    workerThreads.setOutputMarkupId(true);
    workerThreads.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit();
        }
    });
    threadsConfigurationPanel.add(workerThreads);
    VisibleEnableBehaviour hiddenWhenEditingOrNoSubtasks = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !parentPage.isEdit() && !taskDtoModel.getObject().getSubtasks().isEmpty();
        }
    };
    Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel"));
    subtasksLabel.add(hiddenWhenEditingOrNoSubtasks);
    add(subtasksLabel);
    SubtasksPanel subtasksPanel = new SubtasksPanel(ID_SUBTASKS_PANEL, new PropertyModel<List<TaskDto>>(taskDtoModel, TaskDto.F_SUBTASKS), parentPage.getWorkflowManager().isEnabled());
    subtasksPanel.add(hiddenWhenEditingOrNoSubtasks);
    add(subtasksPanel);
    VisibleEnableBehaviour hiddenWhenNoSubtasks = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            TaskDto taskDto = taskDtoModel.getObject();
            return taskDto != null && !taskDto.getTransientSubtasks().isEmpty();
        }
    };
    Label workerThreadsTableLabel = new Label(ID_WORKER_THREADS_TABLE_LABEL, new ResourceModel("TaskStatePanel.workerThreads"));
    workerThreadsTableLabel.add(hiddenWhenNoSubtasks);
    add(workerThreadsTableLabel);
    List<IColumn<WorkerThreadDto, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskName"), WorkerThreadDto.F_NAME));
    columns.add(new EnumPropertyColumn<WorkerThreadDto>(createStringResourceStatic(this, "TaskStatePanel.subtaskState"), WorkerThreadDto.F_EXECUTION_STATUS));
    columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskObjectsProcessed"), WorkerThreadDto.F_PROGRESS));
    ISortableDataProvider<WorkerThreadDto, String> threadsProvider = new ListDataProvider<>(this, new AbstractReadOnlyModel<List<WorkerThreadDto>>() {

        @Override
        public List<WorkerThreadDto> getObject() {
            List<WorkerThreadDto> rv = new ArrayList<>();
            TaskDto taskDto = taskDtoModel.getObject();
            if (taskDto != null) {
                for (TaskDto subtaskDto : taskDto.getTransientSubtasks()) {
                    rv.add(new WorkerThreadDto(subtaskDto));
                }
            }
            return rv;
        }
    });
    TablePanel<WorkerThreadDto> workerThreadsTablePanel = new TablePanel<>(ID_WORKER_THREADS_TABLE, threadsProvider, columns);
    workerThreadsTablePanel.add(hiddenWhenNoSubtasks);
    add(workerThreadsTablePanel);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SubtasksPanel(com.evolveum.midpoint.web.page.admin.server.subtasks.SubtasksPanel) TextField(org.apache.wicket.markup.html.form.TextField) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WorkerThreadDto(com.evolveum.midpoint.web.page.admin.server.dto.WorkerThreadDto) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 3 with ResourceModel

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

the class VietnamImportPage method addDoneButton.

protected void addDoneButton() {
    doneButton = new LaddaAjaxButton("done", Type.Default) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            setResponsePage(Homepage.class);
        }
    };
    doneButton.setDefaultFormProcessing(false);
    doneButton.setLabel(new ResourceModel("done"));
    doneButton.setDefaultFormProcessing(false);
    doneButton.setIconType(FontAwesomeIconType.thumbs_up);
    importForm.add(doneButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Homepage(org.devgateway.toolkit.forms.wicket.page.Homepage) LaddaAjaxButton(de.agilecoders.wicket.extensions.markup.html.bootstrap.ladda.LaddaAjaxButton) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 4 with ResourceModel

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

the class VietnamImportPage method addImportButton.

protected void addImportButton() {
    importButton = new LaddaAjaxButton("import", Type.Danger) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            send(getPage(), Broadcast.BREADTH, new EditingDisabledEvent());
            logText.getSelfUpdatingBehavior().restart(target);
            importContainer.setVisibilityAllowed(true);
            target.add(importContainer);
            target.add(form);
            try {
                vnExcelImportService.importAllSheets(importForm.getModelObject().getFileTypes(), importForm.getModelObject().getSourceFiles().getPrototypeDatabaseFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getPrototypeDatabaseFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getLocationsFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getLocationsFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getPublicInstitutionsSuppliersFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getPublicInstitutionsSuppliersFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getCityDepartmentGroupFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getCityDepartmentGroupFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getDropData(), importForm.getModelObject().getValidateData(), importForm.getModelObject().getFlagData());
            } catch (Exception e) {
                logger.error(e);
                e.printStackTrace();
            } finally {
                target.add(logText);
                target.add(feedbackPanel);
                this.setEnabled(false);
                target.add(this);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            ValidationError error = new ValidationError();
            error.addKey("formHasErrors");
            error(error);
            target.add(form);
            target.add(feedbackPanel);
        }
    };
    importButton.setLabel(new ResourceModel("startImportProcess"));
    importButton.setIconType(FontAwesomeIconType.hourglass_start);
    importForm.add(importButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LaddaAjaxButton(de.agilecoders.wicket.extensions.markup.html.bootstrap.ladda.LaddaAjaxButton) ResourceModel(org.apache.wicket.model.ResourceModel) EditingDisabledEvent(org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent) ValidationError(org.apache.wicket.validation.ValidationError)

Example 5 with ResourceModel

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

the class BasePage method newMyDashboardsMenu.

protected NavbarButton<ListMyDashboardsPage> newMyDashboardsMenu() {
    // home
    NavbarButton<ListMyDashboardsPage> menu = new NavbarButton<>(ListMyDashboardsPage.class, this.getPageParameters(), new ResourceModel("mydashboards"));
    menu.setIconType(GlyphIconType.filter);
    MetaDataRoleAuthorizationStrategy.authorize(menu, Component.RENDER, SecurityConstants.Roles.ROLE_PROCURING_ENTITY);
    return menu;
}
Also used : ListMyDashboardsPage(org.devgateway.ocds.forms.wicket.page.list.ListMyDashboardsPage) NavbarButton(de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton) ResourceModel(org.apache.wicket.model.ResourceModel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

ResourceModel (org.apache.wicket.model.ResourceModel)48 ArrayList (java.util.ArrayList)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)19 Label (org.apache.wicket.markup.html.basic.Label)17 StringResourceModel (org.apache.wicket.model.StringResourceModel)15 Panel (org.apache.wicket.markup.html.panel.Panel)11 List (java.util.List)9 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)9 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)8 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 Form (org.apache.wicket.markup.html.form.Form)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)4 Fragment (org.apache.wicket.markup.html.panel.Fragment)4 NavbarButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton)3 StringUtils (org.apache.commons.lang3.StringUtils)3