Search in sources :

Example 1 with SceneItemValue

use of com.evolveum.midpoint.model.api.visualizer.SceneItemValue 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("name", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            final SceneItemLineDto lineDto = getModel().getObject();
            if (lineDto == null || lineDto.getName() == null) {
                return null;
            }
            String key = lineDto.getName();
            return getLocalizer().getString(key, SceneItemLinePanel.this, key);
        }
    });
    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().isDelta();
        }
    });
    SceneItemValuePanel sivp = new SceneItemValuePanel(ID_OLD_VALUE, new PropertyModel<SceneItemValue>(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;
        }
    });
    oldValueCell.add(oldValueImagePanel);
    add(oldValueCell);
    WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
    sivp = new SceneItemValuePanel(ID_NEW_VALUE, new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_NEW_VALUE));
    sivp.setRenderBodyOnly(true);
    newValueCell.add(sivp);
    newValueCell.add(new AttributeModifier("colspan", new AbstractReadOnlyModel<Integer>() {

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

        @Override
        public String getObject() {
            return !getModelObject().isDelta() && getModelObject().isDeltaScene() ? "center" : null;
        }
    }));
    ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE, !getModelObject().isDelta() && getModelObject().isDeltaScene() ? Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) : Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS), !getModelObject().isDelta() && getModelObject().isDeltaScene() ? createStringResource("SceneItemLinePanel.unchangedValue") : createStringResource("SceneItemLinePanel.addedValue"));
    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; width: 30%; position: absolute;" : "float: left; margin-right: 5px;"));
    newValueCell.add(newValueImagePanel);
    add(newValueCell);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) 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) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 2 with SceneItemValue

use of com.evolveum.midpoint.model.api.visualizer.SceneItemValue 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);
        }
    };
    final ImagePanel icon = new ImagePanel(ID_ICON, new IconModel(), new TitleModel());
    icon.add(visibleIfReference);
    add(icon);
    final Label label = new Label(ID_LABEL, new LabelModel());
    label.add(visibleIfNotReference);
    add(label);
    final LinkPanel link = new LinkPanel(ID_LINK, new LabelModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
                return;
            }
            PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
            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 AbstractReadOnlyModel<String>() {

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

Aggregations

SceneItemValue (com.evolveum.midpoint.model.api.visualizer.SceneItemValue)2 ImagePanel (com.evolveum.midpoint.web.component.data.column.ImagePanel)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 Label (org.apache.wicket.markup.html.basic.Label)2 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 LinkPanel (com.evolveum.midpoint.web.component.data.column.LinkPanel)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 PropertyModel (org.apache.wicket.model.PropertyModel)1