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();
}
use of com.intellij.openapi.application.WriteAction in project kotlin by JetBrains.
the class AbstractQuickFixMultiFileTest method createVirtualFileFromTestFile.
/**
* @param sourceRootDir Base path of test file(Test source directory)
* @param testFile source of VFile content
* @return created VirtualFile
*/
protected static VirtualFile createVirtualFileFromTestFile(File sourceRootDir, final TestFile testFile) {
try {
assertFalse("Please don't use absolute path for multifile test 'FILE' directive: " + testFile.path, FileUtil.isAbsolutePlatformIndependent(testFile.path));
FileType fileType = guessFileType(testFile);
String extension = fileType.getDefaultExtension();
final File fileInSourceRoot = new File(testFile.path);
File container = FileUtil.getParentFile(fileInSourceRoot);
if (container == null) {
container = sourceRootDir;
} else {
container = new File(sourceRootDir, container.getPath());
}
if (!container.exists()) {
assertTrue(container.mkdirs());
}
final File tempFile = FileUtil.createTempFile(container, FileUtil.getNameWithoutExtension(testFile.path), "." + extension, true);
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile);
assert vFile != null;
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
vFile.setCharset(CharsetToolkit.UTF8_CHARSET);
VfsUtil.saveText(vFile, testFile.content);
}
}.execute();
return vFile;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.openapi.application.WriteAction in project kotlin by JetBrains.
the class GradleImportingTestCase method setUp.
@Override
public void setUp() throws Exception {
myJdkHome = IdeaTestUtil.requireRealJdkHome();
super.setUp();
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
if (oldJdk != null) {
ProjectJdkTable.getInstance().removeJdk(oldJdk);
}
VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
assert jdkHomeDir != null;
Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME);
assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
ProjectJdkTable.getInstance().addJdk(jdk);
}
}.execute();
myProjectSettings = new GradleProjectSettings();
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx128m -XX:MaxPermSize=64m");
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
configureWrapper();
}
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());
}
use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class AddFacetTest method testAddFacetAfterCreatingManifest.
public void testAddFacetAfterCreatingManifest() {
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
VirtualFile[] roots = ModuleRootManager.getInstance(myModule).getContentRoots();
VirtualFile metaInf = roots[0].createChildDirectory(this, "META-INF");
VirtualFile manifest = metaInf.createChildData(this, "MANIFEST.MF");
VfsUtil.saveText(manifest, "Manifest-Version: 1.0\n" + "Bundle-ManifestVersion: 2\n" + "Bundle-Name: Test\n" + "Bundle-SymbolicName: test\n" + "Bundle-Version: 1.0.0\n");
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
}
}.execute();
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
ModifiableFacetModel model = FacetManager.getInstance(myModule).createModifiableModel();
OsmorcFacet facet = new OsmorcFacet(myModule);
facet.getConfiguration().setManifestGenerationMode(ManifestGenerationMode.Manually);
model.addFacet(facet);
model.commit();
}
}.execute();
}
Aggregations