use of com.intellij.openapi.command.WriteCommandAction in project android by JetBrains.
the class WidgetConstraintPanel method setAttribute.
private void setAttribute(String nameSpace, String attribute, String value) {
if (mConfiguringUI) {
return;
}
NlModel model = mComponent.getModel();
AttributesTransaction transaction = mComponent.startAttributeTransaction();
transaction.setAttribute(nameSpace, attribute, value);
transaction.apply();
model.requestLayout(false);
myTimer.setRepeats(false);
Project project = model.getProject();
XmlFile file = model.getFile();
String label = "Change Widget";
myWriteAction = new WriteCommandAction(project, label, file) {
@Override
protected void run(@NotNull Result result) throws Throwable {
AttributesTransaction transaction = mComponent.startAttributeTransaction();
transaction.setAttribute(nameSpace, attribute, value);
transaction.commit();
}
};
myTimer.restart();
}
use of com.intellij.openapi.command.WriteCommandAction in project android by JetBrains.
the class ConstraintComponentUtilities method clearAttributes.
public static void clearAttributes(SceneComponent component) {
AttributesTransaction transaction = component.getNlComponent().startAttributeTransaction();
clearAllAttributes(component, transaction);
transaction.apply();
NlModel nlModel = component.getNlComponent().getModel();
Project project = nlModel.getProject();
XmlFile file = nlModel.getFile();
String label = "Cleared all constraints";
WriteCommandAction action = new WriteCommandAction(project, label, file) {
@Override
protected void run(@NotNull Result result) throws Throwable {
transaction.commit();
}
};
action.execute();
}
use of com.intellij.openapi.command.WriteCommandAction in project android by JetBrains.
the class ConstraintComponentUtilities method updateOnDelete.
public static void updateOnDelete(NlComponent component, String targetId) {
AttributesTransaction transaction = null;
transaction = updateOnDelete(component, ourLeftAttributes, transaction, targetId);
transaction = updateOnDelete(component, ourTopAttributes, transaction, targetId);
transaction = updateOnDelete(component, ourRightAttributes, transaction, targetId);
transaction = updateOnDelete(component, ourBottomAttributes, transaction, targetId);
transaction = updateOnDelete(component, ourBaselineAttributes, transaction, targetId);
if (transaction != null) {
transaction.apply();
NlModel nlModel = component.getModel();
Project project = nlModel.getProject();
XmlFile file = nlModel.getFile();
String label = "Remove constraints pointing to a deleted component";
AttributesTransaction finalTransaction = transaction;
WriteCommandAction action = new WriteCommandAction(project, label, file) {
@Override
protected void run(@NotNull Result result) throws Throwable {
finalTransaction.commit();
}
};
action.execute();
}
}
use of com.intellij.openapi.command.WriteCommandAction in project intellij-plugins by JetBrains.
the class CucumberPsiTreeListenerTest method deleteStepDefinition.
private void deleteStepDefinition(@NotNull final String stepDefName) {
final PsiClass psiClass = getStepDefClass();
final PsiFile psiFile = psiClass.getContainingFile();
new WriteCommandAction(getProject(), psiFile) {
@Override
protected void run(@NotNull Result result) throws Throwable {
for (PsiMethod method : psiClass.getAllMethods()) {
if (method.getName().equals(stepDefName)) {
method.delete();
break;
}
}
}
}.execute();
}
use of com.intellij.openapi.command.WriteCommandAction in project android by JetBrains.
the class NewAndroidComponentDialog method addSetContentViewStatement.
private static void addSetContentViewStatement(final PsiCodeBlock body, final String layoutFieldRef) {
final Project project = body.getProject();
final PsiElement lastBodyElement = body.getLastBodyElement();
if (lastBodyElement != null) {
new WriteCommandAction(project, body.getContainingFile()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
final PsiStatement newStatement = PsiElementFactory.SERVICE.getInstance(project).createStatementFromText("setContentView(" + layoutFieldRef + ");", body);
body.addAfter(newStatement, lastBodyElement);
JavaCodeStyleManager.getInstance(project).shortenClassReferences(body);
CodeStyleManager.getInstance(project).reformat(body);
}
}.execute();
}
}
Aggregations