com.intellij.openapi.application.ex.ApplicationManagerEx Java Examples
The following examples show how to use
com.intellij.openapi.application.ex.ApplicationManagerEx.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplierCompleter.java From consulo with Apache License 2.0 | 6 votes |
private void wrapInReadActionAndIndicator(@Nonnull 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); } }
Example #2
Source File: LoadAllVfsStoredContentsAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e) { ApplicationEx application = ApplicationManagerEx.getApplicationEx(); String m = "Started loading content"; LOG.info(m); System.out.println(m); long start = System.currentTimeMillis(); count.set(0); totalSize.set(0); application.runProcessWithProgressSynchronously(() -> { PersistentFS vfs = (PersistentFS)application.getComponent(ManagingFS.class); VirtualFile[] roots = vfs.getRoots(); for (VirtualFile root : roots) { iterateCached(root); } }, "Loading", false, null); long end = System.currentTimeMillis(); String message = "Finished loading content of " + count + " files. " + "Total size=" + StringUtil.formatFileSize(totalSize.get()) + ". " + "Elapsed=" + ((end - start) / 1000) + "sec."; LOG.info(message); System.out.println(message); }
Example #3
Source File: LegalNotice.java From KodeBeagle with Apache License 2.0 | 5 votes |
@NotNull @Override protected final Action[] createActions() { DialogWrapperAction declineAction = new DialogWrapperAction(DECLINE) { @Override protected final void doAction(final ActionEvent e) { PluginManagerCore.disablePlugin(KODEBEAGLEIDEA); ApplicationManagerEx.getApplicationEx().restart(true); } }; return new Action[]{getOKAction(), declineAction, getCancelAction()}; }
Example #4
Source File: ProjectSettingsForm.java From EclipseCodeFormatter with Apache License 2.0 | 5 votes |
public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes, final Runnable onNo, int defaultOptionIndex) { final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) { @Override public PopupStep onChosen(String selectedValue, final boolean finalChoice) { if (selectedValue.equals(yesText)) { onYes.run(); } else { onNo.run(); } return FINAL_CHOICE; } @Override public void canceled() { } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText); }
Example #5
Source File: CustomizeDownloadAndStartStepPanel.java From consulo with Apache License 2.0 | 5 votes |
private JButton createStartButton() { JButton button = new JButton(getStartName()); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myCustomizeIDEWizardDialog.close(DialogWrapper.CLOSE_EXIT_CODE); ApplicationManagerEx.getApplicationEx().restart(true); } }); return button; }
Example #6
Source File: FocusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public AsyncResult<Void> requestFocusInProject(@Nonnull Component c, @Nullable Project project) { if (ApplicationManagerEx.getApplicationEx().isActive() || !Registry.is("suppress.focus.stealing")) { c.requestFocus(); } else { c.requestFocusInWindow(); } return AsyncResult.resolved(); }
Example #7
Source File: FocusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public AsyncResult<Void> requestDefaultFocus(boolean forced) { Component toFocus = null; if (myLastFocusedFrame != null) { toFocus = myLastFocused.get(myLastFocusedFrame); if (toFocus == null || !toFocus.isShowing()) { toFocus = getFocusTargetFor(myLastFocusedFrame.getComponent()); } } else{ Optional<Component> toFocusOptional = Arrays.stream(Window.getWindows()). filter(window -> window instanceof RootPaneContainer). filter(window -> ((RootPaneContainer)window).getRootPane() != null). filter(window -> window.isActive()). findFirst(). map(w -> getFocusTargetFor(((RootPaneContainer)w).getRootPane())); if (toFocusOptional.isPresent()) { toFocus = toFocusOptional.get(); } } if (toFocus != null) { if (ApplicationManagerEx.getApplicationEx().isActive() || !Registry.is("suppress.focus.stealing")) { toFocus.requestFocus(); } else { toFocus.requestFocusInWindow(); } return AsyncResult.resolved(); } return AsyncResult.resolved(); }
Example #8
Source File: ProgressIndicatorUtils.java From consulo with Apache License 2.0 | 5 votes |
/** * Same as {@link #runInReadActionWithWriteActionPriority(Runnable)}, optionally allowing to pass a {@link ProgressIndicator} * instance, which can be used to cancel action externally. */ public static boolean runInReadActionWithWriteActionPriority(@Nonnull final Runnable action, @Nullable ProgressIndicator progressIndicator) { final SimpleReference<Boolean> result = new SimpleReference<>(Boolean.FALSE); runWithWriteActionPriority(() -> result.set(ApplicationManagerEx.getApplicationEx().tryRunReadAction(action)), progressIndicator == null ? new ProgressIndicatorBase(false, false) : progressIndicator); return result.get(); }
Example #9
Source File: CompletionThreading.java From consulo with Apache License 2.0 | 5 votes |
static void tryReadOrCancel(ProgressIndicator indicator, Runnable runnable) { if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> { indicator.checkCanceled(); runnable.run(); })) { indicator.cancel(); indicator.checkCanceled(); } }
Example #10
Source File: RemoteProcessSupport.java From consulo with Apache License 2.0 | 5 votes |
public EntryPoint acquire(@Nonnull Target target, @Nonnull Parameters configuration) throws Exception { ApplicationManagerEx.getApplicationEx().assertTimeConsuming(); Ref<RunningInfo> ref = Ref.create(null); Pair<Target, Parameters> key = Pair.create(target, configuration); if (!getExistingInfo(ref, key)) { startProcess(target, configuration, key); if (ref.isNull()) { try { //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (ref) { while (ref.isNull()) { ref.wait(1000); ProgressManager.checkCanceled(); } } } catch (InterruptedException e) { ProgressManager.checkCanceled(); } } } if (ref.isNull()) throw new RuntimeException("Unable to acquire remote proxy for: " + getName(target)); RunningInfo info = ref.get(); if (info.handler == null) { String message = info.name; if (message != null && message.startsWith("ERROR: transport error 202:")) { message = "Unable to start java process in debug mode: -Xdebug parameters are already in use."; } throw new ExecutionException(message); } return acquire(info); }
Example #11
Source File: LoadAllContentsAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT); String m = "Started loading content"; LOG.info(m); System.out.println(m); long start = System.currentTimeMillis(); count.set(0); totalSize.set(0); ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new ContentIterator() { @Override public boolean processFile(VirtualFile fileOrDir) { if (fileOrDir.isDirectory() || fileOrDir.is(VFileProperty.SPECIAL)) return true; try { count.incrementAndGet(); byte[] bytes = FileUtil.loadFileBytes(new File(fileOrDir.getPath())); totalSize.addAndGet(bytes.length); ProgressManager.getInstance().getProgressIndicator().setText(fileOrDir.getPresentableUrl()); } catch (IOException e1) { LOG.error(e1); } return true; } }); } }, "Loading", false, project); long end = System.currentTimeMillis(); String message = "Finished loading content of " + count + " files. Total size=" + StringUtil.formatFileSize(totalSize.get()) + ". Elapsed=" + ((end - start) / 1000) + "sec."; LOG.info(message); System.out.println(message); }
Example #12
Source File: LegalNotice.java From KodeBeagle with Apache License 2.0 | 4 votes |
@Override public final void doCancelAction() { super.doCancelAction(); PluginManagerCore.disablePlugin(KODEBEAGLEIDEA); ApplicationManagerEx.getApplicationEx().restart(true); }
Example #13
Source File: XQueryRunnerClasspathEntryGenerator.java From intellij-xquery with Apache License 2.0 | 4 votes |
boolean isTestRun(File pluginPath) { return ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists(); }
Example #14
Source File: TabbedPaneWrapper.java From consulo with Apache License 2.0 | 4 votes |
private void assertIsDispatchThread() { final ApplicationEx application = ApplicationManagerEx.getApplicationEx(); if (application != null){ application.assertIsDispatchThread(myTabbedPane.getComponent()); } }
Example #15
Source File: DialogWrapperPeerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("deprecation") public void show() { final DialogWrapper dialogWrapper = getDialogWrapper(); boolean isAutoAdjustable = dialogWrapper.isAutoAdjustable(); Point location = null; if (isAutoAdjustable) { pack(); Dimension packedSize = getSize(); Dimension minSize = getMinimumSize(); setSize(Math.max(packedSize.width, minSize.width), Math.max(packedSize.height, minSize.height)); setSize((int)(getWidth() * dialogWrapper.getHorizontalStretch()), (int)(getHeight() * dialogWrapper.getVerticalStretch())); // Restore dialog's size and location myDimensionServiceKey = dialogWrapper.getDimensionKey(); if (myDimensionServiceKey != null) { final Project projectGuess = DataManager.getInstance().getDataContext((Component)this).getData(CommonDataKeys.PROJECT); location = getWindowStateService(projectGuess).getLocation(myDimensionServiceKey); Dimension size = getWindowStateService(projectGuess).getSize(myDimensionServiceKey); if (size != null) { myInitialSize = new Dimension(size); _setSizeForLocation(myInitialSize.width, myInitialSize.height, location); } } if (myInitialSize == null) { myInitialSize = getSize(); } } if (location == null) { location = dialogWrapper.getInitialLocation(); } if (location != null) { setLocation(location); } else { setLocationRelativeTo(getOwner()); } if (isAutoAdjustable) { final Rectangle bounds = getBounds(); ScreenUtil.fitToScreen(bounds); setBounds(bounds); } if (Registry.is("actionSystem.fixLostTyping")) { final IdeEventQueue queue = IdeEventQueue.getInstance(); if (queue != null) { queue.getKeyEventDispatcher().resetState(); } } // Workaround for switching workspaces on dialog show if (SystemInfo.isMac && myProject != null && Registry.is("ide.mac.fix.dialog.showing") && !dialogWrapper.isModalProgress()) { final IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject.get()); AppIcon.getInstance().requestFocus(frame); } setBackground(UIUtil.getPanelBackground()); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); if (app != null && !app.isLoaded() && DesktopSplash.BOUNDS != null) { final Point loc = getLocation(); loc.y = DesktopSplash.BOUNDS.y + DesktopSplash.BOUNDS.height; setLocation(loc); } super.show(); }
Example #16
Source File: IdeHelper.java From idea-php-symfony2-plugin with MIT License | 2 votes |
/** * Find a window manager * * @see com.intellij.ui.popup.AbstractPopup */ @Nullable private static WindowManagerEx getWindowManager() { return ApplicationManagerEx.getApplicationEx() != null ? WindowManagerEx.getInstanceEx() : null; }