Helper method for creating a list item widget based on a bean.<p>

@param brokenLinkBean the bean with the data for the list item widget

@return the new list item widget
490726
protected CmsListItemWidget createListItemWidget(CmsBrokenLinkBean brokenLinkBean) {

        CmsListInfoBean info = new CmsListInfoBean();
        String title = brokenLinkBean.getTitle();
        if ((title == null) || title.equals("")) {
            title = Messages.get().key(Messages.GUI_BROKEN_LINK_NO_TITLE_0);
        }
        info.setTitle(title);
        info.setSubTitle(brokenLinkBean.getSubTitle());
        String type = brokenLinkBean.getType();
        if (type != null) {
            info.setResourceType(type);
        }
        for (Map.Entry<String, String> entry : brokenLinkBean.getInfo().entrySet()) {
            info.addAdditionalInfo(entry.getKey(), entry.getValue());
        }
        final CmsListItemWidget widget = new CmsListItemWidget(info);
        widget.addAttachHandler(new AttachEvent.Handler() {

            public void onAttachOrDetach(AttachEvent event) {

                if (event.isAttached()) {
                    widget.truncateAdditionalInfo("addinfo", widget.getOffsetWidth());
                }
            }
        });
        return widget;
    }
795059
public void setLinkBean(CmsLinkBean link) {

        if (link == null) {
            link = new CmsLinkBean("", true);
        }
        m_textbox.setFormValueAsString(link.getLink());
        setInternal(link.isInternal());
    }
691426
protected void displayBrokenLinks(CmsDeleteResourceBean brokenLinks) {

        CmsListItemWidget widget = new CmsListItemWidget(brokenLinks.getPageInfo());
        widget.truncate(TM_DIALOG_LIST, 370);
        addTopWidget(widget);
        if (brokenLinks.getBrokenLinks().size() > 0) {
            m_content.fill(brokenLinks.getBrokenLinks());
            addBottomWidget(m_content);
        }
        center();
    }
270176
private CmsCreatableListItem makeNewElementItem(final CmsNewResourceInfo typeInfo) {

        CmsListItemWidget widget = new CmsListItemWidget(typeInfo);
        if ((typeInfo.getDescription() != null) && (typeInfo.getDescription().trim().length() > 0)) {
            widget.addAdditionalInfo(
                new CmsAdditionalInfoBean(
                    Messages.get().key(Messages.GUI_LABEL_DESCRIPTION_0),
                    typeInfo.getDescription(),
                    null));
        }
        if (typeInfo.getVfsPath() != null) {
            widget.addAdditionalInfo(
                new CmsAdditionalInfoBean(
                    Messages.get().key(Messages.GUI_LABEL_VFSPATH_0),
                    typeInfo.getVfsPath(),
                    null));
        }
        if (typeInfo.getDate() != null) {
            widget.addAdditionalInfo(
                new CmsAdditionalInfoBean(Messages.get().key(Messages.GUI_LABEL_DATE_0), typeInfo.getDate(), null));
        }
        CmsCreatableListItem listItem = new CmsCreatableListItem(widget, typeInfo, NewEntryType.regular);
        listItem.initMoveHandle(CmsSitemapView.getInstance().getTree().getDnDHandler(), true);
        return listItem;
    }
165394
private static String getMessage(Collection<Object> brokenReferences) {
        StringBuilder sb = new StringBuilder();
        for (Object o : brokenReferences) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(o);
        }
        return "Unable to resolve reference to bean [" + sb.toString() + "]";
    }
