use of com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode 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.MasterNode 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);
}
}
}
}
}
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode in project cubrid-manager by CUBRID.
the class EditAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchPart workbenchPart = this.getWorkbenchPart();
if (!(workbenchPart instanceof ReplicationEditor) || !isEnabled()) {
return;
}
ReplicationEditor replEditor = (ReplicationEditor) workbenchPart;
Shell shell = replEditor.getSite().getShell();
NodePart nodePart = (NodePart) getSelectedObjects().get(0);
if (nodePart.getModel() instanceof MasterNode) {
SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) nodePart.getModel());
wizard.setEditable(replEditor.isEditable());
CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
dialog.setPageSize(560, 300);
dialog.open();
} else if (nodePart.getModel() instanceof DistributorNode) {
SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
dialog.setDistributor((DistributorNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
} else if (nodePart.getModel() instanceof SlaveNode) {
SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
dialog.setSlave((SlaveNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
} else if (nodePart.getModel() instanceof HostNode) {
SetHostInfoDialog dialog = new SetHostInfoDialog(shell);
dialog.setHostInfo((HostNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode in project cubrid-manager by CUBRID.
the class LeafNodePart method refreshVisuals.
/**
* @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#refreshVisuals()
*/
protected void refreshVisuals() {
super.refreshVisuals();
LeafNode node = (LeafNode) getModel();
LeafNodeFigure figure = (LeafNodeFigure) getFigure();
figure.setText(node.getName());
if (getModel() instanceof MasterNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/master.png"));
}
if (getModel() instanceof DistributorNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/distributor.gif"));
}
if (getModel() instanceof SlaveNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/slave.png"));
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode in project cubrid-manager by CUBRID.
the class LeafNodePart method performRequest.
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
* @param req the request to be performed
*/
public void performRequest(Request req) {
Shell shell = replEditor.getSite().getShell();
if (req.getType() == RequestConstants.REQ_OPEN) {
if (getModel() instanceof MasterNode) {
SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) getModel());
wizard.setEditable(replEditor.isEditable());
CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
dialog.setPageSize(560, 300);
dialog.open();
} else if (getModel() instanceof DistributorNode) {
SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
dialog.setDistributor((DistributorNode) getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
} else if (getModel() instanceof SlaveNode) {
SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
dialog.setSlave((SlaveNode) getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
}
}
}
Aggregations