当前位置: 首页>>代码示例>>Java>>正文


Java ReadonlyStatusHandler.ensureFilesWritable方法代码示例

本文整理汇总了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;
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:18,代码来源:LuaFix.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeInsightUtilBase.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidDesignerEditorPanel.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidDesignerEditorPanel.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:CodeInsightUtilBase.java

示例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();
    }
}
 
开发者ID:chrimm,项目名称:cordovastudio,代码行数:19,代码来源:CordovaDesignerEditorPanel.java

示例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;
}
 
开发者ID:apsun,项目名称:XposedPlugin,代码行数:34,代码来源:AndroidXmlUtils.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AndroidModuleBuilder.java

示例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));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:NewAndroidComponentDialog.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:BaseFix.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:TitleCapitalizationInspection.java

示例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();
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:9,代码来源:AbstractIntention.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:GroovyFix.java

示例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();
    }
}
 
开发者ID:chrimm,项目名称:cordovastudio,代码行数:16,代码来源:CordovaDesignerEditorPanel.java

示例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();
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:InspectionJSFix.java


注:本文中的com.intellij.openapi.vfs.ReadonlyStatusHandler.ensureFilesWritable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。