use of org.talend.sqlbuilder.dbstructure.nodes.INode in project tdi-studio-se by Talend.
the class DBTreeActionGroup method fillContextMenu.
/**
* Fill the node context menu with all the correct actions.
*
* @param menu MenuManager.
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void fillContextMenu(IMenuManager menu) {
// find our target node..
IStructuredSelection selection = (IStructuredSelection) pTreeViewer.getSelection();
// check if we have a valid selection
if (selection == null) {
return;
}
ArrayList selectedNodes = new ArrayList();
Iterator it = selection.iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof INode) {
selectedNodes.add(object);
}
}
if (selectedNodes.size() == 0) {
return;
}
INode[] nodes = (INode[]) selectedNodes.toArray(new INode[] {});
IAction[] actions = getContextActions(nodes);
for (int i = 0; i < actions.length; i++) {
menu.add(actions[i]);
}
}
use of org.talend.sqlbuilder.dbstructure.nodes.INode in project tdi-studio-se by Talend.
the class DBTreeLabelProvider method getText.
/**
* Return the text to display the INode.
*
* @param element Node.
* @return Text.
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
INode node = (INode) element;
String text = node.getLabelText();
// return default if no label is provided
if (text == null) {
text = node.toString();
}
return text;
}
use of org.talend.sqlbuilder.dbstructure.nodes.INode 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;
}
use of org.talend.sqlbuilder.dbstructure.nodes.INode in project tdi-studio-se by Talend.
the class ImportedKeysTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node.getSession() == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ITableInfo ti = tableNode.getTableInfo();
if (tableNode.getTableInfo() == null) {
return null;
}
ResultSet resultSet = null;
SessionTreeNode treeNode = node.getSession();
// For synonym table, should get the corresponding table.
if (ti.getType().equals("SYNONYM")) {
//$NON-NLS-1$
String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
resultSet = treeNode.getMetaData().getJDBCMetaData().getImportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getImportedKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 3, 4, 8, 9, 10, 11, 12, 13, 14 });
resultSet.close();
return dataSet;
}
return null;
}
use of org.talend.sqlbuilder.dbstructure.nodes.INode in project tdi-studio-se by Talend.
the class PrimaryKeysTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node.getSession() == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ITableInfo ti = tableNode.getTableInfo();
if (tableNode.getTableInfo() == null) {
return null;
}
ResultSet resultSet = null;
SessionTreeNode treeNode = node.getSession();
// For synonym table, should get the corresponding table name .
if (ti.getType().equals("SYNONYM")) {
//$NON-NLS-1$
String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
resultSet = treeNode.getMetaData().getJDBCMetaData().getPrimaryKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getPrimaryKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6 });
resultSet.close();
return dataSet;
}
return null;
}
Aggregations