596474
private CmsSitemapEntryBean convertNavigationTreeToBean(CmsObject cms, NavigationNode node, boolean isRoot) {

        CmsSitemapEntryBean bean = null;
        try {
            bean = prepareSitemapEntry(cms, node.getNavElement(), isRoot, false);
            bean.setSearchMatch(node.isMatch());
            List<NavigationNode> children = node.getChildren();
            List<CmsSitemapEntryBean> childBeans = Lists.newArrayList();
            if (children.size() > 0) {
                for (NavigationNode child : children) {
                    childBeans.add(convertNavigationTreeToBean(cms, child, false));
                }
            } else if (node.isLeaf()) {
                childBeans = Lists.newArrayList();
            } else {
                // no children in filter result, but can still load children by clicking on tree item
                childBeans = null;
            }
            bean.setChildren(childBeans);

        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return bean;
    }
125433
private CmsListItemWidget createListWidget(CmsGalleryFolderEntry galleryFolder) {

        String title;
        if (galleryFolder.getOwnProperties().containsKey(CmsClientProperty.PROPERTY_TITLE)) {
            title = galleryFolder.getOwnProperties().get(CmsClientProperty.PROPERTY_TITLE).getStructureValue();
        } else {
            title = CmsResource.getName(galleryFolder.getSitePath());
            if (title.endsWith("/")) {
                title = title.substring(0, title.length() - 1);
            }
        }
        CmsListInfoBean infoBean = new CmsListInfoBean(title, galleryFolder.getSitePath(), null);
        CmsListItemWidget result = new CmsGalleryListItemWidget(infoBean);
        result.setIcon(galleryFolder.getIconClasses());
        result.addIconClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {

                CmsSitemapView.getInstance().getController().loadPath(
                    getSitePath(),
                    new AsyncCallback<CmsClientSitemapEntry>() {

                        public void onFailure(Throwable caught) {

                            // nothing to do

                        }

                        public void onSuccess(CmsClientSitemapEntry entry) {

                            showGallery(entry);
                        }
                    });
            }
        });
        if ((CmsSitemapView.getInstance().getController().getEntryById(galleryFolder.getStructureId()) == null)
            || CmsSitemapView.getInstance().getController().getEntryById(galleryFolder.getStructureId()).isEditable()) {
            result.addTitleStyleName(I_CmsSitemapLayoutBundle.INSTANCE.sitemapItemCss().itemTitle());
            result.setTitleEditable(true);
            result.setTitleEditHandler(new I_CmsTitleEditHandler() {

                /**
                 * @see org.opencms.gwt.client.ui.CmsListItemWidget.I_CmsTitleEditHandler#handleEdit(org.opencms.gwt.client.ui.input.CmsLabel, com.google.gwt.user.client.ui.TextBox)
                 */
                public void handleEdit(final CmsLabel titleLabel, final TextBox box) {

                    CmsSitemapView.getInstance().getController().loadPath(
                        getSitePath(),
                        new AsyncCallback<CmsClientSitemapEntry>() {

                            public void onFailure(Throwable caught) {

                                // nothing to do
                            }

                            public void onSuccess(CmsClientSitemapEntry editEntry) {

                                CmsGalleryTreeItem.this.handleEdit(editEntry, box.getText());
                                box.removeFromParent();
                                titleLabel.setVisible(true);
                            }
                        });
                }
            });
        }
        return result;
    }
129167
static PortComponent getPortComponentByEJBLink(String ejbLink, Adaptable containerToAdapt) throws UnableToAdaptException {
        return getHighLevelElementByServiceImplBean(ejbLink, containerToAdapt, PortComponent.class, LinkType.EJB);
    }
1065435
public List<CmsBrokenLinkBean> renderBrokenLinkInheritanceGroup(CmsResource target, CmsResource source)
    throws CmsException {

        List<CmsBrokenLinkBean> result = new ArrayList<CmsBrokenLinkBean>();
        try {
            Set<String> names = CmsInheritanceGroupUtils.getNamesOfGroupsContainingResource(m_cms, source, target);
            if (!names.isEmpty()) {
                for (String name : names) {
                    String title = null;
                    String path = null;
                    String extraTitle = null;
                    String extraPath = null;

                    CmsResource group = CmsInheritanceGroupUtils.getInheritanceGroupContentByName(m_cms, name);
                    String groupParent = CmsResource.getParentFolder(source.getRootPath());
                    CmsProperty titleProp = m_cms.readPropertyObject(
                        group,
                        CmsPropertyDefinition.PROPERTY_TITLE,
                        false);
                    title = CmsResource.getName(group.getRootPath());
                    if (!titleProp.isNullProperty()) {
                        title = titleProp.getValue();
                    }
                    path = m_cms.getRequestContext().removeSiteRoot(source.getRootPath());
                    List<CmsRelation> relations = m_cms.readRelations(
                        CmsRelationFilter.relationsToStructureId(group.getStructureId()));
                    List<CmsResource> referencingPages = new ArrayList<CmsResource>();
                    for (CmsRelation relation : relations) {
                        CmsResource relSource = relation.getSource(m_cms, CmsResourceFilter.ALL);
                        String pageParent = CmsResource.getParentFolder(relSource.getRootPath());
                        if (CmsResourceTypeXmlContainerPage.isContainerPage(relSource)
                            && pageParent.equals(groupParent)) {
                            referencingPages.add(relSource);
                        }
                    }
                    if (!referencingPages.isEmpty()) {
                        CmsResource firstPage = referencingPages.get(0);
                        extraPath = m_cms.getRequestContext().removeSiteRoot(firstPage.getRootPath());
                        extraTitle = m_cms.readPropertyObject(
                            firstPage,
                            CmsPropertyDefinition.PROPERTY_TITLE,
                            true).getValue();
                    }
                    result.add(
                        createBrokenLinkBean(
                            group.getStructureId(),
                            CmsResourceTypeXmlContainerPage.INHERIT_CONTAINER_CONFIG_TYPE_NAME,
                            title,
                            path,
                            extraTitle,
                            extraPath));
                }
            } else {
                result.add(createSitemapBrokenLinkBean(source));
            }
        } catch (CmsException e) {
            result.add(createSitemapBrokenLinkBean(source));
        }
        return result;
    }
