Search in sources :

Example 16 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class SchemaListPanel method initLayout.

protected void initLayout() {
    final ObjectClassDataProvider dataProvider = new ObjectClassDataProvider(allClasses);
    TextField objectClass = new TextField<>(ID_OBJECT_CLASS, new Model<>());
    objectClass.setOutputMarkupId(true);
    objectClass.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateSearchPerformed(target, dataProvider);
        }
    });
    add(objectClass);
    AjaxButton clearSearch = new AjaxButton(ID_CLEAR_SEARCH) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            clearSearchPerformed(target, dataProvider);
        }
    };
    add(clearSearch);
    WebMarkupContainer tableBody = new WebMarkupContainer(ID_TABLE_BODY);
    tableBody.setOutputMarkupId(true);
    add(tableBody);
    DataView<ObjectClassDto> objectClassDataView = new DataView<ObjectClassDto>(ID_OBJECT_CLASS_LIST, dataProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(final Item<ObjectClassDto> item) {
            AjaxLink link = new AjaxLink(ID_CLASS_LINK) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    objectClassClickPerformed(target, item.getModelObject());
                }
            };
            item.add(link);
            Label label = new Label(ID_LABEL, new PropertyModel<>(item.getModel(), ObjectClassDto.F_DISPLAY_NAME));
            link.add(label);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return item.getModelObject().isSelected() ? "success" : null;
                }
            }));
        }
    };
    tableBody.add(objectClassDataView);
    NavigatorPanel objectClassNavigator = new NavigatorPanel(ID_NAVIGATOR, objectClassDataView, true);
    objectClassNavigator.setOutputMarkupId(true);
    objectClassNavigator.setOutputMarkupPlaceholderTag(true);
    add(objectClassNavigator);
    WebMarkupContainer objectClassInfoContainer = new WebMarkupContainer(ID_OBJECT_CLASS_INFO_CONTAINER);
    objectClassInfoContainer.setOutputMarkupId(true);
    add(objectClassInfoContainer);
    WebMarkupContainer objectClassInfoColumn = new WebMarkupContainer(ID_OBJECT_CLASS_INFO_COLUMN);
    objectClassInfoColumn.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getSelectedObjectClass() != null;
        }
    });
    objectClassInfoContainer.add(objectClassInfoColumn);
    initDetailsPanel(objectClassInfoColumn);
    ListDataProvider<AttributeDto> attributeProvider = new ListDataProvider<>(this, attributeModel, true);
    attributeProvider.setSort(AttributeDto.F_DISPLAY_ORDER, SortOrder.ASCENDING);
    BoxedTablePanel<AttributeDto> attributeTable = new BoxedTablePanel<>(ID_ATTRIBUTE_TABLE, attributeProvider, initColumns());
    attributeTable.setOutputMarkupId(true);
    attributeTable.setItemsPerPage(UserProfileStorage.DEFAULT_PAGING_SIZE);
    attributeTable.setShowPaging(true);
    objectClassInfoColumn.add(attributeTable);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) ObjectClassDataProvider(com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDataProvider) ObjectClassDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDto) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AttributeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.AttributeDto) DataView(org.apache.wicket.markup.repeater.data.DataView) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 17 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class WizardIssuesPanel method initLayout.

private void initLayout() {
    WebMarkupContainer panel = new WebMarkupContainer(ID_PANEL);
    panel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().hasIssues();
        }
    });
    panel.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            WizardIssuesDto issuesDto = WizardIssuesPanel.this.getModelObject();
            WizardIssuesDto.Severity severity = issuesDto.getSeverity();
            return severity != null ? "box-" + severity.getColorStyle() : null;
        }
    }));
    add(panel);
    Label title = new Label(ID_TITLE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            WizardIssuesDto issuesDto = WizardIssuesPanel.this.getModelObject();
            WizardIssuesDto.Severity severity = issuesDto.getSeverity();
            if (severity == null) {
                return "";
            } else if (severity == WizardIssuesDto.Severity.INFO) {
                return getString("Wizard.Notes");
            } else {
                return getString("Wizard.Issues");
            }
        }
    });
    panel.add(title);
    WebMarkupContainer table = new WebMarkupContainer(ID_TABLE);
    panel.add(table);
    ListView<WizardIssuesDto.Issue> issues = new ListView<WizardIssuesDto.Issue>(ID_ROW, new PropertyModel<List<WizardIssuesDto.Issue>>(getModel(), WizardIssuesDto.F_ISSUES)) {

        @Override
        protected void populateItem(ListItem<WizardIssuesDto.Issue> item) {
            WizardIssuesDto.Issue issue = item.getModelObject();
            Label severityLabel = new Label(ID_SEVERITY, "");
            severityLabel.add(AttributeAppender.replace("class", issue.getSeverityClass()));
            item.add(severityLabel);
            item.add(new Label(ID_TEXT, issue.getText()));
        }
    };
    table.add(issues);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WizardIssuesDto(com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 18 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class ConfigurationStep method initLayout.

private void initLayout() {
    com.evolveum.midpoint.web.component.form.Form form = new com.evolveum.midpoint.web.component.form.Form<>(ID_MAIN, true);
    form.setOutputMarkupId(true);
    add(form);
    form.add(WebComponentUtil.createTabPanel(ID_CONFIGURATION, parentPage, new ArrayList<ITab>(), null));
    AjaxSubmitButton testConnection = new AjaxSubmitButton(ID_TEST_CONNECTION, createStringResource("ConfigurationStep.button.testConnection")) {

        @Override
        protected void onError(final AjaxRequestTarget target, Form<?> form) {
            WebComponentUtil.refreshFeedbacks(form, target);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            testConnectionPerformed(target);
        }
    };
    testConnection.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !parentPage.isReadOnly();
        }
    });
    add(testConnection);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 19 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class SchemaHandlingStep method initLayout.

