use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method checkConnectionStatus.
/**
* When selection changed,check whether selected server is connected
*
* @param selection the ISelection object
*/
private void checkConnectionStatus(ISelection selection) {
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
CubridServer cubridServer = cubridNode.getServer();
if (cubridServer == null) {
return;
}
ServerInfo serverInfo = cubridServer.getServerInfo();
boolean needToCheck = !serverInfo.isConnected() && (!(obj instanceof CubridServer) || (cubridServer.getChildren() != null && cubridServer.getChildren().size() > 0));
if (needToCheck) {
boolean connectAgagin = false;
if (CommonUITool.openConfirmBox(Messages.errCannotConnectServerReconnect)) {
connectAgagin = true;
}
closeAllEditorAndViewInServer(cubridServer, false);
cubridServer.removeAllChild();
TreeViewer viewer = (TreeViewer) LayoutManager.getInstance().getSelectionProvider();
viewer.refresh(cubridServer);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cubridServer, CubridNodeChangedEventType.SERVER_DISCONNECTED));
if (connectAgagin && connectHost(serverInfo, true)) {
refreshAfterConnected(cubridServer);
}
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CQBConnectionChangingObserver method afterModify.
/**
* When modify an existed connection.
*
* @param initiator IJDBCInfoChangedSubject who triggered the event.
* @param oldCon IJDBCConnecInfo
* @param newCon IJDBCConnecInfo
*/
public void afterModify(IJDBCInfoChangedSubject initiator, IJDBCConnecInfo oldCon, IJDBCConnecInfo newCon) {
if (CQBDBNodePersistManager.getInstance().equals(initiator)) {
return;
}
//If not a CUBRID connection
if (oldCon.getDbType() != 1 || newCon.getDbType() != 1) {
return;
}
/*Must fire database changed event first*/
CubridDatabase database = CQBDatabaseFactory.getDatabaseJDBCConnectInfo(oldCon);
if (database != null) {
if (isNeedLogout(oldCon, newCon)) {
CQBConnectionUtils.processConnectionLogout(database);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
CubridDatabase newDatabase = CQBDatabaseFactory.modifyDatabaseByJDBCConnectInfo(oldCon, newCon);
CQBDBNodePersistManager.getInstance().saveDatabases();
refreshNavigationTree(newDatabase);
} else {
database = CQBDatabaseFactory.createDatabase(newCon);
CQBDBNodePersistManager.getInstance().addDatabase(database, true);
refreshNavigationTree(null);
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method addDatabase.
/**
*
* Add database
*
* @param database the CubridDatabase object
* @param silence if true the event will not be triggered.
*/
public void addDatabase(CubridDatabase database, boolean silence) {
synchronized (this) {
if (database != null) {
databaseList.add(database);
saveDatabases();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.NODE_ADD));
if (!silence) {
fireAddDatabase(database);
}
}
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method removeServer.
/**
*
* Remove server
*
* @param server the CubridServer object
*/
public void removeServer(CubridServer server) {
synchronized (this) {
if (server != null) {
ServerManager.getInstance().removeServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName());
serverList.remove(server);
CMDBNodePersistManager.getInstance().deleteParameter(server);
saveServers();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.NODE_REMOVE));
}
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method removeAllServer.
/**
*
* Remove all servers
*
*/
public void removeAllServer() {
synchronized (this) {
for (int i = 0; i < serverList.size(); i++) {
CubridServer server = serverList.get(i);
ServerManager.getInstance().removeServer(server.getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName());
serverList.remove(server);
CMDBNodePersistManager.getInstance().deleteParameter(server);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.NODE_REMOVE));
}
saveServers();
}
}
Aggregations