Search in sources :

Example 1 with ConnectionEditPart

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();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) ERDObject(org.jkiss.dbeaver.ext.erd.model.ERDObject) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject)

Example 2 with ConnectionEditPart

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();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) ERDObject(org.jkiss.dbeaver.ext.erd.model.ERDObject) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject)

Example 3 with ConnectionEditPart

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();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) List(java.util.List)

Example 4 with ConnectionEditPart

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();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) List(java.util.List)

Example 5 with ConnectionEditPart

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();
    }
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart)

Aggregations

ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)8 List (java.util.List)4 EditPart (org.eclipse.gef.EditPart)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Point (org.eclipse.draw2d.geometry.Point)2 NodeEditPart (org.eclipse.gef.NodeEditPart)2 RootEditPart (org.eclipse.gef.RootEditPart)2 ERDObject (org.jkiss.dbeaver.ext.erd.model.ERDObject)2 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)2 IConnection (org.talend.core.model.process.IConnection)2 INode (org.talend.core.model.process.INode)2