Move: Add "Update package directive" option to dialog
#KT-6084 Fixed
This commit is contained in:
+15
-6
@@ -26,7 +26,7 @@
|
|||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<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"/>
|
<margin top="7" left="0" bottom="7" right="0"/>
|
||||||
<constraints>
|
<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"/>
|
<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>
|
||||||
<component id="9ea97" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="fileChooser">
|
<component id="9ea97" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="fileChooser">
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
</component>
|
</component>
|
||||||
<component id="58e61" class="javax.swing.JRadioButton" binding="rbMoveToFile">
|
<component id="58e61" class="javax.swing.JRadioButton" binding="rbMoveToFile">
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="To &file:"/>
|
<text value="To &file:"/>
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
|
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<selected value="true"/>
|
<selected value="true"/>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurrences">
|
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurrences">
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<selected value="true"/>
|
<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">
|
<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"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@@ -125,6 +125,15 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</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>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<vspacer id="9c908">
|
<vspacer id="9c908">
|
||||||
|
|||||||
+8
-1
@@ -55,6 +55,7 @@ import kotlin.jvm.functions.Function0;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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.core.refactoring.RefactoringPackage;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle;
|
import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.KotlinMemberInfo;
|
import org.jetbrains.kotlin.idea.refactoring.KotlinMemberInfo;
|
||||||
@@ -110,6 +111,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
private JPanel memberInfoPanel;
|
private JPanel memberInfoPanel;
|
||||||
private JTextField tfFileNameInPackage;
|
private JTextField tfFileNameInPackage;
|
||||||
private JCheckBox cbSpecifyFileNameInPackage;
|
private JCheckBox cbSpecifyFileNameInPackage;
|
||||||
|
private JCheckBox cbUpdatePackageDirective;
|
||||||
private KotlinMemberSelectionTable memberTable;
|
private KotlinMemberSelectionTable memberTable;
|
||||||
|
|
||||||
private final JetFile sourceFile;
|
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) {
|
private void initSearchOptions(boolean searchInComments, boolean searchForTextOccurences) {
|
||||||
@@ -316,6 +320,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
classPackageChooser.setEnabled(moveToPackage);
|
classPackageChooser.setEnabled(moveToPackage);
|
||||||
updateFileNameInPackageField();
|
updateFileNameInPackageField();
|
||||||
fileChooser.setEnabled(!moveToPackage);
|
fileChooser.setEnabled(!moveToPackage);
|
||||||
|
cbUpdatePackageDirective.setEnabled(moveToPackage);
|
||||||
UIUtil.setEnabled(targetPanel, moveToPackage && hasAnySourceRoots(), true);
|
UIUtil.setEnabled(targetPanel, moveToPackage && hasAnySourceRoots(), true);
|
||||||
updateSuggestedFileName();
|
updateSuggestedFileName();
|
||||||
validateButtons();
|
validateButtons();
|
||||||
@@ -375,7 +380,8 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
directory.getVirtualFile().getPath() +
|
directory.getVirtualFile().getPath() +
|
||||||
"/" +
|
"/" +
|
||||||
targetFileName +
|
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());
|
int ret = Messages.showYesNoDialog(myProject, question, RefactoringBundle.message("move.title"), Messages.getQuestionIcon());
|
||||||
if (ret != Messages.YES) return null;
|
if (ret != Messages.YES) return null;
|
||||||
}
|
}
|
||||||
@@ -531,6 +537,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
MovePackage.setUpdatePackageDirective(sourceFile, cbUpdatePackageDirective.isSelected());
|
||||||
invokeRefactoring(
|
invokeRefactoring(
|
||||||
new MoveFilesOrDirectoriesProcessor(
|
new MoveFilesOrDirectoriesProcessor(
|
||||||
myProject,
|
myProject,
|
||||||
|
|||||||
Reference in New Issue
Block a user