use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.
the class CubridSystemViewFolderLoader 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().setSysViewInfoList(null);
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(false, 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;
}
parent.removeAllChild();
if (allClassInfoList != null) {
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_view_item.png");
classNode.setType(NodeType.SYSTEM_VIEW);
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(false);
classNode.setModelObj(classInfo);
parent.addChild(classNode);
}
}
database.getDatabaseInfo().setSysViewInfoList(allClassInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.
the class CubridTablesFolderLoader 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().setUserTableInfoList(null);
database.getDatabaseInfo().setSysTableInfoList(null);
database.getDatabaseInfo().setPartitionedTableMap(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, true);
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 table folder
String systemTableFolderId = parent.getId() + NODE_SEPARATOR + SYSTEM_TABLE_FOLDER_ID;
ICubridNode systemTableFolder = parent.getChild(systemTableFolderId);
parent.removeAllChild();
if (systemTableFolder == null) {
systemTableFolder = new DefaultSchemaNode(systemTableFolderId, SYSTEM_TABLE_FOLDER_NAME, "icons/navigator/folder_sys.png");
systemTableFolder.setType(NodeType.SYSTEM_TABLE_FOLDER);
systemTableFolder.setContainer(true);
ICubridNodeLoader loader = new CubridSystemTableFolderLoader();
loader.setLevel(getLevel());
systemTableFolder.setLoader(loader);
parent.addChild(systemTableFolder);
if (getLevel() == DEFINITE_LEVEL) {
systemTableFolder.getChildren(monitor);
}
} else {
parent.addChild(systemTableFolder);
if (systemTableFolder.getLoader() != null && systemTableFolder.getLoader().isLoaded()) {
systemTableFolder.getLoader().setLoaded(false);
systemTableFolder.getChildren(monitor);
}
}
if (allClassInfoList != null) {
createUserTableNodes(parent, allClassInfoList, getLevel(), monitor);
}
database.getDatabaseInfo().setUserTableInfoList(allClassInfoList);
database.getDatabaseInfo().clearSchemas();
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.
the class CubridSystemTableFolderLoader 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().setSysTableInfoList(null);
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(false, true);
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();
if (allClassInfoList != null) {
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.setType(NodeType.SYSTEM_TABLE);
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(false);
classNode.setModelObj(classInfo);
parent.addChild(classNode);
}
}
database.getDatabaseInfo().setSysTableInfoList(allClassInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.
the class CQBUserEditor method execTask.
/**
* Execute tasks
*
* @param tasks the task array
* @return boolean
*/
public boolean execTask(final ITask[] tasks) {
TaskExecutor taskExecutor = new TaskExecutor() {
public boolean exec(IProgressMonitor monitor) {
for (ITask t : tasks) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof GetUserListTask) {
try {
userListInfo = ((GetUserListTask) t).getResultModel();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return false;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ITask task : tasks) {
taskExecutor.addTask(task);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
return taskExecutor.isSuccess();
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.
the class UserEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> if it is successfully;<code>false</code>
* otherwise
*/
public boolean loadData() {
final CommonQueryTask<DbUserInfoList> userTask = new CommonQueryTask<DbUserInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbUserInfoList(), database.getDatabaseInfo().getCharSet());
userTask.setDbName(database.getName());
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo());
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo());
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof CommonQueryTask) {
userListInfo = ((CommonQueryTask<DbUserInfoList>) t).getResultModel();
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
initial();
}
});
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(userTask);
taskJobExecutor.addTask(classInfoTask);
taskJobExecutor.addTask(partitionTask);
String jobName = Messages.viewUserInfoJobName + " - " + userName + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
Aggregations