if (m_resizeDirection == IPositionConstants.EAST) {
if (m_ctrlPressed) {
int offset = getParentWidth() - m_newSize.width;
final String width = offset > 0 ? "-" + offset : "" + offset;
m_tooltip = "width: " + width + "\nRelease Ctrl to set width in percents";
m_command = new EditCommand(m_widget) {
@Override
protected void executeEdit() throws Exception {
AnchorLayoutInfo.getAnchorData(m_widget).setAnchorWidth(width);
}
};
} else {
final String width = m_newSize.width * 100 / getParentWidth() + "%";
m_tooltip = "width: " + width + "\nPress Ctrl to set offset from right";
m_command = new EditCommand(m_widget) {
@Override
protected void executeEdit() throws Exception {
AnchorLayoutInfo.getAnchorData(m_widget).setAnchorWidth(width);
}
};
}
}
// SOUTH
if (m_resizeDirection == IPositionConstants.SOUTH) {
if (m_ctrlPressed) {
int offset = getParentHeight() - m_newSize.height;
final String height = offset > 0 ? "-" + offset : "" + offset;
m_tooltip = "height: " + height + "\nRelease Ctrl to set height in percents";
m_command = new EditCommand(m_widget) {
@Override
protected void executeEdit() throws Exception {
AnchorLayoutInfo.getAnchorData(m_widget).setAnchorHeight(height);
}
};
} else {
final String height = m_newSize.height * 100 / getParentHeight() + "%";
m_tooltip = "height: " + height + "\nPress Ctrl to set offset from bottom";
m_command = new EditCommand(m_widget) {
@Override
protected void executeEdit() throws Exception {
AnchorLayoutInfo.getAnchorData(m_widget).setAnchorHeight(height);
}
};