From 35d8e8d420d73fec26e5fc84f70b14f49a59b037 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 30 Nov 2018 17:46:46 +0300 Subject: [PATCH] cleanup: convert anonymous to lambda and use generify --- .../classpath/ClasspathPanelImpl.java | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java index b5e36258a476..0e4e6ec2c1bc 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java @@ -134,7 +134,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { myEntryTable.setDefaultRenderer(ClasspathTableItem.class, new TableItemRenderer(getStructureConfigurableContext())); myEntryTable.setDefaultRenderer(Boolean.class, new ExportFlagRenderer(myEntryTable.getDefaultRenderer(Boolean.class))); - JComboBox scopeEditor = new ComboBox(new EnumComboBoxModel<>(DependencyScope.class)); + JComboBox scopeEditor = new ComboBox<>(new EnumComboBoxModel<>(DependencyScope.class)); myEntryTable.setDefaultEditor(DependencyScope.class, new DefaultCellEditor(scopeEditor)); myEntryTable.setDefaultRenderer(DependencyScope.class, new ComboBoxTableRenderer(DependencyScope.values()) { @Override @@ -388,16 +388,13 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { //downButton.setShortcut(CustomShortcutSet.fromString("alt DOWN")); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable); - AnActionButtonUpdater moveUpDownUpdater = new AnActionButtonUpdater() { - @Override - public boolean isEnabled(@NotNull AnActionEvent e) { - for (RowSorter.SortKey key : myEntryTable.getRowSorter().getSortKeys()) { - if (key.getSortOrder() != SortOrder.UNSORTED) { - return false; - } + AnActionButtonUpdater moveUpDownUpdater = e -> { + for (RowSorter.SortKey key : myEntryTable.getRowSorter().getSortKeys()) { + if (key.getSortOrder() != SortOrder.UNSORTED) { + return false; } - return true; } + return true; }; decorator.setAddAction(new AnActionButtonRunnable() { @Override @@ -443,17 +440,14 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { removeAction.actionPerformed(null); } }) - .setRemoveActionUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(@NotNull AnActionEvent e) { - final int[] selectedRows = myEntryTable.getSelectedRows(); - for (final int selectedRow : selectedRows) { - if (!getItemAt(selectedRow).isRemovable()) { - return false; - } + .setRemoveActionUpdater(e -> { + final int[] selectedRows = myEntryTable.getSelectedRows(); + for (final int selectedRow : selectedRows) { + if (!getItemAt(selectedRow).isRemovable()) { + return false; } - return selectedRows.length > 0; } + return selectedRows.length > 0; }) .setMoveUpAction(new AnActionButtonRunnable() { @Override @@ -546,9 +540,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { } finally { enableModelUpdate(); - getGlobalInstance().doWhenFocusSettlesDown(() -> { - getGlobalInstance().requestFocus(myEntryTable, true); - }); + getGlobalInstance().doWhenFocusSettlesDown(() -> getGlobalInstance().requestFocus(myEntryTable, true)); } }