use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CreateViewAction method run.
public void run(CubridDatabase database) {
TaskExecutor taskExcutor = new CommonTaskExec(null);
DatabaseInfo databaseInfo = database.getDatabaseInfo();
JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<String> dbUserList = task.getDbUserList();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, true);
dialog.setDbUserList(dbUserList);
ISelectionProvider provider = getSelectionProvider();
if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String viewName = dialog.getNewViewName();
String owner = dialog.getOwner();
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + viewName;
ClassInfo newClassInfo = new ClassInfo(viewName, owner, ClassType.VIEW, false, false);
ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode(id, newClassInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridUserTableLoader 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;
}
List<ICubridNode> nodes = parent.getChildren();
for (int i = nodes.size() - 1; i >= 0; i--) {
ICubridNode node = nodes.get(i);
if (!node.isContainer()) {
parent.removeChild(node);
}
}
loadColumns(parent, getLevel(), monitor);
loadIndexes(parent, getLevel(), monitor);
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 DefaultCubridNode method removeChild.
/**
* Remove child object from this node
*
* @param obj the ICubridNode object
*/
public void removeChild(ICubridNode obj) {
if (obj != null) {
childList.remove(obj);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(obj, CubridNodeChangedEventType.NODE_REMOVE));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridTriggerFolderLoader 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().setTriggerList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
ITask task = null;
if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
task = new GetTriggerListTask(parent.getServer().getServerInfo());
((GetTriggerListTask) task).setDbName(database.getLabel());
} else {
task = new JDBCGetTriggerListTask(databaseInfo);
}
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<Trigger> triggerList = null;
if (task instanceof GetTriggerListTask) {
triggerList = ((GetTriggerListTask) task).getTriggerInfoList();
} else if (task instanceof JDBCGetTriggerListTask) {
triggerList = ((JDBCGetTriggerListTask) task).getTriggerInfoList();
}
if (triggerList != null && !triggerList.isEmpty()) {
for (Trigger trigger : triggerList) {
String id = parent.getId() + NODE_SEPARATOR + trigger.getName();
ICubridNode triggerNode = createTriggerNode(id, trigger);
parent.addChild(triggerNode);
}
}
databaseInfo.setTriggerList(triggerList);
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 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));
}
}
Aggregations