use of com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassColumnsTask in project cubrid-manager by CUBRID.
the class CubridTablesFolderLoader method createUserTableNodes.
/**
* Create user table node
*
* @param parent ICubridNode
* @param allClassInfoList A list includes all the class info
* @param level The load level
* @param monitor The IProgressMonitor
*/
private void createUserTableNodes(ICubridNode parent, List<ClassInfo> allClassInfoList, int level, IProgressMonitor monitor) {
List<String> tables = new ArrayList<String>();
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(true);
classNode.setModelObj(classInfo);
classNode.setType(NodeType.USER_TABLE);
parent.addChild(classNode);
ICubridNodeLoader loader = null;
if (classInfo.isPartitionedClass()) {
classNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
classNode.setIconPath("icons/navigator/schema_table_partition.png");
classNode.setContainer(true);
loader = new CubridPartitionedTableLoader();
} else {
loader = new CubridUserTableLoader();
}
loader.setLevel(level);
classNode.setLoader(loader);
tables.add(classInfo.getClassName());
}
if (level == DEFINITE_LEVEL) {
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassColumnsTask task = new GetUserClassColumnsTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
Map<String, List<TableColumn>> columnsOfTable = task.getColumns(tables);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && !task.isInTransation() && errorMsg != null && errorMsg.trim().length() > 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
parent.removeAllChild();
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
for (ClassInfo classInfo : allClassInfoList) {
String tableId = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode node = parent.getChild(tableId);
CubridUserTableLoader tableLoader = (CubridUserTableLoader) node.getLoader();
tableLoader.setColumns(columnsOfTable.get(classInfo.getClassName()));
node.getChildren(monitor);
tableLoader.setLoaded(true);
}
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassColumnsTask in project cubrid-manager by CUBRID.
the class CubridUserTableColumnLoader method getColumns.
/**
* Get the columns based upon the given parent node
*
* @param parent the given parent node
* @param monitor the IProgressMonitor object
* @param database the given database
* @return whether is in transaction
*/
private boolean getColumns(ICubridNode parent, final IProgressMonitor monitor, CubridDatabase database) {
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassColumnsTask task = new GetUserClassColumnsTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
String tableName = parent.getParent().getLabel();
columns = task.getColumns(tableName);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
columns = null;
if (!task.isInTransation()) {
parent.removeAllChild();
setLoaded(true);
return false;
}
}
return true;
}
Aggregations