use of org.eclipse.gef.ConnectionEditPart in project dbeaver by serge-rider.
the class PropertyAwarePart method handleOutputChange.
/**
* Called when change to one of the outputs occurs
*/
private void handleOutputChange(PropertyChangeEvent evt) {
//this works but is not efficient
//refreshSourceConnections();
// a more efficient implementation should either remove or add the
// relevant target connect
//using the removeSourceConnection(ConnectionEditPart connection) or
//addSourceConnection(ConnectionEditPart connection, int index)
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (!((oldValue != null) ^ (newValue != null))) {
throw new IllegalStateException("Exactly one of old or new values must be non-null for INPUT event");
}
if (newValue != null) {
//add new connection
ConnectionEditPart editPart = createOrFindConnection(newValue);
int modelIndex = getModelSourceConnections().indexOf(newValue);
addSourceConnection(editPart, modelIndex);
} else {
//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)
removeSourceConnection(partToRemove);
}
getContentPane().revalidate();
}
use of org.eclipse.gef.ConnectionEditPart in project dbeaver by serge-rider.
the class PropertyAwarePart method handleInputChange.
/**
* Called when change to one of the inputs occurs
*/
private void handleInputChange(PropertyChangeEvent evt) {
//this works but is not efficient
//refreshTargetConnections();
//a more efficient implementation should either remove or add the
//relevant target connection
//using the removeTargetConnection(ConnectionEditPart connection) or
//addTargetConnection(ConnectionEditPart connection, int index)
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (!((oldValue != null) ^ (newValue != null))) {
throw new IllegalStateException("Exactly one of old or new values must be non-null for INPUT event");
}
if (newValue != null) {
//add new connection
ConnectionEditPart editPart = createOrFindConnection(newValue);
int modelIndex = getModelTargetConnections().indexOf(newValue);
addTargetConnection(editPart, 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)
removeTargetConnection(partToRemove);
}
getContentPane().revalidate();
}
use of org.eclipse.gef.ConnectionEditPart 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.ConnectionEditPart 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();
}
use of org.eclipse.gef.ConnectionEditPart in project cubrid-manager by CUBRID.
the class BrokerMonitorPart method refreshSourceConnections.
/**
* refresh Target Connections
*/
protected void refreshSourceConnections() {
super.refreshSourceConnections();
for (Object obj : getSourceConnections()) {
ConnectionEditPart ep = (ConnectionEditPart) obj;
ep.refresh();
}
}
Aggregations