Search in sources :

Example 36 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class MDMRepositoryViewerSorter method category.

@Override
public int category(Object element) {
    if (element instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) element;
        ERepositoryObjectType repositoryObjectType = viewObject.getRepositoryObjectType();
        if (repositoryObjectType == null)
            return 0;
        if (repositoryObjectType == IServerObjectRepositoryType.TYPE_RECYCLE_BIN) {
            return 2;
        }
        try {
            Item item = viewObject.getProperty().getItem();
            if (item != null) {
                if (item instanceof MDMServerObjectItem) {
                    return 1;
                }
                if (item instanceof ContainerItem) {
                    return SortOrderFactory.getOrder((ContainerItem) item);
                }
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    return 0;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 37 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class MDMServerDecorator method decorateRecycleBin.

private void decorateRecycleBin(Item item, IDecoration decoration) {
    ItemState state = item.getState();
    String path = state.getPath();
    if (item instanceof ContainerItem) {
        int index = path.lastIndexOf(IPath.SEPARATOR);
        if (index > 0) {
            path = path.substring(0, index);
        } else if (index == 0) {
            // $NON-NLS-1$
            path = "";
        }
    }
    if (path.length() > 0) {
        // $NON-NLS-1$ //$NON-NLS-2$
        decoration.addSuffix(" (" + path + ")");
    }
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState)

Example 38 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class MDMExportRepositoryItemsWizard method getItemsToExport.

/**
 * DOC hywang Comment method "getItemsToExport".
 */
private Collection<Item> getItemsToExport(Collection<IRepositoryViewObject> objs) {
    List<Item> toReturn = null;
    if (objs != null && objs.size() > 0) {
        toReturn = new ArrayList<Item>();
        for (IRepositoryViewObject obj : objs) {
            Item item = obj.getProperty().getItem();
            if (item != null && !(item instanceof ContainerItem)) {
                item = RepositoryResourceUtil.assertItem(item);
                toReturn.add(item);
            }
        }
    }
    return toReturn;
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 39 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class OpenObjectAction method doOpen.

public boolean doOpen() {
    List<Object> sels = getSelectedObject();
    if (selObjects != null) {
        sels = selObjects;
    }
    if (sels.isEmpty()) {
        return false;
    }
    Object obj = sels.get(0);
    if (obj instanceof IRepositoryViewObject) {
        if (obj instanceof WSRootRepositoryObject) {
            return false;
        }
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        Item item = viewObject.getProperty().getItem();
        if (item instanceof ContainerItem) {
            if (viewObject.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_SERVICECONFIGURATION)) {
                // service
                boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
                if (!checkMissingJar) {
                    return false;
                }
                // configuration
                MDMServerDef serverDef = openServerDialog(null);
                openServiceConfig(serverDef);
            } else {
                getCommonViewer().expandToLevel(obj, 1);
            }
        } else {
            IEditorReference editorRef = RepositoryResourceUtil.isOpenedInEditor(viewObject);
            if (editorRef != null) {
                if (page == null) {
                    page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
                }
                if (page != null) {
                    page.bringToTop(editorRef.getPart(false));
                }
                if (marker != null) {
                    IDE.gotoMarker(editorRef.getEditor(true), marker);
                }
                return false;
            } else {
                openItem(viewObject);
                return true;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject)

Example 40 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class RefreshAction method refreshSelection.

private void refreshSelection() {
    List<Object> selectedObject = getSelectedObject();
    if (!selectedObject.isEmpty()) {
        Object obj = selectedObject.get(0);
        commonViewer.refresh(obj);
        Item item = ((IRepositoryViewObject) obj).getProperty().getItem();
        if (item instanceof ContainerItem) {
            commonViewer.expandToLevel(obj, 1);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)46 Item (org.talend.core.model.properties.Item)28 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)24 ItemState (org.talend.core.model.properties.ItemState)18 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)11 FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)11 Property (org.talend.core.model.properties.Property)10 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)9 Resource (org.eclipse.emf.ecore.resource.Resource)8 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)8 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)8 FolderType (org.talend.core.model.properties.FolderType)6 FolderItem (org.talend.core.model.properties.FolderItem)5 Path (org.eclipse.core.runtime.Path)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 WSDataModelItem (org.talend.mdm.repository.model.mdmproperties.WSDataModelItem)4 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)4