Search in sources :

Example 1 with DatabaseNode

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

the class DetailTabManager method createTabs.

/**
     * Returns a list of all available tabs for a given node. These tabs can be
     * standard or plugin tabs.
     * 
     * @param node for which to find tabs.
     * @return List of tabs
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private static List createTabs(INode node) {
    //        if (CONSTANT_LOGGER.isDebugEnabled()) {
    //            CONSTANT_LOGGER.debug("Creating tabs for: " + node.getUniqueIdentifier());
    //        }
    ArrayList tabList = new ArrayList();
    // create connection info tab if needed
    if (node instanceof DatabaseNode) {
        IDetailTab dbTab = new ConnectionInfoTab();
        dbTab.setNode(node);
        tabList.add(dbTab);
    }
    // create our basic table tabs
    if (node instanceof TableNode) {
        IDetailTab tab1 = new ColumnInfoTab();
        //IDetailTab tab2 = new TableInfoTab();
        IDetailTab tab3 = new PreviewTab();
        IDetailTab tab4 = new RowCountTab();
        IDetailTab tab5 = new PrimaryKeysTab();
        IDetailTab tab6 = new ExportedKeysTab();
        IDetailTab tab7 = new ImportedKeysTab();
        IDetailTab tab8 = new IndexesTab();
        //IDetailTab tab9 = new PriviligesTab();
        //IDetailTab tab10 = new ColumnPriviligesTab();
        //IDetailTab tab11 = new RowIdsTab();
        //IDetailTab tab12 = new VersionsTab();
        tab1.setNode(node);
        //tab2.setNode(node);
        tab3.setNode(node);
        tab4.setNode(node);
        tab5.setNode(node);
        tab6.setNode(node);
        tab7.setNode(node);
        tab8.setNode(node);
        //tab9.setNode(node);
        //tab10.setNode(node);
        //tab11.setNode(node);
        //tab12.setNode(node);
        tabList.add(tab1);
        //tabList.add(tab2);
        tabList.add(tab3);
        tabList.add(tab4);
        tabList.add(tab5);
        tabList.add(tab6);
        tabList.add(tab7);
        tabList.add(tab8);
    //tabList.add(tab9);
    //tabList.add(tab10);
    //tabList.add(tab11);
    //tabList.add(tab12);
    }
    return tabList;
}
Also used : DatabaseNode(org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode) PrimaryKeysTab(org.talend.sqlbuilder.dbdetail.tab.PrimaryKeysTab) ImportedKeysTab(org.talend.sqlbuilder.dbdetail.tab.ImportedKeysTab) RowCountTab(org.talend.sqlbuilder.dbdetail.tab.RowCountTab) ArrayList(java.util.ArrayList) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) PreviewTab(org.talend.sqlbuilder.dbdetail.tab.PreviewTab) IndexesTab(org.talend.sqlbuilder.dbdetail.tab.IndexesTab) ExportedKeysTab(org.talend.sqlbuilder.dbdetail.tab.ExportedKeysTab) ConnectionInfoTab(org.talend.sqlbuilder.dbdetail.tab.ConnectionInfoTab) ColumnInfoTab(org.talend.sqlbuilder.dbdetail.tab.ColumnInfoTab)

Example 2 with DatabaseNode

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

the class SessionTreeNodeManager method convert2INode.

/**
     * DOC qianbing Comment method "convert2INode". Converts the RepositoryNode input to INode. INode is used for the
     * sql editor,result viewer and the detail viewer.
     * 
     * @param repositoryNode RepositoryNode
     * @param selectedContext
     * @return INode
     */
public INode convert2INode(RepositoryNode repositoryNode, String selectedContext, SessionTreeNode sessionTreeNode) throws Exception {
    // Creates the SessionTreeNode.
    RepositoryNodeType nodeType = getRepositoryType(repositoryNode);
    if (nodeType.equals(RepositoryNodeType.DATABASE)) {
        // processes the database
        DatabaseModel model = sessionTreeNode.getDbModel();
        INode[] nodes = model.getChildNodes();
        DatabaseNode dn = (DatabaseNode) nodes[0];
        return dn;
    } else if (nodeType.equals(RepositoryNodeType.TABLE)) {
        // processes the table
        MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) repositoryNode.getObject();
        MetadataTable table = tableObject.getTable();
        String realName = table.getSourceName();
        DatabaseModel model = sessionTreeNode.getDbModel();
        INode[] nodes = model.getChildNodes();
        DatabaseNode dn = (DatabaseNode) nodes[0];
        nodes = dn.getChildNodes();
        CatalogNode cn = (CatalogNode) nodes[0];
        nodes = cn.getChildNodes();
        if (nodes != null && nodes.length > 0) {
            for (INode node : nodes) {
                TableNode tableNode = (TableNode) node;
                if (tableNode.getName().equals(realName)) {
                    return node;
                }
            }
        }
    } else if (nodeType.equals(RepositoryNodeType.COLUMN)) {
        // Processes the column.
        // Gets the repositoryNode's parent,should be the repositoryNode of table infomation.
        repositoryNode = repositoryNode.getParent();
        return convert2INode(repositoryNode, selectedContext, sessionTreeNode);
    }
    return null;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) DatabaseNode(org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode) CatalogNode(org.talend.sqlbuilder.dbstructure.nodes.CatalogNode) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)

Example 3 with DatabaseNode

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

the class SessionTreeNode method getCatalogs.

/**
     * @return Catalogs.
     */
public String[] getCatalogs() {
    List catalogs = ((DatabaseNode) dbModel.getChildNodes()[0]).getCatalogs();
    String[] catalogNames = new String[catalogs.size()];
    Iterator it = catalogs.iterator();
    int i = 0;
    while (it.hasNext()) {
        INode node = (INode) it.next();
        if (node != null) {
            catalogNames[i] = node.toString();
            i++;
        }
    }
    return catalogNames;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) DatabaseNode(org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode) Iterator(java.util.Iterator) ListenerList(org.eclipse.core.runtime.ListenerList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DatabaseNode (org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode)3 ArrayList (java.util.ArrayList)2 INode (org.talend.sqlbuilder.dbstructure.nodes.INode)2 TableNode (org.talend.sqlbuilder.dbstructure.nodes.TableNode)2 Iterator (java.util.Iterator)1 List (java.util.List)1 ListenerList (org.eclipse.core.runtime.ListenerList)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ColumnInfoTab (org.talend.sqlbuilder.dbdetail.tab.ColumnInfoTab)1 ConnectionInfoTab (org.talend.sqlbuilder.dbdetail.tab.ConnectionInfoTab)1 ExportedKeysTab (org.talend.sqlbuilder.dbdetail.tab.ExportedKeysTab)1 ImportedKeysTab (org.talend.sqlbuilder.dbdetail.tab.ImportedKeysTab)1 IndexesTab (org.talend.sqlbuilder.dbdetail.tab.IndexesTab)1 PreviewTab (org.talend.sqlbuilder.dbdetail.tab.PreviewTab)1 PrimaryKeysTab (org.talend.sqlbuilder.dbdetail.tab.PrimaryKeysTab)1 RowCountTab (org.talend.sqlbuilder.dbdetail.tab.RowCountTab)1 MetadataTableRepositoryObject (org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)1 CatalogNode (org.talend.sqlbuilder.dbstructure.nodes.CatalogNode)1