Merge branch 'master' into east825/tasks-configurable-issue-states
[idea/community.git] / plugins / tasks / tasks-core / src / com / intellij / tasks / impl / TaskUiUtil.java
index b130f375cfb8387efe5b9e6ab7ad2d4a692dfb0f..38d7fe7f6c03263db96a86a7d5556299efe25aa7 100644 (file)
@@ -61,7 +61,6 @@ public class TaskUiUtil {
     /**
      * {@link #onSuccess()} can't be used for this purpose, because it doesn't consider current modality state
      * which will prevent UI updating in modal dialog (e.g. in {@link com.intellij.tasks.config.TaskRepositoryEditor}).
-     * @return
      */
     @Nullable
     @Override
@@ -118,7 +117,7 @@ public class TaskUiUtil {
     protected void updateUI() {
       if (myResult != null) {
         myComboBox.setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(myResult)));
-        T extra = getExtraItem();
+        final T extra = getExtraItem();
         if (extra != null) {
           myComboBox.insertItemAt(extra, 0);
         }
@@ -126,8 +125,11 @@ public class TaskUiUtil {
         // is the same as the next selected
         myComboBox.setSelectedItem(null);
 
-        T selected = getSelectedItem();
+        final T selected = getSelectedItem();
         if (selected != null) {
+          if (!selected.equals(extra) && !myResult.contains(selected)) {
+            myComboBox.addItem(selected);
+          }
           myComboBox.setSelectedItem(selected);
         }
         else if (myComboBox.getItemCount() > 0) {
@@ -135,7 +137,6 @@ public class TaskUiUtil {
         }
       }
       else {
-        // Some error occurred
         handleError();
       }
     }