Search in sources :

Example 1 with IRepositoryContentHandler

use of org.talend.core.model.repository.IRepositoryContentHandler in project tdi-studio-se by Talend.

the class ItemRecord method getImage.

public Image getImage() {
    // MOD sizhaoliu 2011-12-05
    // In ImportItemWizard, enable custom icons depending on file extension.
    Image img = null;
    boolean isExtensionPoint = false;
    for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
        isExtensionPoint = handler.isRepObjType(getType());
        if (isExtensionPoint == true) {
            IImage icon = handler.getIcon(getItem());
            if (icon != null) {
                img = ImageProvider.getImage(icon);
                break;
            }
        }
    }
    if (isExtensionPoint == false || img == null) {
        img = CoreImageProvider.getImage(getType());
    }
    return img;
}
Also used : IImage(org.talend.commons.ui.runtime.image.IImage) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) IRepositoryContentHandler(org.talend.core.model.repository.IRepositoryContentHandler)

Example 2 with IRepositoryContentHandler

use of org.talend.core.model.repository.IRepositoryContentHandler in project tdi-studio-se by Talend.

the class DetecteViewImpactAction method init.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.commons.ui.swt.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    // try to check via extension point first.
    boolean canWork = UpdateManagerProviderDetector.INSTANCE.validateAction(viewer, selection);
    if (canWork) {
        setEnabled(true);
        return;
    }
    canWork = !selection.isEmpty() && selection.size() == 1;
    if (canWork) {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        if (factory.isUserReadOnlyOnCurrentProject()) {
            canWork = false;
        } else {
            Object o = selection.getFirstElement();
            RepositoryNode node = (RepositoryNode) o;
            ENodeType nodeType = node.getType();
            switch(nodeType) {
                case REPOSITORY_ELEMENT:
                    ERepositoryObjectType objectType = node.getObjectType();
                    /*
                     * TESB-6415 if it's "CAMEL" product, then is disable
                     */
                    if (objectType != null) {
                        String[] products = objectType.getProducts();
                        if (products != null && products.length == 1 && "CAMEL".equals(products[0])) {
                            setEnabled(false);
                            return;
                        }
                    }
                    if (objectType == ERepositoryObjectType.METADATA_CON_TABLE) {
                        IRepositoryViewObject repositoryObject = node.getObject();
                        if (repositoryObject != null) {
                            Item item2 = repositoryObject.getProperty().getItem();
                            if (item2 instanceof DatabaseConnectionItem) {
                                DatabaseConnectionItem item = (DatabaseConnectionItem) repositoryObject.getProperty().getItem();
                                DatabaseConnection connection = (DatabaseConnection) item.getConnection();
                                CDCConnection cdcConns = connection.getCdcConns();
                                if (cdcConns != null) {
                                    if (repositoryObject instanceof MetadataTableRepositoryObject) {
                                        MetadataTable table = ((MetadataTableRepositoryObject) repositoryObject).getTable();
                                        String tableType = table.getTableType();
                                        canWork = RepositoryConstants.TABLE.equals(tableType);
                                        break;
                                    }
                                }
                            }
                        }
                        canWork = true;
                    } else if (objectType == ERepositoryObjectType.METADATA_CON_QUERY || objectType == ERepositoryObjectType.METADATA_CONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_DELIMITED || objectType == ERepositoryObjectType.METADATA_FILE_POSITIONAL || objectType == ERepositoryObjectType.METADATA_FILE_REGEXP || objectType == ERepositoryObjectType.METADATA_FILE_XML || objectType == ERepositoryObjectType.METADATA_FILE_LDIF || objectType == ERepositoryObjectType.METADATA_FILE_EXCEL || objectType == ERepositoryObjectType.METADATA_SAPCONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_EBCDIC || objectType == ERepositoryObjectType.METADATA_FILE_HL7 || objectType == ERepositoryObjectType.METADATA_VALIDATION_RULES || objectType == ERepositoryObjectType.METADATA_FILE_FTP || objectType == ERepositoryObjectType.METADATA_FILE_BRMS || objectType == ERepositoryObjectType.METADATA_MDMCONNECTION || objectType == ERepositoryObjectType.CONTEXT || objectType == ERepositoryObjectType.JOBLET) {
                        canWork = true;
                    } else if (objectType == ERepositoryObjectType.BUSINESS_PROCESS || objectType == ERepositoryObjectType.PROCESS || objectType == ERepositoryObjectType.ROUTINES || objectType == ERepositoryObjectType.PIG_UDF || objectType == ERepositoryObjectType.JOB_SCRIPT || objectType == ERepositoryObjectType.SQLPATTERNS || objectType == ERepositoryObjectType.JOB_DOC || objectType == ERepositoryObjectType.JOBLET_DOC || objectType == ERepositoryObjectType.DOCUMENTATION || objectType == ERepositoryObjectType.PROCESS_MR || objectType == ERepositoryObjectType.METADATA_CON_COLUMN || (ERepositoryObjectType.TEST_CONTAINER != null && objectType == ERepositoryObjectType.TEST_CONTAINER)) {
                        canWork = false;
                    } else {
                        Object obj = selection.getFirstElement();
                        RepositoryNode nodeObj = (RepositoryNode) obj;
                        Item item = nodeObj.getObject().getProperty().getItem();
                        if (item instanceof ConnectionItem) {
                            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                                IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
                                if (service != null) {
                                    boolean flag = service.isServiceItem(item.eClass().getClassifierID());
                                    if (flag) {
                                        canWork = false;
                                        break;
                                    }
                                }
                            }
                        }
                        for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
                            ERepositoryObjectType stype = handler.getRepositoryObjectType(item);
                            if (stype == objectType) {
                                canWork = true;
                                break;
                            }
                        }
                        if (RepositoryContentManager.getHandlers().size() < 0) {
                            canWork = false;
                        }
                    }
                    break;
                default:
                    canWork = false;
            }
            RepositoryNode parent = node.getParent();
            if (canWork && parent != null && parent.isBin()) {
                canWork = false;
            }
            if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
                canWork = false;
            }
        }
    }
    setEnabled(canWork);
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) IRepositoryContentHandler(org.talend.core.model.repository.IRepositoryContentHandler) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IESBService(org.talend.core.IESBService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with IRepositoryContentHandler

use of org.talend.core.model.repository.IRepositoryContentHandler in project tdi-studio-se by Talend.

the class DatabaseTypeFilter method createTypeProcessor.

/**
     * bqian create the correct TypeProcessor according to the type.
     * 
     * @return
     */
private IRepositoryTypeProcessor createTypeProcessor() {
    for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
        IRepositoryTypeProcessor processor = handler.getRepositoryTypeProcessor(repositoryType);
        if (processor != null) {
            return processor;
        }
    }
    if (repositoryType != null && repositoryType.contains("|")) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        String[] repTypes = repositoryType.split("\\|");
        IRepositoryTypeProcessor hadoopTypeProcessor = getHadoopSubMultiRepTypeProcessor(repTypes);
        if (hadoopTypeProcessor != null) {
            return hadoopTypeProcessor;
        }
    }
    if (type == null && repositoryTypes != null) {
        return new MetadataMultiTypeProcessor(repositoryTypes);
    }
    if (type == ERepositoryObjectType.PROCESS) {
        return new JobTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA) {
        return new RepositoryTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
        return new SchemaTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA_CON_QUERY) {
        return new QueryTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA_SAP_FUNCTION) {
        return new SAPFunctionProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.CONTEXT) {
        return new ContextTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA_HEADER_FOOTER) {
        return new HeaderFooterTypeProcessor(repositoryType);
    }
    if (type == ERepositoryObjectType.METADATA_VALIDATION_RULES) {
        return new ValidationRuleTypeProcessor(repositoryType, elem);
    }
    //$NON-NLS-1$
    throw new IllegalArgumentException(Messages.getString("RepositoryReviewDialog.0", type));
}
Also used : IRepositoryTypeProcessor(org.talend.core.model.repository.IRepositoryTypeProcessor) RepositoryTypeProcessor(org.talend.repository.ui.processor.RepositoryTypeProcessor) SchemaTypeProcessor(org.talend.repository.ui.processor.SchemaTypeProcessor) IRepositoryContentHandler(org.talend.core.model.repository.IRepositoryContentHandler) MetadataMultiTypeProcessor(org.talend.repository.ui.processor.MetadataMultiTypeProcessor) HeaderFooterTypeProcessor(org.talend.repository.ui.processor.HeaderFooterTypeProcessor) ValidationRuleTypeProcessor(org.talend.repository.ui.processor.ValidationRuleTypeProcessor) JobTypeProcessor(org.talend.repository.ui.processor.JobTypeProcessor) SAPFunctionProcessor(org.talend.repository.ui.processor.SAPFunctionProcessor) IRepositoryTypeProcessor(org.talend.core.model.repository.IRepositoryTypeProcessor) ContextTypeProcessor(org.talend.repository.ui.processor.ContextTypeProcessor) QueryTypeProcessor(org.talend.repository.ui.processor.QueryTypeProcessor)

Example 4 with IRepositoryContentHandler

use of org.talend.core.model.repository.IRepositoryContentHandler in project tdi-studio-se by Talend.

the class SchemaTypeProcessor method getTypes.

@Override
protected List<ERepositoryObjectType> getTypes() {
    List<ERepositoryObjectType> list = new ArrayList<ERepositoryObjectType>(50);
    String repositoryType = getRepositoryType();
    if (repositoryType != null && repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
        list.add(ERepositoryObjectType.METADATA_CONNECTIONS);
    } else {
        list.add(ERepositoryObjectType.METADATA_CONNECTIONS);
        list.add(ERepositoryObjectType.METADATA_FILE_DELIMITED);
        list.add(ERepositoryObjectType.METADATA_FILE_POSITIONAL);
        list.add(ERepositoryObjectType.METADATA_FILE_REGEXP);
        list.add(ERepositoryObjectType.METADATA_FILE_XML);
        list.add(ERepositoryObjectType.METADATA_FILE_LDIF);
        list.add(ERepositoryObjectType.METADATA_FILE_EXCEL);
        list.add(ERepositoryObjectType.METADATA_FILE_HL7);
        list.add(ERepositoryObjectType.METADATA_FILE_EBCDIC);
        list.add(ERepositoryObjectType.METADATA_FILE_FTP);
        list.add(ERepositoryObjectType.METADATA_FILE_BRMS);
        list.add(ERepositoryObjectType.METADATA_GENERIC_SCHEMA);
        list.add(ERepositoryObjectType.METADATA_LDAP_SCHEMA);
        list.add(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
        list.add(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
        list.add(ERepositoryObjectType.METADATA_SAPCONNECTIONS);
        list.add(ERepositoryObjectType.METADATA_RULES_MANAGEMENT);
        list.add(ERepositoryObjectType.METADATA_MDMCONNECTION);
        list.add(ERepositoryObjectType.METADATA_EDIFACT);
        // Add the type of extended node which has schemas.
        for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
            if (handler.hasSchemas() && handler.getHandleType() != null) {
                list.add(handler.getHandleType());
            }
        }
        // Add generic nodes.
        IGenericWizardService wizardService = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
            wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
        }
        if (wizardService != null) {
            List<String> genericTypeNames = wizardService.getGenericTypeNames();
            for (String genericType : genericTypeNames) {
                ERepositoryObjectType repObjType = ERepositoryObjectType.valueOf(genericType);
                if (repObjType != null) {
                    list.add(repObjType);
                }
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryContentHandler(org.talend.core.model.repository.IRepositoryContentHandler)

Aggregations

IRepositoryContentHandler (org.talend.core.model.repository.IRepositoryContentHandler)4 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 ArrayList (java.util.ArrayList)1 Image (org.eclipse.swt.graphics.Image)1 IImage (org.talend.commons.ui.runtime.image.IImage)1 IESBService (org.talend.core.IESBService)1 CDCConnection (org.talend.core.model.metadata.builder.connection.CDCConnection)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)1 Item (org.talend.core.model.properties.Item)1 IRepositoryTypeProcessor (org.talend.core.model.repository.IRepositoryTypeProcessor)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)1 IGenericWizardService (org.talend.core.runtime.services.IGenericWizardService)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 ENodeType (org.talend.repository.model.IRepositoryNode.ENodeType)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 ContextTypeProcessor (org.talend.repository.ui.processor.ContextTypeProcessor)1