use of com.intellij.ide.SelectInContext in project intellij-community by JetBrains.
the class SelectInContextImpl method createContext.
@Nullable
public static SelectInContext createContext(AnActionEvent event) {
DataContext dataContext = event.getDataContext();
SelectInContext result = createEditorContext(dataContext);
if (result != null) {
return result;
}
JComponent sourceComponent = getEventComponent(event);
if (sourceComponent == null) {
return null;
}
SelectInContext selectInContext = SelectInContext.DATA_KEY.getData(dataContext);
if (selectInContext == null) {
selectInContext = createPsiContext(event);
}
if (selectInContext == null) {
Navigatable descriptor = CommonDataKeys.NAVIGATABLE.getData(dataContext);
if (descriptor instanceof OpenFileDescriptor) {
final VirtualFile file = ((OpenFileDescriptor) descriptor).getFile();
if (file.isValid()) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
selectInContext = OpenFileDescriptorContext.create(project, file);
}
}
}
if (selectInContext == null) {
VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (virtualFile != null && project != null) {
return new VirtualFileSelectInContext(project, virtualFile);
}
}
return selectInContext;
}
use of com.intellij.ide.SelectInContext in project intellij-community by JetBrains.
the class SelectInProjectViewAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ProjectPaneSelectInTarget target = new ProjectPaneSelectInTarget(e.getProject());
final SelectInContext context = SelectInContextImpl.createContext(e);
if (context != null) {
target.selectIn(context, true);
}
}
use of com.intellij.ide.SelectInContext in project intellij-community by JetBrains.
the class SelectInProjectViewAction method update.
@Override
public void update(AnActionEvent e) {
final Project project = e.getProject();
if (project != null) {
final ProjectPaneSelectInTarget target = new ProjectPaneSelectInTarget(project);
final SelectInContext context = SelectInContextImpl.createContext(e);
if (context != null && target.canSelect(context)) {
e.getPresentation().setEnabled(true);
return;
}
}
e.getPresentation().setEnabled(false);
}
Aggregations