本文整理匯總了Java中com.intellij.openapi.application.Application.runWriteAction方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.runWriteAction方法的具體用法?Java Application.runWriteAction怎麽用?Java Application.runWriteAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.application.Application
的用法示例。
在下文中一共展示了Application.runWriteAction方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invokeDialog
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
BaseDialog dialog = new BaseDialog("請輸入基類前綴:",project);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
String prefix = dialog.getClassNamePrefix();
if(prefix != null && !prefix.isEmpty()){
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiElement createdElement = createProjectDir(dir,prefix);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if(view != null&&createdElement != null){
view.selectElement(createdElement);
}
});
}
}
}
示例2: invokeDialog
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
BaseDialog dialog = new BaseDialog("請輸入基類前綴:",project);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
String prefix = dialog.getClassNamePrefix();
if(prefix != null && !prefix.isEmpty()){
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiElement[] elements = createProjectDir(dir,prefix);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if(view != null){
for (PsiElement element : elements) {
view.selectElement(element);
}
}
});
}
}
}
示例3: actionPerformed
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public final void actionPerformed(final AnActionEvent anActionEvent)
{
logger.debug("entered actionPerformed");
// we're being called on the Swing event dispatch thread. Spin off another thread to do the
// rearranging and let Swing's thread go.
// Thread t = new Thread(new Runnable() {
// public void run()
// {
// //To change body of implemented methods use Options | File Templates.
final Application application = ApplicationManager.getApplication();
application.runWriteAction(new RearrangeIt(anActionEvent.getDataContext()));
// }
// }, "RearrangerThread");
// t.start();
// new RearrangeIt(anActionEvent.getDataContext()).run();
}
示例4: actionPerformed
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public final void actionPerformed(final AnActionEvent anActionEvent)
{
logger.debug("entered actionPerformed");
// we're being called on the Swing event dispatch thread. Spin off another thread to do the
// rearranging and let Swing's thread go.
// Thread t = new Thread(new Runnable() {
// public void run()
// {
// //To change body of implemented methods use Options | File Templates.
final Application application = ApplicationManager.getApplication();
application.runWriteAction(new RearrangeIt(anActionEvent.getDataContext()));
// }
// }, "RearrangerThread");
// t.start();
// new RearrangeIt(anActionEvent.getDataContext()).run();
}
示例5: create
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
protected PsiElement[] create(String componentName, PsiDirectory directory) {
List<PsiElement> elements = new LinkedList<>();
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiDirectory componentDirectory = directory.createSubdirectory(componentName);
elements.add(componentDirectory);
String[] fileNames = getRequiredFileNames(componentName);
for (String fileName : fileNames) {
PsiFile file = componentDirectory.createFile(fileName);
elements.add(file);
}
});
return elements.toArray(new PsiElement[elements.size()]);
}
示例6: saveFileButtonActionPerformed
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private void saveFileButtonActionPerformed(java.awt.event.ActionEvent evt) {
Application application = ApplicationManager.getApplication();
application.runWriteAction(new Runnable() {
@Override
public void run() {
BinaryData data = codeArea.getData();
if (data instanceof DeltaDocument) {
try {
segmentsRepository.saveDocument((DeltaDocument) data);
} catch (IOException ex) {
ex.printStackTrace();
}
} else {
try (OutputStream stream = virtualFile.getOutputStream(this)) {
codeArea.getData().saveToStream(stream);
} catch (IOException e) {
e.printStackTrace();
}
}
undoHandler.setSyncPoint();
updateUndoState();
saveFileButton.setEnabled(false);
}
});
}
示例7: notifyPropertyChanged
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
public void notifyPropertyChanged(@NotNull final VirtualFile virtualFile, @NotNull final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例8: waitForTheFile
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static VirtualFile waitForTheFile(final String path) {
final VirtualFile[] file = new VirtualFile[1];
final Application app = ApplicationManager.getApplication();
Runnable action = new Runnable() {
@Override
public void run() {
app.runWriteAction(new Runnable() {
@Override
public void run() {
file[0] = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
}
});
}
};
if (app.isDispatchThread()) {
action.run();
}
else {
app.invokeAndWait(action, ModalityState.defaultModalityState());
}
return file[0];
}
示例9: decrementPostponedCounter
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private void decrementPostponedCounter() {
Application application = ApplicationManager.getApplication();
application.assertIsDispatchThread();
if (--getContext().myPostponedCounter == 0) {
if (application.isWriteAccessAllowed()) {
doPostponedFormatting();
}
else {
application.runWriteAction(new Runnable() {
@Override
public void run() {
doPostponedFormatting();
}
});
}
}
}
示例10: create
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
protected PsiElement[] create(String folderName, PsiDirectory directory) {
List<PsiElement> elements = new LinkedList<>();
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiDirectory folderDirectory = directory.createSubdirectory(folderName);
elements.add(folderDirectory);
PsiFile contentXmlFile = folderDirectory.createFile(".content.xml");
addContentToFile(contentXmlFile);
elements.add(contentXmlFile);
});
return elements.toArray(new PsiElement[elements.size()]);
}
示例11: createFiles
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private boolean createFiles() {
final Application application = ApplicationManager.getApplication();
return application.runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return myVerifier.execute();
}
});
}
示例12: finish
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public void finish()
{
logger.debug("entered finish() on thread " + Thread.currentThread().getName());
// popup.setVisible(false);
// popup.dispose();
// popup.removeWindowFocusListener(windowFocusListener);
// popup.removeWindowListener(windowAdapter);
// popup.removeMouseListener(mouseAdapter);
// popup.removeFocusListener(focusAdapter);
// popup.getContentPane().removeFocusListener(focusAdapter);
outerPanel.removeWindowFocusListener(windowFocusListener);
if (outerPanelFocusOwner != null) {
outerPanelFocusOwner.removeMouseListener(ma2);
}
outerPanel.removeWindowListener(windowAdapter);
outerPanel.removeMouseListener(mouseAdapter);
outerPanel.removeFocusListener(focusAdapter);
// containerPanel.removeFocusListener(containerPanel.getFocusListeners()[0]);
popup.hide();
// popup.dispose();
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(keyEventDispatcher);
// ToolTipManager.sharedInstance().setLightWeightPopupEnabled(wasLightWeight);
if (!rearrangementOccurred)
{
logger.debug("no rearrangement occurred, not rearranging document");
LiveRearrangerActionHandler.setInProgress(false);
return;
}
logger.debug("rearranging document");
final Runnable task = new Runnable()
{
public void run()
{
if (document != null)
{
final Emitter e = new Emitter(psiFile, resultRuleInstances, document);
e.emitRearrangedDocument();
}
}
};
final Application application = ApplicationManager.getApplication();
application.runWriteAction(
new Runnable()
{
public void run()
{
CommandProcessor.getInstance().executeCommand(project, task, "Rearrange", null);
}
}
);
LiveRearrangerActionHandler.setInProgress(false);
logger.debug("exit finish() on thread " + Thread.currentThread().getName());
}