use of org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel in project intellij-community by JetBrains.
the class IpnbPyFunction method navigate.
@Override
public void navigate(boolean requestFocus) {
final IpnbCodeSourcePanel sourcePanel = ((IpnbPyFragment) getContainingFile()).getCodeSourcePanel();
final Editor editor = sourcePanel.getEditor();
final IpnbCodePanel codePanel = sourcePanel.getIpnbCodePanel();
final IpnbFileEditor fileEditor = codePanel.getFileEditor();
final IpnbFilePanel filePanel = fileEditor.getIpnbFilePanel();
codePanel.setEditing(true);
filePanel.setSelectedCellPanel(codePanel);
super.navigate(false);
UIUtil.requestFocus(editor.getContentComponent());
}
use of org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel in project intellij-community by JetBrains.
the class IpnbPyReference method multiResolve.
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
ResolveResult[] results = super.multiResolve(incompleteCode);
if (results.length == 0) {
PsiFile file = myElement.getContainingFile();
if (file instanceof IpnbPyFragment) {
final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
final String referencedName = myElement.getReferencedName();
if (referencedName == null)
return ResolveResult.EMPTY_ARRAY;
for (IpnbEditablePanel editablePanel : panels) {
if (!(editablePanel instanceof IpnbCodePanel))
continue;
final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(myElement.getProject()).getPsiFile(editor.getDocument());
if (psiFile == null)
continue;
final PyResolveProcessor processor = new PyResolveProcessor(referencedName);
PyResolveUtil.scopeCrawlUp(processor, psiFile, referencedName, psiFile);
final List<RatedResolveResult> resultList = getResultsFromProcessor(referencedName, processor, psiFile, psiFile);
if (resultList.size() > 0) {
List<RatedResolveResult> ret = RatedResolveResult.sorted(resultList);
return ret.toArray(new RatedResolveResult[ret.size()]);
}
}
}
}
return results;
}
use of org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel in project intellij-community by JetBrains.
the class IpnbPyTargetExpression method navigate.
@Override
public void navigate(boolean requestFocus) {
final IpnbCodeSourcePanel sourcePanel = ((IpnbPyFragment) getContainingFile()).getCodeSourcePanel();
final Editor editor = sourcePanel.getEditor();
final IpnbCodePanel codePanel = sourcePanel.getIpnbCodePanel();
final IpnbFileEditor fileEditor = codePanel.getFileEditor();
final IpnbFilePanel filePanel = fileEditor.getIpnbFilePanel();
codePanel.setEditing(true);
filePanel.setSelectedCellPanel(codePanel);
super.navigate(false);
UIUtil.requestFocus(editor.getContentComponent());
}
use of org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel in project intellij-community by JetBrains.
the class IpnbUnresolvedReferenceSkipper method unusedImportShouldBeSkipped.
@Override
public boolean unusedImportShouldBeSkipped(@NotNull final PyImportedNameDefiner importNameDefiner) {
final PsiFile file = importNameDefiner.getContainingFile();
if (file instanceof IpnbPyFragment) {
final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
for (IpnbEditablePanel editablePanel : panels) {
if (!(editablePanel instanceof IpnbCodePanel))
continue;
final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(importNameDefiner.getProject()).getPsiFile(editor.getDocument());
if (psiFile == null)
continue;
final MyVisitor visitor = new MyVisitor(importNameDefiner);
psiFile.accept(visitor);
if (visitor.used)
return true;
}
}
return false;
}
use of org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel in project intellij-community by JetBrains.
the class IpnbCodePanel method updatePanel.
public void updatePanel(@Nullable final String replacementContent, @Nullable final IpnbOutputCell outputContent) {
final Application application = ApplicationManager.getApplication();
application.invokeAndWait(() -> {
if (replacementContent == null && outputContent == null) {
myCell.removeCellOutputs();
myViewPanel.removeAll();
application.runReadAction(() -> {
final JComponent panel = createViewPanel();
myViewPanel.add(panel);
String prompt = IpnbEditorUtil.prompt(-1, IpnbEditorUtil.PromptType.In);
myPromptLabel.setText(prompt);
});
}
if (replacementContent != null) {
myCell.setSource(Arrays.asList(StringUtil.splitByLinesKeepSeparators(replacementContent)));
String prompt = IpnbEditorUtil.prompt(null, IpnbEditorUtil.PromptType.In);
myCell.setPromptNumber(null);
myPromptLabel.setText(prompt);
application.runWriteAction(() -> myCodeSourcePanel.getEditor().getDocument().setText(replacementContent));
}
if (outputContent != null) {
myCell.addCellOutput(outputContent);
final JComponent component = myHideableOutputPanel.getSecondComponent();
if (component != null) {
addOutputPanel(component, outputContent, outputContent instanceof IpnbOutOutputCell);
}
}
final IpnbFilePanel filePanel = myParent.getIpnbFilePanel();
filePanel.revalidateAndRepaint();
}, ModalityState.stateForComponent(this));
}
Aggregations