use of com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassIndexesTask in project cubrid-manager by CUBRID.
the class CubridUserTableIndexLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassIndexesTask task = new GetUserClassIndexesTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
String tableName = parent.getParent().getLabel();
List<TableIndex> indexes = task.getIndexesNames(tableName);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
String parentId = parent.getId();
if (indexes != null && !indexes.isEmpty()) {
for (TableIndex index : indexes) {
String indexName = index.getIndexName();
String nodeId = parentId + NODE_SEPARATOR + indexName;
String label = indexName;
List<String> dependColumns = index.getColumns();
if (dependColumns != null && !dependColumns.isEmpty()) {
String keyAttrName = index.getColumns().toString();
label += keyAttrName.replace('[', '(').replace(']', ')');
}
ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_index_item.png");
if (index.isPrimaryKey()) {
node.setIconPath("icons/primary_key.png");
}
node.setType(NodeType.TABLE_INDEX);
node.setModelObj(index);
node.setContainer(false);
parent.addChild(node);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations