Search in sources :

Example 31 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class AssignmentPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isCreateNewObjectVisible() {
            return isNewObjectButtonVisible(getFocusObject());
        }

        @Override
        protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
            return AssignmentPanel.this.getModel();
        }

        @Override
        protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
            AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
        }

        protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
            if (AssignmentPanel.this.getModelObject() == null) {
                return new ArrayList<>();
            }
            return initBasicColumns();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newAssignmentClickPerformed(target);
                }
            };
            newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
            bar.add(newObjectButton);
            newObjectButton.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return isNewObjectButtonVisible(getFocusObject());
                }

                @Override
                public boolean isEnabled() {
                    return !isAssignmentsLimitReached();
                }
            });
            return bar;
        }

        @Override
        public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
            int countAddedAssignments = 0;
            for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
                if (ValueStatus.ADDED.equals(assignment.getStatus())) {
                    countAddedAssignments++;
                }
            }
            boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
            if (isLimitReached) {
                warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            super.deleteItemPerformed(target, toDeleteList);
        }

        @Override
        protected AssignmentListProvider createProvider() {
            PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
            return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
        }

        @Override
        protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
            return createMultivalueContainerDetailsPanel(item);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return AssignmentPanel.this.getTableId();
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
            return createSearchableItems(containerDef);
        }

        @Override
        public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
            super.refreshTable(ajaxRequestTarget);
            AssignmentPanel.this.refreshTable(ajaxRequestTarget);
        }

        @Override
        protected boolean isCollectionViewPanel() {
            return config != null && config.getListView() != null;
        }

        @Override
        protected CompiledObjectCollectionView getObjectCollectionView() {
            if (config == null) {
                return super.getObjectCollectionView();
            }
            GuiObjectListViewType listView = config.getListView();
            if (listView == null) {
                return null;
            }
            CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
            if (collectionRefSpecificationType == null) {
                return null;
            }
            Task task = getPageBase().createSimpleTask("Compile collection");
            OperationResult result = task.getResult();
            try {
                return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return null;
        }
    };
    multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) PageStorage(com.evolveum.midpoint.web.session.PageStorage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 32 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class DelegationEditorPanel method addPrivilegesPanel.

private void addPrivilegesPanel(WebMarkupContainer body) {
    privilegesNames = getPrivilegesNamesList();
    ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<String> item) {
            Label privilageNameLabel = new Label(ID_PRIVILEGE, item.getModel());
            item.add(privilageNameLabel);
        }
    };
    privilegesListComponent.setOutputMarkupId(true);
    privilegesListComponent.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
                return true;
            }
            return false;
        }
    });
    body.addOrReplace(privilegesListComponent);
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 33 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class MultiCompositedButtonPanel method initLayout.

