use of com.cubrid.cubridmanager.ui.replication.editor.model.Diagram in project cubrid-manager by CUBRID.
the class ReplicationEditor method createDiagram.
/**
* create the diagram
*
* @param input IEditorInput
*/
private void createDiagram(IEditorInput input) {
diagram = new Diagram();
if (input instanceof ICubridNode) {
ICubridNode node = (ICubridNode) input;
if (NodeType.DATABASE.equals(node.getType())) {
isEditable = false;
CubridServer server = node.getServer();
int x = 100;
int y = 20;
int hostVertSpan = 100;
if (server != null) {
ReplicationInfo replicationInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
if (replicationInfo != null) {
//distributor component
DistributorInfo distInfo = replicationInfo.getDistInfo();
DistributorNode dist = null;
if (distInfo != null) {
dist = new DistributorNode();
dist.setDbName(distInfo.getDistDbName());
dist.setDbPath(distInfo.getDistDbPath());
dist.setCopyLogPath(distInfo.getCopyLogPath());
dist.setErrorLogPath(distInfo.getErrorLogPath());
dist.setTrailLogPath(distInfo.getTrailLogPath());
dist.setReplAgentPort(distInfo.getAgentPort());
dist.setDelayTimeLogSize(distInfo.getDelayTimeLogSize());
dist.setRestartWhenError(distInfo.isRestartReplWhenError());
dist.setName(distInfo.getDistDbName());
dist.setLocation(new Point(30, 30));
dist.setSize(new Dimension(120, 40));
}
//master component
List<MasterInfo> masterList = replicationInfo.getMasterList();
MasterNode master = null;
for (int i = 0; masterList != null && i < masterList.size(); i++) {
MasterInfo masterInfo = masterList.get(i);
if (masterInfo != null) {
master = new MasterNode();
String ip = masterInfo.getMasterIp();
String masterDbName = masterInfo.getMasterDbName();
String replServerPort = masterInfo.getReplServerPort();
boolean isReplAll = masterInfo.isReplAllTable();
List<String> tableList = masterInfo.getReplTableList();
HostNode mdbHost = new HostNode();
mdbHost.setIp(ip);
mdbHost.setUserName("admin");
mdbHost.setName(ip);
mdbHost.setLocation(new Point(x, y));
y += mdbHost.getSize().height + hostVertSpan;
mdbHost.setParent(diagram);
diagram.addNode(mdbHost);
master.setDbName(masterDbName);
master.setReplServerPort(replServerPort);
master.setReplicateAll(isReplAll);
master.setReplicatedClassList(tableList);
master.setName(masterDbName);
master.setLocation(new Point(30, 80));
master.setSize(new Dimension(120, 40));
master.setParent(mdbHost);
mdbHost.addChildNode(master);
}
}
//distributor host component
HostNode distdbhost = new HostNode();
distdbhost.setIp(server.getHostAddress());
distdbhost.setPort(server.getMonPort());
distdbhost.setUserName(server.getUserName());
distdbhost.setPassword(server.getPassword());
distdbhost.setName(server.getHostAddress() + ":" + server.getMonPort());
distdbhost.setLocation(new Point(x, y));
distdbhost.setParent(diagram);
diagram.addNode(distdbhost);
//distributor component
if (dist != null) {
dist.setParent(distdbhost);
distdbhost.addChildNode(dist);
}
//slave component
List<SlaveInfo> slaveInfoList = replicationInfo.getSlaveList();
SlaveNode slave = null;
for (int i = 0; slaveInfoList != null && i < slaveInfoList.size(); i++) {
SlaveInfo slaveInfo = slaveInfoList.get(i);
if (slaveInfo != null) {
slave = new SlaveNode();
slave.setDbName(slaveInfo.getSlaveDbName());
slave.setDbPath(slaveInfo.getSlaveDbPath());
slave.setDbUser(slaveInfo.getDbUser());
slave.setDbPassword(slaveInfo.getPassword());
ReplicationParamInfo replParaInfo = slaveInfo.getParamInfo();
if (replParaInfo != null) {
slave.setParamMap(replParaInfo.getParamMap());
}
slave.setName(slaveInfo.getSlaveDbName());
slave.setLocation(new Point(30, 150));
slave.setSize(new Dimension(120, 40));
slave.setParent(distdbhost);
distdbhost.addChildNode(slave);
}
}
}
}
}
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.Diagram in project cubrid-manager by CUBRID.
the class DeleteNodeCommand method undo.
/**
* @see org.eclipse.gef.commands.Command#undo()
*/
public void undo() {
if (parent instanceof Diagram) {
Diagram diagram = (Diagram) parent;
diagram.addNode((ContainerNode) node);
} else if (parent instanceof ContainerNode) {
ContainerNode containerNode = (ContainerNode) parent;
containerNode.addChildNode((LeafNode) node);
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.Diagram in project cubrid-manager by CUBRID.
the class SetHostInfoDialog method checkHostExist.
/**
* Check whether the host exist
*
* @param ip the ip address
* @param port the port
* @return <code>true</code> if exist;<code>false</code>otherwise
*/
private boolean checkHostExist(String ip, String port) {
boolean isHostExist = false;
Diagram diagram = (Diagram) hostInfo.getParent();
List<ContainerNode> nodeList = diagram.getChildNodeList();
for (int i = 0; nodeList != null && i < nodeList.size(); i++) {
ContainerNode node = nodeList.get(i);
if (node instanceof HostNode) {
HostNode host = (HostNode) node;
String name = host.getName();
if (name.equals(ip + ":" + port) && !host.equals(hostInfo)) {
isHostExist = true;
break;
}
}
}
return isHostExist;
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.Diagram in project cubrid-manager by CUBRID.
the class DeleteNodeCommand method execute.
/**
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
if (parent instanceof Diagram) {
Diagram diagram = (Diagram) parent;
diagram.removeNode((ContainerNode) node);
} else if (parent instanceof ContainerNode) {
ContainerNode containerNode = (ContainerNode) parent;
containerNode.removeChildNode((LeafNode) node);
}
}
Aggregations