本文整理汇总了Java中com.intellij.openapi.vfs.ReadonlyStatusHandler.ensureFilesWritable方法的典型用法代码示例。如果您正苦于以下问题:Java ReadonlyStatusHandler.ensureFilesWritable方法的具体用法?Java ReadonlyStatusHandler.ensureFilesWritable怎么用?Java ReadonlyStatusHandler.ensureFilesWritable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.ReadonlyStatusHandler
的用法示例。
在下文中一共展示了ReadonlyStatusHandler.ensureFilesWritable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isQuickFixOnReadOnlyFile
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
private static boolean isQuickFixOnReadOnlyFile(PsiElement problemElement) {
final PsiFile containingPsiFile = problemElement.getContainingFile();
if (containingPsiFile == null) {
return false;
}
final VirtualFile virtualFile = containingPsiFile.getVirtualFile();
final Project project = problemElement.getProject();
final ReadonlyStatusHandler handler = ReadonlyStatusHandler.getInstance(project);
final ReadonlyStatusHandler.OperationStatus status;
if (virtualFile != null) {
status = handler.ensureFilesWritable(virtualFile);
return status.hasReadonlyFiles();
}
return false;
}
示例2: prepareFileForWrite
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
public boolean prepareFileForWrite(@Nullable final PsiFile psiFile) {
if (psiFile == null) return false;
final VirtualFile file = psiFile.getVirtualFile();
final Project project = psiFile.getProject();
if (ReadonlyStatusHandler.ensureFilesWritable(project, file)) {
return true;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
final Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, file), true);
if (editor != null && editor.getComponent().isDisplayable()) {
HintManager.getInstance().showErrorHint(editor, CodeInsightBundle.message("error.hint.file.is.readonly", file.getPresentableUrl()));
}
}
}, project.getDisposed());
return false;
}
示例3: executeWithReparse
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
protected void executeWithReparse(ThrowableRunnable<Exception> operation) {
if (!ReadonlyStatusHandler.ensureFilesWritable(getProject(), myFile)) {
return;
}
try {
myPsiChangeListener.stop();
operation.run();
myPsiChangeListener.start();
reparseFile();
}
catch (Throwable e) {
showError("Execute command", e);
myPsiChangeListener.start();
}
}
示例4: execute
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
protected void execute(List<EditOperation> operations) {
if (!ReadonlyStatusHandler.ensureFilesWritable(getProject(), myFile)) {
return;
}
try {
myPsiChangeListener.stop();
for (EditOperation operation : operations) {
operation.execute();
}
updateRenderer(true);
}
catch (Throwable e) {
showError("Execute command", e);
}
finally {
myPsiChangeListener.start();
}
}
示例5: prepareFileForWrite
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
public boolean prepareFileForWrite(@Nullable final PsiFile psiFile) {
if (psiFile == null) return false;
final VirtualFile file = psiFile.getVirtualFile();
final Project project = psiFile.getProject();
final Editor editor =
psiFile.isWritable() ? null : FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, file), true);
if (!ReadonlyStatusHandler.ensureFilesWritable(project, file)) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (editor != null && editor.getComponent().isDisplayable()) {
HintManager.getInstance()
.showErrorHint(editor, CodeInsightBundle.message("error.hint.file.is.readonly", file.getPresentableUrl()));
}
}
});
return false;
}
return true;
}
示例6: execute
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected void execute(java.util.List<EditOperation> operations) {
if (!ReadonlyStatusHandler.ensureFilesWritable(getProject(), myFile)) {
return;
}
try {
myPsiChangeListener.stop();
for (EditOperation operation : operations) {
operation.execute();
}
updateRenderer(true);
}
catch (Throwable e) {
showError("Execute command", e);
}
finally {
myPsiChangeListener.start();
}
}
示例7: getWritableAndroidManifestXml
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Nullable
public static XmlTag getWritableAndroidManifestXml(@NotNull Module module) {
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet == null) {
return null;
}
Manifest manifest = androidFacet.getManifest();
if (manifest == null) {
return null;
}
XmlTag manifestTag = manifest.getXmlTag();
if (manifestTag == null) {
return null;
}
PsiFile manifestFile = manifestTag.getContainingFile();
if (manifestFile == null) {
return null;
}
VirtualFile vManifestFile = manifestFile.getVirtualFile();
if (vManifestFile == null) {
return null;
}
if (!ReadonlyStatusHandler.ensureFilesWritable(manifestFile.getProject(), vManifestFile)) {
return null;
}
return manifestTag;
}
示例8: configureManifest
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
private static void configureManifest(@NotNull AndroidFacet facet, @NotNull IAndroidTarget target) {
final Manifest manifest = facet.getManifest();
if (manifest == null) {
return;
}
final XmlTag manifestTag = manifest.getXmlTag();
if (manifestTag == null) {
return;
}
final PsiFile manifestFile = manifestTag.getContainingFile();
if (manifestFile == null) {
return;
}
final VirtualFile vManifestFile = manifestFile.getVirtualFile();
if (vManifestFile == null ||
!ReadonlyStatusHandler.ensureFilesWritable(manifestFile.getProject(), vManifestFile)) {
return;
}
XmlTag usesSdkTag = manifestTag.createChildTag("uses-sdk", "", null, false);
if (usesSdkTag != null) {
usesSdkTag = manifestTag.addSubTag(usesSdkTag, true);
usesSdkTag.setAttribute("minSdkVersion", SdkConstants.NS_RESOURCES, target.getVersion().getApiString());
}
CodeStyleManager.getInstance(manifestFile.getProject()).reformat(manifestFile);
}
示例9: registerComponent
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected static void registerComponent(String templateName,
PsiClass aClass,
PsiPackage aPackage,
AndroidFacet facet,
String label,
boolean startupActivity) {
final VirtualFile manifestFile = AndroidRootUtil.getManifestFile(facet);
if (manifestFile == null ||
!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), manifestFile)) {
return;
}
final Manifest manifest = AndroidUtils.loadDomElement(facet.getModule(), manifestFile, Manifest.class);
if (manifest == null) {
return;
}
String packageName = manifest.getPackage().getValue();
if (packageName == null || packageName.length() == 0) {
manifest.getPackage().setValue(aPackage.getQualifiedName());
}
Application application = manifest.getApplication();
if (application == null) return;
ApplicationComponent component = addToManifest(templateName, aClass, application, startupActivity);
if (component != null && label.length() > 0) {
component.getLabel().setValue(ResourceValue.literal(label));
}
}
示例10: applyFix
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
// can happen during batch-inspection if resolution has already been applied
// to plugin.xml or java class
if (!myElement.isValid()) return;
final boolean external = descriptor.getPsiElement().getContainingFile() != myElement.getContainingFile();
if (external) {
final PsiClass clazz = PsiTreeUtil.getParentOfType(myElement, PsiClass.class, false);
final ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance(project);
final VirtualFile[] files = new VirtualFile[]{myElement.getContainingFile().getVirtualFile()};
final ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(files);
if (status.hasReadonlyFiles()) {
final String className = clazz != null ? clazz.getQualifiedName() : myElement.getContainingFile().getName();
Messages.showMessageDialog(project,
DevKitBundle.message("inspections.registration.problems.quickfix.read-only",
className),
getName(),
Messages.getErrorIcon());
return;
}
}
try {
doFix(project, descriptor, external);
}
catch (IncorrectOperationException e) {
Logger.getInstance("#" + getClass().getName()).error(e);
}
}
示例11: isQuickFixOnReadOnlyFile
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected static boolean isQuickFixOnReadOnlyFile(PsiElement problemElement) {
final PsiFile containingPsiFile = problemElement.getContainingFile();
if (containingPsiFile == null) {
return false;
}
final VirtualFile virtualFile = containingPsiFile.getVirtualFile();
if (virtualFile == null) {
return false;
}
final Project project = problemElement.getProject();
final ReadonlyStatusHandler handler = ReadonlyStatusHandler.getInstance(project);
final ReadonlyStatusHandler.OperationStatus status = handler.ensureFilesWritable(virtualFile);
return status.hasReadonlyFiles();
}
示例12: isFileReadOnly
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected static boolean isFileReadOnly( @NotNull Project project, @NotNull PsiFile file )
{
VirtualFile virtualFile = file.getVirtualFile();
ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance( project );
ReadonlyStatusHandler.OperationStatus operationStatus =
readonlyStatusHandler.ensureFilesWritable( virtualFile );
return operationStatus.hasReadonlyFiles();
}
示例13: isQuickFixOnReadOnlyFile
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected static boolean isQuickFixOnReadOnlyFile(PsiElement problemElement) {
final PsiFile containingPsiFile = problemElement.getContainingFile();
if (containingPsiFile == null) {
return false;
}
final VirtualFile virtualFile = containingPsiFile.getVirtualFile();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(problemElement.getProject());
final Project project = facade.getProject();
final ReadonlyStatusHandler handler = ReadonlyStatusHandler.getInstance(project);
final ReadonlyStatusHandler.OperationStatus status = handler.ensureFilesWritable(virtualFile);
return status.hasReadonlyFiles();
}
示例14: executeWithReparse
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected void executeWithReparse(ThrowableRunnable<Exception> operation) {
if (!ReadonlyStatusHandler.ensureFilesWritable(getProject(), myFile)) {
return;
}
try {
myPsiChangeListener.stop();
operation.run();
myPsiChangeListener.start();
reparseFile();
}
catch (Throwable e) {
showError("Execute command", e);
myPsiChangeListener.start();
}
}
示例15: isQuickFixOnReadOnlyFile
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
private static boolean isQuickFixOnReadOnlyFile(PsiElement problemElement) {
final PsiFile containingPsiFile = problemElement.getContainingFile();
if (containingPsiFile == null) {
return false;
}
final VirtualFile virtualFile = containingPsiFile.getVirtualFile();
final Project project = problemElement.getProject();
final ReadonlyStatusHandler handler = ReadonlyStatusHandler.getInstance(project);
final ReadonlyStatusHandler.OperationStatus status = handler.ensureFilesWritable(virtualFile);
return status.hasReadonlyFiles();
}