Search in sources :

Example 1 with Diagram

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Point(org.eclipse.draw2d.geometry.Point) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 2 with Diagram

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);
    }
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)

Example 3 with Diagram

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;
}
Also used : HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)

Example 4 with Diagram

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);
    }
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)

Aggregations

Diagram (com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)4 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)3 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)2 LeafNode (com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 DistributorInfo (com.cubrid.cubridmanager.core.replication.model.DistributorInfo)1 MasterInfo (com.cubrid.cubridmanager.core.replication.model.MasterInfo)1 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)1 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)1 SlaveInfo (com.cubrid.cubridmanager.core.replication.model.SlaveInfo)1 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)1 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)1 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1