use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class Flexmojos3ImporterTest method testMainCassAndFinalName.
public void testMainCassAndFinalName() throws Exception {
final VirtualFile file = createProjectSubFile("src/main/flex/SomeClass.mxml");
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
VfsUtil.saveText(file, "<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\"/>");
}
}.execute().throwException();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
importProject(mavenProjectDescription("project", "swf") + "<build>" + " <finalName>foo</finalName>" + " <sourceDirectory>src/main/flex</sourceDirectory>" + " <plugins>" + " <plugin>" + flexmojosPlugin() + " <dependencies>\n" + " <dependency>\n" + " <groupId>com.adobe.flex</groupId>\n" + " <artifactId>compiler</artifactId>\n" + " <version>3.5.0.12683</version>\n" + " <type>pom</type>\n" + " </dependency>\n" + " </dependencies>\n" + " </plugin>" + " </plugins>" + "</build>" + flexFrameworkDependency("3.5.0.12683"));
performPostImportTasks();
checkBCCount("project", 1);
checkBC("project", "project", new BuildConfigurationNature(Web, false, Application), "SomeClass", "foo.swf", "target", "3.5.0.12683", "en_US", "target/foo-config-report.xml");
}
use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class JavaStepDefinitionCreator method getDefaultStepDefinitionFolder.
@NotNull
@Override
public PsiDirectory getDefaultStepDefinitionFolder(@NotNull final GherkinStep step) {
PsiFile featureFile = step.getContainingFile();
if (featureFile != null) {
PsiDirectory psiDirectory = featureFile.getContainingDirectory();
final Project project = step.getProject();
if (psiDirectory != null) {
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
VirtualFile directory = psiDirectory.getVirtualFile();
if (projectFileIndex.isInContent(directory)) {
VirtualFile sourceRoot = projectFileIndex.getSourceRootForFile(directory);
//noinspection ConstantConditions
final Module module = projectFileIndex.getModuleForFile(featureFile.getVirtualFile());
if (module != null) {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
if (sourceRoot != null && sourceRoot.getName().equals("resources")) {
final VirtualFile resourceParent = sourceRoot.getParent();
for (VirtualFile vFile : sourceRoots) {
if (vFile.getPath().startsWith(resourceParent.getPath()) && vFile.getName().equals("java")) {
sourceRoot = vFile;
break;
}
}
} else {
if (sourceRoots.length > 0) {
sourceRoot = sourceRoots[sourceRoots.length - 1];
}
}
}
String packageName = "";
if (sourceRoot != null) {
packageName = CucumberJavaUtil.getPackageOfStepDef(step);
}
final String packagePath = packageName.replace('.', '/');
final String path = sourceRoot != null ? sourceRoot.getPath() : directory.getPath();
// ToDo: I shouldn't create directories, only create VirtualFile object.
final Ref<PsiDirectory> resultRef = new Ref<>();
new WriteAction() {
protected void run(@NotNull Result result) throws Throwable {
final VirtualFile packageFile = VfsUtil.createDirectoryIfMissing(path + '/' + packagePath);
if (packageFile != null) {
resultRef.set(PsiDirectoryFactory.getInstance(project).createDirectory(packageFile));
}
}
}.execute();
return resultRef.get();
}
}
}
assert featureFile != null;
return ObjectUtils.assertNotNull(featureFile.getParent());
}
use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class HeavyOsgiFixtureTestCase method loadModules.
private static void loadModules(String projectName, final Project project, String projectDirPath) throws Exception {
final File projectDir = OsgiTestUtil.extractProject(projectName, projectDirPath);
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
VirtualFile virtualDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(projectDir);
assertNotNull(projectDir.getPath(), virtualDir);
for (File moduleDir : projectDir.listFiles(VISIBLE_DIR_FILTER)) {
File moduleFile = new File(moduleDir, moduleDir.getName() + ".iml");
if (moduleFile.exists()) {
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(moduleFile);
ModuleManager.getInstance(project).loadModule(moduleFile.getPath());
}
}
}
}.execute();
}
use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class RubyMotionFacetConfigurator method configure.
public static void configure(VirtualFile baseDir, Module module) {
final RubyMotionFacet existingFacet = RubyMotionFacet.getInstance(module);
if (existingFacet != null) {
return;
}
FacetManager facetManager = FacetManager.getInstance(module);
final ModifiableFacetModel model = facetManager.createModifiableModel();
RubyMotionFacetType facetType = RubyMotionFacetType.getInstance();
RubyMotionFacetConfiguration configuration = ProjectFacetManager.getInstance(module.getProject()).createDefaultConfiguration(facetType);
//configuration.setProjectRootPath(baseDir.getPath());
VirtualFile testFolder = baseDir.findChild("spec");
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
if (testFolder != null) {
//configuration.setTestPath(testFolder.getPath());
addTestSources(testFolder, rootModel);
}
VirtualFile libFolder = baseDir.findChild("app");
if (libFolder != null) {
//configuration.setLibPath(libFolder.getPath());
}
RubyMotionFacet.updateMotionLibrary(rootModel);
IdeaInternalUtil.runInsideWriteAction(new ActionRunner.InterruptibleRunnable() {
public void run() throws Exception {
rootModel.commit();
}
});
RubyMotionFacet facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), configuration, null);
model.addFacet(facet);
new WriteAction() {
protected void run(@NotNull final Result result) throws Throwable {
model.commit();
}
}.execute();
RubyMotionUtilExt.createMotionRunConfiguration(module);
}
use of com.intellij.openapi.application.WriteAction in project intellij-plugins by JetBrains.
the class RubyMotionFacetConfigurator method configureSdk.
private static void configureSdk(final Project project) {
final ProjectRootManager manager = ProjectRootManager.getInstance(project);
final Sdk sdk = manager.getProjectSdk();
if (!RubySdkUtil.isNativeRuby19(sdk)) {
for (final Sdk newSdk : ProjectJdkTable.getInstance().getSdksOfType(RubySdkType.getInstance())) {
if (RubySdkUtil.isNativeRuby19(newSdk) && !RubySdkUtil.isNativeRuby20(newSdk) && !RubyRemoteInterpreterManager.getInstance().isRemoteSdk(newSdk)) {
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
ProjectRootManager.getInstance(project).setProjectSdk(newSdk);
}
}.execute();
}
}
}
}
Aggregations