Commit 08376811 by Nepxion

增加图形化灰度发布功能

parent 15d085d0
...@@ -45,6 +45,7 @@ import com.nepxion.discovery.console.desktop.entity.RouterEntity; ...@@ -45,6 +45,7 @@ import com.nepxion.discovery.console.desktop.entity.RouterEntity;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory; import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale; import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.discovery.console.desktop.workspace.topology.AbstractTopology; import com.nepxion.discovery.console.desktop.workspace.topology.AbstractTopology;
import com.nepxion.discovery.console.desktop.workspace.topology.LocationEntity;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntity; import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntity;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityType; import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityType;
import com.nepxion.swing.action.JSecurityAction; import com.nepxion.swing.action.JSecurityAction;
...@@ -63,10 +64,7 @@ import com.nepxion.swing.textfield.JBasicTextField; ...@@ -63,10 +64,7 @@ import com.nepxion.swing.textfield.JBasicTextField;
public class RouterTopology extends AbstractTopology { public class RouterTopology extends AbstractTopology {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int nodeStartX = 100; private LocationEntity nodeLocationEntity = new LocationEntity(100, 150, 200, 0);
private int nodeStartY = 150;
private int nodeHorizontalGap = 200;
private int nodeVerticalGap = 0;
private TopologyEntity serviceNodeEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, true); private TopologyEntity serviceNodeEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, true);
...@@ -197,7 +195,7 @@ public class RouterTopology extends AbstractTopology { ...@@ -197,7 +195,7 @@ public class RouterTopology extends AbstractTopology {
private TNode addNode(RouterEntity routerEntity, int index) { private TNode addNode(RouterEntity routerEntity, int index) {
String nodeName = getNodeName(routerEntity); String nodeName = getNodeName(routerEntity);
TNode node = createNode(nodeName, serviceNodeEntity, index, nodeStartX, nodeStartY, nodeHorizontalGap, nodeVerticalGap); TNode node = createNode(nodeName, serviceNodeEntity, nodeLocationEntity, index);
node.setUserObject(routerEntity); node.setUserObject(routerEntity);
dataBox.addElement(node); dataBox.addElement(node);
......
...@@ -49,6 +49,7 @@ import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory; ...@@ -49,6 +49,7 @@ import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale; import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.discovery.console.desktop.util.UIUtil; import com.nepxion.discovery.console.desktop.util.UIUtil;
import com.nepxion.discovery.console.desktop.workspace.topology.AbstractTopology; import com.nepxion.discovery.console.desktop.workspace.topology.AbstractTopology;
import com.nepxion.discovery.console.desktop.workspace.topology.LocationEntity;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntity; import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntity;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityType; import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityType;
import com.nepxion.swing.action.JSecurityAction; import com.nepxion.swing.action.JSecurityAction;
...@@ -74,15 +75,8 @@ import com.nepxion.swing.textfield.number.JNumberTextField; ...@@ -74,15 +75,8 @@ import com.nepxion.swing.textfield.number.JNumberTextField;
public class ServiceTopology extends AbstractTopology { public class ServiceTopology extends AbstractTopology {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int groupStartX = 120; private LocationEntity groupLocationEntity = new LocationEntity(120, 200, 280, 0);
private int groupStartY = 200; private LocationEntity nodeLocationEntity = new LocationEntity(0, 0, 120, 100);
private int groupHorizontalGap = 280;
private int groupVerticalGap = 0;
private int nodeStartX = 0;
private int nodeStartY = 0;
private int nodeHorizontalGap = 120;
private int nodeVerticalGap = 100;
private TopologyEntity serviceGroupEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, true); private TopologyEntity serviceGroupEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, true);
private TopologyEntity serviceNodeEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, false); private TopologyEntity serviceNodeEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, false);
...@@ -183,7 +177,7 @@ public class ServiceTopology extends AbstractTopology { ...@@ -183,7 +177,7 @@ public class ServiceTopology extends AbstractTopology {
int count = groupLocationMap.size(); int count = groupLocationMap.size();
String groupName = getGroupName(serviceId, instances.size(), null); String groupName = getGroupName(serviceId, instances.size(), null);
TGroup group = createGroup(groupName, serviceGroupEntity, count, groupStartX, groupStartY, groupHorizontalGap, groupVerticalGap); TGroup group = createGroup(groupName, serviceGroupEntity, groupLocationEntity, count);
group.setGroupType(TGroupType.ELLIPSE_GROUP_TYPE.getType()); group.setGroupType(TGroupType.ELLIPSE_GROUP_TYPE.getType());
group.setUserObject(serviceId); group.setUserObject(serviceId);
...@@ -199,11 +193,11 @@ public class ServiceTopology extends AbstractTopology { ...@@ -199,11 +193,11 @@ public class ServiceTopology extends AbstractTopology {
TNode node = null; TNode node = null;
if (StringUtils.isNotEmpty(plugin)) { if (StringUtils.isNotEmpty(plugin)) {
node = createNode(nodeName, serviceNodeEntity, i, nodeStartX, nodeStartY, nodeHorizontalGap, nodeVerticalGap); node = createNode(nodeName, serviceNodeEntity, nodeLocationEntity, i);
node.putClientProperty("plugin", plugin); node.putClientProperty("plugin", plugin);
group.putClientProperty("plugin", plugin); group.putClientProperty("plugin", plugin);
} else { } else {
node = createNode(nodeName, notServiceNodeEntity, i, nodeStartX, nodeStartY, nodeHorizontalGap, nodeVerticalGap); node = createNode(nodeName, notServiceNodeEntity, nodeLocationEntity, i);
node.putClientProperty("plugin", ""); node.putClientProperty("plugin", "");
group.putClientProperty("plugin", ""); group.putClientProperty("plugin", "");
} }
...@@ -989,15 +983,15 @@ public class ServiceTopology extends AbstractTopology { ...@@ -989,15 +983,15 @@ public class ServiceTopology extends AbstractTopology {
} }
public void setToUI() { public void setToUI() {
groupStartXTextField.setText(groupStartX + ""); groupStartXTextField.setText(groupLocationEntity.getStartX() + "");
groupStartYTextField.setText(groupStartY + ""); groupStartYTextField.setText(groupLocationEntity.getStartY() + "");
groupHorizontalGapTextField.setText(groupHorizontalGap + ""); groupHorizontalGapTextField.setText(groupLocationEntity.getHorizontalGap() + "");
groupVerticalGapTextField.setText(groupVerticalGap + ""); groupVerticalGapTextField.setText(groupLocationEntity.getVerticalGap() + "");
nodeStartXTextField.setText(nodeStartX + ""); nodeStartXTextField.setText(nodeLocationEntity.getStartX() + "");
nodeStartYTextField.setText(nodeStartY + ""); nodeStartYTextField.setText(nodeLocationEntity.getStartY() + "");
nodeHorizontalGapTextField.setText(nodeHorizontalGap + ""); nodeHorizontalGapTextField.setText(nodeLocationEntity.getHorizontalGap() + "");
nodeVerticalGapTextField.setText(nodeVerticalGap + ""); nodeVerticalGapTextField.setText(nodeLocationEntity.getVerticalGap() + "");
} }
public boolean setFromUI() { public boolean setFromUI() {
...@@ -1024,14 +1018,15 @@ public class ServiceTopology extends AbstractTopology { ...@@ -1024,14 +1018,15 @@ public class ServiceTopology extends AbstractTopology {
return false; return false;
} }
ServiceTopology.this.groupStartX = groupStartX; groupLocationEntity.setStartX(groupStartX);
ServiceTopology.this.groupStartY = groupStartY; groupLocationEntity.setStartY(groupStartY);
ServiceTopology.this.groupHorizontalGap = groupHorizontalGap; groupLocationEntity.setHorizontalGap(groupHorizontalGap);
ServiceTopology.this.groupVerticalGap = groupVerticalGap; groupLocationEntity.setVerticalGap(groupVerticalGap);
ServiceTopology.this.nodeStartX = nodeStartX;
ServiceTopology.this.nodeStartY = nodeStartY; nodeLocationEntity.setStartX(nodeStartX);
ServiceTopology.this.nodeHorizontalGap = nodeHorizontalGap; nodeLocationEntity.setStartY(nodeStartY);
ServiceTopology.this.nodeVerticalGap = nodeVerticalGap; nodeLocationEntity.setHorizontalGap(nodeHorizontalGap);
nodeLocationEntity.setVerticalGap(nodeVerticalGap);
return true; return true;
} }
......
...@@ -231,16 +231,21 @@ public abstract class AbstractTopology extends JPanel { ...@@ -231,16 +231,21 @@ public abstract class AbstractTopology extends JPanel {
linkAutoHideRadioButtonMenuItem.setSelected(hide); linkAutoHideRadioButtonMenuItem.setSelected(hide);
} }
protected TGroup createGroup(String name, TopologyEntity entity, int index, int startX, int startY, int horizontalGap, int verticalGap) { protected TGroup createGroup(String name, TopologyEntity topologyEntity, LocationEntity locationEntity, int index) {
String image = entity.getImage(); String image = topologyEntity.getImage();
Point location = new Point(entity.isHorizontalPile() ? startX + index * horizontalGap : startX, entity.isHorizontalPile() ? startY : startY + index * verticalGap);
int startX = locationEntity.getStartX();
int startY = locationEntity.getStartY();
int horizontalGap = locationEntity.getHorizontalGap();
int verticalGap = locationEntity.getVerticalGap();
Point location = new Point(topologyEntity.isHorizontalPile() ? startX + index * horizontalGap : startX, topologyEntity.isHorizontalPile() ? startY : startY + index * verticalGap);
return createGroup(name, image, location); return createGroup(name, image, location);
} }
protected TGroup createGroup(String name, TopologyEntity entity) { protected TGroup createGroup(String name, TopologyEntity topologyEntity) {
String image = entity.getImage(); String image = topologyEntity.getImage();
Point location = entity.getLocation(); Point location = topologyEntity.getLocation();
return createGroup(name, image, location); return createGroup(name, image, location);
} }
...@@ -255,16 +260,21 @@ public abstract class AbstractTopology extends JPanel { ...@@ -255,16 +260,21 @@ public abstract class AbstractTopology extends JPanel {
return group; return group;
} }
protected TNode createNode(String name, TopologyEntity entity, int index, int startX, int startY, int horizontalGap, int verticalGap) { protected TNode createNode(String name, TopologyEntity topologyEntity, LocationEntity locationEntity, int index) {
String image = entity.getImage(); String image = topologyEntity.getImage();
Point location = new Point(entity.isHorizontalPile() ? startX + index * horizontalGap : startX, entity.isHorizontalPile() ? startY : startY + index * verticalGap);
int startX = locationEntity.getStartX();
int startY = locationEntity.getStartY();
int horizontalGap = locationEntity.getHorizontalGap();
int verticalGap = locationEntity.getVerticalGap();
Point location = new Point(topologyEntity.isHorizontalPile() ? startX + index * horizontalGap : startX, topologyEntity.isHorizontalPile() ? startY : startY + index * verticalGap);
return createNode(name, image, location); return createNode(name, image, location);
} }
protected TNode createNode(String name, TopologyEntity entity) { protected TNode createNode(String name, TopologyEntity topologyEntity) {
String image = entity.getImage(); String image = topologyEntity.getImage();
Point location = entity.getLocation(); Point location = topologyEntity.getLocation();
return createNode(name, image, location); return createNode(name, image, location);
} }
......
package com.nepxion.discovery.console.desktop.workspace.topology;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
public class LocationEntity {
private int startX;
private int startY;
private int horizontalGap;
private int verticalGap;
public LocationEntity(int startX, int startY, int horizontalGap, int verticalGap) {
this.startX = startX;
this.startY = startY;
this.horizontalGap = horizontalGap;
this.verticalGap = verticalGap;
}
public int getStartX() {
return startX;
}
public void setStartX(int startX) {
this.startX = startX;
}
public int getStartY() {
return startY;
}
public void setStartY(int startY) {
this.startY = startY;
}
public int getHorizontalGap() {
return horizontalGap;
}
public void setHorizontalGap(int horizontalGap) {
this.horizontalGap = horizontalGap;
}
public int getVerticalGap() {
return verticalGap;
}
public void setVerticalGap(int verticalGap) {
this.verticalGap = verticalGap;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment