本文整理汇总了Java中com.intellij.openapi.vfs.ReadonlyStatusHandler.OperationStatus方法的典型用法代码示例。如果您正苦于以下问题:Java ReadonlyStatusHandler.OperationStatus方法的具体用法?Java ReadonlyStatusHandler.OperationStatus怎么用?Java ReadonlyStatusHandler.OperationStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.ReadonlyStatusHandler
的用法示例。
在下文中一共展示了ReadonlyStatusHandler.OperationStatus方法的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: preparePsiElementsForWrite
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
public boolean preparePsiElementsForWrite(@NotNull Collection<? extends PsiElement> elements) {
if (elements.isEmpty()) return true;
Set<VirtualFile> files = new THashSet<VirtualFile>();
Project project = null;
for (PsiElement element : elements) {
if (element == null) continue;
PsiFile file = element.getContainingFile();
if (file == null || !file.isPhysical()) continue;
project = file.getProject();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) continue;
files.add(virtualFile);
}
if (!files.isEmpty()) {
VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files);
ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles);
return !status.hasReadonlyFiles();
}
return true;
}
示例3: saveCreatedProperty
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public static boolean saveCreatedProperty(final PropertiesFile bundle, final String name, final String value,
final PsiFile formFile) {
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(bundle.getProject()).ensureFilesWritable(bundle.getVirtualFile());
if (operationStatus.hasReadonlyFiles()) {
return false;
}
CommandProcessor.getInstance().executeCommand(
bundle.getProject(),
new Runnable() {
public void run() {
UndoUtil.markPsiFileForUndo(formFile);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
try {
bundle.addProperty(name, value);
}
catch (IncorrectOperationException e1) {
LOG.error(e1);
}
}
});
}
}, UIDesignerBundle.message("command.create.property"), null);
return true;
}
示例4: ensureEditable
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public boolean ensureEditable() {
if (isEditable()) {
return true;
}
VirtualFile sourceFileToCheckOut = null;
if (!GuiDesignerConfiguration.getInstance(getProject()).INSTRUMENT_CLASSES) {
final String classToBind = myRootContainer.getClassToBind();
if (classToBind != null && classToBind.length() > 0) {
PsiClass psiClass = FormEditingUtil.findClassToBind(getModule(), classToBind);
if (psiClass != null) {
sourceFileToCheckOut = psiClass.getContainingFile().getVirtualFile();
}
}
}
final ReadonlyStatusHandler.OperationStatus status;
if (sourceFileToCheckOut != null) {
status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(myFile, sourceFileToCheckOut);
}
else {
status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(myFile);
}
return !status.hasReadonlyFiles();
}
示例5: actionPerformed
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
try {
final VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] files = context.getSelectedFiles();
if (files.length == 0) return;
final Project project = context.getProject();
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files);
if (operationStatus.hasReadonlyFiles()) {
return;
}
AbstractVcsHelper.getInstance(project).showMergeDialog(Arrays.asList(files), new CvsMergeProvider());
}
catch (Exception e1) {
LOG.error(e1);
}
}
示例6: preparePsiElementsForWrite
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
public boolean preparePsiElementsForWrite(@NotNull Collection<? extends PsiElement> elements) {
if (elements.isEmpty()) return true;
Set<VirtualFile> files = new THashSet<VirtualFile>();
Project project = null;
for (PsiElement element : elements) {
PsiFile file = element.getContainingFile();
if (file == null) continue;
project = file.getProject();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) continue;
files.add(virtualFile);
}
if (!files.isEmpty()) {
VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files);
ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles);
return !status.hasReadonlyFiles();
}
return true;
}
示例7: actionPerformed
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
try {
final VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] files = context.getSelectedFiles();
if (files == null || files.length == 0) return;
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(context.getProject()).ensureFilesWritable(files);
if (operationStatus.hasReadonlyFiles()) {
return;
}
final Project project = context.getProject();
AbstractVcsHelper.getInstance(project).showMergeDialog(Arrays.asList(files), new CvsMergeProvider());
}
catch (Exception e1) {
LOG.error(e1);
}
}
示例8: executeWritable
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Nullable
protected ApplyPatchStatus executeWritable() {
final ReadonlyStatusHandler.OperationStatus readOnlyFilesStatus = getReadOnlyFilesStatus(myVerifier.getWritableFiles());
if (readOnlyFilesStatus.hasReadonlyFiles()) {
showError(myProject, readOnlyFilesStatus.getReadonlyFilesMessage(), true);
return ApplyPatchStatus.ABORT;
}
myFailedPatches.addAll(myVerifier.filterBadFileTypePatches());
ApplyPatchStatus result = myFailedPatches.isEmpty() ? null : ApplyPatchStatus.FAILURE;
final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches = myVerifier.getTextPatches();
try {
markInternalOperation(textPatches, true);
return ApplyPatchStatus.and(result, actualApply(textPatches, myVerifier.getBinaryPatches(), myCommitContext));
}
finally {
markInternalOperation(textPatches, false);
}
}
示例9: preparePsiElementsForWrite
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
@Override
public boolean preparePsiElementsForWrite(@Nonnull Collection<? extends PsiElement> elements) {
if (elements.isEmpty()) return true;
Set<VirtualFile> files = new THashSet<VirtualFile>();
Project project = null;
for (PsiElement element : elements) {
if (element == null) continue;
PsiFile file = element.getContainingFile();
if (file == null || !file.isPhysical()) continue;
project = file.getProject();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) continue;
files.add(virtualFile);
}
if (!files.isEmpty()) {
VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files);
ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles);
return !status.hasReadonlyFiles();
}
return true;
}
示例10: injectText
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
private void injectText(PsiFile psiFile) {
ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(psiFile.getVirtualFile());
if (status.hasReadonlyFiles()) {
ReportHelper.setState(ExecutionState.FAILED);
ReportHelper.putReport(new FailedActionReport(this, Localizer.get("error.ReadOnlyFile"), "InjectTextAction ReadOnlyFile"));
Logger.log("InjectTextAction ReadOnlyFile");
return;
}
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if (document == null) {
ReportHelper.setState(ExecutionState.FAILED);
ReportHelper.putReport(new FailedActionReport(this, Localizer.get("error.internalError"), "InjectTextAction document==nul"));
Logger.log("InjectTextAction document==nul");
return;
}
int offset = getOffset(document, textInjection.getInjectDirection());
if (offset == -1) {
return;
}
String textToInsert = fromVelocity(textInjection.getTextToInject());
if (textToInsert == null) {
return;
}
// Replace
if (textInjection.getInjectDirection() == InjectDirection.REPLACE) {
doReplace(document, textToInsert);
}
// Insert
else {
document.insertString(offset, textToInsert);
}
}
示例11: perform
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
public void perform(final Project project) {
if (myPerformed) return;
myPerformed = true;
if (!myDocument.isWritable()) {
final VirtualFile file = FileDocumentManager.getInstance().getFile(myDocument);
final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(file);
if (status.hasReadonlyFiles()) return;
}
ApplicationManager.getApplication().runWriteAction(new Runnable(){
public void run() {
CommandProcessor.getInstance().executeCommand(project, myModification, getName(), null);
}
});
}
示例12: applyFix
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
/**
* @return true if immediate UI update needed.
*/
protected boolean applyFix(@NotNull RefEntity[] refElements) {
Set<VirtualFile> readOnlyFiles = getReadOnlyFiles(refElements);
if (!readOnlyFiles.isEmpty()) {
final Project project = refElements[0].getRefManager().getProject();
final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(
VfsUtilCore.toVirtualFileArray(readOnlyFiles));
if (operationStatus.hasReadonlyFiles()) return false;
}
return true;
}
示例13: prepareWritable
import com.intellij.openapi.vfs.ReadonlyStatusHandler; //导入方法依赖的package包/类
protected List<VirtualFile> prepareWritable(final Collection<VirtualFile> files) {
final List<VirtualFile> writable = new ArrayList<VirtualFile>();
for (VirtualFile vf : files) {
if (myVcs.equals(myPlVcsManager.getVcsFor(vf))) {
writable.add(vf);
}
}
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(myVcs.getProject()).ensureFilesWritable(writable);
writable.removeAll(Arrays.asList(operationStatus.getReadonlyFiles()));
return writable;
}
示例14: 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);
}
}
示例15: 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();
}