mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Handle binary files while creating editor in file templates settings (EA-118259)
This commit is contained in:
+10
-10
@@ -82,7 +82,6 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
|
||||
private JPanel myMainPanel;
|
||||
private FileTemplate myTemplate;
|
||||
private PsiFile myFile;
|
||||
private Editor myTemplateEditor;
|
||||
private JTextField myNameField;
|
||||
private JTextField myExtensionField;
|
||||
@@ -160,7 +159,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
mySplitter = new Splitter(true, myProportion);
|
||||
myAdjustBox = new JCheckBox(IdeBundle.message("checkbox.reformat.according.to.style"));
|
||||
myLiveTemplateBox = new JCheckBox(IdeBundle.message("checkbox.enable.live.templates"));
|
||||
myTemplateEditor = createEditor();
|
||||
myTemplateEditor = createEditor(null);
|
||||
|
||||
myDescriptionComponent = new JEditorPane();
|
||||
myDescriptionComponent.setEditorKit(UIUtil.getHTMLEditorKit());
|
||||
@@ -208,12 +207,9 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
myProportion = proportion;
|
||||
}
|
||||
|
||||
private Editor createEditor() {
|
||||
private Editor createEditor(@Nullable PsiFile file) {
|
||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
Document doc = myFile == null
|
||||
? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText())
|
||||
: PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
|
||||
assert doc != null;
|
||||
Document doc = createDocument(file, editorFactory);
|
||||
Editor editor = editorFactory.createEditor(doc, myProject);
|
||||
|
||||
EditorSettings editorSettings = editor.getSettings();
|
||||
@@ -246,6 +242,12 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
return editor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Document createDocument(@Nullable PsiFile file, @NotNull EditorFactory editorFactory) {
|
||||
Document document = file != null ? PsiDocumentManager.getInstance(file.getProject()).getDocument(file) : null;
|
||||
return document != null ? document : editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText());
|
||||
}
|
||||
|
||||
private void onTextChanged() {
|
||||
myModified = true;
|
||||
}
|
||||
@@ -336,8 +338,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
}
|
||||
|
||||
EditorFactory.getInstance().releaseEditor(myTemplateEditor);
|
||||
myFile = createFile(text, name);
|
||||
myTemplateEditor = createEditor();
|
||||
myTemplateEditor = createEditor(createFile(text, name));
|
||||
|
||||
myNameField.setText(name);
|
||||
myExtensionField.setText(extension);
|
||||
@@ -381,7 +382,6 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
|
||||
EditorFactory.getInstance().releaseEditor(myTemplateEditor);
|
||||
myTemplateEditor = null;
|
||||
}
|
||||
myFile = null;
|
||||
}
|
||||
|
||||
private EditorHighlighter createHighlighter() {
|
||||
|
||||
Reference in New Issue
Block a user