當前位置: 首頁>>代碼示例>>Java>>正文


Java Application.runWriteAction方法代碼示例

本文整理匯總了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);
                }
            });
        }
    }
}
 
開發者ID:wangtotang,項目名稱:DaggerHelper,代碼行數:20,代碼來源:NewModuleDirAction.java

示例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);
                    }
                }
            });
        }
    }
}
 
開發者ID:wangtotang,項目名稱:DaggerHelper,代碼行數:22,代碼來源:NewProjectDirAction.java

示例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();
    }
 
開發者ID:DaveKriewall,項目名稱:Rearranger,代碼行數:17,代碼來源:RearrangementTest30.java

示例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();
    }
 
開發者ID:DaveKriewall,項目名稱:Rearranger,代碼行數:17,代碼來源:SpaceTest4.java

示例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()]);
}
 
開發者ID:Cognifide,項目名稱:IntelliJ-Shortcuts-For-AEM,代碼行數:17,代碼來源:NewAemComponentAction.java

示例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);
        }
    });
}
 
開發者ID:hajdam,項目名稱:deltahex-intellij-plugin,代碼行數:27,代碼來源:DeltaHexFileEditor.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:VirtualFileManagerImpl.java

示例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];
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:VcsUtil.java

示例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();
        }
      });
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:PostprocessReformattingAspect.java

示例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()]);
}
 
開發者ID:Cognifide,項目名稱:IntelliJ-Shortcuts-For-AEM,代碼行數:15,代碼來源:NewSlingFolder.java

示例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();
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:PatchApplier.java

示例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());
    }
 
開發者ID:DaveKriewall,項目名稱:Rearranger,代碼行數:57,代碼來源:LiveRearrangerPopup.java


注:本文中的com.intellij.openapi.application.Application.runWriteAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。