file type auto-detection: context help based on selection master
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Tue, 22 Sep 2020 18:29:19 +0000 (20:29 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Tue, 22 Sep 2020 19:14:12 +0000 (19:14 +0000)
IDEA-CR-66908

GitOrigin-RevId: 1ed3c68f120ceb587faeea502b5cf24e8fa92f16

platform/platform-impl/resources/messages/FileTypesBundle.properties
platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java

index 8ef8887c7c704885dc323ec8ac853b2b44377e04..25c488007007db881d283a138ae9003475c0f657 100644 (file)
@@ -44,4 +44,4 @@ filetype.associate.button=Associate File Types with {0}...
 filetype.associate.success.message={0} has been set as a default application for chosen file types.
 filetype.associate.dialog.label=Open the following file types with {0}:
 filetype.associate.dialog.title=Associate File Types
-label.help.change.association=To change the association later, go to {0} | File types
\ No newline at end of file
+label.help.change.association=To change the association later, go to {0} | File types{1}
\ No newline at end of file
index fd435301f256ebf3f311d26287fe084405943d99..b62f280b6f03024046cfd05c28da1b9d9bcf7ca1 100644 (file)
@@ -49,7 +49,10 @@ public final class FileTypeChooser extends DialogWrapper {
     myFileName = fileName;
     myOpenInIdea.setText(FileTypesBundle.message("filetype.chooser.association", ApplicationNamesInfo.getInstance().getFullProductName()));
     myDetectFileType.setText(FileTypesBundle.message("filetype.chooser.autodetect"));
-    ActionListener actionListener = e -> myList.setEnabled(myOpenInIdea.isSelected());
+    ActionListener actionListener = e -> {
+      myList.setEnabled(myOpenInIdea.isSelected());
+      updateContextHelp();
+    };
     myDetectFileType.addActionListener(actionListener);
     myOpenInIdea.addActionListener(actionListener);
     myOpenAsNative.addActionListener(actionListener);
@@ -69,15 +72,22 @@ public final class FileTypeChooser extends DialogWrapper {
       }
     }
     myList.setModel(model);
+    myList.addListSelectionListener(e -> updateContextHelp());
     myPattern.setModel(new CollectionComboBoxModel<>(ContainerUtil.map(patterns, FunctionUtil.id()), patterns.get(0)));
     new ListSpeedSearch(myList, (Function<Object, String>)o -> ((FileType)o).getDescription());
 
     myContextHelpLabel.setForeground(UIUtil.getContextHelpForeground());
-    myContextHelpLabel.setText(FileTypesBundle.message("label.help.change.association", ShowSettingsUtil.getSettingsMenuName()));
+    updateContextHelp();
     setTitle(FileTypesBundle.message("filetype.chooser.title"));
     init();
   }
 
+  private void updateContextHelp() {
+    String fileTypeString = myOpenAsNative.isSelected() ? "" : (" | " + getSelectedType().getDescription());
+    myContextHelpLabel.setText(FileTypesBundle.message("label.help.change.association", ShowSettingsUtil.getSettingsMenuName(),
+                                                       fileTypeString));
+  }
+
   @Override
   protected JComponent createCenterPanel() {
     FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(myFileName);