some JComboBox usages generified
authornik <Nikolay.Chashnikov@jetbrains.com>
Mon, 3 Oct 2016 08:19:02 +0000 (11:19 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Mon, 3 Oct 2016 08:19:28 +0000 (11:19 +0300)
java/execution/impl/src/com/intellij/execution/ui/ConfigurationModuleSelector.java
java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
platform/lang-impl/src/com/intellij/application/options/ModulesComboBox.java
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerSettingsEditor.java

index 32204e4eeb29313ca9279c7b4597185108b30b0d..69bea4bfc8e9d12e8b77ef707d708ab7e03b4bf2 100644 (file)
@@ -37,12 +37,12 @@ import java.util.List;
 
 public class ConfigurationModuleSelector {
   private final Project myProject;
-  private final JComboBox myModulesList;
+  private final JComboBox<Module> myModulesList;
 
   /**
    * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox)} instead
    */
-  public ConfigurationModuleSelector(final Project project, final JComboBox modulesList) {
+  public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList) {
     this(project, modulesList, "<no module>");
   }
 
@@ -59,7 +59,7 @@ public class ConfigurationModuleSelector {
   /**
    * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
    */
-  public ConfigurationModuleSelector(final Project project, final JComboBox modulesList, final String noModule) {
+  public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList, final String noModule) {
     myProject = project;
     myModulesList = modulesList;
     new ComboboxSpeedSearch(modulesList){
index f1fa9053884c1792c4a1ea20e9a627c542173b27..f70ed4717890a03bf4fb7bc5f63cfac68fa0d2fe 100644 (file)
@@ -68,7 +68,6 @@ import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.List;
 
 /**
@@ -80,7 +79,7 @@ public class LibraryOptionsPanel implements Disposable {
   private JBLabel myMessageLabel;
   private JPanel myPanel;
   private JButton myConfigureButton;
-  private JComboBox myExistingLibraryComboBox;
+  private JComboBox<LibraryEditor> myExistingLibraryComboBox;
   private JRadioButton myDoNotCreateRadioButton;
   private JPanel myConfigurationPanel;
   private JButton myCreateButton;
@@ -236,9 +235,10 @@ public class LibraryOptionsPanel implements Disposable {
         onVersionChanged(getPresentableVersion());
       }
     });
-    myExistingLibraryComboBox.setRenderer(new ColoredListCellRenderer(myExistingLibraryComboBox) {
+    myExistingLibraryComboBox.setRenderer(new ColoredListCellRenderer<LibraryEditor>(myExistingLibraryComboBox) {
       @Override
-      protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
+      protected void customizeCellRenderer(@NotNull JList<? extends LibraryEditor> list, LibraryEditor value, int index, boolean selected,
+                                           boolean hasFocus) {
         if (value == null) {
           append("[No library selected]");
         }
@@ -249,7 +249,7 @@ public class LibraryOptionsPanel implements Disposable {
         }
         else if (value instanceof NewLibraryEditor) {
           setIcon(PlatformIcons.LIBRARY_ICON);
-          final String name = ((NewLibraryEditor)value).getName();
+          final String name = value.getName();
           append(name != null ? name : "<unnamed>");
         }
       }
index b3b183addb40640a12fee51fb478ffe31f0d50ca..229df0610eaf129e0d700c8cc7b2d7350e03d6ce 100644 (file)
@@ -34,7 +34,7 @@ import java.util.List;
 /**
  * @author nik
  */
-public class ModulesComboBox extends ComboBox {
+public class ModulesComboBox extends ComboBox<Module> {
   private final SortedComboBoxModel<Module> myModel;
   private boolean myAllowEmptySelection;
 
index 77de5769820dd4b47e57dafca71fca333d88b4e1..84faf2703af1f606df99e219078daf6d15315b4e 100644 (file)
@@ -41,7 +41,6 @@ import javax.swing.*;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.Comparator;
 
 /**
  * @author nik
@@ -51,7 +50,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
   private final DeploymentConfigurator<D, S> myDeploymentConfigurator;
   private final Project myProject;
   private final ComboboxWithBrowseButton myServerComboBox;
-  private final ComboBox mySourceComboBox;
+  private final ComboBox<DeploymentSource> mySourceComboBox;
   private final SortedComboBoxModel<String> myServerListModel;
   private final SortedComboBoxModel<DeploymentSource> mySourceListModel;
   private final JPanel myDeploymentSettingsComponent;
@@ -65,7 +64,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
     myProject = project;
 
     myServerListModel = new SortedComboBoxModel<>(String.CASE_INSENSITIVE_ORDER);
-    myServerComboBox = new ComboboxWithBrowseButton(new ComboBox(myServerListModel));
+    myServerComboBox = new ComboboxWithBrowseButton(new ComboBox<>(myServerListModel));
     fillApplicationServersList(null);
     myServerComboBox.addActionListener(new ActionListener() {
       @Override
@@ -82,9 +81,9 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
         updateDeploymentSettingsEditor();
       }
     });
-    myServerComboBox.getComboBox().setRenderer(new ColoredListCellRendererWrapper<String>() {
+    myServerComboBox.getComboBox().setRenderer(new ColoredListCellRenderer<String>() {
       @Override
-      protected void doCustomize(JList list, String value, int index, boolean selected, boolean hasFocus) {
+      protected void customizeCellRenderer(@NotNull JList<? extends String> list, String value, int index, boolean selected, boolean hasFocus) {
         if (value == null) return;
         RemoteServer<S> server = RemoteServersManager.getInstance().findByName(value, type);
         SimpleTextAttributes attributes = server == null ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
@@ -96,7 +95,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
     mySourceListModel = new SortedComboBoxModel<>(
       (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
     mySourceListModel.addAll(deploymentConfigurator.getAvailableDeploymentSources());
-    mySourceComboBox = new ComboBox(mySourceListModel);
+    mySourceComboBox = new ComboBox<>(mySourceListModel);
     mySourceComboBox.setRenderer(new ListCellRendererWrapper<DeploymentSource>() {
       @Override
       public void customize(JList list, DeploymentSource value, int index, boolean selected, boolean hasFocus) {
@@ -156,7 +155,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
   }
 
   @Override
-  protected void resetEditorFrom(DeployToServerRunConfiguration<S,D> configuration) {
+  protected void resetEditorFrom(@NotNull DeployToServerRunConfiguration<S,D> configuration) {
     String serverName = configuration.getServerName();
     if (serverName != null && !myServerListModel.getItems().contains(serverName)) {
       myServerListModel.add(serverName);
@@ -171,7 +170,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
   }
 
   @Override
-  protected void applyEditorTo(DeployToServerRunConfiguration<S,D> configuration) throws ConfigurationException {
+  protected void applyEditorTo(@NotNull DeployToServerRunConfiguration<S,D> configuration) throws ConfigurationException {
     updateDeploymentSettingsEditor();
 
     configuration.setServerName(myServerListModel.getSelectedItem());