{
ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
headerEditPart = (ColumnHeaderEditPart) changeBoundsRequest.getEditParts().get(0);
}
// prepare location
Point location;
{
IDropRequest dropRequest = (IDropRequest) request;
location = dropRequest.getLocation().getCopy();
}
// prepare target header
ColumnHeaderEditPart target = null;
{
for (EditPart editPart : getHost().getChildren()) {
ColumnHeaderEditPart columnEditPart = (ColumnHeaderEditPart) editPart;
Rectangle bounds = columnEditPart.getFigure().getBounds();
if (location.x < bounds.getCenter().x) {
target = columnEditPart;
break;
}
}
}
// prepare grid information
IGridInfo gridInfo = m_panel.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 targetIndex;
int x;
int size = AbstractGridLayoutEditPolicy.INSERT_COLUMN_SIZE;
if (target != null) {
targetIndex = target.getIndex();
x = columnIntervals[targetIndex].begin - size / 2;
if (targetIndex != 0) {
x -= (columnIntervals[targetIndex].begin - columnIntervals[targetIndex - 1].end()) / 2;
}
} else {
targetIndex = m_panel.getColumns().size();
x = columnIntervals[columnIntervals.length - 1].end() - size / 2;
}
// 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);
}
// set bounds
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(MessageFormat.format("column: {0}", targetIndex));