10006---Trail ~ Integration in the hMC



The hybris Management Console (hMC) is a central view to the hybris Suite and is configured in an extension'shmc.xmlfile.

Create the cuppytrailhmc extension

Create the new extension cuppytrailhmc in the same way as you've did it with cuppytrail. Using a different extension gives you the possibility to disable the hmc connection rather easily.

  • Set dependecies to cuppytrail and hmc (Both in Eclipse and extensioninfo.xml file. Please note, extension name for hmc is hmc)
  • Remove webmodule from the cuppytrailhmc/extensioninfo.xml


Create the hmc module

  1. Edit the extensioninfo.xml file in the cuppytrailhmc extension and add the hmcmodule element below and make sure that it is the last line before the close of the <extension> element.

<hmcmodule extensionclassname="de.hybris.platform.cuppytrail.hmc.CuppytrailHMCExtension"/>

  1. Now create a new source folder hmc/src in the cuppytrailhmc project (add it to your build path!!!).
  2. Create the following Java class in that folder and the package de.hybris.platform.cuppytrail.hmc

cuppytrailhmc/hmc/src/de/hybris/platform/cuppytrail/hmc/CuppytrailHMCExtension.java

<strong>package de.hybris.platform.cuppytrail.hmc;
 
import de.hybris.platform.hmc.AbstractEditorMenuChip;
import de.hybris.platform.hmc.AbstractExplorerMenuTreeNodeChip;
import de.hybris.platform.hmc.EditorTabChip;
import de.hybris.platform.hmc.extension.HMCExtension;
import de.hybris.platform.hmc.extension.MenuEntrySlotEntry;
import de.hybris.platform.hmc.generic.ClipChip;
import de.hybris.platform.hmc.generic.ToolbarActionChip;
import de.hybris.platform.hmc.webchips.Chip;
import de.hybris.platform.hmc.webchips.DisplayState;
 
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
 
import org.apache.log4j.Logger;
 
 
/**
 * Provides necessary meta information about the cuppytrail hmc extension.
 *
 *
 * @version ExtGen v4.1
 */
public class CuppytrailHMCExtension extends HMCExtension
{
    /** Edit the local|project.properties to change logging behavior (properties log4j.*). */
    @SuppressWarnings("unused")
    private static final Logger LOG = Logger.getLogger(CuppytrailHMCExtension.class.getName());
 
    /** Path to the resource bundles. */
    public final static String RESOURCE_PATH = "de.hybris.platform.cuppytrail.hmc.locales";
 
 
    /**
     * @see HMCExtension#getTreeNodeChips(de.hybris.platform.hmc.webchips.DisplayState,
     *      de.hybris.platform.hmc.webchips.Chip)
     */
    @Override
    public List<AbstractExplorerMenuTreeNodeChip> getTreeNodeChips(final DisplayState displayState, final Chip parent)
    {
        return Collections.EMPTY_LIST;
    }
 
    /**
     * @see HMCExtension#getMenuEntrySlotEntries(de.hybris.platform.hmc.webchips.DisplayState,
     *      de.hybris.platform.hmc.webchips.Chip)
     */
    @Override
    public List<MenuEntrySlotEntry> getMenuEntrySlotEntries(final DisplayState displayState, final Chip parent)
    {
        return Collections.EMPTY_LIST;
    }
 
    /**
     * @see HMCExtension#getSectionChips(de.hybris.platform.hmc.webchips.DisplayState,
     *      de.hybris.platform.hmc.generic.ClipChip)
     */
    @Override
    public List<ClipChip> getSectionChips(final DisplayState displayState, final ClipChip parent)
    {
        return Collections.EMPTY_LIST;
    }
 
    @Override
    public List<EditorTabChip> getEditorTabChips(final DisplayState displayState, final AbstractEditorMenuChip parent)
    {
        return Collections.EMPTY_LIST;
    }
 
    /**
     * @see HMCExtension#getToolbarActionChips(de.hybris.platform.hmc.webchips.DisplayState,
     *      de.hybris.platform.hmc.webchips.Chip)
     */
    @Override
    public List<ToolbarActionChip> getToolbarActionChips(final DisplayState displayState, final Chip parent)
    {
        return Collections.EMPTY_LIST;
    }
 
    @Override
    public ResourceBundle getLocalizeResourceBundle(final Locale locale)
    {
        return null;
    }
 
