use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class OpenQueryConnAction method run.
/**
* Open the query connection
*/
public void run() {
// TODO remove later
CQBGroupNodePersistManager.getInstance().fix();
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISelectionProvider provider = getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
CubridDatabase[] cubridDatabases = handleSelectionObj(obj);
if (cubridDatabases.length > 1) {
List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
for (CubridDatabase object : cubridDatabases) {
CubridDatabase database = (CubridDatabase) object;
String errMsg = null;
if (database.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo());
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
database.getLoader().setLoaded(false);
database.setLogined(true);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else {
failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
}
}
if (failedDatabaseList.size() > 0) {
MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
dialog.open();
}
return;
}
CubridDatabase database = cubridDatabases[0];
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo())) {
database.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else {
ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridShardsFolderLoader 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;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
if (serverInfo == null) {
LOGGER.error("The serverInfo is a null.");
return;
}
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
if (userInfo == null || CasAuthType.AUTH_NONE == userInfo.getCasAuth()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
Display display = Display.getDefault();
boolean statusTag = false;
boolean confTag = false;
Shards shards = new Shards();
GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
monitorCancel(monitor, new ITask[] { getShardConfTask });
getShardConfTask.execute();
if (!monitor.isCanceled() && !getShardConfTask.isSuccess()) {
final String errorMsg = getShardConfTask.getErrorMsg();
confTag = false;
cubridShardFolder.setEnable(false);
parent.removeAllChild();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
setLoaded(true);
// return;
} else {
confTag = true;
getShardConfTask.loadDataToModel();
serverInfo.setShards(shards);
}
GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
monitorCancel(monitor, new ITask[] { getShardStatusTask });
getShardStatusTask.execute();
ShardsStatus shardsStatus = null;
if (getShardStatusTask.isSuccess()) {
shardsStatus = getShardStatusTask.getShardsStatus();
cubridShardFolder.setRunning(true);
statusTag = true;
} else {
final String errorMsg = getShardStatusTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
statusTag = false;
if (errorMsg.trim().contains("cubrid shard is not running")) {
cubridShardFolder.setRunning(false);
parent.removeAllChild();
// return;
} else {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
}
}
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ICubridNode> oldNodeList = parent.getChildren();
parent.removeAllChild();
Map<String, ShardStatus> tmpCache = new HashMap<String, ShardStatus>();
if (statusTag) {
List<ShardStatus> shardStatuss = (shardsStatus == null || shardsStatus.getShardStatuss() == null) ? null : shardsStatus.getShardStatuss();
for (int i = 0; shardStatuss != null && i < shardStatuss.size(); i++) {
ShardStatus shard = shardStatuss.get(i);
tmpCache.put(shard.getName(), shard);
}
}
if (confTag) {
List<Shard> shardList = (shards == null || shards.getShardList() == null) ? null : shards.getShardList();
for (int i = 0; shardList != null && i < shardList.size(); i++) {
Shard shard = shardList.get(i);
//
ShardConnection shardConnection = new ShardConnection();
shard.setShardConnectionFile(shardConnection);
GetShardConfTask<ShardConnection> getShardConnectionConfTask = new GetShardConfTask<ShardConnection>(serverInfo, shardConnection);
getShardConnectionConfTask.execute();
getShardConnectionConfTask.loadDataToModel();
ShardKeys shardKeys = new ShardKeys();
shard.setShardKeysFile(shardKeys);
GetShardConfTask<ShardKeys> getShardKeyConfTask = new GetShardConfTask<ShardKeys>(serverInfo, shardKeys);
getShardKeyConfTask.execute();
getShardKeyConfTask.loadDataToModel();
//
String id = parent.getId() + NODE_SEPARATOR + shard.getName();
ICubridNode shardNode = isContained(oldNodeList, id);
ShardStatus shardStatus = tmpCache.get(shard.getName());
String shardLabel = shardStatus != null ? " (" + shardStatus.getPort() + "," + shardStatus.getAccessMode() + ")" : "";
if (shardNode == null) {
shardNode = new CubridShard(id, shard.getName() + shardLabel);
((CubridShard) shardNode).setName(shard.getName());
shardNode.setType(CubridNodeType.SHARD);
shardNode.setContainer(true);
shardNode.setModelObj(shard);
shardNode.setLoader(new CubridShardFolderLoader());
} else {
shardNode.setModelObj(shard);
if (shardNode.getLoader() != null && shardNode.getLoader().isLoaded()) {
shardNode.getLoader().setLoaded(false);
shardNode.getChildren(monitor);
}
}
((CubridShard) shardNode).setRunning(shardStatus != null);
parent.addChild(shardNode);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridQueryPlanFolderLoader 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 GetQueryPlanListTask task = new GetQueryPlanListTask(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<QueryPlanInfo> queryPlanInfoList = task.getQueryPlanInfoList();
if (queryPlanInfoList != null && !queryPlanInfoList.isEmpty()) {
for (QueryPlanInfo queryPlanInfo : queryPlanInfoList) {
String id = parent.getId() + NODE_SEPARATOR + queryPlanInfo.getQuery_id();
ICubridNode queryPlanInfoNode = new DefaultSchemaNode(id, queryPlanInfo.getQuery_id(), "icons/navigator/auto_query_item.png");
queryPlanInfoNode.setContainer(false);
queryPlanInfoNode.setModelObj(queryPlanInfo);
queryPlanInfoNode.setType(CubridNodeType.QUERY_PLAN);
parent.addChild(queryPlanInfoNode);
}
}
databaseInfo.setQueryPlanInfoList(queryPlanInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridDatabaseLogLoader 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() || parent == null) {
return;
}
String dbName = parent.getLabel();
ServerInfo serverInfo = parent.getServer().getServerInfo();
DbLogInfos dbLogInfos = new DbLogInfos();
final CommonQueryTask<DbLogInfos> task = new CommonQueryTask<DbLogInfos>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbLogInfos);
task.setDbName(dbName);
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();
dbLogInfos = task.getResultModel();
DbLogInfoList dbLogInfoList = dbLogInfos == null ? null : dbLogInfos.getDbLogInfoList();
List<LogInfo> logInfoList = dbLogInfoList == null ? null : dbLogInfoList.getDbLogInfoList();
if (logInfoList != null) {
for (LogInfo dbLogInfo : logInfoList) {
String id = parent.getId() + NODE_SEPARATOR + dbLogInfo.getName();
CubridDbLogNode dbLogInfoNode = new CubridDbLogNode(id, dbLogInfo.getName(), "icons/navigator/log_item.png");
dbLogInfoNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_LOG);
dbLogInfoNode.setModelObj(dbLogInfo);
dbLogInfoNode.setEditorId(LogEditorPart.ID);
dbLogInfoNode.setContainer(false);
parent.addChild(dbLogInfoNode);
}
}
if (dbLogInfos != null && serverInfo.getLogInfoManager() != null) {
serverInfo.getLogInfoManager().addDbLogInfos(dbLogInfos);
}
if (parent.getChildren() != null && !parent.getChildren().isEmpty()) {
Collections.sort(parent.getChildren());
}
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = (CubridDatabase) parent;
database.getDatabaseInfo().clear();
if (!database.isLogined()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
//when refresh,firstly check whether this database exist
ServerInfo serverInfo = parent.getServer().getServerInfo();
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
ParamDumpTask paramDumpTask = null;
if (CompatibleUtil.isSupportGetParamDump(serverInfo)) {
paramDumpTask = new ParamDumpTask(serverInfo);
paramDumpTask.setDbName(database.getLabel());
paramDumpTask.setBoth(YesNoType.N);
}
monitorCancel(monitor, new ITask[] { getDatabaseListTask, paramDumpTask });
getDatabaseListTask.execute();
if (!checkResult(getDatabaseListTask, monitor)) {
parent.removeAllChild();
return;
}
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
ParamDumpInfo paraDumpInfo = null;
if (paramDumpTask != null) {
paramDumpTask.execute();
if (!checkResult(paramDumpTask, monitor)) {
parent.removeAllChild();
return;
}
paraDumpInfo = paramDumpTask.getContent();
}
String databaseName = database.getLabel();
boolean isExist = false;
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
DatabaseInfo dbInfo = databaseInfoList.get(i);
if (dbInfo.getDbName().equalsIgnoreCase(databaseName)) {
database.setRunningType(dbInfo.getRunningType());
isExist = true;
}
}
if (!isExist) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errDatabaseNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
if (!loadReplication(parent, monitor)) {
setLoaded(true);
return;
}
// add tables folder
addTableFolder(monitor, database);
// add views folder
addViewFolder(monitor, database);
// add serials folder
addSerialFolder(monitor, database);
// add user folder
addUserFolder(monitor, database);
// add triggers folder
addTriggerFolder(monitor, database);
// add stored procedure folder
addProcedureFolder(monitor, database);
// add job automation folder
addJobAutoFolder(monitor, database);
// add database space folder
addSpaceFolder(monitor, database);
// set parameter dump information
database.getDatabaseInfo().setParaDumpInfo(paraDumpInfo);
// set charset info
setDbCollation(database);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations