本文整理汇总了Java中com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction方法的典型用法代码示例。如果您正苦于以下问题:Java WriteCommandAction.runWriteCommandAction方法的具体用法?Java WriteCommandAction.runWriteCommandAction怎么用?Java WriteCommandAction.runWriteCommandAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.command.WriteCommandAction
的用法示例。
在下文中一共展示了WriteCommandAction.runWriteCommandAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
dialog.show();
int exitCode = dialog.getExitCode();
if (exitCode != CANCEL_EXIT_CODE) {
String key = dialog.getKeyText();
String value = dialog.getValueText();
currentLang = dialog.getSelectedLangauge();
if (currentLang != null && !currentLang.isEmpty()) {
Editor ieditor = editorMap.get(currentLang);
Document document = ieditor.getDocument();
WriteCommandAction.runWriteCommandAction(fileEditor.getProject(), () -> updateDocumentHook(document, ieditor.getProject(), currentLang, key, value, model));
} else {
NotificationHelper.showBaloon("No language file available", MessageType.WARNING, fileEditor.getProject());
}
}
}
示例2: build
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void build(PsiFile psiFile, Project project1, Editor editor) {
if (psiFile == null) return;
WriteCommandAction.runWriteCommandAction(project1, () -> {
if (editor == null) return;
Project project = editor.getProject();
if (project == null) return;
PsiElement element = psiFile.findElementAt(editor.getCaretModel().getOffset());
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass == null) return;
if (psiClass.getNameIdentifier() == null) return;
String className = psiClass.getNameIdentifier().getText();
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
build(editor, elementFactory, project, psiClass, className);
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
styleManager.optimizeImports(psiFile);
styleManager.shortenClassReferences(psiClass);
});
}
示例3: actionPerformed
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
RefmtManager refmt = RefmtManager.getInstance();
if (refmt != null) {
PsiFile file = e.getData(PSI_FILE);
Project project = e.getProject();
if (project != null && file != null && (file instanceof OclFile || file instanceof RmlFile)) {
String format = file instanceof OclFile ? "ml" : "re";
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document != null) {
//WriteCommandAction.writeCommandAction(project).run(() -> refmt.refmt(project, format, document));
WriteCommandAction.runWriteCommandAction(project, () -> refmt.refmt(project, format, document)); // idea#143
}
}
}
}
示例4: upgrade
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
@Override
public void upgrade(@NotNull DependencyInfo dependencyInfo, @NotNull Listener listener)
{
if (upgrading)
{
return;
}
upgrading = true;
WriteCommandAction.runWriteCommandAction(project, () ->
{
MavenHelper.upgradeDependency(project.getBaseDir(), dependencyInfo);
GradleHelper.upgradeDependency(project.getBaseDir(), dependencyInfo);
listener.upgradeDone(dependencyInfo);
upgrading = false;
});
}
示例5: testContentChanged_reloadChangedDocument
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testContentChanged_reloadChangedDocument() throws Exception {
final VirtualFile file = createFile();
final Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@Override
public void run() {
document.insertString(0, "zzz");
}
});
myReloadFromDisk = Boolean.TRUE;
setContent(file, "xxx");
assertEquals("xxx", document.getText());
assertEquals(file.getModificationStamp(), document.getModificationStamp());
assertEquals(0, myDocumentManager.getUnsavedDocuments().length);
}
示例6: setDocumentText
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
private void setDocumentText(final Object document, final String value) {
if (document instanceof PlainDocument) {
try {
((PlainDocument)document).remove(0, ((PlainDocument)document).getLength());
((PlainDocument)document).insertString(0, value, null);
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
} else {
WriteCommandAction.runWriteCommandAction(project, new Runnable() {
public void run() {
((com.intellij.openapi.editor.Document)document)
.replaceString(0, ((com.intellij.openapi.editor.Document)document).getTextLength(), value);
}
});
}
}
示例7: testAddPropertyInAlphaOrder
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testAddPropertyInAlphaOrder() {
final PsiFile psiFile = myFixture.configureByFile("bar.xml");
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile);
assertNotNull(propertiesFile);
WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
public void run() {
propertiesFile.addProperty("d", "vvv");
propertiesFile.addProperty("a", "vvv");
propertiesFile.addProperty("l", "vvv");
propertiesFile.addProperty("v", "vvv");
}
});
assertTrue(propertiesFile.isAlphaSorted());
assertTrue(PropertiesImplUtil.getPropertiesFile(psiFile).isAlphaSorted());
}
示例8: testCustomChildrenEvents
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testCustomChildrenEvents() throws Throwable {
final Sepulka element = createElement("<a><foo/><bar/></a>", Sepulka.class);
final List<MyElement> list = element.getCustomChildren();
final XmlTag tag = element.getXmlTag();
WriteCommandAction.runWriteCommandAction(null, new Runnable(){
@Override
public void run() {
tag.getSubTags()[0].delete();
tag.getSubTags()[0].delete();
}
});
tag.add(createTag("<goo/>"));
putExpected(new DomEvent(element, false));
putExpected(new DomEvent(element, false));
putExpected(new DomEvent(element, false));
assertResultsAndClear();
assertEquals(1, element.getCustomChildren().size());
}
示例9: testGetUncommittedDocuments_documentChanged_DontProcessEvents
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testGetUncommittedDocuments_documentChanged_DontProcessEvents() throws Exception {
final PsiFile file = getPsiManager().findFile(createFile());
final Document document = getPsiDocumentManager().getDocument(file);
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
getPsiDocumentManager().getSynchronizer().performAtomically(file, new Runnable() {
@Override
public void run() {
changeDocument(document, PsiDocumentManagerImplTest.this.getPsiDocumentManager());
}
});
}
});
assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
}
示例10: testOnClickIntention
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testOnClickIntention() throws Throwable {
myFixture.copyFileToProject(testFolder + "/OnClickActivity.java", "src/p1/p2/Activity1.java");
final VirtualFile file = copyFileToProject("onClickIntention.xml");
myFixture.configureFromExistingVirtualFile(file);
final AndroidCreateOnClickHandlerAction action = new AndroidCreateOnClickHandlerAction();
assertTrue(action.isAvailable(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile()));
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
action.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile());
}
});
myFixture.checkResultByFile(testFolder + "/onClickIntention.xml");
myFixture.checkResultByFile("src/p1/p2/Activity1.java", testFolder + "/OnClickActivity_after.java", false);
}
示例11: extract
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
private static void extract(final Document document, final Map<String, RangeMarker> sliceUsageName2Offset, final String name) {
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
for (int i = 1; i < 9; i++) {
String newName = name + i;
String s = "<flown" + newName + ">";
if (!document.getText().contains(s)) break;
int off = document.getText().indexOf(s);
document.deleteString(off, off + s.length());
RangeMarker prev = sliceUsageName2Offset.put(newName, document.createRangeMarker(off, off));
assertNull(prev);
extract(document, sliceUsageName2Offset, newName);
}
}
});
}
示例12: testSetsFiletreeDependencies
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
public void testSetsFiletreeDependencies() throws Exception {
final GradleBuildFile file = getTestFile("");
ImmutableList<String> fileList = ImmutableList.of("*.jar", "*.aar");
Map<String, Object> nvMap = ImmutableMap.of(
"dir", "libs",
"includes", (Object)fileList
);
final Dependency dep = new Dependency(Dependency.Scope.COMPILE, Dependency.Type.FILETREE, nvMap);
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@Override
public void run() {
file.setValue(BuildFileKey.DEPENDENCIES, ImmutableList.of(dep));
}
});
String expected =
"dependencies {\n" +
" compile fileTree(dir: 'libs', includes: ['*.jar', '*.aar'])\n" +
"}";
assertContents(expected);
}
示例13: handleNormal
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
private void handleNormal(JSONObject json, List<String> generateFiled) {
WriteCommandAction.runWriteCommandAction(project, new Runnable() {
@Override
public void run() {
if (targetClass == null) {
try {
targetClass = PsiClassUtil.getPsiClass(file, project, generateClassName);
} catch (Throwable throwable) {
handlePathError(throwable);
}
}
if (targetClass != null) {
generateClassEntity.setPsiClass(targetClass);
try {
generateClassEntity.addAllFields(createFields(json, generateFiled, generateClassEntity));
operator.setVisible(false);
DataWriter dataWriter = new DataWriter(file, project, targetClass);
dataWriter.execute(generateClassEntity);
Config.getInstant().saveCurrentPackPath(packageName);
operator.dispose();
} catch (Exception e) {
throw e;
}
}
}
});
}
示例14: formatYaml
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
private void formatYaml(VirtualFile file) throws Exception {
WriteCommandAction.runWriteCommandAction(mProject, new Runnable() {
@Override
public void run() {
try {
file.setBinaryContent(toYaml(new Yaml().load(file.getInputStream())).getBytes(file.getCharset()));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
示例15: setUp
import com.intellij.openapi.command.WriteCommandAction; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");
});
myFixture.addFileToProject("typo3conf/ext/foo/ext_emconf.php", "");
myFixture.copyFileToProject("sample.xlf", "typo3conf/ext/foo/sample.xlf");
myFixture.copyFileToProject("de.sample.xlf", "typo3conf/ext/foo/de.sample.xlf");
}