use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OpenInEditorAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
if (!ActionPlaces.isToolbarPlace(e.getPlace())) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
DiffRequest request = e.getData(DiffDataKeys.DIFF_REQUEST);
DiffContext context = e.getData(DiffDataKeys.DIFF_CONTEXT);
if (DiffUtil.isUserDataFlagSet(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, request, context)) {
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
}
if (e.getProject() == null) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
return;
}
Navigatable[] navigatables = e.getData(DiffDataKeys.NAVIGATABLE_ARRAY);
if (navigatables == null || !ContainerUtil.exists(navigatables, (it) -> it.canNavigate())) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class SMTRunnerConsoleProperties method getErrorNavigatable.
@Nullable
@Override
public Navigatable getErrorNavigatable(@NotNull final Project project, @NotNull final String stacktrace) {
if (myCustomFilter.isEmpty()) {
return null;
}
// iterate stacktrace lines find first navigatable line using
// stacktrace filters
final int stacktraceLength = stacktrace.length();
final String[] lines = StringUtil.splitByLines(stacktrace);
for (String line : lines) {
Filter.Result result;
try {
result = myCustomFilter.applyFilter(line, stacktraceLength);
} catch (Throwable t) {
throw new RuntimeException("Error while applying " + myCustomFilter + " to '" + line + "'", t);
}
final HyperlinkInfo info = result != null ? result.getFirstHyperlinkInfo() : null;
if (info != null) {
// covers 99% use existing cases
if (info instanceof FileHyperlinkInfo) {
return ((FileHyperlinkInfo) info).getDescriptor();
}
// otherwise
return new Navigatable() {
@Override
public void navigate(boolean requestFocus) {
info.navigate(project);
}
@Override
public boolean canNavigate() {
return true;
}
@Override
public boolean canNavigateToSource() {
return true;
}
};
}
}
return null;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OpenRepositoryVersionAction method openRepositoryVersion.
private static void openRepositoryVersion(@NotNull Project project, @NotNull Change[] changes) {
for (Change change : changes) {
ContentRevision revision = change.getAfterRevision();
if (revision == null || revision.getFile().isDirectory())
continue;
VirtualFile vFile = ContentRevisionVirtualFile.create(revision);
Navigatable navigatable = new OpenFileDescriptor(project, vFile);
navigatable.navigate(true);
}
}
use of com.intellij.pom.Navigatable in project android by JetBrains.
the class EditMultipleSourcesAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
assert project != null;
final Navigatable[] files = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
assert files != null && files.length > 0;
if (files.length > 1) {
DefaultListModel listModel = new DefaultListModel();
for (int i = 0; i < files.length; ++i) {
assert files[i] instanceof PsiClassNavigation;
//noinspection unchecked
listModel.add(i, ((PsiClassNavigation) files[i]).getPsiFile());
}
final JBList list = new JBList(listModel);
int width = WindowManager.getInstance().getFrame(project).getSize().width;
list.setCellRenderer(new GotoFileCellRenderer(width));
JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle("Choose Target File").setItemChoosenCallback(new Runnable() {
@Override
public void run() {
Object selectedValue = list.getSelectedValue();
PsiClassNavigation navigationWrapper = null;
for (Navigatable file : files) {
if (selectedValue == ((PsiClassNavigation) file).getPsiFile()) {
navigationWrapper = (PsiClassNavigation) file;
break;
}
}
assert navigationWrapper != null;
if (navigationWrapper.canNavigate()) {
navigationWrapper.navigate(true);
}
}
}).createPopup();
if (e.getInputEvent().getSource() instanceof ActionButton) {
popup.showUnderneathOf((ActionButton) e.getInputEvent().getSource());
} else {
popup.showInBestPositionFor(e.getDataContext());
}
} else {
assert files[0] instanceof PsiClassNavigation;
PsiClassNavigation file = (PsiClassNavigation) files[0];
if (file.canNavigate()) {
file.navigate(true);
}
}
}
use of com.intellij.pom.Navigatable in project android by JetBrains.
the class SyncMessages method report.
public void report(@NotNull SyncMessage message) {
String title = message.getGroup();
String text = join(message.getText(), "\n");
NotificationCategory category = message.getType().convertToCategory();
PositionInFile position = message.getPosition();
NotificationData notification = createNotification(title, text, category, position);
Navigatable navigatable = message.getNavigatable();
notification.setNavigatable(navigatable);
List<NotificationHyperlink> quickFixes = message.getQuickFixes();
if (!quickFixes.isEmpty()) {
updateNotification(notification, text, quickFixes);
}
report(notification);
}
Aggregations