Search in sources :

Example 1 with LeafNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.

the class ReplicationEditor method initConnection.

/**
	 * initialize the connection
	 * 
	 */
private void initConnection() {
    if (diagram != null) {
        MasterNode master = null;
        DistributorNode dist = null;
        SlaveNode slave = null;
        List<ContainerNode> containerNodeList = diagram.getChildNodeList();
        for (int i = 0; containerNodeList != null && i < containerNodeList.size(); i++) {
            ContainerNode containerNode = containerNodeList.get(i);
            if (containerNode != null) {
                List<LeafNode> leafNodeList = containerNode.getChildNodeList();
                for (int j = 0; j < leafNodeList.size(); j++) {
                    LeafNode leafNode = leafNodeList.get(j);
                    if (leafNode instanceof MasterNode) {
                        master = (MasterNode) leafNode;
                    } else if (leafNode instanceof DistributorNode) {
                        dist = (DistributorNode) leafNode;
                    }
                }
            }
        }
        //connection from master to dist
        if (master != null && dist != null) {
            new ArrowConnection(master, dist);
        }
        for (int i = 0; containerNodeList != null && i < containerNodeList.size(); i++) {
            ContainerNode containerNode = containerNodeList.get(i);
            if (containerNode != null) {
                List<LeafNode> leafNodeList = containerNode.getChildNodeList();
                for (int j = 0; j < leafNodeList.size(); j++) {
                    LeafNode leafNode = leafNodeList.get(j);
                    if (leafNode instanceof SlaveNode) {
                        slave = (SlaveNode) leafNode;
                        //connection from dist to slave
                        if (dist != null && slave != null) {
                            new ArrowConnection(dist, slave);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ArrowConnection(com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) Point(org.eclipse.draw2d.geometry.Point) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 2 with LeafNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.

the class SetDistributorDbInfoDialog method checkDatabaseExist.

/**
	 * Check whether the database exist
	 * 
	 * @param dbName the database name
	 * @return <code>true</code> if already exist;<code>false</code> otherwise
	 */
private boolean checkDatabaseExist(String dbName) {
    boolean isDatabaseExist = false;
    List<DatabaseInfo> databaseInfoList = hostNode.getDatabaseInfoList();
    for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
        DatabaseInfo databaseInfo = databaseInfoList.get(i);
        if (dbName.equalsIgnoreCase(databaseInfo.getDbName())) {
            isDatabaseExist = true;
            break;
        }
    }
    if (!isDatabaseExist) {
        List<LeafNode> childNodeList = hostNode.getChildNodeList();
        for (int i = 0; childNodeList != null && i < childNodeList.size(); i++) {
            LeafNode node = childNodeList.get(i);
            if (dbName.equalsIgnoreCase(node.getName()) && !dbName.equals(distributorNode.getDbName())) {
                isDatabaseExist = true;
                break;
            }
        }
    }
    return isDatabaseExist;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)

Example 3 with LeafNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode 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 4 with LeafNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.

the class ContainerNodeLayoutEditPolicy method getCreateCommand.

/**
	 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
	 * @param request the CreateRequest
	 * @return a Command to perform a create
	 * 
	 */
protected Command getCreateCommand(CreateRequest request) {
    if (!(request.getNewObject() instanceof LeafNode)) {
        return null;
    }
    CreateLeafNodeCommand cmd = new CreateLeafNodeCommand();
    cmd.setContainerNode((ContainerNode) getHost().getModel());
    cmd.setLeafNode((LeafNode) request.getNewObject());
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    cmd.setLocation(constraint.getLocation());
    return cmd;
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) CreateLeafNodeCommand(com.cubrid.cubridmanager.ui.replication.editor.commands.CreateLeafNodeCommand)

Example 5 with LeafNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.

the class ContainerNodePart method getModelSourceConnections.

/**
	 * @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#getModelSourceConnections()
	 * @return list
	 */
protected List<ArrowConnection> getModelSourceConnections() {
    List<ArrowConnection> list = new ArrayList<ArrowConnection>();
    list.addAll(getContainerNode().getOutgoingConnections());
    for (Iterator<LeafNode> iter = getContainerNode().getChildNodeList().iterator(); iter.hasNext(); ) {
        LeafNode node = iter.next();
        list.addAll(node.getOutgoingConnections());
    }
    return list;
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ArrayList(java.util.ArrayList) ArrowConnection(com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection)

Aggregations

LeafNode (com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)11 ArrowConnection (com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection)4 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)4 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)3 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)3 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)3 ArrayList (java.util.ArrayList)3 Point (org.eclipse.draw2d.geometry.Point)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 Diagram (com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 CreateLeafNodeCommand (com.cubrid.cubridmanager.ui.replication.editor.commands.CreateLeafNodeCommand)1 LeafNodeFigure (com.cubrid.cubridmanager.ui.replication.editor.figures.LeafNodeFigure)1 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)1 Node (com.cubrid.cubridmanager.ui.replication.editor.model.Node)1 List (java.util.List)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1