Search in sources :

Example 46 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ChooseFocusTypeAndRelationDialogPanel method initLayout.

private void initLayout() {
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_FEEDBACK, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    add(warningMessage);
    DropDownFormGroup<QName> type = new DropDownFormGroup<>(ID_OBJECT_TYPE, Model.of(getDefaultObjectType()), Model.ofList(getSupportedObjectTypes()), new QNameObjectTypeChoiceRenderer(), createStringResource("chooseFocusTypeAndRelationDialogPanel.type"), "chooseFocusTypeAndRelationDialogPanel.tooltip.type", "col-md-4", "col-md-8", true);
    type.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    type.setOutputMarkupId(true);
    type.add(new VisibleBehaviour(this::isFocusTypeSelectorVisible));
    add(type);
    IModel<Map<String, String>> options = new Model(null);
    options.setObject(new HashMap<>());
    ListMultipleChoicePanel<QName> relation = new ListMultipleChoicePanel<>(ID_RELATION, Model.ofList(getDefaultRelations()), new ListModel<>(getSupportedRelations()), WebComponentUtil.getRelationChoicesRenderer(getPageBase()), options);
    relation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    relation.setOutputMarkupId(true);
    add(relation);
    WebMarkupContainer relationRequired = new WebMarkupContainer(ID_RELATION_REQUIRED);
    relationRequired.add(new VisibleBehaviour((this::isRelationRequired)));
    add(relationRequired);
    Label label = new Label(ID_INFO_MESSAGE, getModel());
    label.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(label);
    AjaxButton confirmButton = new AjaxButton(ID_BUTTON_OK, createStringResource("Button.ok")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            DropDownFormGroup<QName> type = getTypePanel(getParent());
            QName typeChosen = type.getModelObject();
            ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
            Collection<QName> relationChosen = relation.getModelObject();
            if (relationChosen.contains(PrismConstants.Q_ANY)) {
                relationChosen = getSupportedRelations();
            }
            ChooseFocusTypeAndRelationDialogPanel.this.okPerformed(typeChosen, relationChosen, target);
            getPageBase().hideMainPopup(target);
        }
    };
    add(confirmButton);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL_OK, createStringResource("Button.cancel")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().hideMainPopup(target);
        }
    };
    add(cancelButton);
    AjaxButton configuredButton = new AjaxButton(ID_CONFIGURE_TASK, new StringResourceModel("ConfigureTaskConfirmationPanel.configure", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            DropDownFormGroup<QName> type = getTypePanel(getParent());
            QName typeChosen = type.getModelObject();
            ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
            Collection<QName> relationChosen = relation.getModelObject();
            PrismObject<TaskType> task = getTask(typeChosen, relationChosen, target);
            if (task == null) {
                return;
            }
            ((PageBase) getPage()).hideMainPopup(target);
            WebComponentUtil.dispatchToObjectDetailsPage(task, true, ChooseFocusTypeAndRelationDialogPanel.this);
        }
    };
    configuredButton.add(new VisibleBehaviour(this::isTaskConfigureButtonVisible));
    add(configuredButton);
}
Also used : DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel) QNameObjectTypeChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)

Example 47 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ConfirmationPanel method initLayout.

