use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class RenameTableAction method doRun.
/**
* Perform rename Table
*
* @param cubridDatabase
* @param table
*/
private void doRun(CubridDatabase cubridDatabase, ISchemaNode table) {
boolean isTable = false;
String type = table.getType();
if (NodeType.USER_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
isTable = true;
} else if (NodeType.USER_VIEW.equals(type)) {
isTable = false;
}
String tableName = table.getName();
CubridDatabase db = table.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetTablesTask getTableTask = new GetTablesTask(dbInfo);
List<String> tableList = getTableTask.getAllTableAndViews();
RenameTableDialog dlg = new RenameTableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), tableName, isTable, tableList, true);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
String newName = dlg.getNewName();
RenameTableOrViewTask task = new RenameTableOrViewTask(dbInfo);
task.setOldClassName(tableName);
task.setNewClassName(newName);
task.setTable(isTable);
String taskName = Messages.bind(com.cubrid.common.ui.cubrid.table.Messages.renameTableTaskName, new String[] { tableName, newName });
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ISelectionProvider provider = this.getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
//remove the old table schema information
table.getDatabase().getDatabaseInfo().removeSchema(tableName);
DefaultSchemaNode cloneTable = null;
try {
cloneTable = ((DefaultSchemaNode) table).clone();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cloneTable, CubridNodeChangedEventType.NODE_REMOVE));
} catch (CloneNotSupportedException ex) {
LOGGER.error(ex.getMessage());
}
ClassInfo classInfo = (ClassInfo) table.getAdapter(ClassInfo.class);
classInfo.setClassName(newName);
table.setId(table.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + newName);
table.setLabel(newName);
viewer.refresh(table, true);
LayoutManager.getInstance().getWorkbenchContrItem().reopenEditorOrView(table);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(table, CubridNodeChangedEventType.NODE_ADD));
ActionManager.getInstance().fireSelectionChanged(getSelection());
/*Broadcast the view changed*/
QueryEditorUtil.fireSchemaNodeChanged(table);
/*For bug TOOLS-3118: close opened TableEditorPart about dropped table*/
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
for (IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
IEditorPart editor = editorRef.getEditor(true);
if (editor.getEditorInput() instanceof TableEditorInput) {
TableEditorInput input = (TableEditorInput) editor.getEditorInput();
ISchemaNode tableOfEditor = input.getEditedTableNode();
if (tableOfEditor.equals(table)) {
workbenchWindow.getActivePage().closeEditor(editor, false);
break;
}
}
}
}
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class PropertyViewAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, false);
GetAllClassListTask getAllClassListTask = new GetAllClassListTask(database.getDatabaseInfo());
getAllClassListTask.setTableName(node.getName());
GetViewAllColumnsTask getAllDBVclassTask = new GetViewAllColumnsTask(database.getDatabaseInfo());
getAllDBVclassTask.setClassName(node.getName());
GetAllAttrTask getAllAttrTask = new GetAllAttrTask(database.getDatabaseInfo());
getAllAttrTask.setClassName(node.getName());
JDBCGetAllDbUserTask getAllDbUserTask = new JDBCGetAllDbUserTask(database.getDatabaseInfo());
dialog.execTask(-1, new ITask[] { getAllClassListTask, getAllDBVclassTask, getAllAttrTask, getAllDbUserTask }, true, getShell());
if (getAllClassListTask.getErrorMsg() != null || getAllDBVclassTask.getErrorMsg() != null || getAllAttrTask.getErrorMsg() != null || getAllDbUserTask.getErrorMsg() != null || getAllClassListTask.isCancel() || getAllDBVclassTask.isCancel() || getAllAttrTask.isCancel() || getAllDbUserTask.isCancel()) {
return;
}
ClassInfo classInfo = getAllClassListTask.getClassInfo();
List<String> vclassList = getAllDBVclassTask.getAllVclassList();
List<DBAttribute> attrList = getAllAttrTask.getAllAttrList();
List<String> dbUserList = getAllDbUserTask.getDbUserList();
dialog.setAttrList(attrList);
dialog.setClassInfo(classInfo);
dialog.setVclassList(vclassList);
dialog.setDbUserList(dbUserList);
dialog.setPropertyQuery(true);
dialog.open();
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method setInputs.
public void setInputs() {
tableListView.setInput(tableList);
tableListView.refresh();
Connection connection = null;
try {
connection = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
isSchemaCommentInstalled = SchemaCommentHandler.isInstalledMetaTable(database.getDatabaseInfo(), connection);
TableDashboardComposite tableComp = new TableDashboardComposite(tabFolder, SWT.NONE);
tableComp.initialize();
if (database.getDatabaseInfo().getUserTableInfoList().size() > 0) {
ClassInfo classInfo = database.getDatabaseInfo().getUserTableInfoList().get(0);
SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, classInfo.getClassName());
IDatabaseSpec dbSpec = database.getDatabaseInfo();
if (schemaInfo != null && SchemaCommentHandler.isInstalledMetaTable(dbSpec, connection)) {
Map<String, SchemaComment> comments = SchemaCommentHandler.loadDescription(dbSpec, connection, classInfo.getClassName());
if (comments != null) {
SchemaCommentHandler.bindSchemaInfo(comments, schemaInfo);
}
}
tableComp.setInput(schemaInfo, database.getDatabaseInfo(), isSchemaCommentInstalled);
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
QueryUtil.freeQuery(connection);
}
if (isSchemaCommentInstalled) {
new TableEditButtonSupport(tableListView, this, 1);
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class TableEditorPart method completeAll.
public void completeAll() {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgNull2DefComplete, jobName));
if (this.isNewTableFlag) {
ICubridNode node = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTablesFolderLoader.TABLES_FOLDER_ID);
if (node == null || !node.getLoader().isLoaded()) {
return;
}
String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
boolean isPartition = newSchemaInfo.getPartitionList() != null && newSchemaInfo.getPartitionList().size() > 0;
ClassInfo newClassInfo = new ClassInfo(tableName, owner, ClassType.NORMAL, false, isPartition);
ICubridNode newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
if (CubridNavigatorView.findNavigationView() == null) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
CommonUITool.addNodeToTree(treeViewer, node, newNode);
// refresh table folder count label
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
if (database == null) {
return;
}
database.getDatabaseInfo().removeSchema(tableName);
if (oldPartitionInfoList.isEmpty() && !partitionInfoList.isEmpty()) {
editedTableNode.setIconPath("icons/navigator/schema_table_partition.png");
editedTableNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
editedTableNode.setLoader(new CubridPartitionedTableLoader());
} else if (!oldPartitionInfoList.isEmpty() && partitionInfoList.isEmpty()) {
editedTableNode.setIconPath("icons/navigator/schema_table_item.png");
editedTableNode.setType(NodeType.USER_TABLE);
editedTableNode.setLoader(new CubridUserTableLoader());
}
TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
CommonUITool.refreshNavigatorTree(treeViewer, editedTableNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(editedTableNode, CubridNodeChangedEventType.NODE_REFRESH));
/* Broadcast the view changed */
QueryEditorUtil.fireSchemaNodeChanged(editedTableNode);
}
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo 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));
}
}
Aggregations