use of com.jetbrains.edu.coursecreator.ui.CCCreateStudyItemDialog in project intellij-community by JetBrains.
the class CCCreateStudyItemActionBase method getItem.
@Nullable
protected StudyItem getItem(@NotNull final PsiDirectory sourceDirectory, @NotNull final Project project, @NotNull final Course course, @Nullable IdeView view, @Nullable StudyItem parentItem) {
String itemName;
int itemIndex;
if (isAddedAsLast(sourceDirectory, project, course)) {
itemIndex = getSiblingsSize(course, parentItem) + 1;
String suggestedName = getItemName() + itemIndex;
itemName = view == null ? suggestedName : Messages.showInputDialog("Name:", getTitle(), null, suggestedName, null);
} else {
StudyItem thresholdItem = getThresholdItem(course, sourceDirectory);
if (thresholdItem == null) {
return null;
}
final int index = thresholdItem.getIndex();
CCCreateStudyItemDialog dialog = new CCCreateStudyItemDialog(project, getItemName(), thresholdItem.getName(), index);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return null;
}
itemName = dialog.getName();
itemIndex = index + dialog.getIndexDelta();
}
if (itemName == null) {
return null;
}
return createAndInitItem(course, parentItem, itemName, itemIndex);
}
Aggregations