use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class HAUtil method calcLocation.
/**
*
* Calculate the location
*
* @param hostNodeList List<HostNode>
*/
public static void calcLocation(List<HostNode> hostNodeList) {
Point zeroLocation = new Point(0, 0);
List<HostNode> zeroPointHostList = new ArrayList<HostNode>();
List<HostNode> noZeroPointHostList = new ArrayList<HostNode>();
for (HostNode hostNode : hostNodeList) {
Point location = hostNode.getLocation();
if (zeroLocation.equals(location)) {
zeroPointHostList.add(hostNode);
} else {
noZeroPointHostList.add(hostNode);
}
}
int hostMaxY = 0;
for (HostNode hostNode : noZeroPointHostList) {
Point hostLocation = hostNode.getLocation();
int tY = hostLocation.y + hostNode.getSize().height;
if (tY > hostMaxY) {
hostMaxY = tY;
}
int nodeMaxY = hostLocation.y + hostNode.getSize().height + HEIGHT_DISTANCE;
int nodeMaxX = hostLocation.x + hostNode.getSize().width;
List<HANode> haNodeList = new ArrayList<HANode>();
haNodeList.addAll(hostNode.getDbNodeList());
haNodeList.addAll(hostNode.getBrokerNodeList());
List<HANode> zeroPointChildList = new ArrayList<HANode>();
for (HANode haNode : haNodeList) {
if (haNode.getLocation().equals(zeroLocation)) {
zeroPointChildList.add(haNode);
} else {
int tX = haNode.getLocation().x + haNode.getSize().width;
if (tX > nodeMaxX) {
nodeMaxX = tX;
}
tY = haNode.getLocation().y;
if (tY > nodeMaxY) {
nodeMaxY = tY;
}
tY = haNode.getLocation().y + haNode.getSize().height;
if (tY > hostMaxY) {
hostMaxY = tY;
}
}
}
nodeMaxX = nodeMaxX + WIDTH_DISTANCE;
for (HANode haNode : zeroPointChildList) {
haNode.setLocation(new Point(nodeMaxX, nodeMaxY));
nodeMaxX = nodeMaxX + haNode.getSize().width + WIDTH_DISTANCE;
}
}
if (!zeroPointHostList.isEmpty()) {
calcLocation(zeroPointHostList, hostMaxY);
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class HAUtil method mergeHostNode.
/**
*
* Merge the host node list
*
* @param hostNodeList The List<HostNode>
* @param addedHostNodeList The addedHostNodeList
*/
public static void mergeHostNode(List<HostNode> hostNodeList, List<HostNode> addedHostNodeList) {
for (int i = 0; i < addedHostNodeList.size(); i++) {
HostNode addedHostNode = addedHostNodeList.get(i);
boolean isExist = false;
for (int j = 0; j < hostNodeList.size(); j++) {
HostNode hostNode = hostNodeList.get(j);
if (addedHostNode.equals(hostNode)) {
isExist = true;
hostNode.setPassword(addedHostNode.getPassword());
hostNode.setHostStatusInfo(addedHostNode.getHostStatusInfo());
mergeCopyedHostChildNode(hostNode, addedHostNode);
}
}
if (!isExist) {
hostNodeList.add(addedHostNode);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class AddHostAndDbWizard method performFinish.
/**
* Called when user clicks Finish
*
* @return boolean
*/
public boolean performFinish() {
List<Map<String, Object>> dbNodeList = selectDbPage == null ? null : selectDbPage.getDbNodeList();
List<Map<String, Object>> brokerNodeNodeList = selectBrokerPage == null ? null : selectBrokerPage.getBrokerNodeList();
HostNode hostNode = mergeHostNode(setHostInfoPage == null ? null : setHostInfoPage.getHostNode());
for (int i = 0; dbNodeList != null && i < dbNodeList.size(); i++) {
Map<String, Object> map = dbNodeList.get(i);
hostNode = mergeHostNode((HostNode) map.get("6"));
DatabaseNode dbNode = (DatabaseNode) map.get("7");
if (hostNode != null) {
dbNode.setParent(hostNode);
hostNode.getCopyedHaNodeList().remove(dbNode);
hostNode.getCopyedHaNodeList().add(dbNode);
}
}
for (int i = 0; brokerNodeNodeList != null && i < brokerNodeNodeList.size(); i++) {
Map<String, Object> map = brokerNodeNodeList.get(i);
hostNode = mergeHostNode((HostNode) map.get("8"));
BrokerNode brokerNode = (BrokerNode) map.get("9");
if (hostNode != null) {
brokerNode.setParent(hostNode);
hostNode.getCopyedHaNodeList().remove(brokerNode);
hostNode.getCopyedHaNodeList().add(brokerNode);
}
}
return true;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class SelectBrokerPage method isBrokerNodeExist.
/**
*
* Whether broker node exist
*
* @param brokerName String
* @return boolean
*/
private boolean isBrokerNodeExist(String brokerName) {
for (int i = 0; i < brokerNodeList.size(); i++) {
Map<String, Object> map = brokerNodeList.get(i);
HostNode hostNode1 = (HostNode) map.get("8");
BrokerNode brokerNode1 = (BrokerNode) map.get("9");
if (hostNode.getIp().equals(hostNode1.getIp()) && hostNode.getPort().equals(hostNode1.getPort()) && hostNode.getUserName().equals(hostNode1.getUserName()) && brokerName.equalsIgnoreCase(brokerNode1.getBrokerName())) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class BrokerDashboardViewPart method init.
/**
* Initializes the parameters of this view
*
* @param brokerNode the instance of BrokerNode
*/
public void init(BrokerNode brokerNode) {
this.brokerNode = brokerNode;
String nodeName = brokerNode.getBrokerName();
String partName = getPartName();
HostNode hn = brokerNode.getParent();
String postfix = " - " + nodeName + "@" + hn.getIp() + ":" + hn.getPort();
if (!partName.endsWith(postfix)) {
setPartName(partName + postfix);
}
serverInfo = hn.getServerInfo();
String generatorName = hn.getUserName() + "@" + hn.getIp() + ":" + hn.getPort();
generator = DataGeneratorPool.getInstance().getDataGenerator(generatorName, new DataProvider());
generator.addDataUpdateListener(this);
}
Aggregations