use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridDbSpaceFolderLoader 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();
HashMap<String, FolderInformationContainer> foldersInformation;
HashMap<String, ICubridNode> foldersHashMap = new HashMap<String, ICubridNode>();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
CommonQueryTask<? extends DbSpaceInfoList> task;
DbSpaceInfoList dbSpaceInfoList;
if (DbSpaceInfoList.useOld(database.getDatabaseInfo().getServerInfo().getEnvInfo())) {
foldersInformation = foldersInformationOldFormat;
task = new CommonQueryTask<DbSpaceInfoListOld>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld());
} else {
foldersInformation = foldersInformationNewFormat;
task = new CommonQueryTask<DbSpaceInfoListNew>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
}
for (Map.Entry<String, FolderInformationContainer> entry : foldersInformation.entrySet()) {
String key = entry.getKey();
FolderInformationContainer value = entry.getValue();
ICubridNode folder = addFolder(parent, key, value.volumeFolderName, value.volumeFolder, value.type);
foldersHashMap.put(value.volumeType, folder);
}
ICubridNode logFolder = addFolder(parent, LOG_VOLUME_FOLDER_ID, LOG_VOLUME_FOLDER_NAME, CubridNodeType.LOG_VOLUEM_FOLDER, null);
foldersHashMap.put(VolumeType.ACTIVE_LOG.getText(), addFolder(logFolder, ACTIVE_LOG_FOLDER_ID, ACTIVE_LOG_FOLDER_NAME, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG));
foldersHashMap.put(VolumeType.ARCHIVE_LOG.getText(), addFolder(logFolder, ARCHIVE_LOG_FOLDER_ID, ARCHIVE_LOG_FOLDER_NAME, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG));
task.setDbName(database.getLabel());
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
for (ICubridNode folder : foldersHashMap.values()) {
folder.removeAllChild();
}
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(null, errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
for (ICubridNode folder : foldersHashMap.values()) {
folder.removeAllChild();
}
dbSpaceInfoList = task.getResultModel();
List<DbSpaceInfo> spaceInfoList = dbSpaceInfoList == null ? null : dbSpaceInfoList.getSpaceinfo();
for (int i = 0; spaceInfoList != null && i < spaceInfoList.size(); i++) {
DbSpaceInfo spaceInfo = spaceInfoList.get(i);
ICubridNode volumeNode = new DefaultSchemaNode("", spaceInfo.getShortVolumeName(), "");
volumeNode.setContainer(false);
volumeNode.setModelObj(spaceInfo);
volumeNode.setEditorId(VolumeInformationEditor.ID);
String key = null;
String type = spaceInfo.getType();
if (spaceInfo.getPurpose() != null) {
key = type + "_" + spaceInfo.getPurpose();
} else {
key = type;
}
if (type == null) {
continue;
}
ICubridNode folder = foldersHashMap.get(key);
if (folder != null) {
String id = folder.getId() + NODE_SEPARATOR + spaceInfo.getShortVolumeName();
volumeNode.setId(id);
volumeNode.setType(folder.getType());
volumeNode.setIconPath("icons/navigator/volume_item.png");
folder.addChild(volumeNode);
}
}
if (spaceInfoList != null && !spaceInfoList.isEmpty()) {
for (ICubridNode folder : foldersHashMap.values()) {
Collections.sort(folder.getChildren());
}
}
databaseInfo.setDbSpaceInfoList(dbSpaceInfoList);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridDbSpaceFolderLoader method addFolder.
private ICubridNode addFolder(ICubridNode parent, String volumeFolderId, String volumeFolderName, String volumeFolder, String type) {
String indexVolumeFolderId = parent.getId() + NODE_SEPARATOR + volumeFolderId;
ICubridNode node = parent.getChild(indexVolumeFolderId);
if (node == null) {
node = new DefaultSchemaNode(indexVolumeFolderId, volumeFolderName, "icons/navigator/folder.png");
node.setType(volumeFolder);
node.setContainer(true);
if (volumeFolder.compareTo(CubridNodeType.LOG_VOLUEM_FOLDER) != 0) {
node.setEditorId(VolumeFolderInfoEditor.ID);
}
parent.addChild(node);
}
return node;
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridBackupPlanFolderLoader 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();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetBackupPlanListTask task = new GetBackupPlanListTask(parent.getServer().getServerInfo());
task.setDbName(database.getLabel());
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<BackupPlanInfo> backupPlanInfoList = task.getBackupPlanInfoList();
if (backupPlanInfoList != null && !backupPlanInfoList.isEmpty()) {
for (BackupPlanInfo backupPlanInfo : backupPlanInfoList) {
String id = parent.getId() + NODE_SEPARATOR + backupPlanInfo.getBackupid();
ICubridNode backupPlanInfoNode = new DefaultSchemaNode(id, backupPlanInfo.getBackupid(), "icons/navigator/auto_backup_item.png");
backupPlanInfoNode.setContainer(false);
backupPlanInfoNode.setType(CubridNodeType.BACKUP_PLAN);
backupPlanInfoNode.setModelObj(backupPlanInfo);
parent.addChild(backupPlanInfoNode);
}
}
databaseInfo.setBackupPlanInfoList(backupPlanInfoList);
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.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridJobAutoFolderLoader 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;
}
// add backup plan folder
String backupPlanFolderId = parent.getId() + NODE_SEPARATOR + BACKUP_PLAN_FOLDER_ID;
ICubridNode backupPlanFolder = parent.getChild(backupPlanFolderId);
if (backupPlanFolder == null) {
backupPlanFolder = new DefaultSchemaNode(backupPlanFolderId, BACKUP_PLAN_FOLDER_NAME, "icons/navigator/folder.png");
backupPlanFolder.setType(CubridNodeType.BACKUP_PLAN_FOLDER);
backupPlanFolder.setContainer(true);
ICubridNodeLoader loader = new CubridBackupPlanFolderLoader();
loader.setLevel(getLevel());
backupPlanFolder.setLoader(loader);
parent.addChild(backupPlanFolder);
if (getLevel() == DEFINITE_LEVEL) {
backupPlanFolder.getChildren(monitor);
}
} else {
if (backupPlanFolder.getLoader() != null && backupPlanFolder.getLoader().isLoaded()) {
backupPlanFolder.getLoader().setLoaded(false);
backupPlanFolder.getChildren(monitor);
}
}
// add query plan folder
String queryPlanFolderId = parent.getId() + NODE_SEPARATOR + QUERY_PLAN_FOLDER_ID;
ICubridNode queryPlanFolder = parent.getChild(queryPlanFolderId);
if (queryPlanFolder == null) {
queryPlanFolder = new DefaultSchemaNode(queryPlanFolderId, QUERY_PLAN_FOLDER_NAME, "icons/navigator/folder.png");
queryPlanFolder.setType(CubridNodeType.QUERY_PLAN_FOLDER);
queryPlanFolder.setContainer(true);
ICubridNodeLoader loader = new CubridQueryPlanFolderLoader();
loader.setLevel(getLevel());
queryPlanFolder.setLoader(loader);
parent.addChild(queryPlanFolder);
if (getLevel() == DEFINITE_LEVEL) {
queryPlanFolder.getChildren(monitor);
}
} else {
if (queryPlanFolder.getLoader() != null && queryPlanFolder.getLoader().isLoaded()) {
queryPlanFolder.getLoader().setLoaded(false);
queryPlanFolder.getChildren(monitor);
}
}
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method openSelectQuery.
public void openSelectQuery(ISelection selection) {
final Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ISchemaNode table = (ISchemaNode) obj;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
boolean existsEditor = false;
QueryEditorPart editor = null;
QueryUnit input = new QueryUnit();
input.setDatabase(table.getDatabase());
try {
IEditorPart editorPart = window.getActivePage().getActiveEditor();
if (editorPart != null && editorPart instanceof QueryEditorPart) {
QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
if (queryEditorPart.getSelectedDatabase() == input.getDatabase()) {
editor = (QueryEditorPart) editorPart;
existsEditor = true;
}
}
if (editor == null) {
editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
editor.connect(table.getDatabase());
}
DefaultSchemaNode tableNode = (DefaultSchemaNode) obj;
String sql = getStmtSQL(tableNode) + StringUtil.NEWLINE + StringUtil.NEWLINE;
if (existsEditor) {
editor.newQueryTab(sql, true);
} else {
editor.setQuery(sql, false, true, false);
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
Aggregations