use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class StepikPyProjectGenerator method getLocationField.
@Nullable
private TextFieldWithBrowseButton getLocationField() {
if (locationField == null) {
Container basePanel = wizardStep.getComponent().getParent();
if (basePanel == null) {
return null;
}
try {
Container topPanel = (Container) basePanel.getComponent(0);
LabeledComponent locationComponent = (LabeledComponent) topPanel.getComponent(0);
locationField = (TextFieldWithBrowseButton) locationComponent.getComponent();
} catch (ClassCastException | ArrayIndexOutOfBoundsException e) {
logger.warn("Auto naming for a project don't work: ", e);
return null;
}
}
return locationField;
}
use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class StepikSendAction method getSubmissionId.
@Nullable
private static Long getSubmissionId(@NotNull Project project, @NotNull StepikApiClient stepikApiClient, @NotNull StepNode stepNode, long intAttemptId) {
SupportedLanguages currentLang = stepNode.getCurrentLang();
String code = getCode(project, stepNode, currentLang);
if (code == null) {
logger.info(String.format("Sending step failed: id=%s. Step content is null", stepNode.getId()));
return null;
}
Submissions submissions;
try {
submissions = stepikApiClient.submissions().post().attempt(intAttemptId).language(currentLang.getName()).code(code).execute();
if (submissions.isEmpty()) {
notifyFailed(project, stepNode, "Submissions is empty", null);
return null;
}
} catch (StepikClientException e) {
notifyFailed(project, stepNode, "Failed post submission", e);
return null;
}
return submissions.getFirst().getId();
}
use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class StepikSendAction method getCode.
@Nullable
private static String getCode(@NotNull Project project, @NotNull StepNode stepNode, @NotNull SupportedLanguages currentLang) {
VirtualFile src = getOrCreateSrcDirectory(project, stepNode, true);
if (src == null) {
return null;
}
VirtualFile mainFile = src.findChild(currentLang.getMainFileName());
if (mainFile == null) {
return null;
}
String text = getFileText(mainFile);
return getTextUnderDirectives(text, currentLang);
}
use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class AbstractMoveHandlerDelegate method doMove.
@Override
public void doMove(Project project, PsiElement[] elements, @Nullable PsiElement targetContainer, @Nullable MoveCallback callback) {
List<PsiFileSystemItem> sources = Arrays.stream(elements).filter(psiElement -> isNotMovableOrRenameElement(psiElement, acceptableClasses)).map(ProjectPsiFilesUtils::getFile).filter(Objects::nonNull).collect(Collectors.toList());
StringBuilder message = new StringBuilder();
if (sources.size() > 1) {
message.append("You can not move the following elements:");
} else {
PsiFileSystemItem source = sources.get(0);
message.append("You can not move the ").append(source.isDirectory() ? "directory" : "file").append(":");
}
for (PsiFileSystemItem file : sources) {
message.append("\n").append(file.getVirtualFile().getPath());
}
MessagesEx.error(project, message.toString(), "Move").showNow();
}
use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class NavigationUtils method findNodeWithObject.
@Nullable
private static DefaultMutableTreeNode findNodeWithObject(@NotNull TreeNode root, PsiFileSystemItem file) {
for (int i = 0; i < root.getChildCount(); i++) {
TreeNode child = root.getChildAt(i);
if (child instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) child;
Object userObject = node.getUserObject();
if (userObject instanceof PsiDirectoryNode) {
PsiDirectoryNode directoryNode = (PsiDirectoryNode) userObject;
PsiDirectory value = directoryNode.getValue();
if (file.equals(value)) {
return node;
}
}
node = findNodeWithObject(child, file);
if (node != null) {
return node;
}
}
}
return null;
}
Aggregations