Search in sources :

Example 1 with ENoSQLSchemaType

use of org.talend.repository.nosql.model.ENoSQLSchemaType in project tbd-studio-se by Talend.

the class AbstractNoSQLRetrieveSchemaForm method udpateItemsStatus.

private void udpateItemsStatus(TreeItem treeItem, Map<TreeItem, AtomicInteger> checkedDBMap) {
    Object data = treeItem.getData();
    if (treeItem != null && data != null) {
        INoSQLSchemaNode node = (INoSQLSchemaNode) treeItem.getData();
        ENoSQLSchemaType schemaType = node.getSchemaType();
        if (ENoSQLSchemaType.DATABASE.equals(schemaType)) {
            AtomicInteger checkedCount = checkedDBMap.get(treeItem);
            if (checkedCount == null) {
                checkedDBMap.put(treeItem, new AtomicInteger(0));
            }
            schemaViewer.expandToLevel(node, 1);
            for (TreeItem item : treeItem.getItems()) {
                udpateItemsStatus(item, checkedDBMap);
            }
        } else if (ENoSQLSchemaType.TABLE.equals(schemaType)) {
            boolean existTable = isExistTable(node, true);
            if (!existTable) {
                clearItemStatus(node);
            }
            schemaViewer.setChecked(node, existTable);
            if (treeItem.getChecked()) {
                TreeItem dbItem = getDBItem(treeItem);
                if (dbItem != null) {
                    AtomicInteger checkedCount = checkedDBMap.get(dbItem);
                    if (checkedCount != null) {
                        checkedCount.incrementAndGet();
                    }
                }
            }
        }
    }
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ENoSQLSchemaType(org.talend.repository.nosql.model.ENoSQLSchemaType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 2 with ENoSQLSchemaType

use of org.talend.repository.nosql.model.ENoSQLSchemaType in project tbd-studio-se by Talend.

the class AbstractNoSQLRetrieveSchemaForm method getExistItem.

private TreeItem getExistItem(MetadataTable table) {
    if (!schemaTree.isDisposed() && table != null && table.eContainer() != null) {
        String parentName = ((orgomg.cwm.objectmodel.core.Package) table.eContainer()).getName();
        TreeItem[] items = schemaTree.getItems();
        for (TreeItem treeItem : items) {
            if (treeItem.getData() != null) {
                ENoSQLSchemaType schemaType = ((INoSQLSchemaNode) treeItem.getData()).getSchemaType();
                if (ENoSQLSchemaType.DATABASE.equals(schemaType)) {
                    for (TreeItem item : treeItem.getItems()) {
                        if (MetadataToolHelper.validateTableName(item.getText(0)).equals(table.getLabel()) && treeItem.getText(0).equals(parentName) && item.getChecked()) {
                            return item;
                        }
                    }
                } else if (ENoSQLSchemaType.TABLE.equals(schemaType)) {
                    if (MetadataToolHelper.validateTableName(treeItem.getText(0)).equals(table.getLabel()) && treeItem.getChecked()) {
                        return treeItem;
                    }
                }
            }
        }
    }
    return null;
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ENoSQLSchemaType(org.talend.repository.nosql.model.ENoSQLSchemaType) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 3 with ENoSQLSchemaType

use of org.talend.repository.nosql.model.ENoSQLSchemaType in project tbd-studio-se by Talend.

the class AbstractNoSQLRetrieveSchemaForm method getDBItem.

private TreeItem getDBItem(TreeItem treeItem) {
    if (treeItem == null || treeItem.getData() == null) {
        return null;
    }
    INoSQLSchemaNode node = (INoSQLSchemaNode) treeItem.getData();
    ENoSQLSchemaType schemaType = node.getSchemaType();
    if (ENoSQLSchemaType.DATABASE.equals(schemaType)) {
        return treeItem;
    } else {
        return getDBItem(treeItem.getParentItem());
    }
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ENoSQLSchemaType(org.talend.repository.nosql.model.ENoSQLSchemaType)

Aggregations

ENoSQLSchemaType (org.talend.repository.nosql.model.ENoSQLSchemaType)3 INoSQLSchemaNode (org.talend.repository.nosql.model.INoSQLSchemaNode)3 TreeItem (org.eclipse.swt.widgets.TreeItem)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1