Java 类com.intellij.openapi.application.ex.ApplicationEx 实例源码

项目:intellij-ce-playground    文件:GenerateAntApplication.java   
public void startup() {
  if (myProjectPath == null || myOutPath == null) {
    GenerateAntMain.printHelp();
  }

  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      ApplicationEx application = ApplicationManagerEx.getApplicationEx();
      try {
        logMessage(0, "Starting app... ");
        application.doNotSave();
        application.load();
        logMessageLn(0, "done");

        GenerateAntApplication.this.run();
      }
      catch (Exception e) {
        GenerateAntApplication.LOG.error(e);
      }
      finally {
        application.exit(true, true);
      }
    }
  });
}
项目:intellij-ce-playground    文件:RefreshQueueImpl.java   
public void execute(@NotNull RefreshSessionImpl session) {
  if (session.isAsynchronous()) {
    ModalityState state = session.getModalityState();
    queueSession(session, state);
  }
  else {
    Application app = ApplicationManager.getApplication();
    if (app.isDispatchThread()) {
      doScan(session);
      session.fireEvents(app.isWriteAccessAllowed());
    }
    else {
      if (((ApplicationEx)app).holdsReadLock()) {
        LOG.error("Do not call synchronous refresh under read lock (except from EDT) - " +
                  "this will cause a deadlock if there are any events to fire.");
        return;
      }
      queueSession(session, ModalityState.defaultModalityState());
      session.waitFor();
    }
  }
}
项目:intellij-ce-playground    文件:IdeErrorsDialog.java   
public IdeErrorsDialog(MessagePool messagePool, @Nullable LogMessage defaultMessage) {
  super(JOptionPane.getRootFrame(), false);
  myMessagePool = messagePool;
  ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  myInternalMode = app != null && app.isInternal();
  setTitle(DiagnosticBundle.message("error.list.title"));
  init();
  rebuildHeaders();
  if (defaultMessage == null || !moveSelectionToMessage(defaultMessage)) {
    moveSelectionToEarliestMessage();
  }
  setCancelButtonText(CommonBundle.message("close.action.name"));
  setModal(false);
  if (myInternalMode) {
    if (ourDevelopersList.isEmpty()) {
      loadDevelopersAsynchronously();
    } else {
      myDetailsTabForm.setDevelopers(ourDevelopersList);
    }
  }
}
项目:intellij-ce-playground    文件:CoreProgressManager.java   
protected boolean runProcessWithProgressSynchronously(@NotNull final Task task, @Nullable final JComponent parentComponent) {
  final boolean result = ((ApplicationEx)ApplicationManager.getApplication())
      .runProcessWithProgressSynchronously(new TaskContainer(task) {
        @Override
        public void run() {
          new TaskRunnable(task, ProgressManager.getInstance().getProgressIndicator()).run();
        }
      }, task.getTitle(), task.isCancellable(), task.getProject(), parentComponent, task.getCancelText());
  if (result) {
    task.onSuccess();
  }
  else {
    task.onCancel();
  }
  return result;
}
项目:intellij-ce-playground    文件:RegistryUi.java   
private void processClose() {
  if (Registry.getInstance().isRestartNeeded()) {
    final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
    final ApplicationInfo info = ApplicationInfo.getInstance();

    final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required",
                                              app.isRestartCapable() ? "Restart Now" : "Shutdown Now",
                                              app.isRestartCapable() ? "Restart Later": "Shutdown Later"
        , Messages.getQuestionIcon());


    if (r == Messages.OK) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          app.restart(true);
        }
      }, ModalityState.NON_MODAL);
    }
  }
}
项目:intellij-ce-playground    文件:GradleOrderEnumeratorHandler.java   
private static void addOutputModuleRoots(@Nullable ExternalSourceSet externalSourceSet,
                                         @NotNull ExternalSystemSourceType sourceType,
                                         @NotNull Collection<String> result) {
  if (externalSourceSet == null) return;
  final ExternalSourceDirectorySet directorySet = externalSourceSet.getSources().get(sourceType);
  if (directorySet == null) return;

  if (directorySet.isCompilerOutputPathInherited()) return;
  final String path = directorySet.getOutputDir().getAbsolutePath();
  VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(path);
  if (virtualFile == null) {
    if(!directorySet.getOutputDir().exists()){
      FileUtil.createDirectory(directorySet.getOutputDir());
    }
    ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication();
    if (app.isDispatchThread() || !app.holdsReadLock()) {
      LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directorySet.getOutputDir());
    }
  }
  result.add(VfsUtilCore.pathToUrl(path));
}
项目:tools-idea    文件:GenerateAntApplication.java   
public void startup() {
  if (myProjectPath == null || myOutPath == null) {
    GenerateAntMain.printHelp();
  }

  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      ApplicationEx application = ApplicationManagerEx.getApplicationEx();
      try {
        logMessage(0, "Starting app... ");
        application.doNotSave();
        application.load(PathManager.getOptionsPath());
        logMessageLn(0, "done");

        GenerateAntApplication.this.run();
      }
      catch (Exception e) {
        GenerateAntApplication.LOG.error(e);
      }
      finally {
        application.exit(true);
      }
    }
  });
}
项目:tools-idea    文件:RefreshQueueImpl.java   
public void execute(@NotNull RefreshSessionImpl session) {
  if (session.isAsynchronous()) {
    ModalityState state = session.getModalityState();
    queueSession(session, state);
  }
  else {
    Application app = ApplicationManager.getApplication();
    if (app.isDispatchThread()) {
      doScan(session);
      session.fireEvents(app.isWriteAccessAllowed());
    }
    else {
      if (((ApplicationEx)app).holdsReadLock()) {
        LOG.error("Do not call synchronous refresh from inside read action except for event dispatch thread. " +
                  "This will eventually cause deadlock if there are any events to fire");
        return;
      }
      queueSession(session, ModalityState.defaultModalityState());
      session.waitFor();
    }
  }
}
项目:tools-idea    文件:ProgressManagerImpl.java   
private static boolean runProcessWithProgressSynchronously(final Task task, @Nullable final JComponent parentComponent) {
  final long start = System.currentTimeMillis();
  final boolean result = ((ApplicationEx)ApplicationManager.getApplication())
      .runProcessWithProgressSynchronously(new TaskContainer(task) {
        @Override
        public void run() {
          new TaskRunnable(task, ProgressManager.getInstance().getProgressIndicator()).run();
        }
      }, task.getTitle(), task.isCancellable(), task.getProject(), parentComponent, task.getCancelText());
  if (result) {
    final long end = System.currentTimeMillis();
    final Task.NotificationInfo notificationInfo = task.notifyFinished();
    long time = end - start;
    if (notificationInfo != null && time > 5000) { // show notification only if process took more than 5 secs
      final JFrame frame = WindowManager.getInstance().getFrame(task.getProject());
      if (!frame.hasFocus()) {
        systemNotify(notificationInfo);
      }
    }
    task.onSuccess();
  }
  else {
    task.onCancel();
  }
  return result;
}
项目:tools-idea    文件:PluginManagerConfigurable.java   
public void apply() throws ConfigurationException {
  final String applyMessage = myPluginManagerMain.apply();
  if (applyMessage != null) {
    throw new ConfigurationException(applyMessage);
  }

  if (myPluginManagerMain.isRequireShutdown()) {
    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();

    int response = app.isRestartCapable() ? showRestartIDEADialog() : showShutDownIDEADialog();
    if (response == 0) {
      app.restart(true);
    }
    else {
      myPluginManagerMain.ignoreChanges();
    }
  }
}
项目:tools-idea    文件:ActionInstallPlugin.java   
private static void notifyPluginsWereInstalled(@Nullable String pluginName) {
  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  final boolean restartCapable = app.isRestartCapable();
  String message =
    restartCapable ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
                   : IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
  message += "<br><a href=";
  message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
  message += "</a>";
  Notifications.Bus.notify(new Notification("Plugins Lifecycle Group",
                                            pluginName != null ? "Plugin \'" + pluginName + "\' was successfully installed" : "Plugins were installed",
                                            XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION,
                                            new NotificationListener() {
                                              @Override
                                              public void hyperlinkUpdate(@NotNull Notification notification,
                                                                          @NotNull HyperlinkEvent event) {
                                                notification.expire();
                                                if (restartCapable) {
                                                  app.restart(true);
                                                }
                                                else {
                                                  app.exit(true);
                                                }
                                              }
                                            }));
}
项目:tools-idea    文件:IdeErrorsDialog.java   
public IdeErrorsDialog(MessagePool messagePool, @Nullable LogMessage defaultMessage) {
  super(JOptionPane.getRootFrame(), false);
  myMessagePool = messagePool;
  ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  myInternalMode = app != null && app.isInternal();
  setTitle(DiagnosticBundle.message("error.list.title"));
  init();
  rebuildHeaders();
  if (defaultMessage == null || !moveSelectionToMessage(defaultMessage)) {
    moveSelectionToEarliestMessage();
  }
  setCancelButtonText(CommonBundle.message("close.action.name"));
  setModal(false);
  if (myInternalMode) {
    if (ourDevelopersList.isEmpty()) {
      loadDevelopersAsynchronously();
    } else {
      myDetailsTabForm.setDevelopers(ourDevelopersList);
    }
  }
}
项目:tools-idea    文件:RegistryUi.java   
private void processClose() {
  if (Registry.getInstance().isRestartNeeded()) {
    final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
    final ApplicationInfo info = ApplicationInfo.getInstance();

    final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required",
            (app.isRestartCapable() ? "Restart Now" : "Shutdown Now"), (app.isRestartCapable() ? "Restart Later": "Shutdown Later")
        , Messages.getQuestionIcon());


    if (r == 0) {
      LaterInvocator.invokeLater(new Runnable() {
        @Override
        public void run() {
            app.restart(true);
        }
      }, ModalityState.NON_MODAL);
    }
  }
}
项目:consulo    文件:RootUIBuilder.java   
@RequiredUIAccess
@Override
public void build(@Nonnull Window window) {
  Disposer.register(window, () -> {
    WebApplication application = WebApplication.getInstance();
    if (application == null || !((ApplicationEx)application).isLoaded()) {
      return;
    }

    WriteAction.run(() -> {
      ProjectManager projectManager = ProjectManager.getInstance();

      Project[] openProjects = projectManager.getOpenProjects();

      for (Project openProject : openProjects) {
        projectManager.closeProject(openProject);
      }
    });
  });

  window.setContent(new WGwtLoadingPanelImpl());

  UIAccess access = UIAccess.get();

  scheduleWelcomeFrame(access, window);
}
项目:consulo    文件:RefreshQueueImpl.java   
public void execute(@Nonnull RefreshSessionImpl session) {
  if (session.isAsynchronous()) {
    queueSession(session, session.getTransaction());
  }
  else {
    Application app = ApplicationManager.getApplication();
    if (app.isDispatchThread()) {
      ((TransactionGuardImpl)TransactionGuard.getInstance()).assertWriteActionAllowed();
      doScan(session);
      session.fireEvents();
    }
    else {
      if (((ApplicationEx)app).holdsReadLock()) {
        LOG.error("Do not call synchronous refresh under read lock (except from EDT) - " +
                  "this will cause a deadlock if there are any events to fire.");
        return;
      }
      queueSession(session, TransactionGuard.getInstance().getContextTransaction());
      session.waitFor();
    }
  }
}
项目:consulo    文件:ApplicationStarter.java   
public void run(boolean newConfigFolder) {
  try {
    ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    app.load(PathManager.getOptionsPath());

    if (myPostStarter.needStartInTransaction()) {
      ((TransactionGuardImpl)TransactionGuard.getInstance()).performUserActivity(() -> myPostStarter.main(newConfigFolder, myArgs));
    }
    else {
      myPostStarter.main(newConfigFolder, myArgs);
    }

    myPostStarter = null;

    ourLoaded = true;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
项目:consulo    文件:PluginManagerConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  final String applyMessage = myPluginManagerMain.apply();
  if (applyMessage != null) {
    throw new ConfigurationException(applyMessage);
  }

  if (myPluginManagerMain.isRequireShutdown()) {
    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();

    int response = app.isRestartCapable() ? showRestartIDEADialog() : showShutDownIDEADialog();
    if (response == Messages.YES) {
      app.restart(true);
    }
    else {
      myPluginManagerMain.ignoreChanges();
    }
  }
}
项目:consulo    文件:PluginManagerMain.java   
public static void notifyPluginsWereUpdated(final String title, final Project project) {
  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  final boolean restartCapable = app.isRestartCapable();
  String message = restartCapable
                   ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
                   : IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
  message += "<br><a href=";
  message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
  message += "</a>";
  new NotificationGroup("Plugins Lifecycle Group", NotificationDisplayType.STICKY_BALLOON, true)
          .createNotification(title, XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION, new NotificationListener() {
            @Override
            public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
              notification.expire();
              if (restartCapable) {
                app.restart(true);
              }
              else {
                app.exit(true, true);
              }
            }
          }).notify(project);
}
项目:consulo    文件:DocumentCommitThread.java   
DocumentCommitThread(final ApplicationEx application) {
  myApplication = application;
  // install listener in EDT to avoid missing events in case we are inside write action right now
  application.invokeLater(() -> {
    if (application.isDisposed()) return;
    assert !application.isWriteAccessAllowed() || application.isUnitTestMode(); // crazy stuff happens in tests, e.g. UIUtil.dispatchInvocationEvents() inside write action
    application.addApplicationListener(new ApplicationAdapter() {
      @Override
      public void beforeWriteActionStart(@Nonnull Object action) {
        disable("Write action started: " + action);
      }

      @Override
      public void afterWriteActionFinished(@Nonnull Object action) {
        // crazy things happen when running tests, like starting write action in one thread but firing its end in the other
        enable("Write action finished: " + action);
      }
    }, this);

    enable("Listener installed, started");
  });
}
项目:consulo    文件:RegistryUi.java   
private void processClose() {
  if (Registry.getInstance().isRestartNeeded()) {
    final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
    final ApplicationInfo info = ApplicationInfo.getInstance();

    final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required",
            (app.isRestartCapable() ? "Restart Now" : "Shutdown Now"), (app.isRestartCapable() ? "Restart Later": "Shutdown Later")
        , Messages.getQuestionIcon());


    if (r == 0) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            app.restart(true);
        }
      }, ModalityState.NON_MODAL);
    }
  }
}
项目:consulo-java    文件:UnscrambleManager.java   
private void updateConnection()
{
    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();

    boolean value = PropertiesComponent.getInstance().getBoolean(KEY);
    if(value)
    {
        myConnection = app.getMessageBus().connect();
        myConnection.subscribe(ApplicationActivationListener.TOPIC, myListener);
    }
    else
    {
        if(myConnection != null)
        {
            myConnection.disconnect();
        }
    }
}
项目:hybris-integration-intellij-idea-plugin    文件:CheckRequiredPluginsStep.java   
private void enablePlugins() {
    notEnabledPlugins.stream().forEach(id -> {
        PluginManager.enablePlugin(id.getIdString());
    });
    final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
    app.restart(true);
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
public static void saveProject(Project project) {
  ApplicationEx application = ApplicationManagerEx.getApplicationEx();
  boolean oldValue = application.isDoNotSave();
  try {
    application.doNotSave(false);
    project.save();
  }
  finally {
    application.doNotSave(oldValue);
  }
}
项目:intellij-ce-playground    文件:LightPlatformTestCase.java   
@Override
public final void runBare() throws Throwable {
  if (!shouldRunTest()) {
    return;
  }

  TestRunnerUtil.replaceIdeEventQueueSafely();
  EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
    @Override
    public void run() throws Throwable {
      try {
        ourTestThread = Thread.currentThread();
        startRunAndTear();
      }
      finally {
        ourTestThread = null;
        try {
          Application application = ApplicationManager.getApplication();
          if (application instanceof ApplicationEx) {
            PlatformTestCase.cleanupApplicationCaches(ourProject);
          }
          resetAllFields();
        }
        catch (Throwable e) {
          e.printStackTrace();
        }
      }
    }
  });

  // just to make sure all deferred Runnables to finish
  SwingUtilities.invokeAndWait(EmptyRunnable.getInstance());

  if (IdeaLogger.ourErrorsOccurred != null) {
    throw IdeaLogger.ourErrorsOccurred;
  }
}
项目:intellij-ce-playground    文件:ApplicationImpl.java   
private static void createLocatorFile() {
  File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
  try {
    byte[] data = PathManager.getHomePath().getBytes(CharsetToolkit.UTF8_CHARSET);
    FileUtil.writeToFile(locatorFile, data);
  }
  catch (IOException e) {
    LOG.warn("can't store a location in '" + locatorFile + "'", e);
  }
}
项目:intellij-ce-playground    文件:AbstractUpdateDialog.java   
protected void restart() {
  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  // do not stack several modal dialogs (native & swing)
  app.invokeLater(new Runnable() {
    @Override
    public void run() {
      app.restart(true);
    }
  });
}
项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
@NotNull
@Override
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() {
      onNo.run();
    }

    @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);
}
项目:intellij-ce-playground    文件:ApplicationImplTest.java   
public void testRunProcessWithProgressSynchronouslyInReadAction() throws Throwable {
  boolean result = ((ApplicationEx)ApplicationManager.getApplication())
    .runProcessWithProgressSynchronouslyInReadAction(getProject(), "title", true, "cancel", null, () -> {
      try {
        assertFalse(SwingUtilities.isEventDispatchThread());
        assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
      }
      catch (Throwable e) {
        exception = e;
      }
    });
  assertTrue(result);
  if (exception != null) throw exception;
}
项目:intellij-ce-playground    文件:ApplicationImplTest.java   
public void testRunProcessWithProgressSynchronouslyInReadActionWithPendingWriteAction() throws Throwable {
  SwingUtilities.invokeLater(() -> ApplicationManager.getApplication().runWriteAction(EmptyRunnable.getInstance()));
  boolean result = ((ApplicationEx)ApplicationManager.getApplication())
    .runProcessWithProgressSynchronouslyInReadAction(getProject(), "title", true, "cancel", null, () -> TimeoutUtil.sleep(10000));
  assertTrue(result);
  UIUtil.dispatchAllInvocationEvents();
  if (exception != null) throw exception;
}
项目:intellij-ce-playground    文件:LocatorTest.java   
public void test() throws Exception {
  File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
  assertTrue("doesn't exist: " + locatorFile.getPath(), locatorFile.exists());
  assertTrue("can't read: " + locatorFile.getPath(), locatorFile.canRead());

  String home = FileUtil.loadFile(locatorFile, CharsetToolkit.UTF8_CHARSET);
  assertTrue(home, StringUtil.isNotEmpty(home));

  assertEquals(home, PathManager.getHomePath());
}
项目:intellij-ce-playground    文件:InspectionApplication.java   
public void startup() {
  if (myProjectPath == null) {
    logError("Project to inspect is not defined");
    printHelp();
  }

  if (myProfileName == null && myProfilePath == null && myStubProfile == null) {
    logError("Profile to inspect with is not defined");
    printHelp();
  }

  final ApplicationEx application = ApplicationManagerEx.getApplicationEx();
  application.runReadAction(new Runnable() {
    @Override
    public void run() {
      try {
        final ApplicationInfoEx applicationInfo = (ApplicationInfoEx)ApplicationInfo.getInstance();
        logMessage(1, InspectionsBundle.message("inspection.application.starting.up", applicationInfo.getFullApplicationName()));
        application.doNotSave();
        logMessageLn(1, InspectionsBundle.message("inspection.done"));

        InspectionApplication.this.run();
      }
      catch (Exception e) {
        LOG.error(e);
      }
      finally {
        if (myErrorCodeRequired) application.exit(true, true);
      }
    }
  });
}
项目:intellij-ce-playground    文件:LoadAllVfsStoredContentsAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final 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);
  ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      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);
}
项目:intellij-ce-playground    文件:TraverseUIStarter.java   
@Override
public void main(String[] args){
  System.out.println("Starting searchable options index builder");
  try {
    startup(OUTPUT_PATH);
    ((ApplicationEx)ApplicationManager.getApplication()).exit(true, true);
  }
  catch (Throwable e) {
    System.out.println("Searchable options index builder failed");
    e.printStackTrace();
    System.exit(-1);
  }
}
项目:intellij-ce-playground    文件:IdeTestApplication.java   
public static synchronized void disposeInstance() {
  if (!isLoaded()) {
    return;
  }
  Application application = ApplicationManager.getApplication();
  if (application != null) {
    if (application instanceof ApplicationEx) {
      ((ApplicationEx)application).exit(true, true);
    }
    else {
      application.exit();
    }
  }
  ourInstance = null;
}
项目:tools-idea    文件:IdeaTestApplication.java   
public static synchronized IdeaTestApplication getInstance(@Nullable final String configPath) {
  if (ourInstance == null) {
    new IdeaTestApplication();
    PluginManager.getPlugins();
    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    new WriteAction() {
      protected void run(Result result) throws Throwable {
        app.load(configPath);
      }
    }.execute();
  }
  return (IdeaTestApplication)ourInstance;
}
项目:tools-idea    文件:ApplicationImpl.java   
private static void createLocatorFile() {
  File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
  try {
    byte[] data = PathManager.getHomePath().getBytes("UTF-8");
    FileUtil.writeToFile(locatorFile, data);
  }
  catch (IOException e) {
    LOG.warn("can't store a location in '" + locatorFile + "'", e);
  }
}
项目:tools-idea    文件:AbstractUpdateDialog.java   
protected void doOKAction() {
  if (doDownloadAndPrepare() && isShowConfirmation()) {
    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    // do not stack several modal dialogs (native & swing)
    app.invokeLater(new Runnable() {
      @Override
      public void run() {
        app.restart(true);
      }
    });
  }
  super.doOKAction();
}
项目:tools-idea    文件:PopupFactoryImpl.java   
@NotNull
@Override
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() {
      onNo.run();
    }

    @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);
}
项目:tools-idea    文件:IdeaApplication.java   
public void run() {
  try {
    ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    app.load(PathManager.getOptionsPath());

    myStarter.main(myArgs);
    myStarter = null; //GC it

    myLoaded = true;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:InvalidateCachesAction.java   
public void actionPerformed(AnActionEvent e) {
  final ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication();
  final boolean mac = Messages.canShowMacSheetPanel();
  boolean canRestart = app.isRestartCapable();

  String[] options = new String[canRestart ? 4 : 3];
  options[0] = canRestart ? "Invalidate and Restart" : "Invalidate and Exit";
  options[1] = mac ? "Cancel" : "Invalidate";
  options[2] = mac ? "Invalidate" : "Cancel";
  if (canRestart) {
    options[3] = "Just Restart";
  }

  int result = Messages.showDialog(e.getData(PlatformDataKeys.PROJECT),
                                   "The caches will be invalidated and rebuilt on the next startup.\n" +
                                   "WARNING: Local History will be also cleared.\n\n" +
                                   "Would you like to continue?\n\n",
                                   "Invalidate Caches",
                                   options, 0,
                                   Messages.getWarningIcon());

  if (result == -1 || result == (mac ? 1 : 2)) {
    return;
  }

  if (result == 3) {
    app.restart(true);
    return;
  }

  FSRecords.invalidateCaches();
  if (result == 0) app.restart(true);
}