本文整理匯總了Java中com.intellij.openapi.application.Application.isWriteAccessAllowed方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.isWriteAccessAllowed方法的具體用法?Java Application.isWriteAccessAllowed怎麽用?Java Application.isWriteAccessAllowed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.application.Application
的用法示例。
在下文中一共展示了Application.isWriteAccessAllowed方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: refreshIoFiles
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
public void refreshIoFiles(@NotNull Iterable<File> files, boolean async, boolean recursive, @Nullable Runnable onFinish) {
final VirtualFileManagerEx manager = (VirtualFileManagerEx)VirtualFileManager.getInstance();
Application app = ApplicationManager.getApplication();
boolean fireCommonRefreshSession = app.isDispatchThread() || app.isWriteAccessAllowed();
if (fireCommonRefreshSession) manager.fireBeforeRefreshStart(false);
try {
List<VirtualFile> filesToRefresh = new ArrayList<VirtualFile>();
for (File file : files) {
final VirtualFile virtualFile = refreshAndFindFileByIoFile(file);
if (virtualFile != null) {
filesToRefresh.add(virtualFile);
}
}
RefreshQueue.getInstance().refresh(async, recursive, onFinish, filesToRefresh);
}
finally {
if (fireCommonRefreshSession) manager.fireAfterRefreshFinish(false);
}
}
示例2: 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();
}
});
}
}
}
示例3: runNotUnderWriteAction
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private static void runNotUnderWriteAction(@NotNull Project project, @NotNull Runnable runnable) {
Application application = ApplicationManager.getApplication();
if (application.isWriteAccessAllowed()) {
application.invokeLater(runnable, project.getDisposed());
}
else {
runnable.run();
}
}
示例4: loadText
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@NotNull
public static CharSequence loadText(@NotNull final VirtualFile file) {
if (file instanceof LightVirtualFile) {
return ((LightVirtualFile)file).getContent();
}
if (file.isDirectory()) {
throw new AssertionError("'" + file.getPresentableUrl() + "' is a directory");
}
FileType fileType = file.getFileType();
if (fileType.isBinary()) {
final BinaryFileDecompiler decompiler = BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType);
if (decompiler != null) {
CharSequence text;
Application app = ApplicationManager.getApplication();
if (app != null && app.isDispatchThread() && !app.isWriteAccessAllowed() && !GraphicsEnvironment.isHeadless()) {
final Ref<CharSequence> result = Ref.create(ArrayUtil.EMPTY_CHAR_SEQUENCE);
final Ref<Throwable> error = Ref.create();
ProgressManager.getInstance().run(new Task.Modal(null, "Decompiling " + file.getName(), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
try {
result.set(ApplicationUtil.runWithCheckCanceled(new Callable<CharSequence>() {
@Override
public CharSequence call() {
return decompiler.decompile(file);
}
}, indicator));
}
catch (Throwable t) {
error.set(t);
}
}
});
ExceptionUtil.rethrowUnchecked(error.get());
text = result.get();
}
else {
text = decompiler.decompile(file);
}
StringUtil.assertValidSeparators(text);
return text;
}
throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl() + ". File type: " + fileType.getName());
}
try {
byte[] bytes = file.contentsToByteArray();
return getTextByBinaryPresentation(bytes, file);
}
catch (IOException e) {
return ArrayUtil.EMPTY_CHAR_SEQUENCE;
}
}