Search in sources :

Example 1 with IRepositoryNodeLabelProvider

use of org.talend.mdm.repository.core.IRepositoryNodeLabelProvider in project tmdm-studio-se by Talend.

the class RecycleBinLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
        ERepositoryObjectType type = viewObj.getRepositoryObjectType();
        if (type == IServerObjectRepositoryType.TYPE_RECYCLE_BIN) {
            if (viewObj instanceof FolderRepositoryObject) {
                return ((FolderRepositoryObject) viewObj).getChildren().isEmpty() ? EMPTY_IMG : FULL_IMG;
            }
        }
        IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(type);
        if (configuration != null) {
            IRepositoryNodeLabelProvider labelProvider = configuration.getLabelProvider();
            return labelProvider.getImage(element);
        }
    }
    return null;
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryNodeLabelProvider(org.talend.mdm.repository.core.IRepositoryNodeLabelProvider) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 2 with IRepositoryNodeLabelProvider

use of org.talend.mdm.repository.core.IRepositoryNodeLabelProvider in project tmdm-studio-se by Talend.

the class RepositoryResourceUtilTest method testGetCategoryViewObject.

/**
 * Test for: getCategoryViewObject(IRepositoryNodeConfiguration conf)
 */
@Test
public void testGetCategoryViewObject() throws Exception {
    IRepositoryNodeConfiguration mockConfiguration = mock(IRepositoryNodeConfiguration.class);
    IRepositoryNodeResourceProvider mockResourceProvider = mock(IRepositoryNodeResourceProvider.class);
    when(mockConfiguration.getResourceProvider()).thenReturn(mockResourceProvider);
    ERepositoryObjectType mockType = mock(ERepositoryObjectType.class);
    when(mockConfiguration.getResourceProvider().getRepositoryObjectType(Mockito.any(Item.class))).thenReturn(mockType);
    IRepositoryNodeLabelProvider mockLabelProvider = mock(IRepositoryNodeLabelProvider.class);
    when(mockConfiguration.getLabelProvider()).thenReturn(mockLabelProvider);
    when(mockLabelProvider.getCategoryLabel(Mockito.any(ERepositoryObjectType.class))).thenReturn("anystring");
    PowerMockito.mockStatic(ContainerCacheService.class);
    PowerMockito.doNothing().when(ContainerCacheService.class, "putContainer", Mockito.any(IRepositoryViewObject.class));
    IRepositoryViewObject categoryViewObject = RepositoryResourceUtil.getCategoryViewObject(mockConfiguration);
    assertNotNull(categoryViewObject);
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryNodeLabelProvider(org.talend.mdm.repository.core.IRepositoryNodeLabelProvider) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)2 IRepositoryNodeLabelProvider (org.talend.mdm.repository.core.IRepositoryNodeLabelProvider)2 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Item (org.talend.core.model.properties.Item)1 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)1