private void initLayout(IModel<String> message) {
    WebMarkupContainer panel = new WebMarkupContainer(ID_PANEL);
    Label label = new Label(ID_CONFIRM_TEXT, message);
    label.setEscapeModelStrings(true);
    panel.add(label);
    AjaxButton yesButton = new AjaxButton(ID_YES, new StringResourceModel("confirmationDialog.yes", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            yesPerformed(target);
        }
    };
    panel.add(yesButton);
    AjaxButton noButton = new AjaxButton(ID_NO, new StringResourceModel("confirmationDialog.no", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            noPerformed(target);
        }
    };
    panel.add(noButton);
    customInitLayout(panel);
    add(panel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Label(org.apache.wicket.markup.html.basic.Label) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 48 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ExportingPanel method initLayout.

private void initLayout() {
    MidpointForm form = new MidpointForm<>(ID_MAIN_FORM, true);
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    form.add(warningMessage);
    FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
    feedbackList.setOutputMarkupId(true);
    feedbackList.setOutputMarkupPlaceholderTag(true);
    form.add(feedbackList);
    TextPanel<String> nameField = new TextPanel<>(ID_NAME, nameModel);
    form.add(nameField);
    BoxedTablePanel<SelectableBean<Integer>> table = createTable(ID_TABLE, dataTable);
    form.add(table);
    AjaxSubmitButton exportSelected = new AjaxSubmitButton(ID_EXPORT, getPageBase().createStringResource("ExportingPopupPanel.exportSelected")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            performSelectedColumns(table);
            if (exportedColumnsIndex.isEmpty()) {
                LOGGER.warn("None columns selected");
                getPageBase().warn(getPageBase().createStringResource("ExportingPanel.message.error.selectColumn").getString());
                target.add(feedbackList);
                return;
            }
            ((PageBase) getPage()).hideMainPopup(target);
            exportPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    form.add(exportSelected);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL, new StringResourceModel("Button.cancel", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancelButton);
    add(form);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 49 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class MainMenuPanel method menuItemPerformed.

private void menuItemPerformed(MenuItem menu) {
    LOGGER.trace("menuItemPerformed: {}", menu);
    // getSession().getSessionStorage().setActiveMenu(menu.getNameModel());
    // getSession().getSessionStorage().setActiveMainMenu(getModelObject().getNameModel());
    IPageFactory pFactory = Session.get().getPageFactory();
    WebPage page;
    if (menu.getParams() == null) {
        page = pFactory.newPage(menu.getPageClass());
    } else {
        page = pFactory.newPage(menu.getPageClass(), menu.getParams());
    }
    if (!(page instanceof PageBase)) {
        setResponsePage(page);
        return;
    }
    PageBase pageBase = (PageBase) page;
    // IMPORTANT: we need to re-bundle the name to a new models
    // that will not be connected to the old page reference
    // otherwise the old page will somehow remain in the memory
    // I have no idea how it could do that and especially how
    // several old pages can remain in memory. But if the model
    // is not re-bundled here then the page size grows and never
    // falls.
    MainMenuItem mainMenuItem = getModelObject();
    String name = mainMenuItem.getNameModel();
    Breadcrumb bc = new Breadcrumb(createStringResource(name));
    bc.setIcon(new Model<>(mainMenuItem.getIconClass()));
    pageBase.addBreadcrumb(bc);
    if (mainMenuItem.containsSubMenu() && mainMenuItem.isInsertDefaultBackBreadcrumb()) {
        MenuItem first = mainMenuItem.getFirstMenuItem();
        BreadcrumbPageClass invisibleBc = new BreadcrumbPageClass(createStringResource(first.getNameModel()), first.getPageClass(), first.getParams());
        invisibleBc.setVisible(false);
        pageBase.addBreadcrumb(invisibleBc);
    }
    setResponsePage(page);
}
Also used : WebPage(org.apache.wicket.markup.html.WebPage) IPageFactory(org.apache.wicket.IPageFactory) BreadcrumbPageClass(com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass) Breadcrumb(com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 50 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ConfigureTaskConfirmationPanel method customInitLayout.

@Override
protected void customInitLayout(WebMarkupContainer panel) {
    AjaxButton configuredButton = new AjaxButton(ID_CONFIGURE, new StringResourceModel("ConfigureTaskConfirmationPanel.configure", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            WebComponentUtil.dispatchToObjectDetailsPage(getTask(target), true, ConfigureTaskConfirmationPanel.this);
        }
    };
    panel.add(configuredButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)82 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)30 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 Task (com.evolveum.midpoint.task.api.Task)16 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)13 IModel (org.apache.wicket.model.IModel)12 Label (org.apache.wicket.markup.html.basic.Label)11 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 ArrayList (java.util.ArrayList)9 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)9 List (java.util.List)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 RestartResponseException (org.apache.wicket.RestartResponseException)6 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)5 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)5 QName (javax.xml.namespace.QName)5