org.eclipse.gef.requests.CreateConnectionRequest Java Examples

The following examples show how to use org.eclipse.gef.requests.CreateConnectionRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionGraphicalNodeEditPolicy.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@Override
protected Command getConnectionCreateCommand(final CreateConnectionRequest request) {
    final Object object = request.getNewObject();

    if (object instanceof CommentConnection) {
        final CommentConnection connection = (CommentConnection) object;

        final CreateConnectionCommand command = new CreateCommentConnectionCommand(connection);

        command.setSource(request.getTargetEditPart());
        request.setStartCommand(command);

        return command;
    }

    return null;
}
 
Example #2
Source File: ProcessLinkCreatePolicy.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest req) {
	CreateLinkCommand cmd = (CreateLinkCommand) req.getStartCommand();
	if (cmd == null)
		return null;
	ExchangeNode toConnect = (ExchangeNode) req.getTargetEditPart().getModel();
	ExchangeNode other = cmd.startedFromOutput ? cmd.output : cmd.input;
	if (!toConnect.matches(other) || toConnect.parent().isConnected(toConnect.exchange.id)) {
		cmd.completeWith(null);
		req.setStartCommand(cmd);
		return null;
	}
	cmd.completeWith(toConnect);
	req.setStartCommand(cmd);
	if (cmd.output == null || cmd.input == null)
		return null;
	return cmd;
}
 
Example #3
Source File: DiagramWalkerGraphicalNodeEditPolicy.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
    final AbstractCreateConnectionCommand command = (AbstractCreateConnectionCommand) request.getStartCommand();
    final DiagramWalkerEditPart targetEditPart = (DiagramWalkerEditPart) request.getTargetEditPart();
    if (command instanceof AbstractCreateRelationshipCommand) {
        if (!(targetEditPart instanceof TableViewEditPart)) {
            return null;
        }
    }
    final String validatedMessage = command.validate();
    if (validatedMessage != null) {
        Activator.showErrorDialog(validatedMessage);
        return null;
    }
    command.setTarget(targetEditPart);
    if (!command.canExecute()) {
        return null;
    }
    return command;
}
 
Example #4
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected org.eclipse.gef.commands.Command getConnectionCompleteCommand(
		CreateConnectionRequest request )
{

	ConnectionCommand command = (ConnectionCommand) request.getStartCommand( );

	if ( command == null )
		return null;
	EditPart sourcePart = command.getSource( );
	if ( !( getHost( ) instanceof ColumnEditPart )
			|| getHost( ) == sourcePart
			|| getHost( ).getParent( ) == sourcePart.getParent( ) )
	{
		return null;
	}
	ColumnEditPart targetPart = (ColumnEditPart) getHost( );
	command.setTarget( targetPart );

	AddJoinConditionCommand addJoinConditionCommand = new AddJoinConditionCommand( sourcePart,
			targetPart );
	return addJoinConditionCommand;
}
 
Example #5
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private ConnectionAnchor sourceAnchor(CreateConnectionRequest req) {
	CreateLinkCommand cmd = (CreateLinkCommand) ((CreateConnectionRequest) req)
			.getStartCommand();
	if (cmd.output != null)
		return LinkAnchor.forOutput(cmd.output.parent(), cmd.output);
	if (cmd.input != null)
		return LinkAnchor.forInput(cmd.input.parent(), cmd.input);
	return null;
}
 
Example #6
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request req) {
	if (req instanceof CreateConnectionRequest)
		return sourceAnchor((CreateConnectionRequest) req);
	if (req instanceof ReconnectRequest)
		return sourceAnchor((ReconnectRequest) req);
	return null;
}
 
Example #7
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request req) {
	if (req instanceof CreateConnectionRequest)
		return targetAnchor((CreateConnectionRequest) req);
	if (req instanceof ReconnectRequest)
		return targetAnchor((ReconnectRequest) req);
	return null;
}
 
Example #8
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private ConnectionAnchor targetAnchor(CreateConnectionRequest req) {
	CreateLinkCommand cmd = (CreateLinkCommand) req.getStartCommand();
	if (cmd.startedFromOutput) {
		if (cmd.input != null)
			return LinkAnchor.forInput(cmd.input.parent(), cmd.input);
		return null;
	}
	if (cmd.output != null)
		return LinkAnchor.forOutput(cmd.output.parent(), cmd.output);
	return null;
}
 
