Search in sources :

Example 21 with WriteAction

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

the class GradleImportingTestCase method configureWrapper.

private void configureWrapper() throws IOException, URISyntaxException {
    URI distributionUri = new AbstractModelBuilderTest.DistributionLocator().getDistributionFor(GradleVersion.version(gradleVersion));
    myProjectSettings.setDistributionType(DistributionType.DEFAULT_WRAPPED);
    final VirtualFile wrapperJarFrom = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(wrapperJar());
    assert wrapperJarFrom != null;
    final VirtualFile wrapperJarFromTo = createProjectSubFile("gradle/wrapper/gradle-wrapper.jar");
    new WriteAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            wrapperJarFromTo.setBinaryContent(wrapperJarFrom.contentsToByteArray());
        }
    }.execute().throwException();
    Properties properties = new Properties();
    properties.setProperty("distributionBase", "GRADLE_USER_HOME");
    properties.setProperty("distributionPath", "wrapper/dists");
    properties.setProperty("zipStoreBase", "GRADLE_USER_HOME");
    properties.setProperty("zipStorePath", "wrapper/dists");
    properties.setProperty("distributionUrl", distributionUri.toString());
    StringWriter writer = new StringWriter();
    properties.store(writer, null);
    createProjectSubFile("gradle/wrapper/gradle-wrapper.properties", writer.toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StringWriter(java.io.StringWriter) WriteAction(com.intellij.openapi.application.WriteAction) Properties(java.util.Properties) URI(java.net.URI) NotNull(org.jetbrains.annotations.NotNull) Result(com.intellij.openapi.application.Result)

Example 22 with WriteAction

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

the class LibraryOptionsPanel method doConfigure.

private void doConfigure() {
    switch(myButtonEnumModel.getSelected()) {
        case DOWNLOAD:
            final LibraryDownloadSettings oldDownloadSettings = mySettings.getDownloadSettings();
            LOG.assertTrue(oldDownloadSettings != null);
            final LibraryDownloadSettings newDownloadSettings = DownloadingOptionsDialog.showDialog(myPanel, oldDownloadSettings, mySettings.getCompatibleVersions(), true);
            if (newDownloadSettings != null) {
                mySettings.setDownloadSettings(newDownloadSettings);
            }
            break;
        case USE_LIBRARY:
            final Object item = myExistingLibraryComboBox.getSelectedItem();
            if (item instanceof LibraryEditor) {
                EditLibraryDialog dialog = new EditLibraryDialog(myPanel, mySettings, (LibraryEditor) item);
                dialog.show();
                if (item instanceof ExistingLibraryEditor) {
                    new WriteAction() {

                        protected void run(@NotNull final Result result) {
                            ((ExistingLibraryEditor) item).commit();
                        }
                    }.execute();
                }
            }
            break;
        case USE_FROM_PROVIDER:
        case SETUP_LIBRARY_LATER:
            break;
    }
    updateState();
}
Also used : ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 23 with WriteAction

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

the class AddCustomLibraryDialog method doOKAction.

@Override
protected void doOKAction() {
    final LibraryCompositionSettings settings = myPanel.apply();
    if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
        if (myModifiableRootModel == null) {
            final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
            new WriteAction() {

                @Override
                protected void run(@NotNull final Result result) {
                    addLibraries(model, settings);
                    model.commit();
                }
            }.execute();
        } else {
            addLibraries(myModifiableRootModel, settings);
        }
    }
    super.doOKAction();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 24 with WriteAction

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

the class CreateNewLibraryDialog method createLibrary.

@NotNull
public Library createLibrary() {
    final LibraryTable.ModifiableModel modifiableModel = getTableModifiableModel();
    final LibraryType<?> type = myLibraryEditor.getType();
    final Library library = modifiableModel.createLibrary(myLibraryEditor.getName(), type != null ? type.getKind() : null);
    final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx) library.getModifiableModel();
    myLibraryEditor.applyTo(model);
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) {
            model.commit();
        }
    }.execute();
    return library;
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) WriteAction(com.intellij.openapi.application.WriteAction) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Library(com.intellij.openapi.roots.libraries.Library) Result(com.intellij.openapi.application.Result) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with WriteAction

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

the class CompilerTestUtil method enableExternalCompiler.

@TestOnly
public static void enableExternalCompiler() {
    final JavaAwareProjectJdkTableImpl table = JavaAwareProjectJdkTableImpl.getInstanceEx();
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) {
            table.addJdk(table.getInternalJdk());
        }
    }.execute();
}
Also used : WriteAction(com.intellij.openapi.application.WriteAction) JavaAwareProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl) Result(com.intellij.openapi.application.Result) TestOnly(org.jetbrains.annotations.TestOnly)

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