use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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.event.CubridNodeChangedEvent 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.event.CubridNodeChangedEvent 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.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridFunctionFolderLoader 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().setSpFunctionInfoList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
task.setSpType(SPType.FUNCTION);
monitorCancel(monitor, new ITask[] { task });
task.execute();
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;
}
parent.removeAllChild();
List<SPInfo> spInfoList = task.getSPInfoList();
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
boolean isDBA = false;
String loginUserName = "";
if (userInfo != null && userInfo.isDbaAuthority()) {
isDBA = true;
}
if (userInfo != null) {
loginUserName = userInfo.getName();
}
List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
if (spInfoList != null && !spInfoList.isEmpty()) {
for (SPInfo spInfo : spInfoList) {
if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
continue;
}
authSpInfoList.add(spInfo);
String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
ICubridNode spNode = createFunctionNode(id, spInfo);
parent.addChild(spNode);
}
}
databaseInfo.setSpFunctionInfoList(authSpInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridProcedureFolderLoader 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().setSpProcedureInfoList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
task.setSpType(SPType.PROCEDURE);
monitorCancel(monitor, new ITask[] { task });
task.execute();
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;
}
parent.removeAllChild();
List<SPInfo> spInfoList = task.getSPInfoList();
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
boolean isDBA = false;
String loginUserName = "";
if (userInfo != null && userInfo.isDbaAuthority()) {
isDBA = true;
}
if (userInfo != null) {
loginUserName = userInfo.getName();
}
List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
if (spInfoList != null && !spInfoList.isEmpty()) {
for (SPInfo spInfo : spInfoList) {
if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
continue;
}
authSpInfoList.add(spInfo);
String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
ICubridNode spNode = createProcedureNode(id, spInfo);
parent.addChild(spNode);
}
}
databaseInfo.setSpProcedureInfoList(authSpInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations