use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class ItemNodeDnDHandler method handle.
/**
* Handle the node to be DND.
*
* @param dragNode the drag node
* @param dropNode the drop node
* @param insertBefore insert into the drop node before or after
* @param dropOperation the drop operation type <code>DND.DROP_COPY</code>
* <code>DND.DROP_MOVE</code>
* @return boolean whether to handle with the drop
*/
public boolean handle(ICubridNode dragNode, ICubridNode dropNode, boolean insertBefore, int dropOperation) {
ICubridNode newDragNode = dragNode;
if (DND.DROP_COPY == dropOperation && dragNode instanceof CubridServer) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
HostDialog dialog = new HostDialog(shell, true, false);
dialog.setServer((CubridServer) dragNode);
int returnCode = dialog.open();
if (returnCode == HostDialog.ADD_ID || returnCode == HostDialog.CONNECT_ID) {
ServerInfo serverInfo = dialog.getServerInfo();
CubridServer server = new CubridServer(serverInfo.getServerName(), serverInfo.getServerName(), "icons/navigator/host.png", "icons/navigator/host_connected.png");
server.setServerInfo(serverInfo);
server.setLoader(new CubridServerLoader());
server.setAutoSavePassword(dialog.isSavePassword());
CMHostNodePersistManager.getInstance().addServer(server);
CubridGroupNode groupNode = CMGroupNodePersistManager.getInstance().getDefaultGroup();
groupNode.addChild(server);
newDragNode = server;
} else {
return false;
}
}
return super.handle(newDragNode, dropNode, insertBefore, dropOperation);
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class CubridHostNavigatorView method getToolTip.
/**
* Get tooltip string
*
* @param cubridNode ICubridNode
* @return String
*/
protected String getToolTip(ICubridNode cubridNode) {
StringBuffer toolTipText = new StringBuffer();
if (cubridNode instanceof CubridServer) {
CubridServer server = (CubridServer) cubridNode;
String ip = server.getHostAddress();
toolTipText.append(Messages.bind(Messages.tipIP, ip == null ? "" : ip)).append("\r\n");
String port = server.getMonPort();
toolTipText.append(Messages.bind(Messages.tipPort, port == null ? "" : port)).append("\r\n");
String userName = server.getUserName();
toolTipText.append(Messages.bind(Messages.tipUser, userName == null ? "" : userName)).append("\r\n");
String jdbcVersion = server.getJdbcDriverVersion();
toolTipText.append(Messages.bind(Messages.tipJDBC, jdbcVersion == null ? "" : jdbcVersion));
} else if (cubridNode instanceof CubridBroker) {
CubridBroker broker = (CubridBroker) cubridNode;
BrokerInfo brokerInfo = broker.getBrokerInfo();
String brokerMode = brokerInfo.getAccess_mode() == null ? Messages.tipBrokerAccessModeNotWorking : brokerInfo.getAccess_mode();
toolTipText.append(Messages.bind(Messages.tipBrokerPort, brokerInfo.getPort())).append("\r\n");
toolTipText.append(Messages.bind(Messages.tipBrokerAccessMode, brokerMode)).append("\r\n");
if (OnOffType.ON.getText().equalsIgnoreCase(brokerInfo.getState())) {
toolTipText.append(Messages.tipBrokerStatusON);
} else {
toolTipText.append(Messages.tipBrokerStatusOFF);
}
}
return toolTipText.toString();
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class LoadMonitorStatisticDataProgress method buildServerInfo.
/**
* Build ServerInfo for multi-host monitor statistic.
*
* @param hostInfo
* @return
*/
public static ServerInfo buildServerInfo(StatisticChartHost hostInfo) {
final CMHostNodePersistManager hostNodePersistManager = CMHostNodePersistManager.getInstance();
ServerInfo serverInfo = hostInfo.getServerInfo();
String serverName = null;
String ip = null;
int port = 0;
String username = null;
String password = null;
boolean isInitial = false;
/* For multi-host monitor statistic, will not keep the connection in ServerManager.
* So if the ServerInfo is null or disconnected, try to get the ServerInfo from ServerManager.
* If failure, then build the ServerInfo with IP/Port/User Name/Password.
*/
if (serverInfo == null || !serverInfo.isConnected()) {
CubridServer cubridServer;
if (hostInfo.getCubridServerId() != null) {
serverName = hostInfo.getCubridServerId();
cubridServer = hostNodePersistManager.getServer(serverName);
if (cubridServer != null) {
isInitial = true;
ip = cubridServer.getHostAddress();
port = Integer.parseInt(cubridServer.getMonPort());
username = cubridServer.getUserName();
password = cubridServer.getPassword();
}
}
if (!isInitial) {
ip = hostInfo.getIp();
serverName = ip;
port = hostInfo.getPort();
username = hostInfo.getUser();
password = hostInfo.getPassword();
}
serverInfo = hostNodePersistManager.getServerInfo(ip, port, username);
if (serverInfo == null) {
//if (serverInfo == null || !serverInfo.isConnected()) {
serverInfo = new ServerInfo();
serverInfo.setServerName(serverName);
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(port);
serverInfo.setHostJSPort(port + 1);
serverInfo.setUserName(username);
serverInfo.setUserPassword(password);
}
}
return serverInfo;
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class AddHostAction method doRun.
public void doRun(Object[] nodes) {
CubridGroupNode parent = getParentGroupNode(nodes);
if (parent == null) {
LOGGER.error("parent is null.");
return;
}
HostDialog dialog = new HostDialog(getShell(), true, false);
int returnCode = dialog.open();
if (returnCode == HostDialog.ADD_ID || returnCode == HostDialog.CONNECT_ID) {
CubridServer server = getServerNode(dialog);
if (server == null) {
LOGGER.error("server is null.");
return;
}
CMHostNodePersistManager.getInstance().addServer(server);
TreeItem item = null;
parent.addChild(server);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView != null) {
boolean isShowGroup = navigatorView.isShowGroup();
TreeViewer treeViewer = navigatorView.getViewer();
if (isShowGroup) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(treeViewer.getTree(), SWT.NONE);
}
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(server.getLabel());
item.setData(server);
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(new StructuredSelection(server), true);
if (returnCode == HostDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
} else {
dialog.closeTestServerConnection();
}
}
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class ChangeManagerPasswordAction method isSupported.
public boolean isSupported(Object obj) {
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
CubridServer server = node.getServer();
if (server == null || !server.isConnected()) {
return false;
}
if (server.getServerInfo() == null) {
return false;
}
if (server.getServerInfo().getLoginedUserInfo() == null) {
return false;
}
return true;
}
return false;
}
Aggregations