Search in sources :

Example 1 with NamedRunnable

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);
    }
}
Also used : GraphTableModel(com.intellij.vcs.log.ui.table.GraphTableModel) NamedRunnable(com.intellij.openapi.util.NamedRunnable)

Example 2 with NamedRunnable

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);
    }
}
Also used : NamedRunnable(com.intellij.openapi.util.NamedRunnable) Application(com.intellij.openapi.application.Application)

Example 3 with NamedRunnable

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);
}
Also used : Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) Application(com.intellij.openapi.application.Application) MessageType(com.intellij.openapi.ui.MessageType) HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotificationGroup(com.intellij.notification.NotificationGroup) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Project(com.intellij.openapi.project.Project) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) NamedRunnable(com.intellij.openapi.util.NamedRunnable) NotNull(org.jetbrains.annotations.NotNull) NotificationListener(com.intellij.notification.NotificationListener) NamedRunnable(com.intellij.openapi.util.NamedRunnable) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

NamedRunnable (com.intellij.openapi.util.NamedRunnable)3 Application (com.intellij.openapi.application.Application)2 Notification (com.intellij.notification.Notification)1 NotificationGroup (com.intellij.notification.NotificationGroup)1 NotificationListener (com.intellij.notification.NotificationListener)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Project (com.intellij.openapi.project.Project)1 MessageType (com.intellij.openapi.ui.MessageType)1 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)1 GraphTableModel (com.intellij.vcs.log.ui.table.GraphTableModel)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1