{
ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
headerEditPart = (DimensionHeaderEditPart) changeBoundsRequest.getEditParts().get(0);
}
// prepare location
Point location;
{
IDropRequest dropRequest = (IDropRequest) request;
location = dropRequest.getLocation().getCopy();
}
// prepare target header
DimensionHeaderEditPart target = null;
{
List<EditPart> children = getHost().getChildren();
for (EditPart child : children) {
DimensionHeaderEditPart rowEditPart = (DimensionHeaderEditPart) child;
Rectangle bounds = rowEditPart.getFigure().getBounds();
if (location.y < bounds.getCenter().y) {
target = rowEditPart;
break;
}
}
}
// prepare grid information
IGridInfo gridInfo = m_layout.getGridInfo();
Interval[] columnIntervals = gridInfo.getColumnIntervals();
Interval[] rowIntervals = gridInfo.getRowIntervals();
int x1 = columnIntervals[0].begin - 5;
int x2 = columnIntervals[columnIntervals.length - 1].end() + 5;
// prepare index of target row and position for insert feedbacks
final int index;
int y;
int size;
if (target != null) {
index = target.getDimension().getIndex();
// prepare previous interval
Interval prevInterval;
if (index == 0) {
prevInterval = new Interval(0, 0);
} else {
prevInterval = rowIntervals[index - 1];
}
// prepare parameters
int[] parameters =
TableLayoutEditPolicy.getInsertFeedbackParameters(
prevInterval,
rowIntervals[index],
AbstractGridLayoutEditPolicy.INSERT_ROW_SIZE);
y = parameters[1];
size = parameters[2] - parameters[1];
} else {
index = m_layout.getRows().size();
m_mainPolicy.showInsertFeedbacks(null, null);
// prepare parameters
y = rowIntervals[rowIntervals.length - 1].end() + 1;
size = AbstractGridLayoutEditPolicy.INSERT_ROW_SIZE;
}
// show insert feedbacks
{
// ...on main viewer
m_mainPolicy.showInsertFeedbacks(null, new Rectangle(x1, y, x2 - x1, size));
// ...on header viewer
{
if (m_insertFeedback.getParent() == null) {
addFeedback(m_insertFeedback);
}
//
Point offset = headerEditPart.getOffset();
Rectangle bounds = new Rectangle(0, y + offset.y, getHostFigure().getSize().width, size);
m_insertFeedback.setBounds(bounds);
}
}
// show text feedback
{
Layer feedbackLayer = getMainLayer(IEditPartViewer.FEEDBACK_LAYER);
// add feedback
if (m_feedback == null) {
m_feedback = new TextFeedback(feedbackLayer);
m_feedback.add();
}
// set feedback bounds
{
Point feedbackLocation = new Point(30, location.y + 10);
FigureUtils.translateAbsoluteToFigure(feedbackLayer, feedbackLocation);
m_feedback.setLocation(feedbackLocation);
}
// set text
m_feedback.setText("row: " + index);