private void initLayout() {
    final ListDataProvider<ResourceObjectTypeDefinitionTypeDto> objectTypeProvider = new ListDataProvider<>(this, new PropertyModel<List<ResourceObjectTypeDefinitionTypeDto>>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_TYPE_DTO_LIST));
    // first row - object types table
    WebMarkupContainer objectTypesTable = new WebMarkupContainer(ID_ROWS);
    objectTypesTable.setOutputMarkupId(true);
    add(objectTypesTable);
    // second row - object type editor
    WebMarkupContainer objectTypeEditor = new WebMarkupContainer(ID_OBJECT_TYPE_EDITOR);
    objectTypeEditor.setOutputMarkupId(true);
    objectTypeEditor.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAnySelected();
        }
    });
    add(objectTypeEditor);
    // third row container
    WebMarkupContainer thirdRowContainer = new WebMarkupContainer(ID_THIRD_ROW_CONTAINER);
    thirdRowContainer.setOutputMarkupId(true);
    add(thirdRowContainer);
    // ---------------------- details -----------------------
    // Object type table (list)
    DataView<ResourceObjectTypeDefinitionTypeDto> objectTypeDataView = new DataView<ResourceObjectTypeDefinitionTypeDto>(ID_ROW_OBJECT_TYPE, objectTypeProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(final Item<ResourceObjectTypeDefinitionTypeDto> item) {
            final ResourceObjectTypeDefinitionTypeDto objectType = item.getModelObject();
            AjaxSubmitLink link = new AjaxSubmitLink(ID_LINK_OBJECT_TYPE) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    editObjectTypePerformed(target, objectType);
                }

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(parentPage.getFeedbackPanel());
                }
            };
            item.add(link);
            Label label = new Label(ID_NAME_OBJECT_TYPE, createObjectTypeDisplayModel(objectType));
            label.setOutputMarkupId(true);
            link.add(label);
            AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE_OBJECT_TYPE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteObjectTypePerformed(target, objectType);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            link.add(delete);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return isSelected(item.getModelObject()) ? "success" : null;
                }
            }));
        }
    };
    objectTypesTable.add(objectTypeDataView);
    NavigatorPanel navigator = new NavigatorPanel(ID_PAGING_OBJECT_TYPE, objectTypeDataView, true);
    navigator.setOutputMarkupPlaceholderTag(true);
    navigator.setOutputMarkupId(true);
    add(navigator);
    AjaxSubmitLink add = new AjaxSubmitLink(ID_BUTTON_ADD_OBJECT_TYPE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            addObjectTypePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
    initObjectTypeEditor(objectTypeEditor);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DataView(org.apache.wicket.markup.repeater.data.DataView) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) ResourceObjectTypeDefinitionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ResourceObjectTypeDefinitionTypeDto) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 20 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class TaskMainPanel method initTabPanel.

protected void initTabPanel(Form mainForm) {
    List<ITab> tabs = createTabs();
    TabbedPanel<ITab> tabPanel = WebComponentUtil.createTabPanel(ID_TAB_PANEL, parentPage, tabs, new TabbedPanel.RightSideItemProvider() {

        @Override
        public Component createRightSideItem(String id) {
            VisibleEnableBehaviour boxEnabled = new VisibleEnableBehaviour() {

                @Override
                public boolean isEnabled() {
                    return !parentPage.isEdit();
                }
            };
            TaskShowAdvancedFeaturesPanel advancedFeaturesPanel = new TaskShowAdvancedFeaturesPanel(id, showAdvancedFeaturesModel, boxEnabled) {

                @Override
                protected void onAdvancedFeaturesUpdate(AjaxRequestTarget target) {
                    target.add(getTabPanel());
                    target.add(getButtonPanel());
                // we DO NOT call parentPage.refresh here because in edit mode this would erase any model changes
                // (well, because - for some strange reasons - even this code erases name and description input fields
                // occassionally, we hide 'advanced features' checkbox in editing mode)
                }
            };
            advancedFeaturesPanel.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    // we don't distinguish between basic/advanced features for other task types yet
                    return parentPage.getTaskDto().isWorkflow();
                }
            });
            return advancedFeaturesPanel;
        }
    });
    mainForm.add(tabPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab)

Aggregations

VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)183 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)116 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)101 Label (org.apache.wicket.markup.html.basic.Label)89 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)51 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)44 List (java.util.List)32 ListItem (org.apache.wicket.markup.html.list.ListItem)29 PropertyModel (org.apache.wicket.model.PropertyModel)29 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)26 ArrayList (java.util.ArrayList)25 Form (org.apache.wicket.markup.html.form.Form)25 ListView (org.apache.wicket.markup.html.list.ListView)25 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)23 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)19 AttributeModifier (org.apache.wicket.AttributeModifier)18 IModel (org.apache.wicket.model.IModel)17 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)16 TextField (org.apache.wicket.markup.html.form.TextField)16 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)15