private static boolean areItemsEquivalent( DirectoryChooser.ItemWrapper oItem, DirectoryChooser.ItemWrapper itemWrapper) { if (oItem == NULL_WRAPPER || itemWrapper == NULL_WRAPPER) { if (oItem != itemWrapper) { return false; } return true; } if (oItem == null) return itemWrapper == null; if (itemWrapper == null) return false; if (oItem.getDirectory() != itemWrapper.getDirectory()) { return false; } return true; }
@Nullable public MoveDestination selectDirectory( final PackageWrapper targetPackage, final boolean showChooserWhenDefault) { final DirectoryChooser.ItemWrapper selectedItem = (DirectoryChooser.ItemWrapper) getComboBox().getSelectedItem(); if (selectedItem == null || selectedItem == NULL_WRAPPER) { return new MultipleRootsMoveDestination(targetPackage); } final PsiDirectory selectedPsiDirectory = selectedItem.getDirectory(); VirtualFile selectedDestination = selectedPsiDirectory.getVirtualFile(); if (showChooserWhenDefault && selectedDestination == myInitialTargetDirectory.getVirtualFile() && mySourceRoots.length > 1) { selectedDestination = MoveClassesOrPackagesUtil.chooseSourceRoot( targetPackage, mySourceRoots, myInitialTargetDirectory); } if (selectedDestination == null) return null; return new AutocreatingSingleSourceRootMoveDestination(targetPackage, selectedDestination); }
@Nullable private static DirectoryChooser.ItemWrapper chooseSelection( final VirtualFile initialTargetDirectorySourceRoot, final ProjectFileIndex fileIndex, final ArrayList<DirectoryChooser.ItemWrapper> items, final DirectoryChooser.ItemWrapper initial, final DirectoryChooser.ItemWrapper oldOne) { if (initial != null || items.contains(NULL_WRAPPER) || items.isEmpty()) { return initial; } else { if (oldOne != null) { return oldOne; } else if (initialTargetDirectorySourceRoot != null) { final boolean inTest = fileIndex.isInTestSourceContent(initialTargetDirectorySourceRoot); for (DirectoryChooser.ItemWrapper item : items) { final VirtualFile virtualFile = item.getDirectory().getVirtualFile(); if (fileIndex.isInTestSourceContent(virtualFile) == inTest) { return item; } } } } return items.get(0); }