Apply settings to model without preview too

(cherry picked from commit 397e9d9)
This commit is contained in:
Rustam Vishnyakov
2017-02-01 17:32:53 +03:00
parent 0e20c05988
commit eadd0616ac
2 changed files with 15 additions and 9 deletions
@@ -210,14 +210,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
PsiFile psiFile = createFileFromText(project, myTextToReformat);
prepareForReformat(psiFile);
try {
apply(mySettings);
if (myModel != null) {
myModel.fireAfterCurrentSettingsChanged();
}
}
catch (ConfigurationException ignore) {
}
applySettingsToModel();
CodeStyleSettings clone = mySettings.clone();
clone.setRightMargin(getDefaultLanguage(), getAdjustedRightMargin());
CodeStyleSettingsManager.getInstance(project).setTemporarySettings(clone);
@@ -242,6 +235,17 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
});
}
private void applySettingsToModel() {
try {
apply(mySettings);
if (myModel != null) {
myModel.fireAfterCurrentSettingsChanged();
}
}
catch (ConfigurationException ignore) {
}
}
/**
* Reformats {@link #myTextToReformat target text} with the {@link #mySettings current code style settings} and returns
* list of changes applied to the target text during that.
@@ -444,6 +448,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
UiNotifyConnector.doWhenFirstShown(myEditor.getComponent(), () -> addUpdatePreviewRequest());
}
}
else {
applySettingsToModel();
}
}
private void addUpdatePreviewRequest() {
@@ -223,7 +223,6 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
private static String getTagText(JTextField field, String defaultValue) {
String fieldText = field.getText();
if (StringUtil.isEmpty(field.getText())) {
field.setText(defaultValue);
return defaultValue;
}
return fieldText;