Search in sources :

Example 1 with IGitMacheteRepositorySnapshot

use of com.virtuslab.gitmachete.backend.api.IGitMacheteRepositorySnapshot in project git-machete-intellij-plugin by VirtusLab.

the class EnhancedGraphTable method getSuccessfulDiscoverRepositoryConsumer.

private Consumer<IGitMacheteRepositorySnapshot> getSuccessfulDiscoverRepositoryConsumer(@UI Runnable doOnUIThreadWhenReady) {
    return (IGitMacheteRepositorySnapshot repositorySnapshot) -> UiThreadExecutionCompat.invokeLaterIfNeeded(NON_MODAL, () -> {
        gitMacheteRepositorySnapshot = repositorySnapshot;
        queueRepositoryUpdateAndModelRefresh(doOnUIThreadWhenReady);
        val notifier = VcsNotifier.getInstance(project);
        val notification = VcsNotifier.STANDARD_NOTIFICATION.createNotification(getString("string.GitMachete.EnhancedGraphTable.automatic-discover.success-message"), NotificationType.INFORMATION);
        notification.addAction(NotificationAction.createSimple(() -> getString("action.GitMachete.OpenMacheteFileAction.description"), () -> {
            val actionEvent = createAnActionEvent();
            ActionManager.getInstance().getAction(ACTION_OPEN_MACHETE_FILE).actionPerformed(actionEvent);
        }));
        notifier.notify(notification);
    });
}
Also used : lombok.val(lombok.val) IGitMacheteRepositorySnapshot(com.virtuslab.gitmachete.backend.api.IGitMacheteRepositorySnapshot)

Example 2 with IGitMacheteRepositorySnapshot

use of com.virtuslab.gitmachete.backend.api.IGitMacheteRepositorySnapshot in project git-machete-intellij-plugin by VirtusLab.

the class EnhancedGraphTable method queueRepositoryUpdateAndModelRefresh.

