IDEA-129447 Arrangement: scroll UI into view when editing rule

This commit is contained in:
Svetlana.Zemlyanskay
2014-09-30 14:03:53 +04:00
parent 3bf8569819
commit b14bcbbddb
3 changed files with 17 additions and 12 deletions
@@ -35,17 +35,6 @@ public abstract class AbstractArrangementRuleAction extends AnAction {
}
protected void scrollRowToVisible(@NotNull ArrangementMatchingRulesControl control, int row) {
final Rectangle rect = control.getCellRect(row, 0, false);
if (row != control.getEditingRow() - 1) {
control.scrollRectToVisible(rect);
}
else {
final Rectangle editorRect = control.getCellRect(row + 1, 0, false);
if(!rect.isEmpty() && !editorRect.isEmpty()) {
final int height = (int)(rect.getHeight() + editorRect.getHeight());
final Rectangle visibleRect = new Rectangle((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), height);
control.scrollRectToVisible(visibleRect);
}
}
control.scrollRowToVisible(row);
}
}
@@ -329,6 +329,21 @@ public class ArrangementMatchingRulesControl extends JBTable {
showEditor(myEditor, rowToEdit);
}
public void scrollRowToVisible(int row) {
final Rectangle rect = getCellRect(row, 0, false);
if (row != getEditingRow() - 1) {
scrollRectToVisible(rect);
}
else {
final Rectangle editorRect = getCellRect(row + 1, 0, false);
if(!rect.isEmpty() && !editorRect.isEmpty()) {
final int height = (int)(rect.getHeight() + editorRect.getHeight());
final Rectangle visibleRect = new Rectangle((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), height);
scrollRectToVisible(visibleRect);
}
}
}
public void showEditor(@NotNull ArrangementMatchingRuleEditor editor, int rowToEdit) {
if (myEditorRow == rowToEdit + 1) {
return;
@@ -214,6 +214,7 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementUi
int row = myControl.getRowByRenderer(this);
if (row >= 0) {
myControl.showEditor(row);
myControl.scrollRowToVisible(row);
myBeingEdited = true;
}
}