use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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.cubridmanager.core.cubrid.database.model.DatabaseInfo 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.cubridmanager.core.cubrid.database.model.DatabaseInfo 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.cubridmanager.core.cubrid.database.model.DatabaseInfo 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));
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class MenuProvider method buildUserTableMenu.
/**
* Construct user table related actions
*
* @param manager the parent IMenuManager
* @param node The ICubridNode object
*/
public void buildUserTableMenu(IMenuManager manager, ICubridNode node) {
DatabaseInfo dbInfo = ((ISchemaNode) node).getDatabase().getDatabaseInfo();
// SELECT GROUP
IMenuManager selectSqlMenu = new MenuManager(Messages.lblMakeSelectQueryGrp);
manager.add(selectSqlMenu);
// SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectQueryAction.ID));
// Parameterized SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectPstmtQueryAction.ID));
// Parameterized INSERT
addActionToManager(manager, getAction(MakeInsertQueryAction.ID));
// Parameterized UPDATE
addActionToManager(manager, getAction(MakeUpdateQueryAction.ID));
// Parameterized DELETE
addActionToManager(manager, getAction(MakeDeleteQueryAction.ID));
// CREATE GROUP
IMenuManager createSqlMenu = new MenuManager(Messages.lblMakeCreateQueryGrp);
manager.add(createSqlMenu);
addActionToManager(createSqlMenu, getAction(MakeCreateQueryAction.ID));
addActionToManager(createSqlMenu, getAction(MakeCloneQueryAction.ID));
manager.add(new Separator());
// Schema to Code Actions
addActionToManager(manager, getAction(TableToJavaCodeAction.ID));
addActionToManager(manager, getAction(TableToPhpCodeAction.ID));
addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
manager.add(new Separator());
// Install Schema Comment
addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
manager.add(new Separator());
// View data
IMenuManager viewDataMenu = new MenuManager(Messages.viewDataMenuName);
manager.add(viewDataMenu);
addActionToManager(viewDataMenu, getAction(TableSelectAllAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByOnePstmtDataAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByMultiPstmtDataAction.ID));
viewDataMenu.add(new Separator());
addActionToManager(viewDataMenu, getAction(TableSelectCountAction.ID));
// Input data
IMenuManager inputDataMenu = new MenuManager(Messages.inputDataMenuName);
manager.add(inputDataMenu);
addActionToManager(inputDataMenu, getAction(InsertOneByPstmtAction.ID));
addActionToManager(inputDataMenu, getAction(ImportDataFromFileAction.ID));
// addActionToManager(manager, getAction(RunSQLFileAction.ID));
manager.add(new Separator());
// Export & Import Actions
addActionToManager(manager, getAction(ExportWizardAction.ID));
addActionToManager(manager, getAction(ImportWizardAction.ID));
manager.add(new Separator());
// Manage table
addActionToManager(manager, getAction(EditTableAction.ID));
IAction renameTableAction = getAction(RenameTableAction.ID);
renameTableAction.setText(com.cubrid.common.ui.spi.Messages.tableRenameActionName);
renameTableAction.setImageDescriptor(CommonUIPlugin.getImageDescriptor("icons/action/table_rename.png"));
addActionToManager(manager, renameTableAction);
IMenuManager moreMenu = new MenuManager(Messages.tableMoreName);
addActionToManager(moreMenu, getAction(DeleteTableAction.ID));
IAction action = getAction(DeleteTableAction.ID);
if (CompatibleUtil.isSupportTruncateTable(dbInfo)) {
if (action != null) {
action.setText(Messages.deleteAllRecordsActionName);
}
addActionToManager(moreMenu, getAction(TruncateTableAction.ID));
} else {
if (action != null) {
action.setText(Messages.tableDeleteAllActionName);
}
}
IAction tableDropAction = getAction(DropTableAction.ID);
addActionToManager(moreMenu, tableDropAction);
moreMenu.add(new Separator());
if (CompatibleUtil.isSupportCreateTableLike(dbInfo)) {
addActionToManager(moreMenu, getAction(CreateLikeTableAction.ID));
}
manager.add(moreMenu);
}
Aggregations