use of com.cubrid.common.ui.spi.model.ISchemaNode 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.ISchemaNode 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.ISchemaNode 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.ISchemaNode 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.ISchemaNode in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method closeAllEditorAndViewInDatabase.
/**
* Close all editor and view part related with this CUBRID Manager database
* node,not include query editor
*
* @param databaseNode the CubridDatabase object
* @param eventType CubridNodeChangedEventType
*/
public void closeAllEditorAndViewInDatabase(CubridDatabase databaseNode, CubridNodeChangedEventType eventType) {
IWorkbenchPage page = LayoutUtil.getActivePage();
if (page == null) {
return;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
for (int i = 0; editorRefArr != null && i < editorRefArr.length; i++) {
IEditorReference editorRef = editorRefArr[i];
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (!(editorInput instanceof ISchemaNode)) {
continue;
}
ISchemaNode schemaNode = ((ISchemaNode) editorInput);
ISchemaNode dbNode = schemaNode.getDatabase();
if (dbNode.getId().equals(databaseNode.getId())) {
page.closeEditor(editorRef.getEditor(false), true);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr == null || viewRefArr.length == 0) {
return;
}
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
if (!(viewPart instanceof CubridViewPart)) {
continue;
}
CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
ICubridNode cubridNode = cubridViewPart.getCubridNode();
if (!(cubridNode instanceof ISchemaNode)) {
continue;
}
ICubridNode cubridDatabaseNode = ((ISchemaNode) cubridNode).getDatabase();
if (cubridDatabaseNode.getId().equals(databaseNode.getId())) {
page.hideView(viewPart);
}
}
}
Aggregations