PY-18792 Better names and descriptions for the new options
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 30 May 2016 18:24:42 +0000 (21:24 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Wed, 15 Jun 2016 16:34:14 +0000 (19:34 +0300)
python/src/com/jetbrains/python/PyBundle.properties
python/src/com/jetbrains/python/codeInsight/imports/PyImportOptimizer.java
python/src/com/jetbrains/python/formatter/PyCodeStyleSettings.java
python/src/com/jetbrains/python/formatter/PyImportsCodeStylePanel.form
python/src/com/jetbrains/python/formatter/PyImportsCodeStylePanel.java
python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java

index af4312a0694eb2431d3ce28a660430cf2eab7cd1..797f0c74f1ec49a0886a2a7efc81b0b673c72f87 100644 (file)
@@ -973,10 +973,10 @@ windowWithActions.stopProcess=Stop currently running process
 
 formatter.imports.panel.title=Imports
 formatter.imports.panel.optimize.imports=Optimize Imports
-formatter.imports.panel.sort.alphabetically=Sort import statements alphabetically
-formatter.imports.panel.sort.names.in.from.imports=Sort names in "from ... import ..." imports
-formatter.imports.panel.join.from.imports.with.same.source=Join "from ... import ..." from the same source
-formatter.import.panel.sort.by.type=Sort imports by type first within section
+formatter.imports.panel.sort.imports=Sort import statements
+formatter.imports.panel.sort.names.in.from.imports=Sort imported names in "from" imports
+formatter.imports.panel.join.from.imports.with.same.source=Join "from" imports with the same source
+formatter.imports.panel.sort.by.type=Sort imports by type first within their sections
 
 formatter.panel.dict.alignment.do.not.align=Do not align
 formatter.panel.dict.alignment.align.on.colon=Align on colon
index 5aa28b658072c967afd58617cefb1f95fa4f0758..1406815aa2d1ac1bb2eae7b653210e2c4b78da66 100644 (file)
@@ -196,7 +196,7 @@ public class PyImportOptimizer implements ImportOptimizer {
     }
 
     private boolean groupsNotSorted() {
-      if (!myPySettings.OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY) {
+      if (!myPySettings.OPTIMIZE_IMPORTS_SORT_IMPORTS) {
         return false;
       }
       final Ordering<PyImportStatementBase> importOrdering = Ordering.from(AddImportHelper.getSameGroupImportsComparator(myFile.getProject()));
@@ -214,7 +214,7 @@ public class PyImportOptimizer implements ImportOptimizer {
     }
 
     private void applyResults() {
-      if (myPySettings.OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY) {
+      if (myPySettings.OPTIMIZE_IMPORTS_SORT_IMPORTS) {
         for (ImportPriority priority : myGroups.keySet()) {
           final List<PyImportStatementBase> imports = myGroups.get(priority);
           Collections.sort(imports, AddImportHelper.getSameGroupImportsComparator(myFile.getProject()));
index c6b6a6aa2eba3cd7bfe6bb9c52d717c9ad636c43..1d1ee8dc6dac7574883b7d2c07b237295b91c3b7 100644 (file)
@@ -88,10 +88,10 @@ public class PyCodeStyleSettings extends CustomCodeStyleSettings {
    */
   public boolean USE_CONTINUATION_INDENT_FOR_ARGUMENTS = false;
 
-  public boolean OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY = true;
+  public boolean OPTIMIZE_IMPORTS_SORT_IMPORTS = true;
   public boolean OPTIMIZE_IMPORTS_SORT_NAMES_IN_FROM_IMPORTS = false;
-  public boolean OPTIMIZE_IMPORTS_JOIN_FROM_IMPORTS_WITH_SAME_SOURCE = false;
   public boolean OPTIMIZE_IMPORTS_SORT_BY_TYPE_FIRST = true;
+  public boolean OPTIMIZE_IMPORTS_JOIN_FROM_IMPORTS_WITH_SAME_SOURCE = false;
 
   public PyCodeStyleSettings(CodeStyleSettings container) {
     super("Python", container);
index 6044dcc0c7444aa695d2bebf9346cfd91c0f97ae..80d4c94d89c3702c1e7f255831c28473583cff07 100644 (file)
         </clientProperties>
         <border type="none" title-resource-bundle="com/jetbrains/python/PyBundle" title-key="formatter.imports.panel.optimize.imports"/>
         <children>
-          <component id="e4d2f" class="com.intellij.ui.components.JBCheckBox" binding="mySortImportsAlphabetically" default-binding="true">
+          <component id="e4d2f" class="com.intellij.ui.components.JBCheckBox" binding="mySortImports" default-binding="true">
             <constraints>
               <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <text resource-bundle="com/jetbrains/python/PyBundle" key="formatter.imports.panel.sort.alphabetically"/>
+              <text resource-bundle="com/jetbrains/python/PyBundle" key="formatter.imports.panel.sort.imports"/>
             </properties>
           </component>
           <component id="fdf9d" class="com.intellij.ui.components.JBCheckBox" binding="mySortNamesInFromImports" default-binding="true">
@@ -53,7 +53,7 @@
               <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <text resource-bundle="com/jetbrains/python/PyBundle" key="formatter.import.panel.sort.by.type"/>
+              <text resource-bundle="com/jetbrains/python/PyBundle" key="formatter.imports.panel.sort.by.type"/>
             </properties>
           </component>
         </children>
index 78c5206fe1fcfab883949f090804c34c7ad848a3..044b8ad601cf3cff27f634493b67e99349f9b6eb 100644 (file)
@@ -34,7 +34,7 @@ import javax.swing.*;
  * @author Mikhail Golubev
  */
 public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
-  private JBCheckBox mySortImportsAlphabetically;
+  private JBCheckBox mySortImports;
   private JBCheckBox mySortNamesInFromImports;
   private JBCheckBox mySortImportsByTypeFirst;
   private JBCheckBox myJoinFromImportsWithSameSource;
@@ -44,8 +44,8 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
     super(PythonLanguage.getInstance(), null, settings);
     addPanelToWatch(myRootPanel);
 
-    mySortImportsAlphabetically.addActionListener(e -> {
-      final boolean sortingEnabled = mySortImportsAlphabetically.isSelected();
+    mySortImports.addActionListener(e -> {
+      final boolean sortingEnabled = mySortImports.isSelected();
       mySortNamesInFromImports.setEnabled(sortingEnabled);
       mySortImportsByTypeFirst.setEnabled(sortingEnabled);
     });
@@ -83,7 +83,7 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
   public void apply(CodeStyleSettings settings) throws ConfigurationException {
     final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class);
 
-    pySettings.OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY = mySortImportsAlphabetically.isSelected();
+    pySettings.OPTIMIZE_IMPORTS_SORT_IMPORTS = mySortImports.isSelected();
     pySettings.OPTIMIZE_IMPORTS_SORT_NAMES_IN_FROM_IMPORTS = mySortNamesInFromImports.isSelected();
     pySettings.OPTIMIZE_IMPORTS_SORT_BY_TYPE_FIRST = mySortImportsByTypeFirst.isSelected();
     pySettings.OPTIMIZE_IMPORTS_JOIN_FROM_IMPORTS_WITH_SAME_SOURCE = myJoinFromImportsWithSameSource.isSelected();
@@ -93,7 +93,7 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
   public boolean isModified(CodeStyleSettings settings) {
     final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class);
 
-    return mySortImportsAlphabetically.isSelected() != pySettings.OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY ||
+    return mySortImports.isSelected() != pySettings.OPTIMIZE_IMPORTS_SORT_IMPORTS ||
            mySortNamesInFromImports.isSelected() != pySettings.OPTIMIZE_IMPORTS_SORT_NAMES_IN_FROM_IMPORTS ||
            mySortImportsByTypeFirst.isSelected() != pySettings.OPTIMIZE_IMPORTS_SORT_BY_TYPE_FIRST ||
            myJoinFromImportsWithSameSource.isSelected() != pySettings.OPTIMIZE_IMPORTS_JOIN_FROM_IMPORTS_WITH_SAME_SOURCE;
@@ -109,11 +109,11 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
   protected void resetImpl(CodeStyleSettings settings) {
     final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class);
 
-    mySortImportsAlphabetically.setSelected(pySettings.OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY);
+    mySortImports.setSelected(pySettings.OPTIMIZE_IMPORTS_SORT_IMPORTS);
     mySortNamesInFromImports.setSelected(pySettings.OPTIMIZE_IMPORTS_SORT_NAMES_IN_FROM_IMPORTS);
-    mySortNamesInFromImports.setEnabled(mySortImportsAlphabetically.isSelected());
+    mySortNamesInFromImports.setEnabled(mySortImports.isSelected());
     mySortImportsByTypeFirst.setSelected(pySettings.OPTIMIZE_IMPORTS_SORT_BY_TYPE_FIRST);
-    mySortImportsByTypeFirst.setSelected(mySortImportsAlphabetically.isSelected());
+    mySortImportsByTypeFirst.setSelected(mySortImports.isSelected());
     myJoinFromImportsWithSameSource.setSelected(pySettings.OPTIMIZE_IMPORTS_JOIN_FROM_IMPORTS_WITH_SAME_SOURCE);
   }
 }
index 1a5137fb1cd3562a98aa8e0bec6ee0f2c2a85446..c3b5fb49b7927be04d4d15e3bb11f28850fc241e 100644 (file)
@@ -139,7 +139,7 @@ public class PyOptimizeImportsTest extends PyTestCase {
   
   // PY-18792
   public void testDisableAlphabeticalOrder() {
-    getPythonCodeStyleSettings().OPTIMIZE_IMPORTS_SORT_ALPHABETICALLY = false;
+    getPythonCodeStyleSettings().OPTIMIZE_IMPORTS_SORT_IMPORTS = false;
     doTest();
   }