use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class ShowHostAction 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();
List<HostNode> hosts = new ArrayList<HostNode>();
EditPart root = null;
while (iterator.hasNext()) {
Object objSelected = iterator.next();
if (objSelected instanceof DatabaseMonitorPart) {
DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
DatabaseNode dn = ((DatabaseNode) cmp.getModel());
if (!hosts.contains(dn.getParent())) {
hosts.add(dn.getParent());
}
root = cmp.getParent();
} else if (objSelected instanceof BrokerMonitorPart) {
BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
BrokerNode bn = ((BrokerNode) cmp.getModel());
if (!hosts.contains(bn.getParent())) {
hosts.add(bn.getParent());
}
root = cmp.getParent();
}
}
for (HostNode host : hosts) {
if (host.isVisible() == isChecked()) {
continue;
}
host.setVisible(isChecked());
}
if (root != null) {
root.refresh();
}
}
use of org.eclipse.gef.EditPart 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 org.eclipse.gef.EditPart 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 org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class AbstractBasicPart method handleInputChange.
private void handleInputChange(PropertyChangeEvent evt) {
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (oldValue == null && newValue == null) {
throw new IllegalStateException(Messages.errOldNewValueBothNull);
}
if (newValue != null) {
// add new connection
ConnectionEditPart connPart = createOrFindConnection(newValue);
int modelIndex = getModelTargetConnections().indexOf(newValue);
addTargetConnection(connPart, modelIndex < 0 ? 0 : modelIndex);
} else {
// remove connection
List children = getTargetConnections();
ConnectionEditPart partToRemove = null;
for (Iterator iter = children.iterator(); iter.hasNext(); ) {
ConnectionEditPart part = (ConnectionEditPart) iter.next();
if (part.getModel() == oldValue) {
partToRemove = part;
break;
}
}
if (partToRemove != null) {
// the connection part should be removed both in source part and in target part
removeTargetConnection(partToRemove);
EditPart sourcePart = partToRemove.getSource();
if (sourcePart instanceof AbstractBasicPart) {
((AbstractBasicPart) sourcePart).removeSourceConnection(partToRemove);
}
}
}
getContentPane().revalidate();
}
use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class AbstractBasicPart method handleOutputChange.
private void handleOutputChange(PropertyChangeEvent evt) {
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if ((oldValue == null) && (newValue == null)) {
throw new IllegalStateException(Messages.errOldNewValueBothNull);
}
if (oldValue == null && newValue != null) {
// add new connection
ConnectionEditPart connPart = createOrFindConnection(newValue);
int modelIndex = getModelSourceConnections().indexOf(newValue);
addSourceConnection(connPart, modelIndex < 0 ? 0 : modelIndex);
} else if (oldValue != null && newValue == null) {
// remove connection
List children = getSourceConnections();
ConnectionEditPart partToRemove = null;
for (Iterator iter = children.iterator(); iter.hasNext(); ) {
ConnectionEditPart part = (ConnectionEditPart) iter.next();
if (part.getModel() == oldValue) {
partToRemove = part;
break;
}
}
if (partToRemove != null) {
// the connection part should be removed both in source part and in target part
removeSourceConnection(partToRemove);
EditPart targetPart = partToRemove.getTarget();
if (targetPart instanceof AbstractBasicPart) {
((AbstractBasicPart) targetPart).removeTargetConnection(partToRemove);
}
}
getViewer().getEditPartRegistry().remove(oldValue);
/*
ConnectionEditPart connPart = (ConnectionEditPart) getViewer().getEditPartRegistry().get(oldValue);
IFigure figure = connPart.getFigure();
if(figure instanceof ConnectionFigure){
ConnectionFigure connFigure = (ConnectionFigure)figure;
if(connFigure.getConnectionRouter() == ConnectionRouter.NULL){
connFigure.setConnectionRouter(new ERConnectionRouter());
}
}
*/
}
getContentPane().revalidate();
}
Aggregations