Search in sources :

Example 1 with RepositoryNodeType

use of org.talend.sqlbuilder.dbstructure.RepositoryNodeType in project tdi-studio-se by Talend.

the class DeleteQueryAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    boolean enabled = true;
    if (selection.size() != 1) {
        enabled = false;
    } else {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        RepositoryNodeType type = (RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.QUERY) {
            enabled = false;
        }
    }
    enabled = enabled && !dialog.getConnParameters().isNodeReadOnly();
    setEnabled(enabled);
}
Also used : RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 2 with RepositoryNodeType

use of org.talend.sqlbuilder.dbstructure.RepositoryNodeType in project tdi-studio-se by Talend.

the class OpenQueryAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    boolean enabled = true;
    if (selection.size() != 1) {
        enabled = false;
    } else {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        RepositoryNodeType type = (RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.QUERY) {
            enabled = false;
        }
    }
    setEnabled(enabled);
}
Also used : RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 3 with RepositoryNodeType

use of org.talend.sqlbuilder.dbstructure.RepositoryNodeType in project tdi-studio-se by Talend.

the class ShowQueryPropertyAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    boolean enabled = true;
    if (selection.size() != 1) {
        enabled = false;
    } else {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        RepositoryNodeType type = (RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.QUERY) {
            enabled = false;
        }
    }
    enabled = enabled && !dialog.getConnParameters().isNodeReadOnly();
    setEnabled(enabled);
}
Also used : RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 4 with RepositoryNodeType

use of org.talend.sqlbuilder.dbstructure.RepositoryNodeType in project tdi-studio-se by Talend.

the class TableNode method getMetadataTable.

/**
     * Get repository table from table repositoryNode.
     * 
     * @param repositoryNode -- table repositoryNode
     * @return columns
     * @exception
     */
//$NON-NLS-1$
@SuppressWarnings("deprecation")
public static MetadataTable getMetadataTable(RepositoryNode repositoryNode) {
    RepositoryNodeType type = SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode);
    if (type != RepositoryNodeType.TABLE) {
        //$NON-NLS-1$
        throw new RuntimeException(Messages.getString("TableNode.exceptionMessage"));
    }
    MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) repositoryNode.getObject();
    return tableObject.getTable();
}
Also used : RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)

Example 5 with RepositoryNodeType

use of org.talend.sqlbuilder.dbstructure.RepositoryNodeType in project tdi-studio-se by Talend.

the class EMFRepositoryNodeManager method getTables.

@SuppressWarnings("unchecked")
public List<MetadataTable> getTables(List<IRepositoryNode> nodes, List<MetadataColumn> selectedColumns) {
    List<MetadataTable> tables = new ArrayList<MetadataTable>();
    for (IRepositoryNode node : nodes) {
        RepositoryNodeType type = SQLBuilderRepositoryNodeManager.getRepositoryType((RepositoryNode) node);
        if (type == RepositoryNodeType.DATABASE) {
            root = (RepositoryNode) node;
            DatabaseConnection connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem((RepositoryNode) node).getConnection();
            for (MetadataTable table : ConnectionHelper.getTables(connection)) {
                if (!tables.contains(table)) {
                    tables.add(table);
                    selectedColumns.addAll(table.getColumns());
                }
            }
            // if database is selected , It does not need to check others.
            break;
        } else if (type == RepositoryNodeType.TABLE) {
            MetadataTable table = ((MetadataTableRepositoryObject) node.getObject()).getTable();
            if (!tables.contains(table)) {
                tables.add(table);
                selectedColumns.addAll(table.getColumns());
            }
            root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
        } else if (type == RepositoryNodeType.COLUMN) {
            MetadataColumn column = ((MetadataColumnRepositoryObject) node.getObject()).getColumn();
            if (!selectedColumns.contains(column)) {
                selectedColumns.add(column);
            }
            MetadataTable table = column.getTable();
            if (!tables.contains(table)) {
                tables.add(table);
            }
            root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
        }
        setRoot(null);
    }
    return tables;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MetadataColumnRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataColumnRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

RepositoryNodeType (org.talend.sqlbuilder.dbstructure.RepositoryNodeType)5 RepositoryNode (org.talend.repository.model.RepositoryNode)4 ArrayList (java.util.ArrayList)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 MetadataColumnRepositoryObject (org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataColumnRepositoryObject)1 MetadataTableRepositoryObject (org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)1