use of com.intellij.openapi.util.NamedRunnable in project intellij-community by JetBrains.
the class AbstractVcsLogUi method jumpTo.
private <T> void jumpTo(@NotNull final T commitId, @NotNull final PairFunction<GraphTableModel, T, Integer> rowGetter, @NotNull final SettableFuture<Boolean> future) {
if (future.isCancelled())
return;
GraphTableModel model = getTable().getModel();
int row = rowGetter.fun(model, commitId);
if (row >= 0) {
getTable().jumpToRow(row);
future.set(true);
} else if (model.canRequestMore()) {
model.requestToLoadMore(() -> jumpTo(commitId, rowGetter, future));
} else if (!myVisiblePack.isFull()) {
invokeOnChange(() -> jumpTo(commitId, rowGetter, future));
} else {
if (getFilters().isEmpty()) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "Commit " + commitId.toString() + " not found.", MessageType.WARNING);
} else {
String message = "Commit " + commitId.toString() + " does not exist or does not match active filters";
VcsBalloonProblemNotifier.showOverChangesView(myProject, message, MessageType.WARNING, new NamedRunnable("Reset filters and search again") {
@Override
public void run() {
getFilterUi().setFilter(null);
invokeOnChange(() -> jumpTo(commitId, rowGetter, SettableFuture.create()));
}
});
}
future.set(false);
}
}
use of com.intellij.openapi.util.NamedRunnable in project intellij-community by JetBrains.
the class VcsBalloonProblemNotifier method show.
private static void show(final Project project, final String message, final MessageType type, @Nullable final NamedRunnable[] notificationListener) {
final Application application = ApplicationManager.getApplication();
if (application.isHeadlessEnvironment())
return;
final Runnable showErrorAction = () -> new VcsBalloonProblemNotifier(project, message, type, notificationListener).run();
if (application.isDispatchThread()) {
showErrorAction.run();
} else {
application.invokeLater(showErrorAction);
}
}
use of com.intellij.openapi.util.NamedRunnable in project intellij-community by JetBrains.
the class VcsBalloonProblemNotifier method run.
public void run() {
final Notification notification;
if (myNotificationListener != null && myNotificationListener.length > 0) {
final StringBuilder sb = new StringBuilder(myMessage);
for (NamedRunnable runnable : myNotificationListener) {
final String name = runnable.toString();
sb.append("<br/><a href=\"").append(name).append("\">").append(name).append("</a>");
}
NotificationListener listener = (currentNotification, event) -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(event.getEventType())) {
if (myNotificationListener.length == 1) {
myNotificationListener[0].run();
} else {
final String description = event.getDescription();
if (description != null) {
for (NamedRunnable runnable : myNotificationListener) {
if (description.equals(runnable.toString())) {
runnable.run();
break;
}
}
}
}
currentNotification.expire();
}
};
notification = NOTIFICATION_GROUP.createNotification("", sb.toString(), myMessageType.toNotificationType(), listener);
} else {
notification = NOTIFICATION_GROUP.createNotification(myMessage, myMessageType);
}
notification.notify(myProject.isDefault() ? null : myProject);
}
Aggregations