{
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 columnEditPart = (DimensionHeaderEditPart) child;
Rectangle bounds = columnEditPart.getFigure().getBounds();
if (location.x < bounds.getCenter().x) {
target = columnEditPart;
break;
}
}
}
// prepare grid information
IGridInfo gridInfo = m_layout.getGridInfo();
Interval[] columnIntervals = gridInfo.getColumnIntervals();
Interval[] rowIntervals = gridInfo.getRowIntervals();
int y1 = rowIntervals[0].begin - 5;
int y2 = rowIntervals[rowIntervals.length - 1].end() + 5;
// prepare index of target column and position for insert feedbacks
final int index;
int x;
int size;
if (target != null) {
index = target.getDimension().getIndex();
// prepare previous interval
Interval prevInterval;
if (index == 0) {
prevInterval = new Interval(0, 0);
} else {
prevInterval = columnIntervals[index - 1];
}
// prepare parameters
int[] parameters =
TableLayoutEditPolicy.getInsertFeedbackParameters(
prevInterval,
columnIntervals[index],
AbstractGridLayoutEditPolicy.INSERT_COLUMN_SIZE);
x = parameters[1];
size = parameters[2] - parameters[1];
} else {
index = m_layout.getColumns().size();
m_mainPolicy.showInsertFeedbacks(null, null);
// prepare parameters
x = columnIntervals[columnIntervals.length - 1].end() + 1;
size = AbstractGridLayoutEditPolicy.INSERT_COLUMN_SIZE;
}
// show insert feedbacks
{
// ...on main viewer
m_mainPolicy.showInsertFeedbacks(new Rectangle(x, y1, size, y2 - y1), null);
// ...on header viewer
{
if (m_insertFeedback.getParent() == null) {
addFeedback(m_insertFeedback);
}
//
Point offset = headerEditPart.getOffset();
Rectangle bounds = new Rectangle(x + offset.x, 0, size, getHostFigure().getSize().height);
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(location.x + 30, 10);
FigureUtils.translateAbsoluteToFigure(feedbackLayer, feedbackLocation);
m_feedback.setLocation(feedbackLocation);
}
// set text
m_feedback.setText("column: " + index);