@Override
public void queueRepositoryUpdateAndModelRefresh(@UI Runnable doOnUIThreadWhenReady) {
    LOG.debug("Entering");
    if (!project.isDisposed()) {
        UiThreadExecutionCompat.invokeLaterIfNeeded(NON_MODAL, () -> {
            val gitRepositorySelectionProvider = getGitRepositorySelectionProvider();
            val gitRepository = gitRepositorySelectionProvider.getSelectedGitRepository().getOrNull();
            if (gitRepository == null) {
                LOG.warn("Selected repository is null");
                return;
            }
            @UI Consumer<Option<IGitMacheteRepositorySnapshot>> doRefreshModel = newGitMacheteRepositorySnapshot -> {
                val nullableRepositorySnapshot = newGitMacheteRepositorySnapshot.getOrNull();
                this.gitMacheteRepositorySnapshot = nullableRepositorySnapshot;
                if (nullableRepositorySnapshot != null) {
                    refreshModel(gitRepository, nullableRepositorySnapshot, doOnUIThreadWhenReady);
                } else {
                    refreshModel(gitRepository, NullGitMacheteRepositorySnapshot.getInstance(), doOnUIThreadWhenReady);
                }
            };
            setTextForEmptyTable(getString("string.GitMachete.EnhancedGraphTable.empty-table-text.loading"));
            LOG.debug("Queuing repository update onto a non-UI thread");
            new GitMacheteRepositoryUpdateBackgroundable(project, gitRepository, branchLayoutReader, doRefreshModel).queue();
            GitVfsUtils.getMacheteFile(gitRepository).forEach(macheteFile -> VfsUtil.markDirtyAndRefresh(/* async */
            true, /* recursive */
            false, /* reloadChildren */
            false, macheteFile));
        });
    } else {
        LOG.debug("Project is disposed");
    }
}
Also used : lombok.val(lombok.val) Match(io.vavr.API.Match) ACTION_OPEN_MACHETE_FILE(com.virtuslab.gitmachete.frontend.defs.ActionIds.ACTION_OPEN_MACHETE_FILE) Presentation(com.intellij.openapi.actionSystem.Presentation) Point(java.awt.Point) Timer(java.util.Timer) Topic(com.intellij.util.messages.Topic) SelectedGitRepositoryProvider(com.virtuslab.gitmachete.frontend.ui.providerservice.SelectedGitRepositoryProvider) Option(io.vavr.control.Option) JBUI(com.intellij.util.ui.JBUI) MouseAdapter(java.awt.event.MouseAdapter) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) BranchLayoutException(com.virtuslab.branchlayout.api.BranchLayoutException) NON_MODAL(com.intellij.openapi.application.ModalityState.NON_MODAL) TimerTask(java.util.TimerTask) GitRepository(git4idea.repo.GitRepository) ACTION_CHECK_OUT(com.virtuslab.gitmachete.frontend.defs.ActionIds.ACTION_CHECK_OUT) Path(java.nio.file.Path) ActionGroupIds(com.virtuslab.gitmachete.frontend.defs.ActionGroupIds) IGitRepositorySelectionProvider(com.virtuslab.gitmachete.frontend.ui.api.gitrepositoryselection.IGitRepositorySelectionProvider) DataKeys.typeSafeCase(com.virtuslab.gitmachete.frontend.datakeys.DataKeys.typeSafeCase) ScrollingUtil(com.intellij.ui.ScrollingUtil) GitVfsUtils.getMacheteFilePath(com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getMacheteFilePath) Case(io.vavr.API.Case) CustomLog(lombok.CustomLog) IBranchLayoutWriter(com.virtuslab.branchlayout.api.readwrite.IBranchLayoutWriter) GitMacheteBundle.getString(com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString) NotificationType(com.intellij.notification.NotificationType) Notification(com.intellij.notification.Notification) NullGitMacheteRepositorySnapshot(com.virtuslab.gitmachete.backend.api.NullGitMacheteRepositorySnapshot) GitMacheteBundle.format(com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.format) PopupMenuEvent(javax.swing.event.PopupMenuEvent) GitVfsUtils(com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) GitRepositoryChangeListener(git4idea.repo.GitRepositoryChangeListener) IRepositoryGraphCache(com.virtuslab.gitmachete.frontend.graph.api.repository.IRepositoryGraphCache) ApplicationManager(com.intellij.openapi.application.ApplicationManager) DataProvider(com.intellij.openapi.actionSystem.DataProvider) ACTION_PLACE_VCS_NOTIFICATION(com.virtuslab.gitmachete.frontend.defs.ActionPlaces.ACTION_PLACE_VCS_NOTIFICATION) UI(org.checkerframework.checker.guieffect.qual.UI) IBranchLayoutReader(com.virtuslab.branchlayout.api.readwrite.IBranchLayoutReader) VcsNotifier(com.intellij.openapi.vcs.VcsNotifier) ACTION_PLACE_CONTEXT_MENU(com.virtuslab.gitmachete.frontend.defs.ActionPlaces.ACTION_PLACE_CONTEXT_MENU) ListSelectionModel(javax.swing.ListSelectionModel) Setter(lombok.Setter) DataContext(com.intellij.openapi.actionSystem.DataContext) Getter(lombok.Getter) IntelliJNotificationCompat(com.virtuslab.gitmachete.frontend.compat.IntelliJNotificationCompat) BaseEnhancedGraphTable(com.virtuslab.gitmachete.frontend.ui.api.table.BaseEnhancedGraphTable) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) IGitMacheteRepositorySnapshot(com.virtuslab.gitmachete.backend.api.IGitMacheteRepositorySnapshot) ActionManager(com.intellij.openapi.actionSystem.ActionManager) SwingUtilities(javax.swing.SwingUtilities) BranchOrCommitCellRenderer(com.virtuslab.gitmachete.frontend.ui.impl.cell.BranchOrCommitCellRenderer) Project(com.intellij.openapi.project.Project) DataManager(com.intellij.ide.DataManager) Nullable(org.checkerframework.checker.nullness.qual.Nullable) API.$(io.vavr.API.$) NullRepositoryGraph(com.virtuslab.gitmachete.frontend.graph.api.repository.NullRepositoryGraph) Set(io.vavr.collection.Set) IGraphItem(com.virtuslab.gitmachete.frontend.graph.api.items.IGraphItem) Files(java.nio.file.Files) RuntimeBinding(com.virtuslab.binding.RuntimeBinding) IRepositoryGraph(com.virtuslab.gitmachete.frontend.graph.api.repository.IRepositoryGraph) JPopupMenu(javax.swing.JPopupMenu) lombok.val(lombok.val) BranchOrCommitCell(com.virtuslab.gitmachete.frontend.ui.impl.cell.BranchOrCommitCell) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) MouseEvent(java.awt.event.MouseEvent) UiThreadExecutionCompat(com.virtuslab.gitmachete.frontend.compat.UiThreadExecutionCompat) Consumer(java.util.function.Consumer) UIEffect(org.checkerframework.checker.guieffect.qual.UIEffect) NotificationAction(com.intellij.notification.NotificationAction) VfsUtil(com.intellij.openapi.vfs.VfsUtil) DataKeys(com.virtuslab.gitmachete.frontend.datakeys.DataKeys) PopupMenuListenerAdapter(com.intellij.ui.PopupMenuListenerAdapter) JBUI(com.intellij.util.ui.JBUI) UI(org.checkerframework.checker.guieffect.qual.UI) Option(io.vavr.control.Option)

Aggregations

IGitMacheteRepositorySnapshot (com.virtuslab.gitmachete.backend.api.IGitMacheteRepositorySnapshot)2 lombok.val (lombok.val)2 DataManager (com.intellij.ide.DataManager)1 Notification (com.intellij.notification.Notification)1 NotificationAction (com.intellij.notification.NotificationAction)1 NotificationType (com.intellij.notification.NotificationType)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 DataProvider (com.intellij.openapi.actionSystem.DataProvider)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 NON_MODAL (com.intellij.openapi.application.ModalityState.NON_MODAL)1 Project (com.intellij.openapi.project.Project)1 VcsNotifier (com.intellij.openapi.vcs.VcsNotifier)1 VfsUtil (com.intellij.openapi.vfs.VfsUtil)1 PopupMenuListenerAdapter (com.intellij.ui.PopupMenuListenerAdapter)1 ScrollingUtil (com.intellij.ui.ScrollingUtil)1