Search in sources :

Example 21 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class ObjectPolicyPanel method createObjectTemplateList.

protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
    return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {

        @Override
        public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
            List<PrismObject<ObjectTemplateType>> templateList = null;
            List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
            OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            try {
                templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
                result.recomputeStatus();
            } catch (Exception e) {
                result.recordFatalError("Could not get list of object templates", e);
                LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
            // TODO - show this error in GUI
            }
            if (templateList != null) {
                ObjectTemplateType template;
                for (PrismObject<ObjectTemplateType> obj : templateList) {
                    template = obj.asObjectable();
                    list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
                }
            }
            return list;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 22 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class ProfilingConfigPanel method createAppendersListModel.

private IModel<List<String>> createAppendersListModel() {
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> list = new ArrayList<>();
            ProfilingDto dto = getModel().getObject();
            for (AppenderConfiguration appender : dto.getAppenders()) {
                list.add(appender.getName());
            }
            return list;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AppenderConfiguration(com.evolveum.midpoint.web.page.admin.configuration.dto.AppenderConfiguration) ProfilingDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ProfilingDto) ArrayList(java.util.ArrayList)

Example 23 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class H3Header method initLayout.

@Override
protected void initLayout() {
    Label title = new Label(ID_TITLE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getDisplayName();
        }
    });
    add(title);
    final IModel<List<InlineMenuItem>> items = new Model((Serializable) createMenuItems());
    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("H3Header.label.error"), new Model(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) Label(org.apache.wicket.markup.html.basic.Label) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) List(java.util.List) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 24 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class PrismOptionButtonPanel method initButtons.

private void initButtons(final IModel<ObjectWrapper> model) {
    AjaxLink showEmpty = new AjaxLink("showEmptyButton") {

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

        @Override
        public boolean isVisible() {
            return !model.getObject().isReadonly();
        }
    });
    Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
        }
    });
    showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return getString("prismOptionButtonPanel.hideEmpty");
            }
            return getString("prismOptionButtonPanel.showEmpty");
        }
    }, ""));
    showEmpty.add(showEmptyImg);
    AjaxLink minimize = new AjaxLink("minimizeButton") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            minimizeOnClick(target);
        }
    };
    add(minimize);
    Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
        }
    });
    minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return getString("prismOptionButtonPanel.maximize");
            }
            return getString("prismOptionButtonPanel.minimize");
        }
    }, ""));
    minimize.add(minimizeImg);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Image(org.apache.wicket.markup.html.image.Image) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 25 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project ocvn by devgateway.

the class BootstrapPagingNavigation method populateItem.

@Override
protected void populateItem(final LoopItem loopItem) {
    super.populateItem(loopItem);
    final long pageIndex = getStartIndex() + loopItem.getIndex();
    // Add disabled class to enclosing list item.
    loopItem.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (pageable.getCurrentPage() == pageIndex) {
                return "active";
            } else {
                return "";
            }
        }
    }));
// Do not mask disabled link by em tag.
// ((AbstractLink)
// loopItem.get("pageLink")).setBeforeDisabledLink("").setAfterDisabledLink("");
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AttributeModifier(org.apache.wicket.AttributeModifier)

Aggregations

AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)52 ArrayList (java.util.ArrayList)22 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)22 Label (org.apache.wicket.markup.html.basic.Label)21 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)20 List (java.util.List)16 ListItem (org.apache.wicket.markup.html.list.ListItem)12 ListView (org.apache.wicket.markup.html.list.ListView)12 IModel (org.apache.wicket.model.IModel)12 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 PropertyModel (org.apache.wicket.model.PropertyModel)8 AttributeModifier (org.apache.wicket.AttributeModifier)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 Model (org.apache.wicket.model.Model)6 Task (com.evolveum.midpoint.task.api.Task)5 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 TooltipBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior)4