1077893
private static DefaultListableBeanFactory createBeanFactory() {
        return new DefaultListableBeanFactory() {
            {
                final InstantiationStrategy is = getInstantiationStrategy();
                setInstantiationStrategy(new InstantiationStrategy() {
                    @Override
                    public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) throws BeansException {
                        return is.instantiate(beanDefinition, beanName, owner);
                    }

                    @Override
                    public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Constructor<?> ctor, Object[] args) throws BeansException {
                        final Object bean = is.instantiate(beanDefinition, beanName, owner, ctor, args);
                        addDependencies(bean, args);
                        return bean;
                    }

                    @Override
                    public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Object factoryBean, Method factoryMethod, Object[] args) throws BeansException {
                        final Object bean = is.instantiate(beanDefinition, beanName, owner, factoryBean, factoryMethod, args);
                        addDependencies(bean, args);
                        return bean;
                    }
                });
            }

            private void addDependencies(Object bean, Object[] args) {
                if (bean instanceof Service) {
                    for (Object arg : args) {
                        if (arg instanceof Service) {
                            ((Service) arg).addDependedBy((Service) bean);
                            ((Service) bean).addDependsOn((Service) arg);
                        }
                    }
                }
            }
        };
    }
993885
@Override
    protected <T> T instantiateClass(Class<T> clazz) throws Throwable {
        // Get the current BeanManager for this module. If one doesn't exist it is because 
        // the module isn't CDI enabled and we fall back to the original behavior.

        ManagedObject<T> mo = null;
        if (releasableFactory != null) {
            mo = releasableFactory.createValidationReleasable(clazz);
        }

        if (mo != null) {
            if (releasables == null) {
                releasables = new LinkedList<ValidationReleasable<?>>();
            }

            // Save off the context under which the class was created as a CDI managed
            // bean so it can be cleaned up upon stopping the module.
            //releasables.add(mo);

            return mo.getObject();
        } else {
            return super.instantiateClass(clazz);
        }
    }
1007041
protected CmsContextMenuEntry createRawMenuEntry(CmsUUID structureId, final Runnable action) {

        CmsContextMenuEntry entry = new CmsContextMenuEntry(this, structureId, new I_CmsContextMenuCommand() {

            public void execute(
                CmsUUID innerStructureId,
                I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                if (action != null) {
                    action.run();
                }
            }

            public A_CmsContextMenuItem getItemWidget(
                CmsUUID innerStructureId,
                I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                return null;
            }

            public boolean hasItemWidget() {

                return false;
            }

        });
        return entry;
    }
893776
static WebserviceDescription getWebserviceDescriptionByEJBLink(String ejbLink, Adaptable containerToAdapt) throws UnableToAdaptException {
        return getHighLevelElementByServiceImplBean(ejbLink, containerToAdapt, WebserviceDescription.class, LinkType.EJB);
    }
859034
public static <T> List<T> toBeanList(String text, Class<T> clazz) {
        return JSON.parseArray(text, clazz);
    }
890345
public CmsLinkBean getLinkBean() {

        String link = m_textbox.getText();
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(link)) {
            return null;
        }
        return new CmsLinkBean(m_textbox.getText(), m_internal);
    }
1201591
protected Widget getViewFromAdapter(final int index, ListItemHostWidget host) {
        return mAdapter == null ? null : mAdapter.getView(index, host.getGuest(), host);
    }
476022
private void addBrokenLinkAdditionalInfo(CmsObject cms, CmsResource resource, CmsBrokenLinkBean result) {

        String dateLastModifiedLabel = org.opencms.workplace.commons.Messages.get().getBundle(
            OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key(
                org.opencms.workplace.commons.Messages.GUI_LABEL_DATE_LAST_MODIFIED_0);
        String dateLastModified = CmsVfsService.formatDateTime(cms, resource.getDateLastModified());

        String userLastModifiedLabel = org.opencms.workplace.commons.Messages.get().getBundle(
            OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key(
                org.opencms.workplace.commons.Messages.GUI_LABEL_USER_LAST_MODIFIED_0);
        String userLastModified = "" + resource.getUserLastModified();
        try {
            userLastModified = cms.readUser(resource.getUserLastModified()).getName();
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }

        result.addInfo(dateLastModifiedLabel, dateLastModified);
        result.addInfo(userLastModifiedLabel, userLastModified);
    }