Search in sources :

Example 1 with ImagePanel

use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.

the class SceneItemLinePanel method initLayout.

private void initLayout() {
    WebMarkupContainer nameCell = new WebMarkupContainer(ID_NAME_CONTAINER);
    nameCell.add(new AttributeModifier("rowspan", new PropertyModel<Integer>(getModel(), SceneItemLineDto.F_NUMBER_OF_LINES)));
    Label label = new Label(ID_NAME, createStringResource("${name}", getModel()));
    nameCell.add(label);
    nameCell.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isFirst();
        }
    });
    add(nameCell);
    WebMarkupContainer oldValueCell = new WebMarkupContainer(ID_OLD_VALUE_CONTAINER);
    oldValueCell.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isNullEstimatedOldValues() || getModelObject().isDelta();
        }
    });
    Component sivp;
    if (getModelObject().isNullEstimatedOldValues()) {
        sivp = new Label(ID_OLD_VALUE, createStringResource("SceneItemLinePanel.unknownLabel"));
    } else {
        sivp = new SceneItemValuePanel(ID_OLD_VALUE, new PropertyModel<>(getModel(), SceneItemLineDto.F_OLD_VALUE));
    }
    sivp.setRenderBodyOnly(true);
    oldValueCell.add(sivp);
    ImagePanel oldValueImagePanel = new ImagePanel(ID_OLD_VALUE_IMAGE, Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER), createStringResource("SceneItemLinePanel.removedValue"));
    oldValueImagePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getOldValue() != null && getModelObject().getOldValue().getSourceValue() != null && !getModelObject().isNullEstimatedOldValues();
        }
    });
    oldValueCell.add(oldValueImagePanel);
    add(oldValueCell);
    IModel<String> newValueIconModel;
    IModel<String> newValueTitleModel;
    if (getModelObject().isNullEstimatedOldValues()) {
        if (getModelObject().isAdd()) {
            newValueIconModel = Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
            newValueTitleModel = createStringResource("SceneItemLinePanel.addedValue");
        } else if (getModelObject().isDelete()) {
            newValueIconModel = Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER);
            newValueTitleModel = createStringResource("SceneItemLinePanel.removedValue");
        } else if (getModelObject().isReplace()) {
            newValueIconModel = Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL);
            newValueTitleModel = createStringResource("SceneItemLinePanel.unchangedValue");
        } else {
            newValueIconModel = Model.of("");
            newValueTitleModel = Model.of("");
        }
    } else {
        if (getModelObject().isDescriptive()) {
            newValueIconModel = Model.of("");
            newValueTitleModel = Model.of("");
        } else {
            newValueIconModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ? Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) : Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
            newValueTitleModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ? createStringResource("SceneItemLinePanel.unchangedValue") : createStringResource("SceneItemLinePanel.addedValue");
        }
    }
    WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
    sivp = new SceneItemValuePanel(ID_NEW_VALUE, new PropertyModel<>(getModel(), SceneItemLineDto.F_NEW_VALUE));
    sivp.setRenderBodyOnly(true);
    newValueCell.add(sivp);
    newValueCell.add(new AttributeModifier("colspan", new IModel<Integer>() {

        @Override
        public Integer getObject() {
            return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? 2 : 1;
        }
    }));
    newValueCell.add(new AttributeModifier("align", new IModel<String>() {

        @Override
        public String getObject() {
            return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? "center" : null;
        }
    }));
    ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE, newValueIconModel, newValueTitleModel);
    newValueImagePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getNewValue() != null && getModelObject().getNewValue().getSourceValue() != null;
        }
    });
    // newValueImagePanel.add(new AttributeAppender("style",
    // !getModelObject().isDelta() && getModelObject().isDeltaScene() ?
    // ""
    // : "float: left; margin-right: 5px;"));
    newValueCell.add(newValueImagePanel);
    add(newValueCell);
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 2 with ImagePanel

use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.

the class ApprovalProcessExecutionInformationPanel method initLayout.

