mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-126408 Code Style | Arrangement: list of rules could be scrolled on moving rules up/down
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options.codeStyle.arrangement.action;
|
||||
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Svetlana.Zemlyanskaya
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -17,7 +17,6 @@ package com.intellij.application.options.codeStyle.arrangement.action;
|
||||
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +29,7 @@ import java.util.List;
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/13/12 7:17 PM
|
||||
*/
|
||||
public abstract class AbstractMoveArrangementRuleAction extends AnAction implements DumbAware {
|
||||
public abstract class AbstractMoveArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
@@ -95,8 +94,17 @@ public abstract class AbstractMoveArrangementRuleAction extends AnAction impleme
|
||||
}
|
||||
|
||||
|
||||
int visibleRow = -1;
|
||||
if (newRowToEdit >= 0) {
|
||||
control.showEditor(newRowToEdit);
|
||||
visibleRow = newRowToEdit;
|
||||
}
|
||||
else if (!mappings.isEmpty()) {
|
||||
visibleRow = mappings.get(0)[1];
|
||||
}
|
||||
|
||||
if (visibleRow != -1) {
|
||||
scrollRowToVisible(control, visibleRow);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-12
@@ -19,7 +19,6 @@ import com.intellij.application.options.codeStyle.arrangement.match.ArrangementM
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel;
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.EmptyArrangementRuleComponent;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
@@ -27,13 +26,11 @@ import com.intellij.openapi.util.SystemInfoRt;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/24/12 1:54 PM
|
||||
*/
|
||||
public class AddArrangementRuleAction extends AnAction implements DumbAware {
|
||||
public class AddArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware {
|
||||
|
||||
public AddArrangementRuleAction() {
|
||||
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.add.text"));
|
||||
@@ -66,14 +63,7 @@ public class AddArrangementRuleAction extends AnAction implements DumbAware {
|
||||
}
|
||||
showEditor(control, rowToEdit);
|
||||
control.getSelectionModel().setSelectionInterval(rowToEdit, rowToEdit);
|
||||
|
||||
final Rectangle rect = control.getCellRect(rowToEdit, 0, false);
|
||||
final Rectangle editorRect = control.getCellRect(rowToEdit + 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);
|
||||
}
|
||||
scrollRowToVisible(control, rowToEdit);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-3
@@ -16,7 +16,6 @@
|
||||
package com.intellij.application.options.codeStyle.arrangement.action;
|
||||
|
||||
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Toggleable;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
@@ -27,7 +26,7 @@ import gnu.trove.TIntArrayList;
|
||||
* @author Denis Zhdanov
|
||||
* @since 10/29/12 11:01 AM
|
||||
*/
|
||||
public class EditArrangementRuleAction extends AnAction implements DumbAware, Toggleable {
|
||||
public class EditArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware, Toggleable {
|
||||
|
||||
public EditArrangementRuleAction() {
|
||||
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.edit.text"));
|
||||
@@ -50,6 +49,8 @@ public class EditArrangementRuleAction extends AnAction implements DumbAware, To
|
||||
if (rows.size() != 1) {
|
||||
return;
|
||||
}
|
||||
control.showEditor(rows.get(0));
|
||||
final int row = rows.get(0);
|
||||
control.showEditor(row);
|
||||
scrollRowToVisible(control, row);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user