Move: Add "Update package directive" option to dialog
#KT-6084 Fixed
This commit is contained in:
+15
-6
@@ -26,7 +26,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="fced3" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="fced3" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="7" left="0" bottom="7" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -50,13 +50,13 @@
|
||||
</component>
|
||||
<component id="9ea97" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="fileChooser">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="58e61" class="javax.swing.JRadioButton" binding="rbMoveToFile">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" 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 value="To &file:"/>
|
||||
@@ -64,7 +64,7 @@
|
||||
</component>
|
||||
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
@@ -73,7 +73,7 @@
|
||||
</component>
|
||||
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurrences">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
@@ -103,7 +103,7 @@
|
||||
<grid id="ce694" binding="targetPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="5" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="5" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -125,6 +125,15 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="684be" class="javax.swing.JCheckBox" binding="cbUpdatePackageDirective">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="5" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="&Update package directive"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="9c908">
|
||||
|
||||
+8
-1
@@ -55,6 +55,7 @@ import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.core.CorePackage;
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.RefactoringPackage;
|
||||
import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle;
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinMemberInfo;
|
||||
@@ -110,6 +111,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||
private JPanel memberInfoPanel;
|
||||
private JTextField tfFileNameInPackage;
|
||||
private JCheckBox cbSpecifyFileNameInPackage;
|
||||
private JCheckBox cbUpdatePackageDirective;
|
||||
private KotlinMemberSelectionTable memberTable;
|
||||
|
||||
private final JetFile sourceFile;
|
||||
@@ -238,6 +240,8 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
cbUpdatePackageDirective.setSelected(CorePackage.packageMatchesDirectory(sourceFile));
|
||||
}
|
||||
|
||||
private void initSearchOptions(boolean searchInComments, boolean searchForTextOccurences) {
|
||||
@@ -316,6 +320,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||
classPackageChooser.setEnabled(moveToPackage);
|
||||
updateFileNameInPackageField();
|
||||
fileChooser.setEnabled(!moveToPackage);
|
||||
cbUpdatePackageDirective.setEnabled(moveToPackage);
|
||||
UIUtil.setEnabled(targetPanel, moveToPackage && hasAnySourceRoots(), true);
|
||||
updateSuggestedFileName();
|
||||
validateButtons();
|
||||
@@ -375,7 +380,8 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||
directory.getVirtualFile().getPath() +
|
||||
"/" +
|
||||
targetFileName +
|
||||
"' already exists. Do you want to move selected declarations to this file?";
|
||||
"' already exists." +
|
||||
"Do you want to move selected declarations to this file?";
|
||||
int ret = Messages.showYesNoDialog(myProject, question, RefactoringBundle.message("move.title"), Messages.getQuestionIcon());
|
||||
if (ret != Messages.YES) return null;
|
||||
}
|
||||
@@ -531,6 +537,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||
}
|
||||
}
|
||||
);
|
||||
MovePackage.setUpdatePackageDirective(sourceFile, cbUpdatePackageDirective.isSelected());
|
||||
invokeRefactoring(
|
||||
new MoveFilesOrDirectoriesProcessor(
|
||||
myProject,
|
||||
|
||||
Reference in New Issue
Block a user