protected void initLayout() {
    // TODO clean this code up!!!
    ListView<ApprovalStageExecutionInformationDto> stagesList = new ListView<ApprovalStageExecutionInformationDto>(ID_STAGES, new PropertyModel<>(getModel(), ApprovalProcessExecutionInformationDto.F_STAGES)) {

        @Override
        protected void populateItem(ListItem<ApprovalStageExecutionInformationDto> stagesListItem) {
            ApprovalProcessExecutionInformationDto process = ApprovalProcessExecutionInformationPanel.this.getModelObject();
            ApprovalStageExecutionInformationDto stage = stagesListItem.getModelObject();
            int stageNumber = stage.getStageNumber();
            int numberOfStages = process.getNumberOfStages();
            int currentStageNumber = process.getCurrentStageNumber();
            WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
            arrow.add(new VisibleBehaviour(() -> stageNumber > 1));
            stagesListItem.add(arrow);
            WebMarkupContainer currentStageMarker = new WebMarkupContainer(ID_CURRENT_STAGE_MARKER);
            currentStageMarker.add(new VisibleBehaviour(() -> stageNumber == currentStageNumber && process.isRunning()));
            stagesListItem.add(currentStageMarker);
            ListView<ApproverEngagementDto> approversList = new ListView<ApproverEngagementDto>(ID_APPROVERS, new PropertyModel<>(stagesListItem.getModel(), ApprovalStageExecutionInformationDto.F_APPROVER_ENGAGEMENTS)) {

                @Override
                protected void populateItem(ListItem<ApproverEngagementDto> approversListItem) {
                    ApproverEngagementDto ae = approversListItem.getModelObject();
                    // original approver name
                    approversListItem.add(createReferencedObjectLabel(ID_APPROVER_NAME, "ApprovalProcessExecutionInformationPanel.approver", ae.getApproverRef(), true));
                    // outcome
                    WorkItemOutcomeType outcome = ae.getOutput() != null ? ApprovalUtils.fromUri(ae.getOutput().getOutcome()) : null;
                    ApprovalOutcomeIcon outcomeIcon;
                    if (outcome != null) {
                        switch(outcome) {
                            case APPROVE:
                                outcomeIcon = ApprovalOutcomeIcon.APPROVED;
                                break;
                            case REJECT:
                                outcomeIcon = ApprovalOutcomeIcon.REJECTED;
                                break;
                            // perhaps should throw AssertionError instead
                            default:
                                outcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
                                break;
                        }
                    } else {
                        if (stageNumber < currentStageNumber) {
                            // history: do not show anything for work items with no outcome
                            outcomeIcon = ApprovalOutcomeIcon.EMPTY;
                        } else if (stageNumber == currentStageNumber) {
                            outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
                            ApprovalOutcomeIcon.CANCELLED;
                        } else {
                            outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
                        }
                    }
                    ImagePanel outcomePanel = new ImagePanel(ID_OUTCOME, Model.of(outcomeIcon.getIcon()), Model.of(getString(outcomeIcon.getTitle())));
                    outcomePanel.add(new VisibleBehaviour(() -> outcomeIcon != ApprovalOutcomeIcon.EMPTY));
                    approversListItem.add(outcomePanel);
                    // content (incl. performer)
                    WebMarkupContainer approvalBoxContent = new WebMarkupContainer(ID_APPROVAL_BOX_CONTENT);
                    approversListItem.add(approvalBoxContent);
                    approvalBoxContent.setVisible(performerVisible(ae) || attorneyVisible(ae));
                    approvalBoxContent.add(createReferencedObjectLabel(ID_PERFORMER_NAME, "ApprovalProcessExecutionInformationPanel.performer", ae.getCompletedBy(), performerVisible(ae)));
                    approvalBoxContent.add(createReferencedObjectLabel(ID_ATTORNEY_NAME, "ApprovalProcessExecutionInformationPanel.attorney", ae.getAttorney(), attorneyVisible(ae)));
                    // junction
                    // or "+" for first decides? probably not
                    Label junctionLabel = new Label(ID_JUNCTION, stage.isFirstDecides() ? "" : " & ");
                    // not showing "" to save space (if aligned vertically)
                    junctionLabel.setVisible(!stage.isFirstDecides() && !ae.isLast());
                    approversListItem.add(junctionLabel);
                }
            };
            approversList.setVisible(stage.getAutomatedCompletionReason() == null);
            stagesListItem.add(approversList);
            String autoCompletionKey;
            if (stage.getAutomatedCompletionReason() != null) {
                switch(stage.getAutomatedCompletionReason()) {
                    case AUTO_COMPLETION_CONDITION:
                        autoCompletionKey = "DecisionDto.AUTO_COMPLETION_CONDITION";
                        break;
                    case NO_ASSIGNEES_FOUND:
                        autoCompletionKey = "DecisionDto.NO_ASSIGNEES_FOUND";
                        break;
                    // or throw an exception?
                    default:
                        autoCompletionKey = null;
                }
            } else {
                autoCompletionKey = null;
            }
            Label automatedOutcomeLabel = new Label(ID_AUTOMATED_OUTCOME, autoCompletionKey != null ? getString(autoCompletionKey) : "");
            automatedOutcomeLabel.setVisible(stage.getAutomatedCompletionReason() != null);
            stagesListItem.add(automatedOutcomeLabel);
            stagesListItem.add(new Label(ID_STAGE_NAME, getStageNameLabel(stage, stageNumber, numberOfStages)));
            ApprovalLevelOutcomeType stageOutcome = stage.getOutcome();
            ApprovalOutcomeIcon stageOutcomeIcon;
            if (stageOutcome != null) {
                switch(stageOutcome) {
                    case APPROVE:
                        stageOutcomeIcon = ApprovalOutcomeIcon.APPROVED;
                        break;
                    case REJECT:
                        stageOutcomeIcon = ApprovalOutcomeIcon.REJECTED;
                        break;
                    case SKIP:
                        stageOutcomeIcon = ApprovalOutcomeIcon.SKIPPED;
                        break;
                    // perhaps should throw AssertionError instead
                    default:
                        stageOutcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
                        break;
                }
            } else {
                if (stageNumber < currentStageNumber) {
                    // history: do not show anything (shouldn't occur, as historical stages are filled in)
                    stageOutcomeIcon = ApprovalOutcomeIcon.EMPTY;
                } else if (stageNumber == currentStageNumber) {
                    stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
                    ApprovalOutcomeIcon.CANCELLED;
                } else {
                    stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
                }
            }
            ImagePanel stageOutcomePanel = new ImagePanel(ID_STAGE_OUTCOME, Model.of(stageOutcomeIcon.getIcon()), Model.of(getString(stageOutcomeIcon.getTitle())));
            stageOutcomePanel.add(new VisibleBehaviour(() -> stageOutcomeIcon != ApprovalOutcomeIcon.EMPTY));
            stagesListItem.add(stageOutcomePanel);
        }
    };
    add(stagesList);
}
Also used : ApproverEngagementDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ApproverEngagementDto) ApprovalStageExecutionInformationDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalStageExecutionInformationDto) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ApprovalProcessExecutionInformationDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto) ListView(org.apache.wicket.markup.html.list.ListView) ApprovalLevelOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalLevelOutcomeType) WorkItemOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemOutcomeType) ApprovalOutcomeIcon(com.evolveum.midpoint.web.page.admin.server.dto.ApprovalOutcomeIcon) ListItem(org.apache.wicket.markup.html.list.ListItem) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 3 with ImagePanel

