本文整理汇总了Java中com.intellij.util.Alarm.addRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Alarm.addRequest方法的具体用法?Java Alarm.addRequest怎么用?Java Alarm.addRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.Alarm
的用法示例。
在下文中一共展示了Alarm.addRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitProcess
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public void waitProcess(final ProcessHandler processHandler) {
Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, getTestRootDisposable());
final boolean[] isRunning = {true};
alarm.addRequest(new Runnable() {
@Override
public void run() {
boolean b;
synchronized (isRunning) {
b = isRunning[0];
}
if (b) {
processHandler.destroyProcess();
LOG.error("process was running over " + myTimeout / 1000 + " seconds. Interrupted. ");
}
}
}, myTimeout);
processHandler.waitFor();
synchronized (isRunning) {
isRunning[0] = false;
}
alarm.dispose();
}
示例2: waitFor
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public void waitFor(Runnable r) {
Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, getTestRootDisposable());
final Thread thread = Thread.currentThread();
final boolean[] isRunning = {true};
alarm.addRequest(new Runnable() {
@Override
public void run() {
boolean b;
synchronized (isRunning) {
b = isRunning[0];
}
if (b) {
thread.interrupt();
LOG.error("test was running over " + myTimeout / 1000 + " seconds. Interrupted. ");
}
}
}, myTimeout);
r.run();
synchronized (isRunning) {
isRunning[0] = false;
}
Thread.interrupted();
}
示例3: addNotify
import com.intellij.util.Alarm; //导入方法依赖的package包/类
@Override
public void addNotify() {
super.addNotify();
final String key = "toolwindow.stripes.buttons.info.shown";
if (UISettings.getInstance().HIDE_TOOL_STRIPES && !PropertiesComponent.getInstance().isTrueValue(key)) {
PropertiesComponent.getInstance().setValue(key, String.valueOf(true));
final Alarm alarm = new Alarm();
alarm.addRequest(new Runnable() {
@Override
public void run() {
GotItMessage.createMessage(UIBundle.message("tool.window.quick.access.title"), UIBundle.message(
"tool.window.quick.access.message"))
.setDisposable(ToolWindowsWidget.this)
.show(new RelativePoint(ToolWindowsWidget.this, new Point(10, 0)), Balloon.Position.above);
Disposer.dispose(alarm);
}
}, 20000);
}
}
示例4: ControlledCycle
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public ControlledCycle(final Project project, final Getter<Boolean> callback, @NotNull final String name, final int refreshInterval) {
myRefreshInterval = (refreshInterval <= 0) ? ourRefreshInterval : refreshInterval;
myActive = new AtomicBoolean(false);
myRunnable = new Runnable() {
boolean shouldBeContinued = true;
public void run() {
if (! myActive.get() || project.isDisposed()) return;
try {
shouldBeContinued = callback.get();
} catch (ProcessCanceledException e) {
return;
} catch (RuntimeException e) {
LOG.info(e);
}
if (! shouldBeContinued) {
myActive.set(false);
} else {
mySimpleAlarm.addRequest(myRunnable, myRefreshInterval);
}
}
};
mySimpleAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
}
示例5: AsyncPopupImpl
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public AsyncPopupImpl(@Nullable WizardPopup parent, @Nonnull AsyncPopupStep step, Object parentValue) {
super(parent, step);
if (!(parent instanceof NextStepHandler)) throw new IllegalArgumentException("parent must be NextStepHandler");
myCallBackParent = (NextStepHandler)parent;
myParentValue = parentValue;
myFuture = ApplicationManager.getApplication().executeOnPooledThread(step);
myAlarm = new Alarm(this);
myAlarm.addRequest(this, 200);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
if (!myFuture.isCancelled() && !myFuture.isDone()) {
myFuture.cancel(false);
}
}
});
}
示例6: ControlledCycle
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public ControlledCycle(final Project project, final Getter<Boolean> callback, @Nonnull final String name, final int refreshInterval) {
myRefreshInterval = (refreshInterval <= 0) ? ourRefreshInterval : refreshInterval;
myActive = new AtomicBoolean(false);
myRunnable = new Runnable() {
boolean shouldBeContinued = true;
@Override
public void run() {
if (! myActive.get() || project.isDisposed()) return;
try {
shouldBeContinued = callback.get();
} catch (ProcessCanceledException e) {
return;
} catch (RuntimeException e) {
LOG.info(e);
}
if (! shouldBeContinued) {
myActive.set(false);
} else {
mySimpleAlarm.addRequest(myRunnable, myRefreshInterval);
}
}
};
mySimpleAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
}
示例7: openTargets
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public static void openTargets(MouseEvent e,
NavigatablePsiElement[] targets,
String title,
final String findUsagesTitle,
ListCellRenderer listRenderer,
@Nullable ListBackgroundUpdaterTask listUpdaterTask) {
JBPopup popup = navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask);
if (popup != null) {
if (listUpdaterTask != null) {
Alarm alarm = new Alarm(popup);
alarm.addRequest(() -> popup.show(new RelativePoint(e)), 300);
ProgressManager.getInstance().run(listUpdaterTask);
}
else {
popup.show(new RelativePoint(e));
}
}
}
示例8: rebuildWithAlarm
import com.intellij.util.Alarm; //导入方法依赖的package包/类
protected void rebuildWithAlarm(final Alarm alarm) {
alarm.cancelAllRequests();
alarm.addRequest(() -> {
final Set<VirtualFile> files = new HashSet<>();
DumbService.getInstance(myProject).runReadActionInSmartMode(() -> {
if (myTodoTreeBuilder.isDisposed()) return;
myTodoTreeBuilder.collectFiles(virtualFile -> {
files.add(virtualFile);
return true;
});
final Runnable runnable = () -> {
if (myTodoTreeBuilder.isDisposed()) return;
myTodoTreeBuilder.rebuildCache(files);
updateTree();
};
ApplicationManager.getApplication().invokeLater(runnable);
});
}, 300);
}
示例9: terminateAndInvoke
import com.intellij.util.Alarm; //导入方法依赖的package包/类
/**
* waits COMMAND_TIMEOUT milliseconds
* if worker thread is still processing the same command
* calls terminateCommand
*/
public void terminateAndInvoke(DebuggerCommandImpl command, int terminateTimeout) {
final DebuggerCommandImpl currentCommand = myEvents.getCurrentEvent();
invoke(command);
if (currentCommand != null) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
alarm.addRequest(new Runnable() {
@Override
public void run() {
try {
if (currentCommand == myEvents.getCurrentEvent()) {
// if current command is still in progress, cancel it
getCurrentRequest().requestStop();
try {
getCurrentRequest().join();
}
catch (InterruptedException ignored) {
}
catch (Exception e) {
throw new RuntimeException(e);
}
finally {
if (!myDisposed) {
startNewWorkerThread();
}
}
}
}
finally {
Disposer.dispose(alarm);
}
}
}, terminateTimeout);
}
}
示例10: animate
import com.intellij.util.Alarm; //导入方法依赖的package包/类
private void animate() {
final int height = getPreferredSize().height;
final int frameCount = 10;
final boolean toClose = isShowing();
final AtomicInteger i = new AtomicInteger(-1);
final Alarm animator = new Alarm(myDisposable);
final Runnable runnable = new Runnable() {
@Override
public void run() {
int state = i.addAndGet(1);
double linearProgress = (double)state / frameCount;
if (toClose) {
linearProgress = 1 - linearProgress;
}
myLayout.myPhase = (1 - Math.cos(Math.PI * linearProgress)) / 2;
Window window = getPeer().getWindow();
Rectangle bounds = window.getBounds();
bounds.height = (int)(height * myLayout.myPhase);
window.setBounds(bounds);
if (state == 0 && !toClose && window.getOwner() instanceof IdeFrame) {
WindowManager.getInstance().requestUserAttention((IdeFrame)window.getOwner(), true);
}
if (state < frameCount) {
animator.addRequest(this, 10);
}
else if (toClose) {
MessageDialog.super.dispose();
}
}
};
animator.addRequest(runnable, 10, ModalityState.stateForComponent(getRootPane()));
}
示例11: createRequest
import com.intellij.util.Alarm; //导入方法依赖的package包/类
private static Runnable createRequest(final Project project, final Alarm alarm) {
return new Runnable() {
@Override
public void run() {
if (! ((StartupManagerEx) StartupManager.getInstance(project)).postStartupActivityPassed()) {
alarm.addRequest(createRequest(project, alarm), DELAY_MILLIS);
} else {
runActivities(project);
}
}
};
}
示例12: doShow
import com.intellij.util.Alarm; //导入方法依赖的package包/类
private static void doShow(@NotNull final ExecutionConsole executionConsole) {
final Alarm alarm = new Alarm();
alarm.addRequest(new Runnable() {
@Override
public void run() {
String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(
ActionManager.getInstance().getAction(RerunTestsAction.ID)
);
if (shortcutText.isEmpty()) {
return;
}
GotItMessage message = GotItMessage.createMessage("Rerun tests with " + shortcutText, "");
message.setDisposable(executionConsole);
message.setCallback(new Runnable() {
@Override
public void run() {
PropertiesComponent.getInstance().setValue(KEY, true);
}
});
message.setShowCallout(false);
Dimension consoleSize = executionConsole.getComponent().getSize();
message.show(
new RelativePoint(
executionConsole.getComponent(),
new Point(consoleSize.width - 185, consoleSize.height - 60)
),
Balloon.Position.below
);
Disposer.dispose(alarm);
}
}, 1000);
}
示例13: createAlarmForAutogeneration
import com.intellij.util.Alarm; //导入方法依赖的package包/类
private void createAlarmForAutogeneration() {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myDisposable);
alarm.addRequest(new Runnable() {
@Override
public void run() {
final Map<AndroidFacet, Collection<AndroidAutogeneratorMode>> facetsToProcess =
new HashMap<AndroidFacet, Collection<AndroidAutogeneratorMode>>();
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
final Module[] modulesCopy = Arrays.copyOf(modules, modules.length);
for (Module module : modulesCopy) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null && facet.isAutogenerationEnabled()) {
final Set<AndroidAutogeneratorMode> modes = EnumSet.noneOf(AndroidAutogeneratorMode.class);
for (AndroidAutogeneratorMode mode : AndroidAutogeneratorMode.values()) {
if (facet.cleanRegeneratingState(mode) || facet.isGeneratedFileRemoved(mode)) {
modes.add(mode);
}
}
if (modes.size() > 0) {
facetsToProcess.put(facet, modes);
}
}
}
if (facetsToProcess.size() > 0) {
generate(facetsToProcess);
}
if (!alarm.isDisposed()) {
alarm.addRequest(this, 2000);
}
}
}, 2000);
}
示例14: testCancellation
import com.intellij.util.Alarm; //导入方法依赖的package包/类
public void testCancellation() {
if (GraphicsEnvironment.isHeadless()) {
System.err.println("** skipped in headless env.");
return;
}
final VirtualFile file = getTestFile(PlatformTestUtil.getRtJarPath() + "!/javax/swing/JTable.class");
final IdeaDecompiler decompiler = (IdeaDecompiler)ClassFileDecompilers.find(file);
assertNotNull(decompiler);
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, getProject());
alarm.addRequest(new Runnable() {
@Override
public void run() {
ProgressIndicator progress = decompiler.getProgress(file);
if (progress != null) {
progress.cancel();
}
else {
alarm.addRequest(this, 200, ModalityState.any());
}
}
}, 750, ModalityState.any());
try {
FileDocumentManager.getInstance().getDocument(file);
fail("should have been cancelled");
}
catch (ProcessCanceledException ignored) { }
}
示例15: SshConnectionPool
import com.intellij.util.Alarm; //导入方法依赖的package包/类
private SshConnectionPool() {
myPool = new HashMap<MyKey, SshSharedConnection>();
myLock = new Object();
myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, ApplicationManager.getApplication());
myAlarm.addRequest(new Runnable() {
public void run() {
controlPoolState();
myAlarm.addRequest(this, CONTROL_INTERVAL);
}
}, CONTROL_INTERVAL);
}