private void initLayout() {
    ListView<CompositedIconButtonDto> buttonsPanel = new ListView<>(ID_BUTTONS_PANEL, getModel()) {

        @Override
        protected void populateItem(ListItem<CompositedIconButtonDto> item) {
            CompositedButtonPanel additionalButton = new CompositedButtonPanel(ID_ADDITIONAL_BUTTON, item.getModel()) {

                @Override
                protected void onButtonClicked(AjaxRequestTarget target, CompositedIconButtonDto buttonDescription) {
                    buttonClickPerformed(target, buttonDescription.getAssignmentObjectRelation(), buttonDescription.getCollectionView(), buttonDescription.getPage());
                }
            };
            // AjaxCompositedIconButton additionalButton = new AjaxCompositedIconButton(ID_COMPOSITED_BUTTON, item.getModel()) {
            // 
            // @Override
            // public void onClick(AjaxRequestTarget target) {
            // buttonClickPerformed(target, item.getModelObject().getAssignmentObjectRelation(), item.getModelObject().getCollectionView(), item.getModelObject().getPage());
            // }
            // };
            item.add(additionalButton);
        // 
        // item.add(new Label(ID_BUTTON_DESCRIPTION, getButtonDescription(item.getModelObject())));
        }
    };
    buttonsPanel.add(new VisibleBehaviour(() -> getModelObject() != null));
    add(buttonsPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 34 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class ApplicablePolicyGroupPanel method initLayout.

private void initLayout() {
    Label policyGroupName = new Label(ID_POLICY_GROUP_NAME, Model.of(WebComponentUtil.getDisplayNameOrName(getModelObject(), getPageBase(), OPERATION_LOAD_POLICY_GROUP_NAME)));
    policyGroupName.setOutputMarkupId(true);
    add(policyGroupName);
    ListView<PrismObject<AbstractRoleType>> policiesPanel = new ListView<PrismObject<AbstractRoleType>>(ID_POLICIES_CONTAINER, policiesListModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<PrismObject<AbstractRoleType>> listItem) {
            PrismObject<AbstractRoleType> abstractRole = listItem.getModelObject();
            CheckBoxPanel policyCheckBox = new CheckBoxPanel(ID_POLICY_CHECK_BOX, getCheckboxModel(abstractRole), // label
            Model.of(WebComponentUtil.getDisplayNameOrName(abstractRole)), // tooltip
            null) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onUpdate(AjaxRequestTarget target) {
                    onPolicyAddedOrRemoved(listItem.getModelObject(), getValue());
                }
            };
            policyCheckBox.setOutputMarkupId(true);
            listItem.add(policyCheckBox);
        }
    };
    policiesPanel.setOutputMarkupId(true);
    add(policiesPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) ListItem(org.apache.wicket.markup.html.list.ListItem) CheckBoxPanel(com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel)

Example 35 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class PageAbout method initLayout.

private void initLayout() {
    Label branch = new Label(ID_BRANCH, createStringResource("midpoint.system.branch"));
    branch.setRenderBodyOnly(true);
    add(branch);
    Label revision = new Label(ID_BUILD, createStringResource("midpoint.system.build"));
    revision.setRenderBodyOnly(true);
    add(revision);
    Label build = new Label(ID_BUILD_TIMESTAMP, createStringResource("midpoint.system.buildTimestamp"));
    build.setRenderBodyOnly(true);
    add(build);
    ListView<SystemItem> listSystemItems = new ListView<SystemItem>(ID_LIST_SYSTEM_ITEMS, getItems()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<SystemItem> item) {
            SystemItem systemItem = item.getModelObject();
            Label property = new Label(ID_PROPERTY, systemItem.getProperty());
            property.setRenderBodyOnly(true);
            item.add(property);
            Label value = new Label(ID_VALUE, systemItem.getValue());
            value.setRenderBodyOnly(true);
            item.add(value);
        }
    };
    add(listSystemItems);
    addLabel(ID_IMPLEMENTATION_SHORT_NAME, "implementationShortName");
    addLabel(ID_IMPLEMENTATION_DESCRIPTION, "implementationDescription");
    addLabel(ID_IS_EMBEDDED, "isEmbedded");
    addLabel(ID_DRIVER_SHORT_NAME, "driverShortName");
    addLabel(ID_DRIVER_VERSION, "driverVersion");
    addLabel(ID_REPOSITORY_URL, "repositoryUrl");
    ListView<LabeledString> additionalDetails = new ListView<LabeledString>(ID_ADDITIONAL_DETAILS, new PropertyModel<>(repoDiagModel, "additionalDetails")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<LabeledString> item) {
            LabeledString labeledString = item.getModelObject();
            Label property = new Label(ID_DETAIL_NAME, labeledString.getLabel());
            property.setRenderBodyOnly(true);
            item.add(property);
            Label value = new Label(ID_DETAIL_VALUE, labeledString.getData());
            value.setRenderBodyOnly(true);
            item.add(value);
        }
    };
    add(additionalDetails);
    ListView<LabeledString> provisioningAdditionalDetails = new ListView<LabeledString>(ID_PROVISIONING_ADDITIONAL_DETAILS, new PropertyModel<>(provisioningDiagModel, "additionalDetails")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<LabeledString> item) {
            LabeledString labeledString = item.getModelObject();
            Label property = new Label(ID_PROVISIONING_DETAIL_NAME, labeledString.getLabel());
            property.setRenderBodyOnly(true);
            item.add(property);
            Label value = new Label(ID_PROVISIONING_DETAIL_VALUE, labeledString.getData());
            value.setRenderBodyOnly(true);
            item.add(value);
        }
    };
    add(provisioningAdditionalDetails);
    String nodeId = getTaskManager().getNodeId();
    OperationResult result = new OperationResult(OPERATION_LOAD_NODE);
    List<PrismObject<NodeType>> nodes = WebModelServiceUtils.searchObjects(NodeType.class, getPrismContext().queryFor(NodeType.class).item(NodeType.F_NODE_IDENTIFIER).eq(nodeId).build(), result, PageAbout.this);
    if (nodes.isEmpty()) {
        throw new IllegalArgumentException("Couldn't find NodeType with identifier '" + nodeId + "'");
    }
    if (nodes.size() > 1) {
        throw new IllegalArgumentException("Found more as one NodeType with identifier '" + nodeId + "'");
    }
    PrismObject<NodeType> node = nodes.get(0);
    if (node == null) {
        throw new IllegalArgumentException("Found NodeType with identifier '" + nodeId + "' is null");
    }
    NodeType nodeType = node.asObjectable();
    Label nodeName = new Label(ID_NODE_NAME, nodeType.getName() != null ? nodeType.getName() : "");
    nodeName.setRenderBodyOnly(true);
    add(nodeName);
    Label nodeIdValue = new Label(ID_NODE_ID, nodeType.getNodeIdentifier());
    nodeIdValue.setRenderBodyOnly(true);
    add(nodeIdValue);
    Label nodeUrl = new Label(ID_NODE_URL, nodeType.getUrl() != null ? nodeType.getUrl() : "");
    nodeUrl.setRenderBodyOnly(true);
    add(nodeUrl);
    Label jvmProperties = new Label(ID_JVM_PROPERTIES, new LoadableModel<String>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String load() {
            try {
                RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
                List<String> arguments = runtimeMxBean.getInputArguments();
                return StringUtils.join(arguments, "<br/>");
            } catch (Exception ex) {
                return PageAbout.this.getString("PageAbout.message.couldntObtainJvmParams");
            }
        }
    });
    jvmProperties.setEscapeModelStrings(false);
    add(jvmProperties);
    initButtons();
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LabeledString(com.evolveum.midpoint.schema.LabeledString) RuntimeMXBean(java.lang.management.RuntimeMXBean) RestartResponseException(org.apache.wicket.RestartResponseException) PrismObject(com.evolveum.midpoint.prism.PrismObject) ListView(org.apache.wicket.markup.html.list.ListView) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) List(java.util.List) ArrayList(java.util.ArrayList) ListItem(org.apache.wicket.markup.html.list.ListItem) LabeledString(com.evolveum.midpoint.schema.LabeledString)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)127 ListView (org.apache.wicket.markup.html.list.ListView)103 Label (org.apache.wicket.markup.html.basic.Label)79 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)70 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)69 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 IModel (org.apache.wicket.model.IModel)40 List (java.util.List)38 ArrayList (java.util.ArrayList)37 PropertyModel (org.apache.wicket.model.PropertyModel)28 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)23 TextField (org.apache.wicket.markup.html.form.TextField)15 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)14 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)14 QName (javax.xml.namespace.QName)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10