use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class RollbackDeletionAction method processFiles.
protected List<VcsException> processFiles(final AbstractVcs vcs, final List<FilePath> files) {
RollbackEnvironment environment = vcs.getRollbackEnvironment();
if (environment == null)
return Collections.emptyList();
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setText(vcs.getDisplayName() + ": performing rollback...");
}
final List<VcsException> result = new ArrayList<>(0);
try {
environment.rollbackMissingFileDeletion(files, result, new RollbackProgressModifier(files.size(), indicator));
} catch (ProcessCanceledException e) {
// for files refresh
}
LocalFileSystem.getInstance().refreshIoFiles(ChangesUtil.filePathsToFiles(files));
return result;
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class ApplierCompleter method wrapInReadActionAndIndicator.
private void wrapInReadActionAndIndicator(@NotNull final Runnable process) {
Runnable toRun = runInReadAction ? () -> {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(process)) {
failedSubTasks.add(this);
doComplete(throwable);
}
} : process;
ProgressIndicator existing = ProgressManager.getInstance().getProgressIndicator();
if (existing == progressIndicator) {
// we are already wrapped in an indicator - most probably because we came here from helper which steals children tasks
toRun.run();
} else {
ProgressManager.getInstance().executeProcessUnderProgress(toRun, progressIndicator);
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class JobLauncherImpl method invokeConcurrentlyUnderProgress.
@Override
public <T> boolean invokeConcurrentlyUnderProgress(@NotNull final List<T> things, ProgressIndicator progress, boolean runInReadAction, boolean failFastOnAcquireReadAction, @NotNull final Processor<? super T> thingProcessor) throws ProcessCanceledException {
// supply our own indicator even if we haven't given one - to support cancellation
// use StandardProgressIndicator by default to avoid assertion in SensitiveProgressWrapper() ctr later
final ProgressIndicator wrapper = progress == null ? new StandardProgressIndicatorBase() : new SensitiveProgressWrapper(progress);
Boolean result = processImmediatelyIfTooFew(things, wrapper, runInReadAction, thingProcessor);
if (result != null)
return result.booleanValue();
HeavyProcessLatch.INSTANCE.stopThreadPrioritizing();
List<ApplierCompleter<T>> failedSubTasks = Collections.synchronizedList(new ArrayList<>());
ApplierCompleter<T> applier = new ApplierCompleter<>(null, runInReadAction, failFastOnAcquireReadAction, wrapper, things, thingProcessor, 0, things.size(), failedSubTasks, null);
try {
ForkJoinPool.commonPool().invoke(applier);
if (applier.throwable != null)
throw applier.throwable;
} catch (ApplierCompleter.ComputationAbortedException e) {
// one of the processors returned false
return false;
} catch (ApplicationUtil.CannotRunReadActionException e) {
// failFastOnAcquireReadAction==true and one of the processors called runReadAction() during the pending write action
throw e;
} catch (ProcessCanceledException e) {
// then task2 calls checkCancel() and get here
return false;
} catch (RuntimeException | Error e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
assert applier.isDone();
return applier.completeTaskWhichFailToAcquireReadAction();
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class ToggleDumbModeAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
if (myDumb) {
myDumb = false;
} else {
myDumb = true;
final Project project = e.getProject();
if (project == null)
return;
DumbServiceImpl.getInstance(project).queueTask(new DumbModeTask() {
@Override
public void performInDumbMode(@NotNull ProgressIndicator indicator) {
while (myDumb) {
indicator.checkCanceled();
TimeoutUtil.sleep(100);
}
}
});
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class MacMessagesTest method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent anActionEvent) {
JDialog controlDialog = new JDialog();
controlDialog.setTitle("Messages testing control panel");
controlDialog.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
controlDialog.setModal(false);
controlDialog.setFocusableWindowState(false);
controlDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container cp = controlDialog.getContentPane();
cp.setLayout(new FlowLayout());
JButton showDialogWrapperButton = new JButton("Show a dialog wrapper");
showDialogWrapperButton.setFocusable(false);
FocusManagerImpl fmi = FocusManagerImpl.getInstance();
final Project p = fmi.getLastFocusedFrame().getProject();
showDialogWrapperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
DialogWrapper dw = new SimpleDialogWrapper(p);
dw.setTitle(dw.getWindow().getName());
dw.show();
}
});
JButton showMessageButton = new JButton("Show a message");
showDialogWrapperButton.setFocusable(false);
showMessageButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
showTestMessage(p);
}
});
JButton showProgressIndicatorButton = new JButton("Show progress indicator");
showProgressIndicatorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Task task = new Task.Modal(null, "Test task", true) {
public void run(@NotNull final ProgressIndicator indicator) {
ApplicationManager.getApplication().invokeAndWait(() -> {
FocusManagerImpl fmi1 = FocusManagerImpl.getInstance();
final Project p1 = fmi1.getLastFocusedFrame().getProject();
showTestMessage(p1);
}, ModalityState.any());
}
@Override
public void onCancel() {
}
};
ProgressManager.getInstance().run(task);
}
});
cp.add(showDialogWrapperButton);
cp.add(showMessageButton);
cp.add(showProgressIndicatorButton);
controlDialog.pack();
controlDialog.setVisible(true);
}
Aggregations