use of com.cubrid.common.ui.cubrid.table.dialog.CreateLikeTableDialog in project cubrid-manager by CUBRID.
the class CreateLikeTableAction method doRun.
/**
* Do run
*
* @param node
*/
private void doRun(ISchemaNode node) {
CreateLikeTableDialog dialog = new CreateLikeTableDialog(getShell());
dialog.setDatabase(node.getDatabase());
if (NodeType.USER_TABLE.equals(node.getType())) {
String tableName = node.getName();
dialog.setLikeTableName(tableName);
}
if (IDialogConstants.OK_ID == dialog.open()) {
// FIXME
TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
String tableName = dialog.getNewTableName();
ICubridNode newNode = null;
if (NodeType.USER_TABLE.equals(node.getType())) {
ClassInfo classInfo = (ClassInfo) node.getAdapter(ClassInfo.class);
String id = node.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
ClassInfo newClassInfo = new ClassInfo(tableName, null, ClassType.NORMAL, classInfo.isSystemClass(), classInfo.isPartitionedClass());
newNode = CubridTablesFolderLoader.createUserTableNode(node.getParent(), id, newClassInfo, node.getParent().getLoader().getLevel(), new NullProgressMonitor());
if (node.getDatabase().getDatabaseInfo().getUserTableInfoList() != null) {
node.getDatabase().getDatabaseInfo().getUserTableInfoList().add(newClassInfo);
}
CommonUITool.addNodeToTree(treeViewer, node.getParent(), newNode);
} else {
if (node == null || !node.getLoader().isLoaded()) {
return;
}
String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
ClassInfo newClassInfo = new ClassInfo(tableName, null, ClassType.NORMAL, false, false);
newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
CommonUITool.addNodeToTree(treeViewer, node, newNode);
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
}
}
Aggregations