diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java index 9642dce5d7ac..b7d7a8924837 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java @@ -56,8 +56,8 @@ public class PathEditor { public static final Color INVALID_COLOR = new JBColor(new Color(210, 0, 0), JBColor.RED); protected JPanel myPanel; - private JBList myList; - private final DefaultListModel myModel; + private JBList myList; + private final DefaultListModel myModel; private final Set myAllFiles = new HashSet<>(); private boolean myModified = false; protected boolean myEnabled = false; @@ -108,9 +108,10 @@ public class PathEditor { } public JComponent createComponent() { - myList = new JBList(getListModel()); + myList = new JBList<>(getListModel()); + //noinspection unchecked myList.setCellRenderer(createListCellRenderer(myList)); - TreeUIHelper.getInstance().installListSpeedSearch(myList, file -> ((VirtualFile)file).getPresentableUrl()); + TreeUIHelper.getInstance().installListSpeedSearch(myList, VirtualFile::getPresentableUrl); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList) .disableUpDownActions() @@ -181,15 +182,15 @@ public class PathEditor { itemsRemoved(removedItems); } - protected DefaultListModel createListModel() { - return new DefaultListModel(); + protected DefaultListModel createListModel() { + return new DefaultListModel<>(); } protected ListCellRenderer createListCellRenderer(JBList list) { return new PathCellRenderer(); } - protected void itemsRemoved(List removedItems) { + protected void itemsRemoved(List removedItems) { myAllFiles.removeAll(removedItems); if (removedItems.size() > 0) { setModified(true); @@ -213,16 +214,15 @@ public class PathEditor { protected boolean isUrlInserted() { if (getRowCount() > 0) { - return ((VirtualFile)getListModel().lastElement()).getFileSystem() instanceof HttpFileSystem; + return getListModel().lastElement().getFileSystem() instanceof HttpFileSystem; } return false; } protected void requestDefaultFocus() { if (myList != null) { - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myList, true); - }); + IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown( + () -> IdeFocusManager.getGlobalInstance().requestFocus(myList, true)); } } @@ -249,7 +249,7 @@ public class PathEditor { indicesToRemove.add(idx); } } - final List list = ListUtil.removeIndices(myList, indicesToRemove.toNativeArray()); + final List list = ListUtil.removeIndices(myList, indicesToRemove.toNativeArray()); itemsRemoved(list); } @@ -273,7 +273,7 @@ public class PathEditor { return true; } - protected DefaultListModel getListModel() { + protected DefaultListModel getListModel() { return myModel; } @@ -313,7 +313,7 @@ public class PathEditor { } protected VirtualFile getValueAt(int row) { - return (VirtualFile)getListModel().get(row); + return getListModel().get(row); } public void clearList() { diff --git a/platform/platform-api/src/com/intellij/ui/ListUtil.java b/platform/platform-api/src/com/intellij/ui/ListUtil.java index 042256f6b14d..893bf5b55b9c 100644 --- a/platform/platform-api/src/com/intellij/ui/ListUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ListUtil.java @@ -78,7 +78,7 @@ public class ListUtil { return removeSelectedItems(list, null); } - public static List removeIndices(JList list, int[] indices) { + public static List removeIndices(JList list, int[] indices) { return removeIndices(list, indices, null); } diff --git a/platform/platform-api/src/com/intellij/ui/TreeUIHelper.java b/platform/platform-api/src/com/intellij/ui/TreeUIHelper.java index 978b0172d780..492a4f53c661 100644 --- a/platform/platform-api/src/com/intellij/ui/TreeUIHelper.java +++ b/platform/platform-api/src/com/intellij/ui/TreeUIHelper.java @@ -45,9 +45,9 @@ public abstract class TreeUIHelper { public abstract void installEditSourceOnDoubleClick(JTree tree); public abstract void installTreeSpeedSearch(JTree tree); - public abstract void installListSpeedSearch(JList list); + public abstract void installListSpeedSearch(JList list); public abstract void installTreeSpeedSearch(JTree tree, Convertor convertor, boolean canExpand); - public abstract void installListSpeedSearch(JList list, Convertor convertor); + public abstract void installListSpeedSearch(JList list, Convertor convertor); public abstract void installEditSourceOnEnterKeyHandler(JTree tree); diff --git a/platform/platform-impl/src/com/intellij/ui/TreeUIHelperImpl.java b/platform/platform-impl/src/com/intellij/ui/TreeUIHelperImpl.java index 8fcc86efd8b8..43384d0b24c2 100644 --- a/platform/platform-impl/src/com/intellij/ui/TreeUIHelperImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/TreeUIHelperImpl.java @@ -58,12 +58,12 @@ public class TreeUIHelperImpl extends TreeUIHelper { new TreeSpeedSearch(tree, convertor, canExpand); } - public void installListSpeedSearch(JList list) { - new ListSpeedSearch(list); + public void installListSpeedSearch(JList list) { + new ListSpeedSearch<>(list); } - public void installListSpeedSearch(JList list, Convertor convertor) { - new ListSpeedSearch(list, (Function)convertor::convert); + public void installListSpeedSearch(JList list, Convertor convertor) { + new ListSpeedSearch<>(list, (Function)convertor::convert); } public void installEditSourceOnEnterKeyHandler(final JTree tree) {