    @Override
    public String getResourcePath()
    {
        return RESOURCE_PATH;
    }
 
}</strong>

4. Run ant all and refresh the workspace. You should be able to see the hmc folder


Add CuppyTrail to the hMC

  1. Create the file cuppytrailhmc/hmc/resources/hmc.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration xmlns="hybris.de/schemas/hmc/generic"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="hybris.de/schemas/hmc/generic hmc.xsd">
 
    <!-- Configuration for extension cuppytrail -->
    <explorertree>
        <group name="cuppytrailgroup">
            <typeref type="Stadium"/>
        </group>
    </explorertree>
 
    <type name="Stadium" mode="append">
            <organizer>
            <search mode="replace">
                <condition attribute="code"/>
                <condition attribute="capacity"/>
                <condition attribute="matches"/>
            </search>
            <result>
                <listview mode="replace">
                    <itemlayout>
                        <attribute name="code"/>
                        <attribute name="capacity"/>
                        <attribute name="matches"/>
                    </itemlayout>
                </listview>
            </result>
            <editor>
                <essentials>
                    <listlayout>
                        <attribute name="code"/>
                    </listlayout>
                </essentials>
                <tab name="tab.cuppytrail">
                    <section name="section.cuppytrail">
                        <listlayout>
                            <attribute name="capacity"/>
                            <attribute name="matches"/>
                        </listlayout>
                    </section>
                </tab>
            </editor>
        </organizer>
    </type>
</configuration>

  1. Invoke ant all
  2. If not already running, start hybris
  3. Navigate to the hMC: http://localhost:9001/hmc/hybris and note that a new node is visible in the tree for our new extension cuppytrail


4. Key points to note:

  1. We have added a reference to Stadium in the hMC's explorer tree (the tree displayed on the left side of the hMC)
  2. We specify an organizer tag for Stadium describing how the Organizer's three main areas, i.e. search, result and editor areas should appear.
  3. If we have multiple tabs, content under <essentials> tag will always appear on the top of each.
  4. The build process combines the hmc.xml files found in each extension into one large hmc.xml in platform/ext-platform-optional/hmc/web/webroot/WEB-INF/classes/de/hybris/platform/hmc/hmc.xml
  5. The hMC layout is then determined at run-time by the contents of this master hmc.xml file

5. Note that the cuppytrail node name appears as [cuppytrailgroup].  Expand this node – the child node's name may can vary, depending on whether or not you have already  

    performed the type-system localizations in the previous trail step, Trail ~ New Data Model_.  (If you have not, the child node appears as [Stadium] - otherwise, the hMC

    defaults to the localized type's 'name' attribute).  Either way, we will override those defaults and localize the names of these hMC nodes next.

  1. Because you specified hmc.structure.db=false in config/local.properties, hybris will load the hmc configuration from this file rather than storing it in the database


Localize the hMC labels

  1. Create the following file and folders:

cuppytrailhmc/hmc/resources/de/hybris/platform/cuppytrail/hmc/locales_en.properties

<strong>cuppytrailgroup=Cuppy Trail
type_tree_stadium=Stadiums
tab.cuppytrail=Cuppy Trail
section.cuppytrail=Cuppy Trail</strong>

2. Create the following file:

cuppytrailhmc/hmc/resources/de/hybris/platform/cuppytrail/hmc/locales_de.properties

 

cuppytrailgroup=Das Cuppy Trail
type_tree_stadium=Fussballstadien
tab.cuppytrail=Das Cuppy Trail
section.cuppytrail=Das Cuppy Trail
3. Make sure your project structure looks like this


  1. Reinvoke the Ant All task from within Eclipse.
  2. If not already running, restart hybris
  3. Explore how Cuppytrail tree elements are now localized in the hMC at http://localhost:9001/hmc/hybris.
  4. We recommended above to add the entry hmc.structure.db=false to force the hMC to reload its configuration. Otherwise you would have to tell hybris to reload the hMC:
  5. Note that the localizations we performed here apply only to hMC-specific view elements, such as the cuppytrail node in the left-hand tree.  Other localizations, such as the names of the Stadium attributes (despite being visible from within the hMC search windows) come from within the hybris type system via a system-wide data model, and are not affected by hMC localizations.  For example, attribute localization strings are used in hybris Cockpits as well, whereas hMC localization strings are not.

======

hmc的本地文件,ant all就可反应进去。不需要update。

itemtype的本地文件,需要update locale properties.不用ant all

======




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值