本文整理匯總了Java中com.intellij.openapi.application.Application.isReadAccessAllowed方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.isReadAccessAllowed方法的具體用法?Java Application.isReadAccessAllowed怎麽用?Java Application.isReadAccessAllowed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.application.Application
的用法示例。
在下文中一共展示了Application.isReadAccessAllowed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: waitForSmartMode
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
public void waitForSmartMode() {
if (!isDumb()) {
return;
}
final Application application = ApplicationManager.getApplication();
if (application.isReadAccessAllowed() || application.isDispatchThread()) {
throw new AssertionError("Don't invoke waitForSmartMode from inside read action in dumb mode");
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
runWhenSmart(new Runnable() {
@Override
public void run() {
semaphore.up();
}
});
while (true) {
if (semaphore.waitFor(50)) {
return;
}
ProgressManager.checkCanceled();
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例5: resolve
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Nullable
@Override
public ResolvedNode resolve(@NonNull JavaContext context, @NonNull Node node) {
final PsiElement element = getPsiElement(node);
if (element == null) {
return null;
}
Application application = ApplicationManager.getApplication();
if (application.isReadAccessAllowed()) {
return resolve(element);
}
return application.runReadAction(new Computable<ResolvedNode>() {
@Nullable
@Override
public ResolvedNode compute() {
return resolve(element);
}
});
}
示例6: getType
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Nullable
@Override
public TypeDescriptor getType(@NonNull JavaContext context, @NonNull Node node) {
final PsiElement element = getPsiElement(node);
if (element == null) {
return null;
}
Application application = ApplicationManager.getApplication();
if (application.isReadAccessAllowed()) {
return getTypeDescriptor(element);
}
return application.runReadAction(new Computable<TypeDescriptor>() {
@Nullable
@Override
public TypeDescriptor compute() {
return getTypeDescriptor(element);
}
});
}
示例7: 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;
}
}
示例8: 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);
}
});
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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();
}
示例13: 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();
}
示例14: 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();
}
示例15: ask
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
protected boolean ask(final AuthenticationRequest obj, String description) {
if (myVerificationInProgress) {
return showAlreadyChecking();
}
myVerificationInProgress = true;
final Ref<Boolean> resultRef = new Ref<Boolean>();
final Runnable checker = new Runnable() {
@Override
public void run() {
try {
final boolean result =
interactiveValidation(obj.myProject, obj.getUrl(), obj.getRealm(), obj.getKind());
log("ask result for: " + obj.getUrl() + " is: " + result);
resultRef.set(result);
if (result) {
onStateChangedToSuccess(obj);
}
}
finally {
myVerificationInProgress = false;
}
}
};
final Application application = ApplicationManager.getApplication();
// also do not show auth if thread does not have progress indicator
if (application.isReadAccessAllowed() || !ProgressManager.getInstance().hasProgressIndicator()) {
application.executeOnPooledThread(checker);
}
else {
checker.run();
return resultRef.get();
}
return false;
}