Example #9
Source File: ProcessLinkCreatePolicy.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected Connection createDummyConnection(Request req) {
	PolylineConnection con = (PolylineConnection) super.createDummyConnection(req);
	con.setForegroundColor(Link.COLOR);
	if (!(req instanceof CreateConnectionRequest)) {
		con.setTargetDecoration(new PolygonDecoration());
		return con;
	}
	CreateLinkCommand cmd = (CreateLinkCommand) ((CreateConnectionRequest) req).getStartCommand();
	if (cmd.output != null)
		con.setTargetDecoration(new PolygonDecoration());
	else if (cmd.input != null)
		con.setSourceDecoration(new PolygonDecoration());
	return con;
}
 
Example #10
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected org.eclipse.gef.commands.Command getConnectionCreateCommand(
		CreateConnectionRequest request )
{

	ConnectionCommand command = new ConnectionCommand( );
	command.setSource( getSourceEditPart( ) );
	request.setStartCommand( command );
	return command;
}
 
Example #11
Source File: NodeElementGraphicalNodeEditPolicy.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getConnectionCompleteCommand(final CreateConnectionRequest request) {
    final AbstractCreateConnectionCommand command = (AbstractCreateConnectionCommand) request.getStartCommand();

    final NodeElementEditPart targetEditPart = (NodeElementEditPart) request.getTargetEditPart();

    if (command instanceof AbstractCreateRelationCommand) {
        if (!(targetEditPart instanceof TableViewEditPart)) {
            return null;
        }
    }

    final String validatedMessage = command.validate();
    if (validatedMessage != null) {
        ERDiagramActivator.showErrorDialog(validatedMessage);

        return null;
    }

    command.setTarget(targetEditPart);

    if (!command.canExecute()) {
        return null;
    }

    return command;
}
 
Example #12
Source File: ConnectionGraphicalNodeEditPolicy.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
protected Command getConnectionCompleteCommand(final CreateConnectionRequest request) {
    final CreateCommentConnectionCommand command = (CreateCommentConnectionCommand) request.getStartCommand();

    command.setTarget(request.getTargetEditPart());

    if (!command.canExecute()) {
        return null;
    }

    return command;
}
 
Example #13
Source File: NodeElementGraphicalNodeEditPolicy.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getConnectionCompleteCommand(
		CreateConnectionRequest request) {
	AbstractCreateConnectionCommand command = (AbstractCreateConnectionCommand) request
			.getStartCommand();

	NodeElementEditPart targetEditPart = (NodeElementEditPart) request
			.getTargetEditPart();

	if (command instanceof AbstractCreateRelationCommand) {
		if (!(targetEditPart instanceof TableViewEditPart)) {
			return null;
		}
	}

	String validatedMessage = command.validate();
	if (validatedMessage != null) {
		Activator.showErrorDialog(validatedMessage);

		return null;
	}

	command.setTarget(targetEditPart);

	if (!command.canExecute()) {
		return null;
	}

	return command;
}
 
Example #14
Source File: TableViewEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
	if (request instanceof ReconnectRequest) {
		ReconnectRequest reconnectRequest = (ReconnectRequest) request;

		ConnectionEditPart connectionEditPart = reconnectRequest
				.getConnectionEditPart();

		if (!(connectionEditPart instanceof RelationEditPart)) {
			return super.getSourceConnectionAnchor(request);
		}

		Relation relation = (Relation) connectionEditPart.getModel();
		if (relation.getSource() == relation.getTarget()) {
			return new XYChopboxAnchor(this.getFigure());
		}

		EditPart editPart = reconnectRequest.getTarget();

		if (editPart == null
				|| !editPart.getModel().equals(relation.getSource())) {
			return new XYChopboxAnchor(this.getFigure());
		}

		Point location = new Point(reconnectRequest.getLocation());
		this.getFigure().translateToRelative(location);
		IFigure sourceFigure = ((TableViewEditPart) connectionEditPart
				.getSource()).getFigure();

		XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure());

		Rectangle bounds = sourceFigure.getBounds();

		Rectangle centerRectangle = new Rectangle(bounds.x
				+ (bounds.width / 4), bounds.y + (bounds.height / 4),
				bounds.width / 2, bounds.height / 2);

		if (!centerRectangle.contains(location)) {
			Point point = getIntersectionPoint(location, sourceFigure);
			anchor.setLocation(point);
		}

		return anchor;

	} else if (request instanceof CreateConnectionRequest) {
		CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

		Command command = connectionRequest.getStartCommand();

		if (command instanceof CreateCommentConnectionCommand) {
			return super.getTargetConnectionAnchor(request);
		}
	}

	return new XYChopboxAnchor(this.getFigure());
}
 
Example #15
Source File: ProcessLinkCreatePolicy.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected ConnectionRouter getDummyConnectionRouter(CreateConnectionRequest request) {
	return ConnectionRouter.NULL;
}
 
Example #16
Source File: TableViewEditPart.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
	if (request instanceof ReconnectRequest) {
		ReconnectRequest reconnectRequest = (ReconnectRequest) request;

		ConnectionEditPart connectionEditPart = reconnectRequest
				.getConnectionEditPart();

		if (!(connectionEditPart instanceof RelationEditPart)) {
			return super.getTargetConnectionAnchor(request);
		}

		Relation relation = (Relation) connectionEditPart.getModel();
		if (relation.getSource() == relation.getTarget()) {
			return new XYChopboxAnchor(this.getFigure());
		}

		EditPart editPart = reconnectRequest.getTarget();

		if (editPart == null
				|| !editPart.getModel().equals(relation.getTarget())) {
			return new XYChopboxAnchor(this.getFigure());
		}

		Point location = new Point(reconnectRequest.getLocation());
		this.getFigure().translateToRelative(location);
		IFigure targetFigure = ((TableViewEditPart) connectionEditPart
				.getTarget()).getFigure();

		XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure());

		Rectangle bounds = targetFigure.getBounds();

		Rectangle centerRectangle = new Rectangle(bounds.x
				+ (bounds.width / 4), bounds.y + (bounds.height / 4),
				bounds.width / 2, bounds.height / 2);

		if (!centerRectangle.contains(location)) {
			Point point = getIntersectionPoint(location, targetFigure);
			anchor.setLocation(point);
		}

		return anchor;

	} else if (request instanceof CreateConnectionRequest) {
		CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

		Command command = connectionRequest.getStartCommand();

		if (command instanceof CreateCommentConnectionCommand) {
			return super.getTargetConnectionAnchor(request);
		}
	}

	return new XYChopboxAnchor(this.getFigure());
}
 
Example #17
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected ConnectionAnchor getSourceConnectionAnchor(
		CreateConnectionRequest request )
{
	// TODO Auto-generated method stub
	return super.getSourceConnectionAnchor( request );
}
 
Example #18
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void showCreationFeedback( CreateConnectionRequest request )
{
	// TODO Auto-generated method stub
	super.showCreationFeedback( request );
}
 
Example #19
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected ConnectionAnchor getTargetConnectionAnchor(
		CreateConnectionRequest request )
{
	// TODO Auto-generated method stub
	return super.getTargetConnectionAnchor( request );
}
 
Example #20
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getSourceConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getSource())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = sourceFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, sourceFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
Example #21
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected FeedbackHelper getFeedbackHelper( CreateConnectionRequest request )
{
	// TODO Auto-generated method stub
	return super.getFeedbackHelper( request );
}
 
Example #22
Source File: ConnectionCreationEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void eraseCreationFeedback( CreateConnectionRequest request )
{
	// TODO Auto-generated method stub
	super.eraseCreationFeedback( request );
}
 
Example #23
Source File: TableViewEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;
        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
        if (!(connectionEditPart instanceof RelationEditPart)) {
            return super.getTargetConnectionAnchor(request);
        }

        final Relationship relation = (Relationship) connectionEditPart.getModel();
        if (relation.getSourceWalker() == relation.getTargetWalker()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();
        if (editPart == null || !editPart.getModel().equals(relation.getTargetWalker())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);

        final IFigure targetFigure = ((TableViewEditPart) connectionEditPart.getTarget()).getFigure();
        final Rectangle bounds = targetFigure.getBounds();
        final Rectangle centerRectangle =
                new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, targetFigure);
            anchor.setLocation(point);
        }

        return anchor;
    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;
        final Command command = connectionRequest.getStartCommand();
        if (command instanceof CreateCommentConnectionCommand) {
            return super.getTargetConnectionAnchor(request);
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
Example #24
Source File: TableViewEditPart.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;
        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
        if (!(connectionEditPart instanceof RelationEditPart)) {
            return super.getSourceConnectionAnchor(request);
        }

        final Relationship relation = (Relationship) connectionEditPart.getModel();
        if (relation.getSourceWalker() == relation.getTargetWalker()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();
        if (editPart == null || !editPart.getModel().equals(relation.getSourceWalker())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);

        final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure();
        final Rectangle bounds = sourceFigure.getBounds();
        final Rectangle centerRectangle =
                new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, sourceFigure);
            anchor.setLocation(point);
        }

        return anchor;
    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;
        final Command command = connectionRequest.getStartCommand();
        if (command instanceof CreateCommentConnectionCommand) {
            return super.getTargetConnectionAnchor(request);
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
Example #25
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getTargetConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getTarget())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure targetFigure = ((AbstractModelEditPart) connectionEditPart.getTarget()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = targetFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, targetFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}