use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode in project cubrid-manager by CUBRID.
the class ClearNodeErrorMsgAction method run.
/**
* Create a new figure in dashboard.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IStructuredSelection selection = (IStructuredSelection) getSelection();
Iterator<?> iterator = selection.iterator();
EditPart root = null;
while (iterator.hasNext()) {
Object objSelected = iterator.next();
if (objSelected instanceof HANodePart) {
HANodePart ep = (HANodePart) objSelected;
((HANode) ep.getModel()).clearErrorMessages();
root = ep.getParent();
}
}
if (root != null) {
root.refresh();
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode in project cubrid-manager by CUBRID.
the class DashboardRefreshAction method run.
/**
* refresh dashboard run.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
DashboardPart dp = null;
if (objArr[0] instanceof DashboardPart) {
dp = (DashboardPart) objArr[0];
} else {
dp = (DashboardPart) ((EditPart) objArr[0]).getParent();
}
//Clear error messages
IStructuredSelection selection = (IStructuredSelection) getSelection();
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object objSelected = iterator.next();
if (objSelected instanceof HANodePart) {
HANodePart ep = (HANodePart) objSelected;
((HANode) ep.getModel()).clearErrorMessages();
}
}
dp.refresh();
List<?> childEditPart = dp.getChildren();
for (Object child : childEditPart) {
((EditPart) child).refresh();
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode in project cubrid-manager by CUBRID.
the class HAUtil method calcLocation.
/**
*
* Calculate the location
*
* @param hostNodeList List<HostNode>
*/
public static void calcLocation(List<HostNode> hostNodeList) {
Point zeroLocation = new Point(0, 0);
List<HostNode> zeroPointHostList = new ArrayList<HostNode>();
List<HostNode> noZeroPointHostList = new ArrayList<HostNode>();
for (HostNode hostNode : hostNodeList) {
Point location = hostNode.getLocation();
if (zeroLocation.equals(location)) {
zeroPointHostList.add(hostNode);
} else {
noZeroPointHostList.add(hostNode);
}
}
int hostMaxY = 0;
for (HostNode hostNode : noZeroPointHostList) {
Point hostLocation = hostNode.getLocation();
int tY = hostLocation.y + hostNode.getSize().height;
if (tY > hostMaxY) {
hostMaxY = tY;
}
int nodeMaxY = hostLocation.y + hostNode.getSize().height + HEIGHT_DISTANCE;
int nodeMaxX = hostLocation.x + hostNode.getSize().width;
List<HANode> haNodeList = new ArrayList<HANode>();
haNodeList.addAll(hostNode.getDbNodeList());
haNodeList.addAll(hostNode.getBrokerNodeList());
List<HANode> zeroPointChildList = new ArrayList<HANode>();
for (HANode haNode : haNodeList) {
if (haNode.getLocation().equals(zeroLocation)) {
zeroPointChildList.add(haNode);
} else {
int tX = haNode.getLocation().x + haNode.getSize().width;
if (tX > nodeMaxX) {
nodeMaxX = tX;
}
tY = haNode.getLocation().y;
if (tY > nodeMaxY) {
nodeMaxY = tY;
}
tY = haNode.getLocation().y + haNode.getSize().height;
if (tY > hostMaxY) {
hostMaxY = tY;
}
}
}
nodeMaxX = nodeMaxX + WIDTH_DISTANCE;
for (HANode haNode : zeroPointChildList) {
haNode.setLocation(new Point(nodeMaxX, nodeMaxY));
nodeMaxX = nodeMaxX + haNode.getSize().width + WIDTH_DISTANCE;
}
}
if (!zeroPointHostList.isEmpty()) {
calcLocation(zeroPointHostList, hostMaxY);
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode in project cubrid-manager by CUBRID.
the class HAUtil method mergeCopyedHostChildNode.
/**
*
* Merge the database node
*
* @param hostNode The HostNode
* @param addedHostNode The HostNode
*/
private static void mergeCopyedHostChildNode(HostNode hostNode, HostNode addedHostNode) {
List<HANode> haNodeList = hostNode.getCopyedHaNodeList();
//merge database node
List<DatabaseNode> addedDbNodeList = addedHostNode.getCopyedDbNodeList();
for (int i = 0; i < addedDbNodeList.size(); i++) {
DatabaseNode addDbNode = addedDbNodeList.get(i);
addDbNode.setParent(hostNode);
if (haNodeList.contains(addDbNode)) {
haNodeList.remove(addDbNode);
haNodeList.add(addDbNode);
} else {
haNodeList.add(addDbNode);
}
}
//merge broker node
List<BrokerNode> addedBrokerNodeList = addedHostNode.getCopyedBrokerNodeList();
for (int i = 0; i < addedBrokerNodeList.size(); i++) {
BrokerNode addBrokerNode = addedBrokerNodeList.get(i);
addBrokerNode.setParent(hostNode);
if (haNodeList.contains(addBrokerNode)) {
haNodeList.remove(addBrokerNode);
haNodeList.add(addBrokerNode);
} else {
haNodeList.add(addBrokerNode);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode in project cubrid-manager by CUBRID.
the class GefViewerKeyHandler method moveHANodesByKey.
/**
* move figures by keyboard.
*
* @param event KeyEvent
* @return if handled the event return true else return false.
*/
private boolean moveHANodesByKey(KeyEvent event) {
List<?> selectedEditParts = getViewer().getSelectedEditParts();
boolean flag = false;
for (Object obj : selectedEditParts) {
if (!(obj instanceof HANodePart)) {
continue;
}
GraphicalEditPart editPart = (GraphicalEditPart) obj;
Command command = null;
if ((event.stateMask & SWT.ALT) == 0 && (event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
HANode node = (HANode) editPart.getModel();
ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
request.setLocation(node.getLocation());
request.setEditParts(editPart);
//get move delta
Point moveDelta = null;
switch(event.keyCode) {
case SWT.ARROW_LEFT:
moveDelta = new Point(-1, 0);
break;
case SWT.ARROW_RIGHT:
moveDelta = new Point(1, 0);
break;
case SWT.ARROW_UP:
moveDelta = new Point(0, -1);
break;
case SWT.ARROW_DOWN:
moveDelta = new Point(0, 1);
break;
default:
return true;
}
request.setMoveDelta(moveDelta);
command = editPart.getCommand(request);
}
if (command != null && !(command instanceof UnexecutableCommand)) {
command.execute();
flag = true;
}
}
return flag;
}
Aggregations