Search in sources :

Example 31 with PropertyModel

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

the class PageDebugList method initColumns.

private List<IColumn> initColumns(final Class<? extends ObjectType> type) {
    List<IColumn> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<ObjectType>();
    columns.add(column);
    column = new LinkColumn<DebugObjectItem>(createStringResource("pageDebugList.name"), DebugObjectItem.F_NAME, DebugObjectItem.F_NAME) {

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, final IModel<DebugObjectItem> rowModel) {
            TwoValueLinkPanel panel = new TwoValueLinkPanel(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    DebugObjectItem object = rowModel.getObject();
                    if (object == null) {
                        return null;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(object.getName());
                    if (object.getStatus() != null && object.getStatus() != OperationResultStatusType.SUCCESS && object.getStatus() != OperationResultStatusType.HANDLED_ERROR) {
                        sb.append(" (");
                        sb.append(object.getStatus());
                        sb.append(")");
                    }
                    return sb.toString();
                }
            }, new PropertyModel<String>(rowModel, DebugObjectItem.F_OID)) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    DebugObjectItem object = rowModel.getObject();
                    objectEditPerformed(target, object.getOid(), type);
                }

                @Override
                public boolean isEnabled() {
                    return rowModel.getObject().getOid() != null;
                }
            };
            cellItem.add(panel);
            cellItem.add(new AttributeModifier("class", "col-md-3"));
        }
    };
    columns.add(column);
    columns.add(new PropertyColumn(createStringResource("pageDebugList.description"), DebugObjectItem.F_DESCRIPTION));
    if (ShadowType.class.isAssignableFrom(type)) {
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceName"), DebugObjectItem.F_RESOURCE_NAME));
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceType"), DebugObjectItem.F_RESOURCE_TYPE));
    }
    column = new AbstractColumn<DebugObjectItem, String>(new Model(), null) {

        @Override
        public String getCssClass() {
            return "debug-list-buttons";
        }

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, IModel<DebugObjectItem> rowModel) {
            cellItem.add(new DebugButtonPanel<DebugObjectItem>(componentId, rowModel) {

                @Override
                public void deletePerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    deleteSelected(target, model.getObject());
                }

                @Override
                public void exportPerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    exportSelected(target, model.getObject());
                }
            });
        }
    };
    columns.add(column);
    column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {

        @Override
        public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
            // we don't need row inline menu
            cellItem.add(new Label(componentId));
        }
    };
    columns.add(column);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) DebugObjectItem(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugObjectItem) TwoValueLinkPanel(com.evolveum.midpoint.web.component.data.column.TwoValueLinkPanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) AttributeModifier(org.apache.wicket.AttributeModifier) InlineMenuable(com.evolveum.midpoint.web.component.data.column.InlineMenuable) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DebugButtonPanel(com.evolveum.midpoint.web.page.admin.configuration.component.DebugButtonPanel)

Example 32 with PropertyModel

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

the class PageDebugView method initLayout.

private void initLayout() {
    add(mainForm);
    mainForm.add(new AjaxCheckBox("encrypt", encrypt) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.add(new AjaxCheckBox("saveAsRaw", saveAsRaw) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.add(new AjaxCheckBox("reevaluateSearchFilters", reevaluateSearchFilters) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.add(new AjaxCheckBox("validateSchema", validateSchema) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.add(new AjaxCheckBox("switchToPlainText", switchToPlainText) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            if (switchToPlainText.getObject()) {
                editor.setVisible(false);
                plainTextarea.setVisible(true);
            } else {
                editor.setVisible(true);
                plainTextarea.setVisible(false);
            }
            target.add(mainForm);
        }
    });
    plainTextarea = new TextArea<>(ID_PLAIN_TEXTAREA, new PropertyModel<String>(model, ObjectViewDto.F_XML));
    plainTextarea.setVisible(false);
    mainForm.add(plainTextarea);
    addOrReplaceEditor();
    initButtons(mainForm);
    initViewButton(mainForm);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)

Example 33 with PropertyModel

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

the class PageDebugView method addOrReplaceEditor.

private void addOrReplaceEditor() {
    editor = new AceEditor("aceEditor", new PropertyModel<String>(model, ObjectViewDto.F_XML));
    editor.setModeForDataLanguage(dataLanguage);
    editor.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.addOrReplace(editor);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PropertyModel(org.apache.wicket.model.PropertyModel) AceEditor(com.evolveum.midpoint.web.component.AceEditor)

Example 34 with PropertyModel

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

the class AdminGuiConfigPanel method initLayout.

private void initLayout() {
    GenericMultiValueLabelEditPanel<RichHyperlinkType> dashboardLinkEditor = new GenericMultiValueLabelEditPanel<RichHyperlinkType>(ID_DASHBOARD_LINK_EDITOR, new PropertyModel<List<RichHyperlinkType>>(getModel(), "userDashboardLink"), createStringResource("AdminGuiConfigPanel.dashboardLinksConfig"), LABEL_SIZE, INPUT_SIZE, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createTextModel(final IModel<RichHyperlinkType> model) {
            return new PropertyModel<String>(model, "label");
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<RichHyperlinkType> rowModel) {
            RichHyperlinkConfigPanel contentPanel = new RichHyperlinkConfigPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject(), false) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getDashboardLinkEditorContainer());
                }

                @Override
                public StringResourceModel getTitle() {
                    return createStringResource("AdminGuiConfigPanel.dashboardLinkDialogTitle.title");
                }
            };
            showDialog(contentPanel, target);
        }

        @Override
        protected RichHyperlinkType createNewEmptyItem() {
            RichHyperlinkType link = new RichHyperlinkType();
            link.getAuthorization().add("");
            return link;
        }
    };
    dashboardLinkEditor.setOutputMarkupId(true);
    add(dashboardLinkEditor);
    GenericMultiValueLabelEditPanel<RichHyperlinkType> additionalMenuItemEditor = new GenericMultiValueLabelEditPanel<RichHyperlinkType>(ID_ADDITIONAL_MENU_ITEM_EDITOR, new PropertyModel<List<RichHyperlinkType>>(getModel(), "additionalMenuLink"), createStringResource("AdminGuiConfigPanel.additionalMenuItemConfig"), LABEL_SIZE, INPUT_SIZE, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createTextModel(final IModel<RichHyperlinkType> model) {
            return new PropertyModel<String>(model, "label");
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<RichHyperlinkType> rowModel) {
            RichHyperlinkConfigPanel contentPanel = new RichHyperlinkConfigPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject(), true) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getAdditionalMenuItemContainer());
                }

                @Override
                public StringResourceModel getTitle() {
                    return createStringResource("AdminGuiConfigPanel.additionalMenuItemDialog.title");
                }
            };
            showDialog(contentPanel, target);
        }

        @Override
        protected RichHyperlinkType createNewEmptyItem() {
            RichHyperlinkType link = new RichHyperlinkType();
            link.getAuthorization().add("");
            return link;
        }
    };
    additionalMenuItemEditor.setOutputMarkupId(true);
    add(additionalMenuItemEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) RichHyperlinkType(com.evolveum.midpoint.xml.ns._public.common.common_3.RichHyperlinkType) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) PropertyModel(org.apache.wicket.model.PropertyModel) List(java.util.List)

Example 35 with PropertyModel

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

the class ObjectSelectionPanel method initLayout.

public void initLayout(PageBase pageBase) {
    Form searchForm = new Form(ID_SEARCH_FORM);
    searchForm.setOutputMarkupId(true);
    add(searchForm);
    searchForm.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return context.isSearchEnabled();
        }
    });
    BasicSearchPanel<ObjectSearchDto> basicSearch = new BasicSearchPanel<ObjectSearchDto>(ID_BASIC_SEARCH) {

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, ObjectSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.clearSearchPerformed(target);
        }
    };
    searchForm.add(basicSearch);
    add(context.createExtraContentContainer(ID_EXTRA_CONTENT_CONTAINER, this));
    List<IColumn<SelectableBean<ObjectType>, String>> columns = initColumns();
    ObjectDataProvider provider = new ObjectDataProvider(pageBase, this.objectType);
    provider.setQuery(context.getDataProviderQuery());
    provider.setOptions(context.getDataProviderOptions());
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    addOrReplace(table);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("chooseTypeDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            modalWindow.close(ajaxRequestTarget);
        }
    };
    add(cancelButton);
}
Also used : ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) Form(org.apache.wicket.markup.html.form.Form) PropertyModel(org.apache.wicket.model.PropertyModel) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Aggregations

PropertyModel (org.apache.wicket.model.PropertyModel)70 Label (org.apache.wicket.markup.html.basic.Label)38 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)37 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)29 ArrayList (java.util.ArrayList)22 List (java.util.List)21 IModel (org.apache.wicket.model.IModel)21 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)20 ListItem (org.apache.wicket.markup.html.list.ListItem)17 ListView (org.apache.wicket.markup.html.list.ListView)15 Model (org.apache.wicket.model.Model)13 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)10 TextField (org.apache.wicket.markup.html.form.TextField)10 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)9 QName (javax.xml.namespace.QName)8 Form (org.apache.wicket.markup.html.form.Form)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5