Search in sources :

Example 16 with Application

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

the class IpnbCodePanel method updatePrompt.

public void updatePrompt() {
    final Application application = ApplicationManager.getApplication();
    application.invokeAndWait(() -> {
        myCell.setPromptNumber(-1);
        final String promptText = IpnbEditorUtil.prompt(myCell.getPromptNumber(), IpnbEditorUtil.PromptType.In);
        myPromptLabel.setText(promptText);
    }, ModalityState.stateForComponent(this));
}
Also used : Application(com.intellij.openapi.application.Application)

Example 17 with Application

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

the class MvcModuleStructureSynchronizer method scheduleRunActions.

private void scheduleRunActions() {
    if (myProject.isDisposed())
        return;
    final Application app = ApplicationManager.getApplication();
    if (app.isUnitTestMode()) {
        if (ourGrailsTestFlag && !myProject.isInitialized()) {
            runActions(computeRawActions(takeOrderSnapshot()));
        }
        return;
    }
    final Set<Pair<Object, SyncAction>> orderSnapshot = takeOrderSnapshot();
    ReadTask task = new ReadTask() {

        @Nullable
        @Override
        public Continuation performInReadAction(@NotNull final ProgressIndicator indicator) throws ProcessCanceledException {
            final Set<Trinity<Module, SyncAction, MvcFramework>> actions = isUpToDate() ? computeRawActions(orderSnapshot) : Collections.<Trinity<Module, SyncAction, MvcFramework>>emptySet();
            return new Continuation(() -> {
                if (isUpToDate()) {
                    runActions(actions);
                } else if (!indicator.isCanceled()) {
                    scheduleRunActions();
                }
            }, ModalityState.NON_MODAL);
        }

        @Override
        public void onCanceled(@NotNull ProgressIndicator indicator) {
            scheduleRunActions();
        }

        private boolean isUpToDate() {
            return !myProject.isDisposed() && orderSnapshot.equals(takeOrderSnapshot());
        }
    };
    GuiUtils.invokeLaterIfNeeded(() -> ProgressIndicatorUtils.scheduleWithWriteActionPriority(ourExecutor, task), ModalityState.NON_MODAL);
}
Also used : Trinity(com.intellij.openapi.util.Trinity) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Module(com.intellij.openapi.module.Module) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull) Pair(com.intellij.openapi.util.Pair) ReadTask(com.intellij.openapi.progress.util.ReadTask)

Example 18 with Application

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

the class MvcModuleStructureUtil method updateModuleStructure.

public static void updateModuleStructure(final Module module, MvcProjectStructure structure, @NotNull VirtualFile root) {
    final Pair<Collection<Consumer<ModifiableRootModel>>, Collection<Consumer<ModifiableFacetModel>>> actions = getUpdateProjectStructureActions(Collections.singletonList(root), structure);
    // update module
    if (!actions.first.isEmpty()) {
        ModuleRootModificationUtil.updateModel(module, model -> {
            for (final Consumer<ModifiableRootModel> action : actions.first) {
                action.consume(model);
            }
        });
    }
    // update facets
    if (!actions.second.isEmpty()) {
        final Application application = ApplicationManager.getApplication();
        final ModifiableFacetModel model = application.runReadAction(new Computable<ModifiableFacetModel>() {

            @Override
            public ModifiableFacetModel compute() {
                return FacetManager.getInstance(module).createModifiableModel();
            }
        });
        for (Consumer<ModifiableFacetModel> action : actions.second) {
            action.consume(model);
        }
        application.invokeAndWait(() -> application.runWriteAction(() -> model.commit()));
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) Application(com.intellij.openapi.application.Application)

Example 19 with Application

use of com.intellij.openapi.application.Application in project smali by JesusFreke.

the class ITNProxy method createParameters.

public static Map<String, String> createParameters(ErrorBean error) {
    Map<String, String> params = ContainerUtil.newLinkedHashMap(40);
    params.put("protocol.version", "1");
    params.put("os.name", SystemProperties.getOsName());
    params.put("java.version", SystemProperties.getJavaVersion());
    params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
    ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
    Application application = ApplicationManager.getApplication();
    params.put("app.name", namesInfo.getProductName());
    params.put("app.name.full", namesInfo.getFullProductName());
    params.put("app.name.version", appInfo.getVersionName());
    params.put("app.eap", Boolean.toString(appInfo.isEAP()));
    params.put("app.internal", Boolean.toString(application.isInternal()));
    params.put("app.build", appInfo.getBuild().asString());
    params.put("app.version.major", appInfo.getMajorVersion());
    params.put("app.version.minor", appInfo.getMinorVersion());
    params.put("app.build.date", format(appInfo.getBuildDate()));
    params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
    params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
    UpdateSettings updateSettings = UpdateSettings.getInstance();
    params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
    params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
    params.put("plugin.name", error.getPluginName());
    params.put("plugin.version", error.getPluginVersion());
    params.put("last.action", error.getLastAction());
    params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
    params.put("error.message", error.getMessage());
    params.put("error.stacktrace", error.getStackTrace());
    params.put("error.description", error.getDescription());
    params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
    for (Attachment attachment : error.getAttachments()) {
        params.put("attachment.name", attachment.getName());
        params.put("attachment.value", attachment.getEncodedBytes());
    }
    return params;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Attachment(com.intellij.openapi.diagnostic.Attachment) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) Application(com.intellij.openapi.application.Application)

Example 20 with Application

use of com.intellij.openapi.application.Application in project ideavim by JetBrains.

the class UiHelper method requestFocus.

/**
   * Get focus reliably.
   */
public static void requestFocus(@NotNull final JComponent component) {
    final Application application = ApplicationManager.getApplication();
    // XXX: This workaround is required at least for Oracle Java 6
    application.invokeLater(new Runnable() {

        @Override
        public void run() {
            application.invokeLater(new Runnable() {

                @Override
                public void run() {
                    component.requestFocus();
                }
            });
        }
    });
}
Also used : Application(com.intellij.openapi.application.Application)

Aggregations

Application (com.intellij.openapi.application.Application)188 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 IOException (java.io.IOException)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)12 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)9 ModalityState (com.intellij.openapi.application.ModalityState)8 Ref (com.intellij.openapi.util.Ref)7 ArrayList (java.util.ArrayList)7 List (java.util.List)6 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)5 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)4 Document (com.intellij.openapi.editor.Document)4 Module (com.intellij.openapi.module.Module)4 Computable (com.intellij.openapi.util.Computable)4 PsiFile (com.intellij.psi.PsiFile)4 File (java.io.File)4 Editor (com.intellij.openapi.editor.Editor)3