Search in sources :

Example 6 with Form

use of com.evolveum.midpoint.web.component.form.Form in project midpoint by Evolveum.

the class AbstractObjectMainPanel method initLayoutPreviewButton.

// TEMPORARY
protected void initLayoutPreviewButton(final PageAdminObjectDetails<O> parentPage) {
    AjaxSubmitButton previewButton = new AjaxSubmitButton(ID_PREVIEW_CHANGES, parentPage.createStringResource("pageAdminFocus.button.previewChanges")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            getDetailsPage().previewPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    previewButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return AbstractObjectMainPanel.this.isPreviewButtonVisible();
        }

        @Override
        public boolean isEnabled() {
            PrismContainerDefinition def = getObjectWrapper().getDefinition();
            if (ContainerStatus.MODIFYING.equals(getObjectWrapper().getStatus()) && !def.canModify()) {
                return areSavePreviewButtonsEnabled();
            }
            return true;
        }
    });
    mainForm.add(previewButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 7 with Form

use of com.evolveum.midpoint.web.component.form.Form in project midpoint by Evolveum.

the class AbstractObjectMainPanel method initLayoutSaveButton.

protected void initLayoutSaveButton(final PageAdminObjectDetails<O> parentPage) {
    AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_SAVE, parentPage.createStringResource("pageAdminFocus.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            getDetailsPage().savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    saveButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !getObjectWrapper().isReadonly();
        }

        @Override
        public boolean isEnabled() {
            //in case user isn't allowed to modify focus data but has
            // e.g. #assign authorization, Save button is disabled on page load.
            // Save button becomes enabled just if some changes are made
            // on the Assignments tab (in the use case with #assign authorization)
            PrismContainerDefinition def = getObjectWrapper().getDefinition();
            if (ContainerStatus.MODIFYING.equals(getObjectWrapper().getStatus()) && !def.canModify()) {
                return areSavePreviewButtonsEnabled();
            }
            return true;
        }
    });
    mainForm.setDefaultButton(saveButton);
    mainForm.add(saveButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 8 with Form

use of com.evolveum.midpoint.web.component.form.Form in project midpoint by Evolveum.

the class FocusMainPanel method createTabPanel.

protected WebMarkupContainer createTabPanel(String panelId, FormSpecificationType formSpecificationType, PageAdminObjectDetails<F> parentPage) {
    String panelClassName = formSpecificationType.getPanelClass();
    Class<?> panelClass;
    try {
        panelClass = Class.forName(panelClassName);
    } catch (ClassNotFoundException e) {
        throw new SystemException("Panel class '" + panelClassName + "' as specified in admin GUI configuration was not found", e);
    }
    if (AbstractFocusTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, LoadableModel.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,LoadableModel,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractFocusTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractFocusTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), assignmentsModel, projectionModel, parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else if (AbstractObjectTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractObjectTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractObjectTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else {
        throw new UnsupportedOperationException("Tab panels that are not subclasses of AbstractObjectTabPanel or AbstractFocusTabPanel are not supported yet (got " + panelClass + ")");
    }
}
Also used : Form(com.evolveum.midpoint.web.component.form.Form) Constructor(java.lang.reflect.Constructor) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CountableLoadableModel(com.evolveum.midpoint.gui.api.model.CountableLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 9 with Form

use of com.evolveum.midpoint.web.component.form.Form in project midpoint by Evolveum.

the class PageAssignmentsList method initLayout.

public void initLayout() {
    setOutputMarkupId(true);
    Form mainForm = new Form(ID_FORM);
    mainForm.setOutputMarkupId(true);
    add(mainForm);
    AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_ASSIGNMENT_TABLE_PANEL, createStringResource("FocusType.assignment"), assignmentsModel, PageAssignmentsList.this) {

        @Override
        protected List<InlineMenuItem> createAssignmentMenu() {
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.unassign"), new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteAssignmentPerformed(target);
                }
            });
            items.add(item);
            return items;
        }
    };
    mainForm.add(panel);
    WebMarkupContainer targetUserPanel = new TargetUserSelectorComponent(ID_TARGET_USER_PANEL, PageAssignmentsList.this);
    targetUserPanel.setOutputMarkupId(true);
    mainForm.add(targetUserPanel);
    TextArea descriptionInput = new TextArea<String>(ID_DESCRIPTION, descriptionModel);
    descriptionInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            getSessionStorage().getRoleCatalog().setRequestDescription(getDescriptionComponent().getValue());
        }
    });
    mainForm.add(descriptionInput);
    AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageAssignmentDetails.backButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(back);
    AjaxSubmitButton requestAssignments = new AjaxSubmitButton(ID_REQUEST_BUTTON, createStringResource("PageAssignmentsList.requestButton")) {

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            if (getSessionStorage().getRoleCatalog().getTargetUserList() == null || getSessionStorage().getRoleCatalog().getTargetUserList().size() <= 1) {
                onSingleUserRequestPerformed(target);
            } else {
                onMultiUserRequestPerformed(target);
            }
        }
    };
    requestAssignments.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getSessionStorage().getRoleCatalog().isMultiUserRequest() || areConflictsResolved();
        }
    });
    mainForm.add(requestAssignments);
    AjaxSubmitButton resolveAssignments = new AjaxSubmitButton(ID_RESOLVE_CONFLICTS_BUTTON, createStringResource("PageAssignmentsList.resolveConflicts")) {

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            PageAssignmentsList.this.navigateToNext(PageAssignmentConflicts.class);
        }
    };
    resolveAssignments.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getSessionStorage().getRoleCatalog().isMultiUserRequest() && getSessionStorage().getRoleCatalog().getConflictsList() != null && getSessionStorage().getRoleCatalog().getConflictsList().size() > 0;
        }
    });
    mainForm.add(resolveAssignments);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) TargetUserSelectorComponent(com.evolveum.midpoint.web.component.assignment.TargetUserSelectorComponent) AssignmentTablePanel(com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 10 with Form

use of com.evolveum.midpoint.web.component.form.Form in project midpoint by Evolveum.

the class PageAssignmentConflicts method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    mainForm.setOutputMarkupId(true);
    add(mainForm);
    RepeatingView conflictsPanel = new RepeatingView(ID_CONFLICTS_PANEL);
    conflictsPanel.setOutputMarkupId(true);
    List<AssignmentConflictDto> conflicts = getSessionStorage().getRoleCatalog().getConflictsList();
    for (AssignmentConflictDto dto : conflicts) {
        AssignmentConflictPanel panel = new AssignmentConflictPanel(conflictsPanel.newChildId(), Model.of(dto));
        conflictsPanel.add(panel);
    }
    mainForm.add(conflictsPanel);
    AjaxSubmitButton back = new AjaxSubmitButton(ID_BACK, createStringResource("PageAssignmentConflicts.back")) {

        @Override
        public void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            redirectBack();
        }
    };
    mainForm.add(back);
    AjaxSubmitButton submit = new AjaxSubmitButton(ID_SUBMIT, createStringResource("PageAssignmentConflicts.submit")) {

        @Override
        public void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            redirectBack();
        }
    };
    mainForm.add(submit);
}
Also used : AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) AssignmentConflictPanel(com.evolveum.midpoint.web.page.self.component.AssignmentConflictPanel)

Aggregations

Form (com.evolveum.midpoint.web.component.form.Form)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)9 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 CaptchaPanel (com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel)2 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 ArrayList (java.util.ArrayList)2 TextArea (org.apache.wicket.markup.html.form.TextArea)2 CountableLoadableModel (com.evolveum.midpoint.gui.api.model.CountableLoadableModel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)1 AssignmentDetailsPanel (com.evolveum.midpoint.web.component.assignment.AssignmentDetailsPanel)1 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)1 AssignmentTablePanel (com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel)1 TargetUserSelectorComponent (com.evolveum.midpoint.web.component.assignment.TargetUserSelectorComponent)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1