cleanup. Use ScrollingUtil

This commit is contained in:
Konstantin Bulenkov
2015-08-17 15:16:41 +02:00
parent 87e1ab64e7
commit 4c355c0a9b
14 changed files with 49 additions and 50 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -69,7 +69,7 @@ public class MethodListDlg extends DialogWrapper {
}
}.installOn(myList);
ListScrollingUtil.ensureSelectionExists(myList);
ScrollingUtil.ensureSelectionExists(myList);
setTitle(ExecutionBundle.message("choose.test.method.dialog.title"));
init();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -33,6 +33,7 @@ import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.ui.ClickListener;
import com.intellij.ui.DoubleClickListener;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.components.JBList;
import com.intellij.util.ArrayUtil;
import gnu.trove.TIntArrayList;
@@ -47,8 +48,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.util.*;
import static com.intellij.ui.ListScrollingUtil.ensureSelectionExists;
public class JdkChooserPanel extends JPanel {
private JList myList = null;
private DefaultListModel myListModel = null;
@@ -226,7 +225,7 @@ public class JdkChooserPanel extends JPanel {
jdkChooserPanel.selectJdk(jdkToSelect);
}
else {
ensureSelectionExists(jdkChooserPanel.myList);
ScrollingUtil.ensureSelectionExists(jdkChooserPanel.myList);
}
new DoubleClickListener() {
@Override
@@ -31,7 +31,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.components.JBList;
import org.jetbrains.annotations.NonNls;
@@ -96,7 +96,7 @@ public class JavaAutoImportOptions implements AutoImportOptionsProvider {
myExcludePackagesModel.add(index, packageName);
myExcludePackagesList.setSelectedValue(packageName, true);
ListScrollingUtil.ensureIndexIsVisible(myExcludePackagesList, index, 0);
ScrollingUtil.ensureIndexIsVisible(myExcludePackagesList, index, 0);
IdeFocusManager.getGlobalInstance().requestFocus(myExcludePackagesList, false);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -32,7 +32,7 @@ import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.psi.tree.IElementType;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.util.ui.UIUtil;
import org.intellij.lang.annotations.JdkConstants;
@@ -73,7 +73,7 @@ public class ClickNavigator {
if (o instanceof EditorSchemeAttributeDescriptor) {
if (type.equals(((EditorSchemeAttributeDescriptor)o).getType())) {
if (select) {
ListScrollingUtil.selectItem(myOptionsList, i);
ScrollingUtil.selectItem(myOptionsList, i);
}
return true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -27,7 +27,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
@@ -275,7 +275,7 @@ public class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerA
public void addExecutorComponent(Executor executor, JComponent component) {
myRunnerPanel.add(component, executor.getId());
myListModel.addElement(executor);
ListScrollingUtil.ensureSelectionExists(myRunnersList);
ScrollingUtil.ensureSelectionExists(myRunnersList);
}
public List<Executor> getExecutors() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -24,7 +24,7 @@ import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.util.Alarm;
import com.intellij.util.containers.HashMap;
import gnu.trove.THashSet;
@@ -146,11 +146,11 @@ public abstract class AbstractListBuilder {
}
protected void selectItem(int i) {
ListScrollingUtil.selectItem(myList, i);
ScrollingUtil.selectItem(myList, i);
}
protected void ensureSelectionExist() {
ListScrollingUtil.ensureSelectionExists(myList);
ScrollingUtil.ensureSelectionExists(myList);
}
public final void selectElement(final Object element, VirtualFile virtualFile) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -115,7 +115,7 @@ public class CommanderPanel extends JPanel {
myListSpeedSearch = new ListSpeedSearch(myList);
myListSpeedSearch.setClearSearchOnNavigateNoMatch(true);
ListScrollingUtil.installActions(myList);
ScrollingUtil.installActions(myList);
myList.registerKeyboardAction(new ActionListener() {
@Override
@@ -599,16 +599,16 @@ public abstract class ChooseByNameBase {
}
switch (keyCode) {
case KeyEvent.VK_DOWN:
ListScrollingUtil.moveDown(myList, e.getModifiersEx());
ScrollingUtil.moveDown(myList, e.getModifiersEx());
break;
case KeyEvent.VK_UP:
ListScrollingUtil.moveUp(myList, e.getModifiersEx());
ScrollingUtil.moveUp(myList, e.getModifiersEx());
break;
case KeyEvent.VK_PAGE_UP:
ListScrollingUtil.movePageUp(myList);
ScrollingUtil.movePageUp(myList);
break;
case KeyEvent.VK_PAGE_DOWN:
ListScrollingUtil.movePageDown(myList);
ScrollingUtil.movePageDown(myList);
break;
case KeyEvent.VK_TAB:
close(true);
@@ -624,10 +624,10 @@ public abstract class ChooseByNameBase {
if (myList.getSelectedValue() == NON_PREFIX_SEPARATOR) {
if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_PAGE_UP) {
ListScrollingUtil.moveUp(myList, e.getModifiersEx());
ScrollingUtil.moveUp(myList, e.getModifiersEx());
}
else {
ListScrollingUtil.moveDown(myList, e.getModifiersEx());
ScrollingUtil.moveDown(myList, e.getModifiersEx());
}
}
}
@@ -1072,7 +1072,7 @@ public abstract class ChooseByNameBase {
pos = detectBestStatisticalPosition();
}
ListScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
ScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
myList.setVisibleRowCount(Math.min(VISIBLE_LIST_SIZE_LIMIT, myList.getModel().getSize()));
showList();
myTextFieldPanel.repositionHint();
@@ -1188,7 +1188,7 @@ public abstract class ChooseByNameBase {
if (!myListModel.isEmpty()) {
int pos = selectionPos <= 0 ? detectBestStatisticalPosition() : selectionPos;
ListScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
ScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
}
}
}
@@ -24,7 +24,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame;
import com.intellij.platform.DirectoryProjectGenerator;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.components.JBList;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.update.UiNotifyConnector;
@@ -68,7 +68,7 @@ public abstract class AbstractNewProjectDialog extends DialogWrapper {
UiNotifyConnector.doWhenFirstShown(myList, new Runnable() {
@Override
public void run() {
ListScrollingUtil.ensureSelectionExists(myList);
ScrollingUtil.ensureSelectionExists(myList);
}
});
return component;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -133,7 +133,7 @@ public class DiffOptionsPanel implements OptionsPanel {
myDescriptions.put(type.getExternalName(), (MyColorAndFontDescription)description);
}
}
ListScrollingUtil.ensureSelectionExists(myOptionsList);
ScrollingUtil.ensureSelectionExists(myOptionsList);
}
@Override
@@ -151,7 +151,7 @@ public class DiffOptionsPanel implements OptionsPanel {
return new Runnable() {
@Override
public void run() {
ListScrollingUtil.selectItem(myOptionsList, i1);
ScrollingUtil.selectItem(myOptionsList, i1);
}
};
@@ -197,7 +197,7 @@ public class DiffOptionsPanel implements OptionsPanel {
Object o = myOptionsModel.get(i);
if (o instanceof TextDiffType) {
if (typeToSelect.equals(((TextDiffType)o).getDisplayName())) {
ListScrollingUtil.selectItem(myOptionsList, i);
ScrollingUtil.selectItem(myOptionsList, i);
return;
}
}
@@ -132,7 +132,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
getTableHeader().setReorderingAllowed(false);
PopupHandler.installPopupHandler(this, VcsLogUiImpl.POPUP_ACTION_GROUP, VcsLogUiImpl.VCS_LOG_TABLE_PLACE);
TableScrollingUtil.installActions(this, false);
ScrollingUtil.installActions(this, false);
setModel(new GraphTableModel(initialDataPack, myLogDataHolder, myUI));
}
@@ -377,7 +377,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
public void stateChanged(ChangeEvent e) {
TableModel model = getModel();
if (model instanceof AbstractTableModel) {
Couple<Integer> visibleRows = TableScrollingUtil.getVisibleRows(VcsLogGraphTable.this);
Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(VcsLogGraphTable.this);
((AbstractTableModel)model)
.fireTableChanged(new TableModelEvent(model, visibleRows.first - 1, visibleRows.second, GraphTableModel.ROOT_COLUMN));
}
@@ -471,7 +471,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
public Selection(@NotNull VcsLogGraphTable table) {
myTable = table;
List<Integer> selectedRows = ContainerUtil.sorted(toList(myTable.getSelectedRows()));
Couple<Integer> visibleRows = TableScrollingUtil.getVisibleRows(myTable);
Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(myTable);
myScrollToTop = visibleRows.first - 1 == 0;
VisibleGraph<Integer> graph = myTable.getVisibleGraph();
@@ -710,7 +710,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
if (value instanceof VirtualFile) {
VirtualFile root = (VirtualFile)value;
int readableRow = TableScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
int readableRow = ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
if (row < readableRow) {
text = "";
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -25,8 +25,8 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Factory;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ReorderableListController;
import com.intellij.ui.ScrollingUtil;
import javax.swing.*;
import java.awt.*;
@@ -115,7 +115,7 @@ public class AnActionListEditor<T> extends JPanel {
for (T item : items) {
model.addElement(item);
}
ListScrollingUtil.ensureSelectionExists(getList());
ScrollingUtil.ensureSelectionExists(getList());
}
public void updateItem(T item) {
@@ -160,10 +160,10 @@ public class AnActionListEditor<T> extends JPanel {
public void select(T item) {
if (item != null) {
ListScrollingUtil.selectItem(myList, item);
ScrollingUtil.selectItem(myList, item);
}
else {
ListScrollingUtil.ensureSelectionExists(myList);
ScrollingUtil.ensureSelectionExists(myList);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -19,7 +19,7 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.SortedListModel;
import com.intellij.ui.TableUtil;
import com.intellij.ui.table.BaseTableView;
@@ -555,7 +555,7 @@ public abstract class UIPropertyBinding {
public void loadValues(AbstractProperty.AbstractPropertyContainer container) {
getModel().setAll(getProperty().get(container));
ListScrollingUtil.ensureSelectionExists(getList());
ScrollingUtil.ensureSelectionExists(getList());
}
private SortedListModel<T> getModel() {
@@ -577,7 +577,7 @@ public abstract class UIPropertyBinding {
Object item = iterator.next();
model.addElement(item);
}
ListScrollingUtil.ensureSelectionExists(getList());
ScrollingUtil.ensureSelectionExists(getList());
}
private DefaultListModel getModel() {
@@ -594,7 +594,7 @@ public abstract class UIPropertyBinding {
}
for (final T item : items) {
getModel().addElement(item);
ListScrollingUtil.selectItem(getList(), item);
ScrollingUtil.selectItem(getList(), item);
}
}
});
@@ -6,7 +6,7 @@ import com.intellij.openapi.fileTypes.impl.FileTypeRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.DoubleClickListener;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.components.JBList;
import com.jetbrains.edu.courseFormat.Course;
import com.jetbrains.edu.coursecreator.CCLanguageManager;
@@ -58,7 +58,7 @@ public class CreateTaskFileDialog extends DialogWrapper {
CCLanguageManager manager = CCUtils.getStudyLanguageManager(myCourse);
if (manager != null) {
String extension = manager.getDefaultTaskFileExtension();
ListScrollingUtil.selectItem(myList, FileTypeManager.getInstance().getFileTypeByExtension(extension != null ? extension : "txt"));
ScrollingUtil.selectItem(myList, FileTypeManager.getInstance().getFileTypeByExtension(extension != null ? extension : "txt"));
}
return myPanel;
}