Java Code Examples for org.eclipse.gef.requests.DirectEditRequest#getLocation()

The following examples show how to use org.eclipse.gef.requests.DirectEditRequest#getLocation() . 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: ColumnSelectionHandlesEditPolicy.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private int getColumnIndex(final DirectEditRequest editRequest) {
    final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
    final double zoom = zoomManager.getZoom();

    final ColumnEditPart columnEditPart = (ColumnEditPart) getHost();

    Column column = (Column) columnEditPart.getModel();
    final TableView newTableView = (TableView) getHost().getParent().getModel();

    final List<Column> columns = newTableView.getColumns();

    if (column.getColumnHolder() instanceof ColumnGroup) {
        column = (ColumnGroup) column.getColumnHolder();
    }
    int index = columns.indexOf(column);

    final Rectangle columnRectangle = getColumnRectangle();
    final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom);

    if (editRequest.getLocation().y >= center) {
        index++;
    }

    return index;
}
 
Example 2
Source File: ColumnSelectionHandlesEditPolicy.java    From erflute with Apache License 2.0 6 votes vote down vote up
private int getColumnIndex(DirectEditRequest editRequest) {
    final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
    final double zoom = zoomManager.getZoom();
    final ColumnEditPart columnEditPart = (ColumnEditPart) getHost();
    ERColumn column = (ERColumn) columnEditPart.getModel();
    final TableView newTableView = (TableView) getHost().getParent().getModel();
    final List<ERColumn> columns = newTableView.getColumns();
    if (column.getColumnHolder() instanceof ColumnGroup) {
        column = (ColumnGroup) column.getColumnHolder();
    }
    int index = columns.indexOf(column);
    final Rectangle columnRectangle = getColumnRectangle();
    final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom);
    if (editRequest.getLocation().y >= center) {
        index++;
    }
    return index;
}
 
Example 3
Source File: TableViewComponentEditPolicy.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private int getColumnIndex(DirectEditRequest editRequest) {
	ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
			.getHost().getRoot()).getZoomManager();
	double zoom = zoomManager.getZoom();

	IFigure figure = ((TableViewEditPart) this.getHost()).getFigure();

	int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2)
			* zoom);

	int index = 0;

	if (editRequest.getLocation().y >= center) {
		TableView newTableView = (TableView) this.getHost().getModel();

		index = newTableView.getColumns().size();
	}

	return index;
}
 
Example 4
Source File: TableViewComponentEditPolicy.java    From erflute with Apache License 2.0 5 votes vote down vote up
private int getColumnIndex(DirectEditRequest editRequest) {
    final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
    final double zoom = zoomManager.getZoom();

    final IFigure figure = ((TableViewEditPart) getHost()).getFigure();
    final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom);

    int index = 0;
    if (editRequest.getLocation().y >= center) {
        final TableView newTableView = (TableView) getHost().getModel();
        index = newTableView.getColumns().size();
    }

    return index;
}
 
Example 5
Source File: ColumnSelectionHandlesEditPolicy.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private int getColumnIndex(DirectEditRequest editRequest) {
	ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
			.getHost().getRoot()).getZoomManager();
	double zoom = zoomManager.getZoom();

	ColumnEditPart columnEditPart = (ColumnEditPart) this.getHost();

	Column column = (Column) columnEditPart.getModel();
	TableView newTableView = (TableView) this.getHost().getParent()
			.getModel();

	List<Column> columns = newTableView.getColumns();

	if (column.getColumnHolder() instanceof ColumnGroup) {
		column = (ColumnGroup) column.getColumnHolder();
	}
	int index = columns.indexOf(column);

	Rectangle columnRectangle = this.getColumnRectangle();
	int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom);

	if (editRequest.getLocation().y >= center) {
		index++;
	}

	return index;
}
 
Example 6
Source File: TableViewComponentEditPolicy.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
private int getColumnIndex(final DirectEditRequest editRequest) {
    final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
    final double zoom = zoomManager.getZoom();

    final IFigure figure = ((TableViewEditPart) getHost()).getFigure();

    final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom);

    int index = 0;

    if (editRequest.getLocation().y >= center) {
        final TableView newTableView = (TableView) getHost().getModel();

        index = newTableView.getColumns().size();
    }

    return index;
}