use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.

the class LinkedReferencePanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return null;
        }
        DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
        if (displayType == null) {
            displayType = new DisplayType();
        }
        if (displayType.getIcon() == null) {
            displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
        }
        return displayType;
    });
    ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
    imagePanel.setOutputMarkupId(true);
    add(imagePanel);
    AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
        }
    };
    nameLink.add(new EnableBehaviour(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return false;
        }
        return ref.getObject() != null;
    }));
    nameLink.setOutputMarkupId(true);
    add(nameLink);
    Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return "";
        }
        return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
    }));
    nameLinkText.setOutputMarkupId(true);
    nameLink.add(nameLinkText);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 4 with ImagePanel

use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.

the class SceneItemValuePanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return hasValidReferenceValue(object);
        }
    };
    final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return !hasValidReferenceValue(object);
        }
    };
    IModel<DisplayType> displayModel = (IModel) () -> {
        ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor();
        String cssClass = ObjectTypeGuiDescriptor.ERROR_ICON;
        String title = null;
        if (guiDescriptor != null) {
            cssClass = guiDescriptor.getBlackIcon();
            title = createStringResource(guiDescriptor.getLocalizationKey()).getObject();
        }
        return GuiDisplayTypeUtil.createDisplayType(cssClass, "", title);
    };
    final ImagePanel icon = new ImagePanel(ID_ICON, displayModel);
    icon.add(visibleIfReference);
    add(icon);
    final Label label = new Label(ID_LABEL, new LabelModel());
    label.add(visibleIfNotReference);
    add(label);
    final AjaxLinkPanel link = new AjaxLinkPanel(ID_LINK, new LabelModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
                return;
            }
            PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
            if (refValue == null) {
                return;
            }
            ObjectReferenceType ort = new ObjectReferenceType();
            ort.setupReferenceValue(refValue);
            WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
        }
    };
    link.add(visibleIfReference);
    add(link);
    final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new IModel<String>() {

        @Override
        public String getObject() {
            return getModelObject() != null ? getModelObject().getAdditionalText() : null;
        }
    });
    add(additionalText);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) IModel(org.apache.wicket.model.IModel) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Aggregations

ImagePanel (com.evolveum.midpoint.web.component.data.column.ImagePanel)4 Label (org.apache.wicket.markup.html.basic.Label)4 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IModel (org.apache.wicket.model.IModel)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 SceneItemValue (com.evolveum.midpoint.model.api.visualizer.SceneItemValue)1 AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)1 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 ApprovalOutcomeIcon (com.evolveum.midpoint.web.page.admin.server.dto.ApprovalOutcomeIcon)1 ApprovalProcessExecutionInformationDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto)1 ApprovalStageExecutionInformationDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalStageExecutionInformationDto)1 ApproverEngagementDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ApproverEngagementDto)1 ObjectTypeGuiDescriptor (com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)1 ApprovalLevelOutcomeType (com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalLevelOutcomeType)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1