Search in sources :

Example 21 with CalledInAwt

use of org.jetbrains.annotations.CalledInAwt in project intellij-community by JetBrains.

the class ApplyPatchDefaultExecutor method apply.

@CalledInAwt
@Override
public void apply(@NotNull List<FilePatch> remaining, @NotNull MultiMap<VirtualFile, AbstractFilePatchInProgress> patchGroupsToApply, @Nullable LocalChangeList localList, @Nullable String fileName, @Nullable ThrowableComputable<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo) {
    final CommitContext commitContext = new CommitContext();
    applyAdditionalInfoBefore(myProject, additionalInfo, commitContext);
    final Collection<PatchApplier> appliers = getPatchAppliers(patchGroupsToApply, localList, commitContext);
    executeAndApplyAdditionalInfo(localList, additionalInfo, commitContext, appliers);
}
Also used : PatchApplier(com.intellij.openapi.diff.impl.patch.formove.PatchApplier) CommitContext(com.intellij.openapi.vcs.changes.CommitContext) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 22 with CalledInAwt

use of org.jetbrains.annotations.CalledInAwt in project intellij-community by JetBrains.

the class BackgroundTaskUtil method executeAndTryWait.

@NotNull
@CalledInAwt
public static ProgressIndicator executeAndTryWait(@NotNull Function<ProgressIndicator, /*@NotNull*/
Runnable> backgroundTask, @Nullable Runnable onSlowAction, long waitMillis, boolean forceEDT) {
    ModalityState modality = ModalityState.current();
    if (forceEDT) {
        ProgressIndicator indicator = new EmptyProgressIndicator(modality);
        try {
            Runnable callback = backgroundTask.fun(indicator);
            finish(callback, indicator);
        } catch (ProcessCanceledException ignore) {
        } catch (Throwable t) {
            LOG.error(t);
        }
        return indicator;
    } else {
        Pair<Runnable, ProgressIndicator> pair = computeInBackgroundAndTryWait(backgroundTask, (callback, indicator) -> {
            ApplicationManager.getApplication().invokeLater(() -> {
                finish(callback, indicator);
            }, modality);
        }, modality, waitMillis);
        Runnable callback = pair.first;
        ProgressIndicator indicator = pair.second;
        if (callback != null) {
            finish(callback, indicator);
        } else {
            if (onSlowAction != null)
                onSlowAction.run();
        }
        return indicator;
    }
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ModalityState(com.intellij.openapi.application.ModalityState) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) CalledInAwt(org.jetbrains.annotations.CalledInAwt) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with CalledInAwt

use of org.jetbrains.annotations.CalledInAwt in project intellij-community by JetBrains.

the class BackgroundTaskUtil method tryComputeFast.

/**
   * Try to compute value in background and abort computation if it takes too long.
   * <ul>
   * <li> If the computation is fast, return computed value.
   * <li> If the computation is slow, abort computation (cancel ProgressIndicator).
   * </ul>
   */
@Nullable
@CalledInAwt
public static <T> T tryComputeFast(@NotNull Function<ProgressIndicator, T> backgroundTask, long waitMillis) {
    Pair<T, ProgressIndicator> pair = computeInBackgroundAndTryWait(backgroundTask, (result, indicator) -> {
    }, ModalityState.defaultModalityState(), waitMillis);
    T result = pair.first;
    ProgressIndicator indicator = pair.second;
    indicator.cancel();
    return result;
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) CalledInAwt(org.jetbrains.annotations.CalledInAwt) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with CalledInAwt

use of org.jetbrains.annotations.CalledInAwt in project intellij-community by JetBrains.

the class VcsDiffUtil method showDiffFor.

@CalledInAwt
public static void showDiffFor(@NotNull Project project, @NotNull final Collection<Change> changes, @NotNull final String revNumTitle1, @NotNull final String revNumTitle2, @NotNull final FilePath filePath) {
    if (filePath.isDirectory()) {
        showChangesDialog(project, getDialogTitle(filePath, revNumTitle1, revNumTitle2), ContainerUtil.newArrayList(changes));
    } else {
        if (changes.isEmpty()) {
            DiffManager.getInstance().showDiff(project, new MessageDiffRequest("No Changes Found"));
        } else {
            final HashMap<Key, Object> revTitlesMap = new HashMap<>(2);
            revTitlesMap.put(VCS_DIFF_LEFT_CONTENT_TITLE, revNumTitle1);
            revTitlesMap.put(VCS_DIFF_RIGHT_CONTENT_TITLE, revNumTitle2);
            ShowDiffContext showDiffContext = new ShowDiffContext() {

                @NotNull
                @Override
                public Map<Key, Object> getChangeContext(@NotNull Change change) {
                    return revTitlesMap;
                }
            };
            ShowDiffAction.showDiffForChange(project, changes, 0, showDiffContext);
        }
    }
}
Also used : MessageDiffRequest(com.intellij.diff.requests.MessageDiffRequest) HashMap(com.intellij.util.containers.hash.HashMap) ShowDiffContext(com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull) Key(com.intellij.openapi.util.Key) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 25 with CalledInAwt

use of org.jetbrains.annotations.CalledInAwt in project intellij-community by JetBrains.

the class HgIncomingOutgoingWidget method deactivate.

@CalledInAwt
public void deactivate() {
    if (!isAlreadyShown)
        return;
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (null != statusBar) {
        statusBar.removeWidget(ID());
        isAlreadyShown = false;
    }
}
Also used : StatusBar(com.intellij.openapi.wm.StatusBar) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Aggregations

CalledInAwt (org.jetbrains.annotations.CalledInAwt)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 Project (com.intellij.openapi.project.Project)5 NotNull (org.jetbrains.annotations.NotNull)5 FileEditor (com.intellij.openapi.fileEditor.FileEditor)4 Nullable (org.jetbrains.annotations.Nullable)4 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)3 StatusBar (com.intellij.openapi.wm.StatusBar)3 SyncScrollSupport (com.intellij.diff.tools.util.SyncScrollSupport)2 TextDiffViewerUtil (com.intellij.diff.tools.util.base.TextDiffViewerUtil)2 Document (com.intellij.openapi.editor.Document)2 Editor (com.intellij.openapi.editor.Editor)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)2 List (java.util.List)2 MessageDiffRequest (com.intellij.diff.requests.MessageDiffRequest)1 ThreesideSyncScrollSupport (com.intellij.diff.tools.util.SyncScrollSupport.ThreesideSyncScrollSupport)1 TwosideSyncScrollSupport (com.intellij.diff.tools.util.SyncScrollSupport.TwosideSyncScrollSupport)1