Java Code Examples for org.eclipse.gef.ConnectionEditPart#getModel()

The following examples show how to use org.eclipse.gef.ConnectionEditPart#getModel() . 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: NormalColumnEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private List<NormalColumn> getSelectedForeignKeyColulmnList() {
    final List<NormalColumn> foreignKeyColulmnList = new ArrayList<NormalColumn>();

    final TableViewEditPart parent = (TableViewEditPart) getParent();

    for (final Object object : parent.getTargetConnections()) {
        final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;

        final int selected = connectionEditPart.getSelected();

        if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) {
            final ConnectionElement connectionElement = (ConnectionElement) connectionEditPart.getModel();

            if (connectionElement instanceof Relation) {
                final Relation relation = (Relation) connectionElement;

                foreignKeyColulmnList.addAll(relation.getForeignKeyColumns());
            }
        }
    }

    return foreignKeyColulmnList;
}
 
Example 2
Source File: TableViewEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(
		ConnectionEditPart editPart) {
	if (!(editPart instanceof RelationEditPart)) {
		return super.getTargetConnectionAnchor(editPart);
	}

	Relation relation = (Relation) editPart.getModel();

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

	Rectangle bounds = this.getFigure().getBounds();

	if (relation.getTargetXp() != -1 && relation.getTargetYp() != -1) {
		anchor.setLocation(new Point(bounds.x
				+ (bounds.width * relation.getTargetXp() / 100), bounds.y
				+ (bounds.height * relation.getTargetYp() / 100)));
	}

	return anchor;
}
 
Example 3
Source File: TableViewEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(
		ConnectionEditPart editPart) {
	if (!(editPart instanceof RelationEditPart)) {
		return super.getSourceConnectionAnchor(editPart);
	}

	Relation relation = (Relation) editPart.getModel();

	Rectangle bounds = this.getFigure().getBounds();

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

	if (relation.getSourceXp() != -1 && relation.getSourceYp() != -1) {
		anchor.setLocation(new Point(bounds.x
				+ (bounds.width * relation.getSourceXp() / 100), bounds.y
				+ (bounds.height * relation.getSourceYp() / 100)));
	}

	return anchor;
}
 
Example 4
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart editPart) {
    // if (!(editPart instanceof RelationEditPart)) {
    // return new ChopboxAnchor(this.getFigure());
    // }

    final ConnectionElement connection = (ConnectionElement) editPart.getModel();

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

    final Rectangle bounds = getFigure().getBounds();

    if (connection.getTargetXp() != -1 && connection.getTargetYp() != -1) {
        anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getTargetXp() / 100), bounds.y + (bounds.height * connection.getTargetYp() / 100)));
    }

    return anchor;
}
 
Example 5
Source File: TableViewEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart editPart) {
    if (!(editPart instanceof RelationEditPart)) {
        return super.getSourceConnectionAnchor(editPart);
    }

    final Relationship relation = (Relationship) editPart.getModel();
    final Rectangle bounds = getFigure().getBounds();
    final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
    if (relation.getSourceXp() != -1 && relation.getSourceYp() != -1) {
        anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getSourceXp() / 100),
                bounds.y + (bounds.height * relation.getSourceYp() / 100)));
    }

    return anchor;
}
 
Example 6
Source File: TableViewEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart editPart) {
    if (!(editPart instanceof RelationEditPart)) {
        return super.getTargetConnectionAnchor(editPart);
    }

    final Relationship relation = (Relationship) editPart.getModel();
    final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
    final Rectangle bounds = getFigure().getBounds();
    if (relation.getTargetXp() != -1 && relation.getTargetYp() != -1) {
        anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getTargetXp() / 100),
                bounds.y + (bounds.height * relation.getTargetYp() / 100)));
    }

    return anchor;
}
 
Example 7
Source File: NormalColumnEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
private List<NormalColumn> getSelectedForeignKeyColulmnList() {
    final List<NormalColumn> foreignKeyColulmnList = new ArrayList<>();
    final TableViewEditPart parent = (TableViewEditPart) getParent();
    for (final Object object : parent.getTargetConnections()) {
        final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;
        final int selected = connectionEditPart.getSelected();
        if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) {
            final WalkerConnection connectionElement = (WalkerConnection) connectionEditPart.getModel();
            if (connectionElement instanceof Relationship) {
                final Relationship relation = (Relationship) connectionElement;
                foreignKeyColulmnList.addAll(relation.getForeignKeyColumns());
            }
        }
    }
    return foreignKeyColulmnList;
}
 
