mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move: cache relative to project path
This commit is contained in:
+2
-11
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.ComboBoxWithWidePopup;
|
||||
@@ -108,7 +107,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton
|
||||
if (itemWrapper != NULL_WRAPPER && itemWrapper != null) {
|
||||
setIcon(itemWrapper.getIcon(fileIndex));
|
||||
|
||||
setText(getPresentableText(itemWrapper, project));
|
||||
setText(itemWrapper.getRelativeToProjectPath());
|
||||
}
|
||||
else {
|
||||
setText(LEAVE_IN_SAME_SOURCE_ROOT);
|
||||
@@ -161,14 +160,6 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton
|
||||
});
|
||||
}
|
||||
|
||||
private static String getPresentableText(DirectoryChooser.ItemWrapper itemWrapper, Project project) {
|
||||
final PsiDirectory directory = itemWrapper.getDirectory();
|
||||
final VirtualFile virtualFile = directory != null ? directory.getVirtualFile() : null;
|
||||
return virtualFile != null
|
||||
? ProjectUtil.calcRelativeToProjectPath(virtualFile, project, true, true)
|
||||
: itemWrapper.getPresentableUrl();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MoveDestination selectDirectory(final PackageWrapper targetPackage, final boolean showChooserWhenDefault) {
|
||||
final DirectoryChooser.ItemWrapper selectedItem = (DirectoryChooser.ItemWrapper)getComboBox().getSelectedItem();
|
||||
@@ -257,7 +248,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton
|
||||
public int compare(DirectoryChooser.ItemWrapper o1, DirectoryChooser.ItemWrapper o2) {
|
||||
if (o1 == NULL_WRAPPER) return -1;
|
||||
if (o2 == NULL_WRAPPER) return 1;
|
||||
return getPresentableText(o1, project).compareToIgnoreCase(getPresentableText(o2, project));
|
||||
return o1.getRelativeToProjectPath().compareToIgnoreCase(o2.getRelativeToProjectPath());
|
||||
}
|
||||
});
|
||||
comboBox.setModel(new CollectionComboBoxModel(items, selection));
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ide.util.gotoByName.GotoClassModel2;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.FileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -309,6 +310,8 @@ public class DirectoryChooser extends DialogWrapper {
|
||||
private PathFragment[] myFragments;
|
||||
private final String myPostfix;
|
||||
|
||||
private String myRelativeToProjectPath = null;
|
||||
|
||||
public ItemWrapper(PsiDirectory directory, String postfix) {
|
||||
myDirectory = directory;
|
||||
myPostfix = postfix != null && postfix.length() > 0 ? postfix : null;
|
||||
@@ -354,6 +357,17 @@ public class DirectoryChooser extends DialogWrapper {
|
||||
public PsiDirectory getDirectory() {
|
||||
return myDirectory;
|
||||
}
|
||||
|
||||
public String getRelativeToProjectPath() {
|
||||
if (myRelativeToProjectPath == null) {
|
||||
final PsiDirectory directory = getDirectory();
|
||||
final VirtualFile virtualFile = directory != null ? directory.getVirtualFile() : null;
|
||||
myRelativeToProjectPath = virtualFile != null
|
||||
? ProjectUtil.calcRelativeToProjectPath(virtualFile, directory.getProject(), true, true)
|
||||
: getPresentableUrl();
|
||||
}
|
||||
return myRelativeToProjectPath;
|
||||
}
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusedComponent(){
|
||||
|
||||
Reference in New Issue
Block a user