Search in sources :

Example 71 with WriteAction

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

the class AppEngineCodeInsightTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = JavaTestFixtureFactory.createFixtureBuilder(getName());
    myModuleBuilder = fixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
    myProjectFixture = fixtureBuilder.getFixture();
    myCodeInsightFixture = createCodeInsightFixture(getBaseDirectoryPath());
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) {
            addAppEngineSupport(myProjectFixture.getModule());
        }
    }.execute();
}
Also used : JavaModuleFixtureBuilder(com.intellij.testFramework.builders.JavaModuleFixtureBuilder) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 72 with WriteAction

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

the class DependenciesImportingTest method testSaveJdkPosition.

public void testSaveJdkPosition() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<packaging>pom</packaging>" + "<version>1</version>" + "<modules>" + "  <module>m1</module>" + "  <module>m2</module>" + "</modules>");
    createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + "  <dependency>" + "    <groupId>test</groupId>" + "    <artifactId>m2</artifactId>" + "    <version>1</version>" + "  </dependency>" + "  <dependency>" + "    <groupId>junit</groupId>" + "    <artifactId>junit</artifactId>" + "    <version>4.0</version>" + "  </dependency>" + "</dependencies>");
    createModulePom("m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
    importProject();
    new WriteAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            ModifiableRootModel rootModel = ModuleRootManager.getInstance(getModule("m1")).getModifiableModel();
            OrderEntry[] orderEntries = rootModel.getOrderEntries().clone();
            assert orderEntries.length == 4;
            assert orderEntries[0] instanceof JdkOrderEntry;
            assert orderEntries[1] instanceof ModuleSourceOrderEntry;
            assert ((ModuleOrderEntry) orderEntries[2]).getModuleName().equals("m2");
            assert "Maven: junit:junit:4.0".equals(((LibraryOrderEntry) orderEntries[3]).getLibraryName());
            rootModel.rearrangeOrderEntries(new OrderEntry[] { orderEntries[2], orderEntries[3], orderEntries[0], orderEntries[1] });
            rootModel.commit();
        }
    }.execute();
    resolveDependenciesAndImport();
    // JDK position was saved
    OrderEntry[] orderEntries = ModuleRootManager.getInstance(getModule("m1")).getOrderEntries();
    assert orderEntries.length == 4;
    assert ((ModuleOrderEntry) orderEntries[0]).getModuleName().equals("m2");
    assert "Maven: junit:junit:4.0".equals(((LibraryOrderEntry) orderEntries[1]).getLibraryName());
    assert orderEntries[2] instanceof JdkOrderEntry;
    assert orderEntries[3] instanceof ModuleSourceOrderEntry;
}
Also used : WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 73 with WriteAction

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

the class MavenModuleBuilderTest method createNewModule.

private void createNewModule(MavenId id) throws Exception {
    myBuilder.setProjectId(id);
    new WriteAction() {

        protected void run(@NotNull Result result) throws Throwable {
            ModifiableModuleModel model = ModuleManager.getInstance(myProject).getModifiableModel();
            myBuilder.createModule(model);
            model.commit();
        }
    }.execute();
    resolveDependenciesAndImport();
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 74 with WriteAction

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

the class MergeFromTheirsResolver method applyBinaryChanges.

private void applyBinaryChanges() throws VcsException {
    List<FilePath> dirtyPaths = newArrayList();
    for (Change change : myTheirsBinaryChanges) {
        RunResult result = new WriteAction() {

            @Override
            protected void run(@NotNull Result result) throws Throwable {
                dirtyPaths.add(getFilePath(change));
                try {
                    applyBinaryChange(change);
                } catch (IOException e) {
                    throw new VcsException(e);
                }
            }
        }.execute();
        if (result.hasException()) {
            processBinaryChangeError(result.getThrowable());
        }
    }
    VcsDirtyScopeManager.getInstance(myVcs.getProject()).filePathsDirty(dirtyPaths, null);
}
Also used : WriteAction(com.intellij.openapi.application.WriteAction) IOException(java.io.IOException) RunResult(com.intellij.openapi.application.RunResult) RunResult(com.intellij.openapi.application.RunResult) Result(com.intellij.openapi.application.Result)

Example 75 with WriteAction

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

the class AddExternalLibraryToDependenciesQuickFix method invoke.

@Override
public void invoke(@NotNull Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
    DependencyScope scope = suggestScopeByLocation(myCurrentModule, myReference.getElement());
    JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibraryDescriptor, scope).done(aVoid -> new WriteAction() {

        protected void run(@NotNull final Result result) {
            try {
                importClass(myCurrentModule, editor, myReference, myQualifiedClassName);
            } catch (IndexNotReadyException e) {
                LOG.info(e);
            }
        }
    }.execute());
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope) WriteAction(com.intellij.openapi.application.WriteAction) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) NotNull(org.jetbrains.annotations.NotNull) Result(com.intellij.openapi.application.Result)

Aggregations

Result (com.intellij.openapi.application.Result)85 WriteAction (com.intellij.openapi.application.WriteAction)85 NotNull (org.jetbrains.annotations.NotNull)38 VirtualFile (com.intellij.openapi.vfs.VirtualFile)37 File (java.io.File)20 IOException (java.io.IOException)16 Module (com.intellij.openapi.module.Module)10 PsiFile (com.intellij.psi.PsiFile)7 Sdk (com.intellij.openapi.projectRoots.Sdk)5 RunResult (com.intellij.openapi.application.RunResult)4 Document (com.intellij.openapi.editor.Document)4 Project (com.intellij.openapi.project.Project)4 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)4 Library (com.intellij.openapi.roots.libraries.Library)4 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)4 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 FacetManager (com.intellij.facet.FacetManager)2 ProjectFacetManager (com.intellij.facet.ProjectFacetManager)2