public CmsContextMenu getContextMenuForItem(Object itemId) {

        CmsContextMenu result = null;
        try {
            final Item item = m_container.getItem(itemId);
            Property<?> keyProp = item.getItemProperty(TableProperty.KEY);
            String key = (String)keyProp.getValue();
            if ((null != key) && !key.isEmpty()) {
                loadAllRemainingLocalizations();
                final Map<Locale, String> localesWithEntries = new HashMap<Locale, String>();
                for (Locale l : m_localizations.keySet()) {
                    if (l != m_locale) {
                        String value = m_localizations.get(l).getProperty(key);
                        if ((null != value) && !value.isEmpty()) {
                            localesWithEntries.put(l, value);
                        }
                    }
                }
                if (!localesWithEntries.isEmpty()) {
                    result = new CmsContextMenu();
                    ContextMenuItem mainItem = result.addItem(
                        Messages.get().getBundle(UI.getCurrent().getLocale()).key(
                            Messages.GUI_BUNDLE_EDITOR_CONTEXT_COPY_LOCALE_0));
                    for (final Locale l : localesWithEntries.keySet()) {

                        ContextMenuItem menuItem = mainItem.addItem(l.getDisplayName(UI.getCurrent().getLocale()));
                        menuItem.addItemClickListener(new ContextMenuItemClickListener() {

                            public void contextMenuItemClicked(ContextMenuItemClickEvent event) {

                                item.getItemProperty(TableProperty.TRANSLATION).setValue(localesWithEntries.get(l));

                            }
                        });
                    }
                }
            }
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            //TODO: Improve
        }
        return result;
    }
public CmsContextMenu getContextMenuForItem ( Object itemId ) { CmsContextMenu result = null ; try { final Item item = m_container . getItem ( itemId ) ; Property < ? > keyProp = item . getItemProperty ( TableProperty . KEY ) ; String key = ( String ) keyProp . getValue ( ) ; if ( ( null != key ) && ! key . isEmpty ( ) ) { loadAllRemainingLocalizations ( ) ; final Map < Locale , String > localesWithEntries = new HashMap < Locale , String > ( ) ; for ( Locale l : m_localizations . keySet ( ) ) { if ( l != m_locale ) { String value = m_localizations . get ( l ) . getProperty ( key ) ; if ( ( null != value ) && ! value . isEmpty ( ) ) { localesWithEntries . put ( l , value ) ; } } } if ( ! localesWithEntries . isEmpty ( ) ) { result = new CmsContextMenu ( ) ; ContextMenuItem mainItem = result . addItem ( Messages . get ( ) . getBundle ( UI . getCurrent ( ) . getLocale ( ) ) . key ( Messages . GUI_BUNDLE_EDITOR_CONTEXT_COPY_LOCALE_0 ) ) ; for ( final Locale l : localesWithEntries . keySet ( ) ) { ContextMenuItem menuItem = mainItem . addItem ( l . getDisplayName ( UI . getCurrent ( ) . getLocale ( ) ) ) ; menuItem . addItemClickListener ( new ContextMenuItemClickListener ( ) { public void contextMenuItemClicked ( ContextMenuItemClickEvent event ) { item . getItemProperty ( TableProperty . TRANSLATION ) . setValue ( localesWithEntries . get ( l ) ) ; } } ) ; } } } } catch ( Exception e ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; } return result ; }
Returns the context menu for the table item.
@param itemId the table item.
@return the context menu for the given item.