use of com.intellij.openapi.vfs.ReadonlyStatusHandler in project intellij-community by JetBrains.
the class ChangeFormComponentTypeFix method invoke.
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
CommandProcessor.getInstance().executeCommand(file.getProject(), () -> {
final ReadonlyStatusHandler readOnlyHandler = ReadonlyStatusHandler.getInstance(myFormFile.getProject());
final ReadonlyStatusHandler.OperationStatus status = readOnlyHandler.ensureFilesWritable(myFormFile.getVirtualFile());
if (!status.hasReadonlyFiles()) {
FormReferenceProvider.setGUIComponentType(myFormFile, myFieldName, myComponentTypeToSet);
}
}, getText(), null);
}
use of com.intellij.openapi.vfs.ReadonlyStatusHandler in project intellij-community by JetBrains.
the class VcsOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
if (project == null || ProjectLevelVcsManager.getInstance(project).getAllVcss().length == 0) {
return Collections.emptyList();
}
VcsConfiguration vcs = VcsConfiguration.getInstance(project);
if (vcs == null) {
return Collections.emptyList();
}
ArrayList<BooleanOptionDescription> options = new ArrayList<>();
// process Version Control settings
String id = "project.propVCSSupport.Mappings";
options.add(option(vcs, id, "Limit history by " + vcs.MAXIMUM_HISTORY_ROWS + " rows", "LIMIT_HISTORY"));
options.add(option(vcs, id, "Show directories with changed descendants", "SHOW_DIRTY_RECURSIVELY"));
VcsContentAnnotationSettings vcsCA = VcsContentAnnotationSettings.getInstance(project);
if (vcsCA != null) {
options.add(option(vcsCA, id, "Show changed in last " + vcsCA.getLimitDays() + " days", "isShow", "setShow"));
}
options.add(option(vcs, id, "Notify about VCS root errors", "SHOW_VCS_ERROR_NOTIFICATIONS"));
options.add(option(vcs, id, "Commit message right margin " + vcs.COMMIT_MESSAGE_MARGIN_SIZE + " columns", "USE_COMMIT_MESSAGE_MARGIN"));
options.add(option(vcs, id, ApplicationBundle.message("checkbox.wrap.typing.on.right.margin"), "WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN"));
// process Version Control / Confirmation settings
id = "project.propVCSSupport.Confirmation";
ReadonlyStatusHandler vcsROSH = ReadonlyStatusHandler.getInstance(project);
if (vcsROSH instanceof ReadonlyStatusHandlerImpl) {
options.add(option(((ReadonlyStatusHandlerImpl) vcsROSH).getState(), id, "Show \"Clear Read-only Status\" Dialog", "SHOW_DIALOG"));
}
options.add(option(vcs, id, "Confirmation: Suggest to move uncommitted changes to another changelist", "OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT"));
options.add(option(vcs, id, "Confirmation: Force non-empty checkin comments", "FORCE_NON_EMPTY_COMMENT"));
options.add(option(vcs, id, "Confirmation: Clear initial commit message", "CLEAR_INITIAL_COMMIT_MESSAGE"));
// process Version Control / Background settings
id = "project.propVCSSupport.Background";
options.add(option(vcs, id, "Perform in background: update from VCS", "PERFORM_UPDATE_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: commit to VCS", "PERFORM_COMMIT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: checkout from VCS", "PERFORM_CHECKOUT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: Edit/Checkout", "PERFORM_EDIT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: Add/Remove", "PERFORM_ADD_REMOVE_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: revert", "PERFORM_ROLLBACK_IN_BACKGROUND"));
id = ShelfProjectConfigurable.HELP_ID;
options.add(option(vcs, id, VcsBundle.message("vcs.shelf.store.base.content"), "INCLUDE_TEXT_INTO_SHELF"));
if (!project.isDefault()) {
// process Version Control / Changelist Conflicts settings
options.add(tracker(project, "Changelists: Enable changelist conflict tracking", "TRACKING_ENABLED"));
options.add(tracker(project, "Changelists: Show conflict resolving dialog", "SHOW_DIALOG"));
options.add(tracker(project, "Changelists: Highlight files with conflicts", "HIGHLIGHT_CONFLICTS"));
options.add(tracker(project, "Changelists: Highlight files from non-active changelists", "HIGHLIGHT_NON_ACTIVE_CHANGELIST"));
}
return Collections.unmodifiableCollection(options);
}
use of com.intellij.openapi.vfs.ReadonlyStatusHandler in project intellij-community by JetBrains.
the class BaseFix method applyFix.
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
PsiElement element = myPointer.getElement();
if (element == null || !element.isValid())
return;
boolean external = descriptor.getPsiElement().getContainingFile() != element.getContainingFile();
if (external) {
PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance(project);
VirtualFile[] files = new VirtualFile[] { element.getContainingFile().getVirtualFile() };
ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(files);
if (status.hasReadonlyFiles()) {
String className = clazz != null ? clazz.getQualifiedName() : element.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);
}
}
use of com.intellij.openapi.vfs.ReadonlyStatusHandler in project qi4j-sdk by Qi4j.
the class AbstractIntention method isFileReadOnly.
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();
}
use of com.intellij.openapi.vfs.ReadonlyStatusHandler in project intellij-community by JetBrains.
the class DescriptorUtil method patchPluginXml.
public static void patchPluginXml(Patcher patcher, PsiClass klass, XmlFile... pluginXmls) throws IncorrectOperationException {
final VirtualFile[] files = new VirtualFile[pluginXmls.length];
int i = 0;
for (XmlFile pluginXml : pluginXmls) {
files[i++] = pluginXml.getVirtualFile();
}
final ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance(klass.getProject());
final ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(files);
if (status.hasReadonlyFiles()) {
throw new IncorrectOperationException(DevKitBundle.message("error.plugin.xml.readonly"));
}
WriteAction.run((ThrowableRunnable<IncorrectOperationException>) () -> {
for (XmlFile pluginXml : pluginXmls) {
patcher.patchPluginXml(pluginXml, klass);
}
});
}
Aggregations