use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class CubridStatusLineContrItem method updateStatusLine.
/**
*
* Update the status line information
*
* @param statusLineManager StatusLineManager
* @param cubridNode The selected ICubridNode object
*/
protected void updateStatusLine(StatusLineManager statusLineManager, ICubridNode cubridNode) {
clearStatusLine();
updateStatusLineForRestoreQueryEditor();
if (cubridNode == null || cubridNode.getServer() == null || cubridNode.getServer().getServerInfo() == null) {
return;
}
String serverInfoStr = cubridNode.getServer().getLabel();
if (!DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(cubridNode.getId())) {
ServerUserInfo userInfo = cubridNode.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
serverInfoStr = userInfo.getUserName() + "@" + serverInfoStr;
}
String monPort = cubridNode.getServer().getMonPort();
if (monPort != null && monPort.trim().length() > 0) {
serverInfoStr = serverInfoStr + ":" + monPort;
}
}
StringBuffer dbInfoStrBuffer = new StringBuffer();
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
CubridDatabase database = schemaNode.getDatabase();
dbInfoStrBuffer.append(database.getDatabaseInfo().getDbName());
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (database.isLogined() && dbUserInfo != null && dbUserInfo.getName() != null && dbUserInfo.getName().trim().length() > 0) {
dbInfoStrBuffer = new StringBuffer(dbUserInfo.getName() + "@" + dbInfoStrBuffer.toString());
}
String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
boolean isExist = false;
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
if (brokerPort == null || brokerInfo.getPort() == null || brokerInfo.getPort().trim().length() == 0 || !brokerPort.equals(brokerInfo.getPort())) {
continue;
}
if (brokerPort.equals(brokerInfo.getPort())) {
isExist = true;
String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
dbInfoStrBuffer.append(":").append(text);
break;
}
}
if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
dbInfoStrBuffer.append(":").append(brokerPort);
}
String charset = database.getDatabaseInfo().getCharSet();
if (charset != null && charset.trim().length() > 0) {
dbInfoStrBuffer.append(":charset=").append(charset);
}
}
String numberStr = getChilderenNumStr(cubridNode);
if (numberStr != null && numberStr.length() > 0) {
StatusLineContributionItem item = new StatusLineContributionItem(OBJ_NUM_INFO_CONTR_ID, numberStr.length() + 4);
statusLineManager.add(item);
item.setText(numberStr);
}
int addedWidth = 3;
if (dbInfoStrBuffer == null || dbInfoStrBuffer.length() == 0) {
addedWidth = 30;
}
StatusLineContributionItem item = new StatusLineContributionItem(SERVER_INFO_CONTR_ID, serverInfoStr.length() + addedWidth);
statusLineManager.add(item);
item.setText(serverInfoStr);
if (dbInfoStrBuffer != null && dbInfoStrBuffer.length() > 0) {
item = new StatusLineContributionItem(DB_INFO_CONTR_ID, dbInfoStrBuffer.length() + 3);
statusLineManager.add(item);
item.setText(dbInfoStrBuffer.toString());
}
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class CubridTitleLineContrItem method getTitleForViewOrEdit.
/**
*
* Get the title of view or editor(not including query editor)
*
* @param cubridNode the ICubridNode object
* @param workbenchPart the IWorkbenchPart object
* @return the title
*/
protected String getTitleForViewOrEdit(ICubridNode cubridNode, IWorkbenchPart workbenchPart) {
String serverTitle = "";
if (cubridNode != null && cubridNode.getServer() != null && cubridNode.getServer().isConnected()) {
CubridServer server = cubridNode.getServer();
serverTitle = server.getLabel();
ServerUserInfo userInfo = cubridNode.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
serverTitle = userInfo.getUserName() + "@" + serverTitle;
}
String monPort = cubridNode.getServer().getMonPort();
if (monPort != null && monPort.trim().length() > 0) {
serverTitle = serverTitle + ":" + monPort;
}
}
String partTitle = "";
if (cubridNode != null && workbenchPart == null) {
if (null != cubridNode.getViewId()) {
IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, cubridNode.getViewId());
if (viewPart != null) {
partTitle = viewPart.getTitle();
}
}
if (null != cubridNode.getEditorId()) {
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, cubridNode.getEditorId());
if (editorPart != null) {
partTitle = editorPart.getTitle();
}
}
} else if (workbenchPart != null) {
partTitle = workbenchPart.getTitle();
}
String title = "";
if (serverTitle != null && serverTitle.trim().length() > 0) {
title = serverTitle;
}
if (partTitle != null && partTitle.trim().length() > 0) {
if (title != null && title.trim().length() > 0) {
title += " / ";
}
title += partTitle;
}
return title;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class CubridTitleLineContrItem method getTitleForNavigator.
/**
*
* Get title of CUBRID manager application for navigator
*
* @param cubridNode the ICubridNode object
* @return the title
*/
protected String getTitleForNavigator(ICubridNode cubridNode) {
if (cubridNode == null) {
return "";
}
String title = cubridNode.getLabel();
CubridServer server = cubridNode.getServer();
String serverTitle = server == null ? null : server.getLabel();
if (server != null && server.isConnected()) {
ServerInfo serverInfo = server.getServerInfo();
ServerUserInfo userInfo = serverInfo == null ? null : serverInfo.getLoginedUserInfo();
if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
serverTitle = userInfo.getUserName() + "@" + serverTitle;
}
String monPort = server.getMonPort();
if (monPort != null && monPort.trim().length() > 0) {
serverTitle = serverTitle + ":" + monPort;
}
}
StringBuffer dbTitleBuffer = new StringBuffer("");
CubridDatabase database = cubridNode instanceof ISchemaNode ? ((ISchemaNode) cubridNode).getDatabase() : null;
if (database != null && database.getDatabaseInfo() != null) {
DatabaseInfo dbInfo = database.getDatabaseInfo();
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
String userName = dbUserInfo == null ? null : dbUserInfo.getName();
dbTitleBuffer = (userName != null && userName.trim().length() > 0) ? dbTitleBuffer.append(userName).append("@").append(dbInfo.getDbName()) : dbTitleBuffer;
String brokerPort = QueryOptions.getBrokerPort(dbInfo);
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
boolean isExist = false;
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
if (brokerPort != null && brokerPort.equals(brokerInfo.getPort())) {
isExist = true;
String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
dbTitleBuffer.append(":").append(text);
break;
}
}
if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
dbTitleBuffer.append(":").append(brokerPort);
}
String charset = database.getDatabaseInfo().getCharSet();
if (charset != null && charset.trim().length() > 0) {
dbTitleBuffer.append(":charset=").append(charset);
}
}
if (serverTitle != null && serverTitle.trim().length() > 0) {
title = serverTitle;
}
if (dbTitleBuffer != null && dbTitleBuffer.toString().trim().length() > 0) {
title = serverTitle + " / " + dbTitleBuffer.toString();
}
return title;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo 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.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class CubridDatabasesFolderLoader method buildDatabasesFolder.
/**
* Construct the database folder children
*
* @param parent the database folder node
* @param monitor the IProgressMonitor
* @param serverInfo the ServerInfo
* @param oldDatabaseInfoList the old database information list
* @param newDatabaseInfoList the new database information list
* @param oldNodeList the old node list
*/
private void buildDatabasesFolder(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo, List<DatabaseInfo> oldDatabaseInfoList, List<DatabaseInfo> newDatabaseInfoList, List<ICubridNode> oldNodeList) {
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
List<DatabaseInfo> authorDatabaseList = userInfo.getDatabaseInfoList();
if (authorDatabaseList == null) {
authorDatabaseList = new ArrayList<DatabaseInfo>();
userInfo.setDatabaseInfoList(authorDatabaseList);
}
filterDatabaseList(serverInfo, newDatabaseInfoList, authorDatabaseList);
for (int i = 0; i < authorDatabaseList.size() && !monitor.isCanceled(); i++) {
DatabaseInfo databaseInfo = authorDatabaseList.get(i);
DatabaseInfo newDatabaseInfo = getDatabaseInfo(newDatabaseInfoList, databaseInfo.getDbName());
if (newDatabaseInfo == null) {
continue;
} else {
databaseInfo.setDbDir(newDatabaseInfo.getDbDir());
databaseInfo.setRunningType(newDatabaseInfo.getRunningType());
newDatabaseInfo = getDatabaseInfo(oldDatabaseInfoList, databaseInfo.getDbName());
if (newDatabaseInfo != null) {
DbUserInfo dbUserInfo = newDatabaseInfo.getAuthLoginedDbUserInfo();
if (dbUserInfo != null && databaseInfo.getAuthLoginedDbUserInfo() != null) {
databaseInfo.getAuthLoginedDbUserInfo().setNoEncryptPassword(dbUserInfo.getNoEncryptPassword());
}
}
}
String name = databaseInfo.getDbName();
String id = parent.getId() + NODE_SEPARATOR + name;
ICubridNode databaseNode = isContained(oldNodeList, id);
if (databaseNode == null) {
databaseNode = new CubridDatabase(id, databaseInfo.getDbName());
CubridDatabase database = (CubridDatabase) databaseNode;
database.setStartAndLoginIconPath("icons/navigator/database_start_connected.png");
database.setStartAndLogoutIconPath("icons/navigator/database_start_disconnected.png");
database.setStopAndLogoutIconPath("icons/navigator/database_stop_disconnected.png");
database.setStopAndLoginIconPath("icons/navigator/database_stop_connected.png");
ICubridNodeLoader loader = new CubridDatabaseLoader();
loader.setLevel(getLevel());
databaseNode.setLoader(loader);
parent.addChild(databaseNode);
if (getLevel() == DEFINITE_LEVEL) {
databaseNode.getChildren(monitor);
}
databaseNode.setEditorId(DatabaseDashboardEditor.ID);
((CubridDatabase) databaseNode).setDatabaseInfo(databaseInfo);
databaseNode.setContainer(true);
((CubridDatabase) databaseNode).setAutoSavePassword(CMDBNodePersistManager.getInstance().getDbSavePassword(serverInfo.getHostAddress(), String.valueOf(serverInfo.getHostMonPort()), databaseInfo.getDbName(), databaseInfo.getAuthLoginedDbUserInfo().getName()));
String jdbcAttrs = CMDBNodePersistManager.getInstance().getJdbcAttrs((CubridDatabase) databaseNode);
databaseInfo.setJdbcAttrs(jdbcAttrs);
} else {
parent.addChild(databaseNode);
databaseInfo.setLogined(((CubridDatabase) databaseNode).isLogined());
((CubridDatabase) databaseNode).setDatabaseInfo(databaseInfo);
if (databaseNode.getLoader() != null && databaseNode.getLoader().isLoaded()) {
databaseNode.getLoader().setLoaded(false);
databaseNode.getChildren(monitor);
}
}
}
}
Aggregations