Search in sources :

Example 11 with ApplicationEx

use of com.intellij.openapi.application.ex.ApplicationEx in project android by JetBrains.

the class IdeTestApplication method disposeInstance.

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;
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) Application(com.intellij.openapi.application.Application)

Example 12 with ApplicationEx

use of com.intellij.openapi.application.ex.ApplicationEx in project intellij-community by JetBrains.

the class GenerateAntApplication method startup.

public void startup() {
    if (myProjectPath == null || myOutPath == null) {
        GenerateAntMain.printHelp();
    }
    SwingUtilities.invokeLater(() -> {
        ApplicationEx application = ApplicationManagerEx.getApplicationEx();
        try {
            logMessage(0, "Starting app... ");
            application.doNotSave();
            application.load();
            logMessageLn(0, "done");
            this.run();
        } catch (Exception e) {
            GenerateAntApplication.LOG.error(e);
        } finally {
            application.exit(true, true);
        }
    });
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) IOException(java.io.IOException)

Example 13 with ApplicationEx

use of com.intellij.openapi.application.ex.ApplicationEx in project intellij-community by JetBrains.

the class CoreProgressManager method runProcessWithProgressSynchronously.

public boolean runProcessWithProgressSynchronously(@NotNull final Task task, @Nullable final JComponent parentComponent) {
    final Ref<Throwable> exceptionRef = new Ref<>();
    TaskContainer taskContainer = new TaskContainer(task) {

        @Override
        public void run() {
            try {
                new TaskRunnable(task, getProgressIndicator()).run();
            } catch (ProcessCanceledException e) {
                throw e;
            } catch (Throwable e) {
                exceptionRef.set(e);
            }
        }
    };
    ApplicationEx application = (ApplicationEx) ApplicationManager.getApplication();
    boolean result = application.runProcessWithProgressSynchronously(taskContainer, task.getTitle(), task.isCancellable(), task.getProject(), parentComponent, task.getCancelText());
    finishTask(task, !result, exceptionRef.get());
    return result;
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx)

Example 14 with ApplicationEx

use of com.intellij.openapi.application.ex.ApplicationEx in project intellij-community by JetBrains.

the class FormatterStarter method main.

@Override
public void main(String[] args) {
    @SuppressWarnings("UseOfSystemOutOrSystemErr") MessageOutput messageOutput = new MessageOutput(new PrintWriter(System.out), new PrintWriter(System.err));
    messageOutput.info(getAppInfo() + " Formatter\n");
    FileSetFormatter fileSetFormatter = new FileSetFormatter(messageOutput);
    logArgs(args);
    if (args.length < 2) {
        showUsageInfo(messageOutput);
    }
    for (int i = 1; i < args.length; i++) {
        if (args[i].startsWith("-")) {
            if (checkOption(args[i], "-h", "-help")) {
                showUsageInfo(messageOutput);
            }
            if (checkOption(args[i], "-s", "-settings")) {
                //noinspection AssignmentToForLoopParameter
                i++;
                if (i >= args.length) {
                    fatalError(messageOutput, "Missing settings file path.");
                }
                try {
                    CodeStyleSettings settings = readSettings(args[i]);
                    fileSetFormatter.setCodeStyleSettings(settings);
                } catch (SchemeImportException e) {
                    fatalError(messageOutput, e.getLocalizedMessage() + "\n");
                }
            } else if (checkOption(args[i], "-r", "-R")) {
                fileSetFormatter.setRecursive();
            } else if (checkOption(args[i], "-m", "-mask")) {
                //noinspection AssignmentToForLoopParameter
                i++;
                if (i >= args.length) {
                    fatalError(messageOutput, "Missing file mask(s).");
                }
                for (String mask : args[i].split(",")) {
                    if (!mask.isEmpty()) {
                        fileSetFormatter.addFileMask(mask);
                    }
                }
            } else {
                fatalError(messageOutput, "Unknown option " + args[i]);
            }
        } else {
            try {
                fileSetFormatter.addEntry(args[i]);
            } catch (IOException e) {
                fatalError(messageOutput, e.getLocalizedMessage());
            }
        }
    }
    try {
        fileSetFormatter.processFiles();
        messageOutput.info("\n" + fileSetFormatter.getProcessedFiles() + " file(s) formatted.\n");
    } catch (IOException e) {
        fatalError(messageOutput, e.getLocalizedMessage());
    }
    ((ApplicationEx) ApplicationManager.getApplication()).exit(true, true);
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) SchemeImportException(com.intellij.openapi.options.SchemeImportException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 15 with ApplicationEx

use of com.intellij.openapi.application.ex.ApplicationEx in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method testDaemonIgnoresFrameDeactivation.

public void testDaemonIgnoresFrameDeactivation() throws Throwable {
    // return default value to avoid unnecessary save
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
    String text = "class S { ArrayList<caret>XXX x;}";
    configureByText(StdFileTypes.JAVA, text);
    highlightErrors();
    GeneralSettings settings = GeneralSettings.getInstance();
    ApplicationEx application = ApplicationManagerEx.getApplicationEx();
    boolean frameSave = settings.isSaveOnFrameDeactivation();
    boolean appSave = application.isDoNotSave();
    settings.setSaveOnFrameDeactivation(true);
    application.doNotSave(false);
    try {
        SaveAndSyncHandlerImpl.doSaveDocumentsAndProjectsAndApp();
        checkDaemonReaction(false, SaveAndSyncHandlerImpl::doSaveDocumentsAndProjectsAndApp);
    } finally {
        application.doNotSave(appSave);
        settings.setSaveOnFrameDeactivation(frameSave);
    }
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) SaveAndSyncHandlerImpl(com.intellij.ide.SaveAndSyncHandlerImpl) GeneralSettings(com.intellij.ide.GeneralSettings)

Aggregations

ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)21 NotNull (org.jetbrains.annotations.NotNull)5 IOException (java.io.IOException)4 Application (com.intellij.openapi.application.Application)3 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Project (com.intellij.openapi.project.Project)2 SmartList (com.intellij.util.SmartList)2 THashMap (gnu.trove.THashMap)2 HyperlinkEvent (javax.swing.event.HyperlinkEvent)2 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)1 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)1 AsyncFuture (com.intellij.concurrency.AsyncFuture)1 AsyncUtil (com.intellij.concurrency.AsyncUtil)1 JobLauncher (com.intellij.concurrency.JobLauncher)1 GeneralSettings (com.intellij.ide.GeneralSettings)1 SaveAndSyncHandlerImpl (com.intellij.ide.SaveAndSyncHandlerImpl)1 CachesInvalidator (com.intellij.ide.caches.CachesInvalidator)1 IdeaApplication (com.intellij.idea.IdeaApplication)1 IdeaTestApplication (com.intellij.idea.IdeaTestApplication)1 MockApplication (com.intellij.mock.MockApplication)1