Example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

Introduction

In this page you can find the example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel.

Prototype

AbstractReadOnlyModel

Source Link

Usage

From source file:com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb.java

License:Apache License

public IModel<String> getLabel() {
    if (labelModel == null && label != null) {
        labelModel = new AbstractReadOnlyModel<String>() {
            private static final long serialVersionUID = 1L;

            @Override/*from w  w  w .j  a  v a2s .c o  m*/
            public String getObject() {
                return label;
            }
        };
    }
    return labelModel;
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb.java

License:Apache License

public void setLabel(final IModel<String> label) {
    if (label == null) {
        this.labelModel = null;
        return;// ww w.  j a va2  s .c om
    }

    this.labelModel = new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            try {
                return label.getObject();
            } catch (Exception ex) {
                LOG.warn("Couldn't load breadcrumb model value", ex);
                return null;
            }
        }

        @Override
        public void detach() {
            super.detach();
            Breadcrumb.this.label = label.getObject();
            Breadcrumb.this.labelModel = null;
        }

    };
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb.java

License:Apache License

public IModel<String> getIcon() {
    if (iconModel == null && icon != null) {
        iconModel = new AbstractReadOnlyModel<String>() {
            private static final long serialVersionUID = 1L;

            @Override//from   w w  w . j a  v  a2  s. c  om
            public String getObject() {
                return icon;
            }
        };
    }
    return iconModel;
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb.java

License:Apache License

public void setIcon(final IModel<String> icon) {
    if (icon == null) {
        this.iconModel = null;
        return;// w  w  w  . ja va 2s  .  c  o m
    }

    this.iconModel = new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            try {
                return icon.getObject();
            } catch (Exception ex) {
                LOG.warn("Couldn't load breadcrumb model value", ex);
                return null;
            }
        }

        @Override
        public void detach() {
            super.detach();
            Breadcrumb.this.icon = icon.getObject();
            Breadcrumb.this.iconModel = null;
        }

    };
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb.java

License:Apache License

private <T extends Serializable> IModel<T> wrapModel(final IModel<T> model) {
    if (model == null) {
        return null;
    }/*ww w .  java2 s .  c o m*/

    return new AbstractReadOnlyModel<T>() {

        @Override
        public T getObject() {
            try {
                return model.getObject();
            } catch (Exception ex) {
                LOG.warn("Couldn't load breadcrumb model value", ex);
                return null;
            }
        }

        @Override
        public void detach() {
            super.detach();
            model.getObject();
        }

    };
}

From source file:com.evolveum.midpoint.web.component.data.BoxedTablePanel.java

License:Apache License

private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, int pageSize) {
    setOutputMarkupId(true);/* w  ww. ja  v a2 s . co m*/
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    box.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String boxCssClasses = getAdditionalBoxCssClasses();
            if (boxCssClasses == null) {
                return "";
            } else {
                return " " + boxCssClasses;
            }
        }
    }));
    add(box);

    WebMarkupContainer tableContainer = new WebMarkupContainer(ID_TABLE_CONTAINER);
    tableContainer.setOutputMarkupId(true);

    DataTable<T, String> table = new SelectableDataTable<T>(ID_TABLE, columns, provider, pageSize) {
        @Override
        protected Item<T> newRowItem(String id, int index, IModel<T> rowModel) {
            Item<T> item = super.newRowItem(id, index, rowModel);
            return customizeNewRowItem(item, rowModel);
        }
    };
    table.setOutputMarkupId(true);
    tableContainer.add(table);
    box.add(tableContainer);

    TableHeadersToolbar headersTop = new TableHeadersToolbar(table, provider);
    headersTop.setOutputMarkupId(true);
    table.addTopToolbar(headersTop);

    box.add(createHeader(ID_HEADER));
    box.add(createFooter(ID_FOOTER));
}

From source file:com.evolveum.midpoint.web.component.data.column.ColumnUtils.java

License:Apache License

private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getEmptyIconColumn() {
    return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
        private static final long serialVersionUID = 1L;

        @Override//from  w  w  w  .  j  a v a  2  s  .  c  om
        protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
            return new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return "";
                }
            };
        }
    };
}

From source file:com.evolveum.midpoint.web.component.data.column.ColumnUtils.java

License:Apache License

private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getDefaultIcons() {
    return new IconColumn<SelectableBean<T>>(createStringResource("userBrowserDialog.type")) {

        @Override/*from www. j  av  a2s.  c om*/
        protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
            return new AbstractReadOnlyModel() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    T object = rowModel.getObject().getValue();
                    return WebComponentUtil.createDefaultIcon(object.asPrismObject());
                }
            };

        }
    };
}

From source file:com.evolveum.midpoint.web.component.data.column.ColumnUtils.java

License:Apache License

private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getUserIconColumn() {
    return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
        private static final long serialVersionUID = 1L;

        @Override//from   w  ww.  ja v a  2s .c  o m
        protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
            return new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    T user = rowModel.getObject().getValue();
                    return WebComponentUtil.createUserIcon(user.asPrismContainer());
                }
            };
        }

        @Override
        protected IModel<String> createTitleModel(final IModel<SelectableBean<T>> rowModel) {

            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    T user = rowModel.getObject().getValue();
                    String iconClass = WebComponentUtil.createUserIcon(user.asPrismContainer());
                    String compareStringValue = GuiStyleConstants.CLASS_OBJECT_USER_ICON + " "
                            + GuiStyleConstants.CLASS_ICON_STYLE;
                    String titleValue = "";
                    if (iconClass != null && iconClass.startsWith(compareStringValue)
                            && iconClass.length() > compareStringValue.length()) {
                        titleValue = iconClass.substring(compareStringValue.length());
                    }
                    return createStringResource(
                            "ColumnUtils.getUserIconColumn.createTitleModel." + titleValue) == null
                                    ? ""
                                    : createStringResource(
                                            "ColumnUtils.getUserIconColumn.createTitleModel." + titleValue)
                                                    .getString();
                }
            };
        }

    };
}

From source file:com.evolveum.midpoint.web.component.data.column.ColumnUtils.java

License:Apache License

public static <T extends ObjectType> IColumn<SelectableBean<T>, String> getShadowIconColumn() {
    return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
        private static final long serialVersionUID = 1L;

        @Override//from  w w  w  .  jav a  2 s . c om
        protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
            return new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    T shadow = rowModel.getObject().getValue();
                    if (shadow == null) {
                        return WebComponentUtil.createErrorIcon(rowModel.getObject().getResult());
                    } else {
                        return WebComponentUtil.createShadowIcon(shadow.asPrismContainer());
                    }
                }
            };
        }
    };
}