use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project buck by facebook.
the class GoToBuckFile method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor == null) {
return;
}
final Document document = editor.getDocument();
if (document == null) {
return;
}
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
final VirtualFile file = BuckFileUtil.getBuckFile(virtualFile);
if (file != null) {
final OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
// This is for better cursor position.
final Navigatable n = descriptor.setUseCurrentWindow(false);
if (!n.canNavigate()) {
return;
}
n.navigate(true);
}
}
use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.
the class ProblemsView method addMessage.
public final void addMessage(CompilerMessage message, @NotNull UUID sessionId) {
final VirtualFile file = message.getVirtualFile();
Navigatable navigatable = message.getNavigatable();
if (navigatable == null && file != null) {
navigatable = new OpenFileDescriptor(myProject, file, -1, -1);
}
final CompilerMessageCategory category = message.getCategory();
final int type = CompilerTask.translateCategory(category);
final String[] text = convertMessage(message);
final String groupName = file != null ? file.getPresentableUrl() : category.getPresentableText();
addMessage(type, text, groupName, navigatable, message.getExportTextPrefix(), message.getRenderTextPrefix(), sessionId);
}
use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.
the class ExcludeFromValidationAction method getExcludedConfigurationAndFile.
@Nullable
private static Pair<ExcludesConfiguration, VirtualFile> getExcludedConfigurationAndFile(final AnActionEvent event, Project project) {
Navigatable navigatable = event.getData(CommonDataKeys.NAVIGATABLE);
if (project != null && navigatable instanceof OpenFileDescriptor) {
final VirtualFile file = ((OpenFileDescriptor) navigatable).getFile();
final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
return Pair.create(configuration, file);
}
return null;
}
use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project android by JetBrains.
the class AndroidManifestsGroupNode method navigate.
@Override
public void navigate(boolean requestFocus) {
VirtualFile fileToOpen = findFileToOpen(mySources);
if (fileToOpen == null) {
return;
}
new OpenFileDescriptor(myProject, fileToOpen).navigate(requestFocus);
}
use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project android by JetBrains.
the class GutterIconRenderer method getClickAction.
@Nullable
@Override
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
if (editor != null) {
Project project = editor.getProject();
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(myFile);
if (project != null && virtualFile != null) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile, -1);
FileEditorManager.getInstance(project).openEditor(descriptor, true);
}
}
}
};
}
Aggregations