Search in sources :

Example 1 with ToggleIconButton

use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.

the class PrismHeaderPanel method initLayout.

private void initLayout(final IModel model) {
    VisibleEnableBehaviour buttonsVisibleBehaviour = new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return PrismHeaderPanel.this.isButtonsVisible();
        }
    };
    ToggleIconButton showMetadataButton = new ToggleIconButton(ID_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setShowMetadata(!objectWrapper.isShowMetadata());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isShowMetadata();
        }
    };
    showMetadataButton.add(new AttributeModifier("title", getObjectWrapper(model) == null ? "" : (getObjectWrapper(model).isShowMetadata() ? createStringResource("PrismObjectPanel.hideMetadata") : createStringResource("PrismObjectPanel.showMetadata"))));
    showMetadataButton.add(buttonsVisibleBehaviour);
    add(showMetadataButton);
    ToggleIconButton showEmptyFieldsButton = new ToggleIconButton(ID_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_NOT_SHOW_EMPTY_FIELDS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setShowEmpty(!objectWrapper.isShowEmpty());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isShowEmpty();
        }
    };
    showEmptyFieldsButton.setMarkupId(ID_SHOW_EMPTY_FIELDS);
    showEmptyFieldsButton.add(buttonsVisibleBehaviour);
    add(showEmptyFieldsButton);
    ToggleIconButton sortPropertiesButton = new ToggleIconButton(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setSorted(!objectWrapper.isSorted());
            objectWrapper.sort((PageBase) getPage());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isSorted();
        }
    };
    sortPropertiesButton.add(buttonsVisibleBehaviour);
    add(sortPropertiesButton);
    IModel<String> headerLabelModel = new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            Object wrapper = model.getObject();
            String displayName = null;
            if (wrapper instanceof ContainerWrapper) {
                displayName = ((ContainerWrapper) wrapper).getDisplayName();
            } else if (wrapper instanceof ObjectWrapper) {
                // HACK HACK HACK
                // If we would display label for the object itself, display label for main container instead
                // the "object label" is actually displayed in front of main container
                ContainerWrapper mainContainerWrapper = ((ObjectWrapper) wrapper).findMainContainerWrapper();
                if (mainContainerWrapper != null) {
                    displayName = mainContainerWrapper.getDisplayName();
                } else {
                    // e.g. resource wizard needs this
                    displayName = ((ObjectWrapper) wrapper).getDisplayName();
                }
            }
            return getString(displayName, null, displayName);
        }
    };
    add(new Label(ID_LABEL, headerLabelModel));
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 2 with ToggleIconButton

use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.

the class CheckTableHeader method initLayout.

private void initLayout() {
    AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, new PropertyModel<Boolean>(getModel(), ObjectWrapper.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    add(check);
    Label icon = new Label(ID_ICON);
    icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return "check-table-header-icon " + createAccountIcon();
        }
    }));
    add(icon);
    Label trigger = new Label(ID_TRIGGER);
    trigger.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return createTriggerTooltip();
        }
    }));
    trigger.add(new TooltipBehavior());
    trigger.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasTriggers();
        }
    });
    add(trigger);
    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"), new Model<>(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    add(link);
    Label name = new Label(ID_NAME, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDisplayName();
        }
    });
    link.add(name);
    Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDescription();
        }
    });
    add(description);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !CheckTableHeader.this.getModelObject().isMinimalized();
        }
    };
    add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) Label(org.apache.wicket.markup.html.basic.Label) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 3 with ToggleIconButton

use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.

the class DelegationEditorPanel method initHeaderRow.

@Override
protected void initHeaderRow() {
    if (delegatedToMe) {
        privilegesListModel = new LoadableModel<List<AssignmentsPreviewDto>>(false) {

            @Override
            protected List<AssignmentsPreviewDto> load() {
                return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
            }
        };
    }
    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    selected.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(selected);
    Label arrowIcon = new Label(ID_ARROW_ICON);
    headerRow.add(arrowIcon);
    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
    headerRow.add(typeImage);
    AjaxLink name = new AjaxLink(ID_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);
    Label nameLabel;
    if (delegatedToMe) {
        OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
        Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
        nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils.resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
    } else {
        nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    }
    nameLabel.setOutputMarkupId(true);
    name.add(nameLabel);
    AssignmentEditorDto dto = getModelObject();
    dto.getTargetRef();
    WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
    if (delegatedToMe) {
        delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
    } else {
        if (getModelObject().getDelegationOwner() != null) {
            delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
        }
    }
    headerRow.add(delegatedToTypeImage);
    AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(delegatedToName);
    Label delegatedToNameLabel;
    if (delegatedToMe) {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    } else {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
    }
    delegatedToNameLabel.setOutputMarkupId(true);
    delegatedToName.add(delegatedToNameLabel);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !DelegationEditorPanel.this.getModelObject().isMinimized();
        }
    };
    headerRow.add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) Task(com.evolveum.midpoint.task.api.Task) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 4 with ToggleIconButton

use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.

the class AssignmentEditorPanel method initHeaderRow.

protected void initHeaderRow() {
    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        // do we want to update something?
        }
    };
    selected.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(selected);
    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
    headerRow.add(typeImage);
    Label errorIcon = new Label(ID_ERROR_ICON);
    errorIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isTargetValid();
        }
    });
    headerRow.add(errorIcon);
    AjaxLink name = new AjaxLink(ID_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);
    AjaxLink errorLink = new AjaxLink(ID_BUTTON_SHOW_MORE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showErrorPerformed(target);
        }
    };
    errorLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isTargetValid();
        }
    });
    headerRow.add(errorLink);
    Label nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel(false));
    nameLabel.setOutputMarkupId(true);
    name.add(nameLabel);
    Label activation = new Label(ID_ACTIVATION, createActivationModel());
    headerRow.add(activation);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !AssignmentEditorPanel.this.getModelObject().isMinimized();
        }
    };
    expandButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(expandButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

ToggleIconButton (com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 Label (org.apache.wicket.markup.html.basic.Label)4 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)3 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 BootstrapLabel (com.evolveum.midpoint.web.component.BootstrapLabel)1 PageUser (com.evolveum.midpoint.web.page.admin.users.PageUser)1 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AttributeModifier (org.apache.wicket.AttributeModifier)1