use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridBrokersFolderLoader 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();
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;
}
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
monitorCancel(monitor, new ITask[] { task });
task.execute();
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;
}
brokerInfos = task.getResultModel();
List<ICubridNode> oldNodeList = parent.getChildren();
parent.removeAllChild();
List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
String id = parent.getId() + NODE_SEPARATOR + brokerInfo.getName();
ICubridNode brokerInfoNode = isContained(oldNodeList, id);
if (brokerInfoNode == null) {
brokerInfoNode = new CubridBroker(id, brokerInfo.getName(), "icons/navigator/broker.png");
((CubridBroker) brokerInfoNode).setStartedIconPath("icons/navigator/broker_started.png");
brokerInfoNode.setType(CubridNodeType.BROKER);
brokerInfoNode.setContainer(true);
brokerInfoNode.setModelObj(brokerInfo);
brokerInfoNode.setViewId(BrokerStatusView.ID);
brokerInfoNode.setLoader(new CubridBrokerFolderLoader());
} else {
brokerInfoNode.setModelObj(brokerInfo);
if (brokerInfoNode.getLoader() != null && brokerInfoNode.getLoader().isLoaded()) {
brokerInfoNode.getLoader().setLoaded(false);
brokerInfoNode.getChildren(monitor);
}
}
parent.addChild(brokerInfoNode);
}
serverInfo.setBrokerInfos(brokerInfos);
// For the Shard Broker Folder
if (CompatibleUtil.isSupportShard(serverInfo)) {
Shards shards = new Shards();
GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
getShardConfTask.execute();
// !"File(?) open error".equals(errorMsg.trim())) {
if (getShardConfTask.isSuccess()) {
GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
getShardStatusTask.execute();
boolean runningShard = getShardStatusTask.isSuccess();
serverInfo.setShards(shards);
shards.setRunning(runningShard);
String shardFolderId = parent.getId() + NODE_SEPARATOR + SHARD_FOLDER_ID;
ICubridNode shardFolder = parent.getChild(shardFolderId);
if (shardFolder == null) {
shardFolder = new CubridShardFolder(shardFolderId, SHARD_FOLDER_NAME);
ICubridNodeLoader loader = new CubridShardsFolderLoader((CubridShardFolder) shardFolder);
loader.setLevel(getLevel());
shardFolder.setLoader(loader);
parent.addChild(shardFolder);
// shardFolder.getChildren(monitor);
} else {
if (shardFolder.getLoader() != null && shardFolder.getLoader().isLoaded()) {
shardFolder.getLoader().setLoaded(false);
shardFolder.getChildren(monitor);
}
}
}
}
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.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method addSerialFolder.
/**
* Add serial folder
*
* @param monitor the IProgressMonitor
* @param database the CubridDatabase
*/
private void addSerialFolder(final IProgressMonitor monitor, CubridDatabase database) {
String serialFolderId = database.getId() + NODE_SEPARATOR + CubridSerialFolderLoader.SERIAL_FOLDER_ID;
ICubridNode serialFolder = database.getChild(serialFolderId);
if (serialFolder == null) {
serialFolder = new DefaultSchemaNode(serialFolderId, SERIAL_FOLDER_NAME, "icons/navigator/serial_group.png");
serialFolder.setType(NodeType.SERIAL_FOLDER);
serialFolder.setContainer(true);
ICubridNodeLoader loader = new CubridSerialFolderLoader();
loader.setLevel(getLevel());
serialFolder.setLoader(loader);
database.addChild(serialFolder);
if (getLevel() == DEFINITE_LEVEL) {
serialFolder.getChildren(monitor);
}
} else {
if (serialFolder.getLoader() != null && serialFolder.getLoader().isLoaded()) {
serialFolder.getLoader().setLoaded(false);
serialFolder.getChildren(monitor);
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method addViewFolder.
/**
* Add view folder
*
* @param monitor the IProgressMonitor
* @param database the CubridDatabase
*/
private void addViewFolder(final IProgressMonitor monitor, CubridDatabase database) {
String viewsFolderId = database.getId() + NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID;
ICubridNode viewsFolder = database.getChild(viewsFolderId);
if (viewsFolder == null) {
viewsFolder = new DefaultSchemaNode(viewsFolderId, VIEWS_FOLDER_NAME, "icons/navigator/schema_view.png");
viewsFolder.setType(NodeType.VIEW_FOLDER);
viewsFolder.setContainer(true);
ICubridNodeLoader loader = new CubridViewsFolderLoader();
loader.setLevel(getLevel());
viewsFolder.setLoader(loader);
database.addChild(viewsFolder);
if (getLevel() == DEFINITE_LEVEL) {
viewsFolder.getChildren(monitor);
}
} else {
if (viewsFolder.getLoader() != null && viewsFolder.getLoader().isLoaded()) {
viewsFolder.getLoader().setLoaded(false);
viewsFolder.getChildren(monitor);
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method addSpaceFolder.
/**
* Add database space folder
*
* @param monitor the IProgressMonitor
* @param database the CubridDatabase
*/
private void addSpaceFolder(final IProgressMonitor monitor, CubridDatabase database) {
String databaseSpaceFolderId = database.getId() + NODE_SEPARATOR + DB_SPACE_FOLDER_ID;
ICubridNode databaseSpaceFolder = database.getChild(databaseSpaceFolderId);
if (databaseSpaceFolder == null) {
databaseSpaceFolder = new DefaultSchemaNode(databaseSpaceFolderId, DB_SPACE_FOLDER_NAME, "icons/navigator/volume_group.png");
databaseSpaceFolder.setType(CubridNodeType.DBSPACE_FOLDER);
databaseSpaceFolder.setContainer(true);
databaseSpaceFolder.setEditorId(DatabaseStatusEditor.ID);
ICubridNodeLoader loader = new CubridDbSpaceFolderLoader();
loader.setLevel(getLevel());
databaseSpaceFolder.setLoader(loader);
database.addChild(databaseSpaceFolder);
if (getLevel() == DEFINITE_LEVEL) {
databaseSpaceFolder.getChildren(monitor);
}
} else {
if (databaseSpaceFolder.getLoader() != null && databaseSpaceFolder.getLoader().isLoaded()) {
databaseSpaceFolder.getLoader().setLoaded(false);
databaseSpaceFolder.getChildren(monitor);
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method addProcedureFolder.
/**
* Add procedure folder
*
* @param monitor the IProgressMonitor
* @param database the CubridDatabase
*/
private void addProcedureFolder(final IProgressMonitor monitor, CubridDatabase database) {
String spFolderId = database.getId() + NODE_SEPARATOR + CubridSPFolderLoader.SP_FOLDER_ID;
ICubridNode spFolder = database.getChild(spFolderId);
if (spFolder == null) {
spFolder = new DefaultSchemaNode(spFolderId, SP_FOLDER_NAME, "icons/navigator/procedure_group.png");
spFolder.setType(NodeType.STORED_PROCEDURE_FOLDER);
spFolder.setContainer(true);
ICubridNodeLoader loader = new CubridSPFolderLoader();
loader.setLevel(getLevel());
spFolder.setLoader(loader);
database.addChild(spFolder);
if (getLevel() == DEFINITE_LEVEL) {
spFolder.getChildren(monitor);
}
} else {
if (spFolder.getLoader() != null && spFolder.getLoader().isLoaded()) {
spFolder.getLoader().setLoaded(false);
spFolder.getChildren(monitor);
}
}
}
Aggregations