Example 8
Source File: NormalColumnEditPart.java    From erflute with Apache License 2.0 5 votes vote down vote up
private List<NormalColumn> getSelectedReferencedColulmnList() {
    final List<NormalColumn> referencedColulmnList = new ArrayList<>();

    final TableViewEditPart parent = (TableViewEditPart) getParent();
    final TableView tableView = (TableView) parent.getModel();

    for (final Object object : parent.getSourceConnections()) {
        final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;

        final int selected = connectionEditPart.getSelected();

        if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) {
            final WalkerConnection connectionElement = (WalkerConnection) connectionEditPart.getModel();

            if (connectionElement instanceof Relationship) {
                final Relationship relation = (Relationship) connectionElement;

                if (relation.isReferenceForPK()) {
                    referencedColulmnList.addAll(((ERTable) tableView).getPrimaryKeys());

                } else if (relation.getReferredCompoundUniqueKey() != null) {
                    referencedColulmnList.addAll(relation.getReferredCompoundUniqueKey().getColumnList());

                } else {
                    referencedColulmnList.add(relation.getReferredSimpleUniqueColumn());
                }
            }
        }
    }
    return referencedColulmnList;
}
 
Example 9
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart con) {
	Link link = (Link) con.getModel();
	ProcessNode process = link.inputNode;
	ExchangeNode input = process.getInput(link.processLink);
	return LinkAnchor.forInput(process, input);
}
 
Example 10
Source File: AbstractNodeEditPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart con) {
	Link link = (Link) con.getModel();
	ProcessNode process = link.outputNode;
	ExchangeNode output = process.getOutput(link.processLink);
	return LinkAnchor.forOutput(process, output);
}
 
Example 11
Source File: NormalColumnEditPart.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private List<NormalColumn> getSelectedReferencedColulmnList() {
    final List<NormalColumn> referencedColulmnList = new ArrayList<NormalColumn>();

    final TableViewEditPart parent = (TableViewEditPart) getParent();
    final TableView tableView = (TableView) parent.getModel();

    for (final Object object : parent.getSourceConnections()) {
        final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;

        final int selected = connectionEditPart.getSelected();

        if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) {
            final ConnectionElement connectionElement = (ConnectionElement) connectionEditPart.getModel();

            if (connectionElement instanceof Relation) {
                final Relation relation = (Relation) connectionElement;

                if (relation.isReferenceForPK()) {
                    referencedColulmnList.addAll(((ERTable) tableView).getPrimaryKeys());

                } else if (relation.getReferencedComplexUniqueKey() != null) {
                    referencedColulmnList.addAll(relation.getReferencedComplexUniqueKey().getColumnList());

                } else {
                    referencedColulmnList.add(relation.getReferencedColumn());
                }
            }
        }

    }
    return referencedColulmnList;
}
 
Example 12
Source File: NormalColumnEditPart.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private List<NormalColumn> getSelectedReferencedColulmnList() {
	List<NormalColumn> referencedColulmnList = new ArrayList<NormalColumn>();

	TableViewEditPart parent = (TableViewEditPart) this.getParent();
	TableView tableView = (TableView) parent.getModel();

	for (Object object : parent.getSourceConnections()) {
		ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;

		int selected = connectionEditPart.getSelected();

		if (selected == EditPart.SELECTED
				|| selected == EditPart.SELECTED_PRIMARY) {
			ConnectionElement connectionElement = (ConnectionElement) connectionEditPart
					.getModel();

			if (connectionElement instanceof Relation) {
				Relation relation = (Relation) connectionElement;

				if (relation.isReferenceForPK()) {
					referencedColulmnList.addAll(((ERTable) tableView)
							.getPrimaryKeys());

				} else if (relation.getReferencedComplexUniqueKey() != null) {
					referencedColulmnList.addAll(relation
							.getReferencedComplexUniqueKey()
							.getColumnList());

				} else {
					referencedColulmnList.add(relation
							.getReferencedColumn());
				}
			}
		}

	}
	return referencedColulmnList;
}
 
Example 13
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 14
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 15
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());
}
 
Example 16
Source File: ProcessPart.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
	Link link = (Link) connection.getModel();
	return new ProcessLinkAnchor(link, false);
}
 
Example 17
Source File: ProcessPart.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
	Link link = (Link) connection.getModel();
	return new ProcessLinkAnchor(link, true);
}
 
Example 18
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 19
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 20
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());
}