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


Java Application.runReadAction方法代碼示例

本文整理匯總了Java中com.intellij.openapi.application.Application.runReadAction方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.runReadAction方法的具體用法?Java Application.runReadAction怎麽用?Java Application.runReadAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.application.Application的用法示例。


在下文中一共展示了Application.runReadAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runBackgroundLoading

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
protected void runBackgroundLoading(@NotNull final Runnable runnable) {
  if (isDisposed()) return;

  final Application app = ApplicationManager.getApplication();
  if (app != null) {
    app.runReadAction(new TreeRunnable("AbstractTreeBuilder.runBackgroundLoading") {
      @Override
      public void perform() {
        runnable.run();
      }
    });
  }
  else {
    runnable.run();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:AbstractTreeBuilder.java

示例2: findValidParentUnderReadAction

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Nullable
public static VirtualFile findValidParentUnderReadAction(final FilePath file) {
  if (file.getVirtualFile() != null) return file.getVirtualFile();
  final Computable<VirtualFile> computable = new Computable<VirtualFile>() {
    @Override
    public VirtualFile compute() {
      return findValidParent(file);
    }
  };
  final Application application = ApplicationManager.getApplication();
  if (application.isReadAccessAllowed()) {
    return computable.compute();
  } else {
    return application.runReadAction(computable);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ChangesUtil.java

示例3: getAttributes

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public NamedNodeMap getAttributes() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<NamedNodeMap>() {
      @Override
      public NamedNodeMap compute() {
        return getAttributes();
      }
    });
  }

  if (myAttributes == null) {
    XmlAttribute[] attributes = myTag.getAttributes();
    if (attributes.length == 0) {
     myAttributes = EMPTY_ATTRIBUTES;
    } else {
      myAttributes = new DomNamedNodeMap(this, attributes);
    }
  }

  return myAttributes;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:DomPsiConverter.java

示例4: getValue

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getValue() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getValue();
      }
    });
  }

  String value = myAttribute.getValue();
  if (value == null) {
    value = "";
  }
  return value;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:DomPsiConverter.java

示例5: getRootTagAttributeSafely

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
/**
 * Get the value of an attribute in the {@link com.intellij.psi.xml.XmlFile} safely (meaning it will acquire the read lock first).
 */
@Nullable
public static String getRootTagAttributeSafely(@NotNull final XmlFile file,
                                               @NotNull final String attribute,
                                               @Nullable final String namespace) {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Nullable
      @Override
      public String compute() {
        return getRootTagAttributeSafely(file, attribute, namespace);
      }
    });
  } else {
    XmlTag tag = file.getRootTag();
    if (tag != null) {
      XmlAttribute attr = namespace != null ? tag.getAttribute(attribute, namespace) : tag.getAttribute(attribute);
      if (attr != null) {
        return attr.getValue();
      }
    }
    return null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:AndroidPsiUtils.java

示例6: buildLiveRearrangerData

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
/**
 * must be called from within an IDEA read-action thread.
 *
 * @param project
 * @param document
 * @param psiFile
 */
void buildLiveRearrangerData(final Project project,
                             final Document document,
                             final PsiFile psiFile,
                             final int cursorOffset)
{
    /**
     * Per instructions from IntelliJ, we have to commit any changes to the document to the Psi
     * tree.
     */
    final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    documentManager.commitDocument(document);
    final RearrangerSettings settings    = new RearrangerSettings(); // use default settings with no rules
    settings.setAskBeforeRearranging(true);
    final Runnable task = new Runnable()
    {
        public void run()
        {
            logger.debug("liveRearrangeDocument task started");
            liveRearrangeDocument(project, psiFile, settings, document, cursorOffset);
        }
    };

    Thread t = new Thread(new Runnable()
    {
        public void run()
        {
            logger.debug("started thread " + Thread.currentThread().getName());
            final Application application = ApplicationManager.getApplication();
            application.runReadAction(new Runnable() {
                public void run() {
                    logger.debug("enter application.runReadAction() on thread " + Thread.currentThread().getName());
                    task.run();
                    logger.debug("exit application.runReadAction() on thread " + Thread.currentThread().getName());
            }});
        }
    }, "Live Rearranger parser");
    t.start();
    logger.debug("exit buildLiveRearrangerData on thread " + Thread.currentThread().getName());
}
 
開發者ID:DaveKriewall,項目名稱:Rearranger,代碼行數:47,代碼來源:RearrangementResult31.java

示例7: sortModules

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static void sortModules(final Project project, final List<Module> modules) {
  final Application application = ApplicationManager.getApplication();
  Runnable sort = new Runnable() {
    public void run() {
      Comparator<Module> comparator = ModuleManager.getInstance(project).moduleDependencyComparator();
      Collections.sort(modules, comparator);
    }
  };
  if (application.isDispatchThread()) {
    sort.run();
  }
  else {
    application.runReadAction(sort);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:ModuleCompilerUtil.java

示例8: runOnSyncPublisher

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static <T> void runOnSyncPublisher(final Project project, final Topic<T> topic, final Consumer<T> listener) {
  final Application application = ApplicationManager.getApplication();
  final Runnable runnable = createPublisherRunnable(project, topic, listener);
  if (application.isDispatchThread()) {
    runnable.run();
  } else {
    application.runReadAction(runnable);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:MessageBusUtil.java

示例9: getPosition

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
@Nullable
public Position getPosition(@NonNull final Node node) {
  Application application = ApplicationManager.getApplication();
  if (application.isReadAccessAllowed()) {
    return getPositionImmediate(node);
  }
  return application.runReadAction(new Computable<Position>() {
    @Override
    @Nullable
    public Position compute() {
      return getPositionImmediate(node);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:LombokPsiConverter.java

示例10: getTagName

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getTagName() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getTagName();
      }
    });
  }

  return myTag.getName();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:DomPsiConverter.java

示例11: getNodeValue

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getNodeValue() throws DOMException {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getNodeValue();
      }
    });
  }

  return myText.getText();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:DomPsiConverter.java

示例12: getName

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getName() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getName();
      }
    });
  }
  return myAttribute.getName();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:DomPsiConverter.java

示例13: getLocalName

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getLocalName() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getLocalName();
      }
    });
  }

  return myAttribute.getLocalName();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:DomPsiConverter.java

示例14: getPrefix

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getPrefix() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getPrefix();
      }
    });
  }

  return myAttribute.getNamespacePrefix();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:DomPsiConverter.java

示例15: getNamespaceURI

import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
@Override
public String getNamespaceURI() {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Override
      public String compute() {
        return getNamespaceURI();
      }
    });
  }

  return myAttribute.getNamespace();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:DomPsiConverter.java


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