use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridUserTableColumnLoader 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;
}
if (columns == null && !getColumns(parent, monitor, database)) {
return;
}
if (monitor.isCanceled()) {
columns = null;
setLoaded(true);
return;
}
parent.removeAllChild();
String parentId = parent.getId();
if (columns != null && !columns.isEmpty()) {
for (TableColumn column : columns) {
String label = column.getColumnName() + ",";
label += FieldHandlerUtils.getComleteType(column.getTypeName(), column.getSubElementTypeName(), column.getPrecision(), column.getScale());
String nodeId = parentId + NODE_SEPARATOR + column.getColumnName();
ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_column_item.png");
if (column.isPrimaryKey()) {
node.setIconPath("icons/primary_key.png");
}
node.setType(NodeType.TABLE_COLUMN);
node.setModelObj(column);
node.setContainer(false);
parent.addChild(node);
}
}
columns = null;
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode 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));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridUserTableLoader method loadIndexes.
/**
* Load the indexes and its children node
*
* @param parent the parent node
* @param level the node level
* @param monitor the IProgressMonitor object
*/
protected void loadIndexes(ICubridNode parent, int level, final IProgressMonitor monitor) {
synchronized (this) {
String indexFolderId = parent.getId() + NODE_SEPARATOR + INDEX_FOLDER_ID;
ICubridNode indexFolder = parent.getChild(indexFolderId);
if (indexFolder == null) {
indexFolder = new DefaultSchemaNode(indexFolderId, INDEX_FOLDER_NAME, "icons/navigator/folder.png");
indexFolder.setType(NodeType.TABLE_INDEX_FOLDER);
indexFolder.setContainer(true);
parent.addChild(indexFolder);
ICubridNodeLoader indexLoader = new CubridUserTableIndexLoader();
indexLoader.setLevel(level);
indexFolder.setLoader(indexLoader);
} else {
if (indexFolder.getLoader() != null && indexFolder.getLoader().isLoaded()) {
indexFolder.getLoader().setLoaded(false);
indexFolder.getChildren(monitor);
}
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridViewsFolderLoader 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) {
database.getDatabaseInfo().setUserViewInfoList(null);
database.getDatabaseInfo().setSysViewInfoList(null);
database.getDatabaseInfo().clearSchemas();
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
List<ClassInfo> allClassInfoList = task.getSchema(true, false);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
// add system view folder
String systemViewFolderId = parent.getId() + NODE_SEPARATOR + SYSTEM_VIEW_FOLDER_ID;
ICubridNode systemViewFolder = parent.getChild(systemViewFolderId);
parent.removeAllChild();
if (systemViewFolder == null) {
systemViewFolder = new DefaultSchemaNode(systemViewFolderId, SYSTEM_VIEW_FOLDER_NAME, "icons/navigator/folder_sys.png");
systemViewFolder.setType(NodeType.SYSTEM_VIEW_FOLDER);
systemViewFolder.setContainer(true);
ICubridNodeLoader loader = new CubridSystemViewFolderLoader();
loader.setLevel(getLevel());
systemViewFolder.setLoader(loader);
parent.addChild(systemViewFolder);
if (getLevel() == DEFINITE_LEVEL) {
systemViewFolder.getChildren(monitor);
}
} else {
parent.addChild(systemViewFolder);
if (systemViewFolder.getLoader() != null && systemViewFolder.getLoader().isLoaded()) {
systemViewFolder.getLoader().setLoaded(false);
systemViewFolder.getChildren(monitor);
}
}
if (allClassInfoList != null) {
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = createUserViewNode(id, classInfo);
parent.addChild(classNode);
}
}
database.getDatabaseInfo().setUserViewInfoList(allClassInfoList);
database.getDatabaseInfo().clearSchemas();
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridFunctionFolderLoader method createFunctionNode.
/**
*
* Create function node
*
* @param id The node id
* @param spInfo The model object
* @return ICubridNode
*/
public static ICubridNode createFunctionNode(String id, SPInfo spInfo) {
ICubridNode spNode = new DefaultSchemaNode(id, spInfo.getSpName(), "icons/navigator/procedure_func_item.png");
spNode.setType(NodeType.STORED_PROCEDURE_FUNCTION);
spNode.setModelObj(spInfo);
spNode.setContainer(false);
return spNode;
}
Aggregations