use of com.cubrid.common.ui.spi.model.CubridDatabase 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.common.ui.spi.model.CubridDatabase 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.common.ui.spi.model.CubridDatabase 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.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class TitleLineContrItem method changeTitleForQueryEditor.
/**
*
* Change title line for query editor
*
* @param cubridNode the ICubridNode object
*/
public void changeTitleForQueryEditor(ICubridNode cubridNode) {
if (cubridNode == null) {
return;
}
CubridDatabase database = null;
String title = null;
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
database = schemaNode.getDatabase();
title = getTitleForQueryEditor(database);
}
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if (shell == null || shell.isDisposed()) {
return;
}
String productName = getProductName();
if (DatabaseNavigatorMenu.NULL_DATABASE.equals(database)) {
shell.setText(productName + " - " + DatabaseNavigatorMenu.NO_DATABASE_SELECTED_LABEL);
} else {
shell.setText(productName);
if (title != null && title.trim().length() > 0) {
shell.setText(productName + " - " + title);
}
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method getStmtSQL.
/**
* Create select statement SQL
*
* @param schemaNode DefaultSchemaNode
* @return String
*/
protected String getStmtSQL(DefaultSchemaNode schemaNode) {
// FIXME move this logic to core module
if (schemaNode == null) {
return "";
}
CubridDatabase db = schemaNode.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetAllAttrTask task = new GetAllAttrTask(dbInfo);
task.setClassName(schemaNode.getName());
task.getAttrList();
if (task.getErrorMsg() != null) {
return "";
}
List<DBAttribute> allAttrList = task.getAllAttrList();
return SQLGenerateUtils.getSelectSQLWithLimit(schemaNode.getName(), allAttrList);
}
Aggregations