mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
resource bundle editor: flush properties file document changes before property document editing IDEA-160829
This commit is contained in:
@@ -160,7 +160,11 @@ class NewPropertyAction extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> WriteCommandAction.runWriteCommandAction(resourceBundle.getProject(), () -> myResourceBundleEditor.getPropertiesInsertDeleteManager().insertNewProperty(newPropertyName, "")));
|
||||
final Runnable action = () -> {
|
||||
myResourceBundleEditor.getPropertiesInsertDeleteManager().insertNewProperty(newPropertyName, "");
|
||||
myResourceBundleEditor.flush();
|
||||
};
|
||||
ApplicationManager.getApplication().runWriteAction(() -> WriteCommandAction.runWriteCommandAction(resourceBundle.getProject(), action));
|
||||
|
||||
myResourceBundleEditor.updateTreeRoot();
|
||||
myResourceBundleEditor.selectProperty(newPropertyName);
|
||||
|
||||
+7
-9
@@ -62,7 +62,6 @@ import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileListener;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
@@ -127,7 +126,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
private JPanel myValuesPanel;
|
||||
private JPanel myStructureViewPanel;
|
||||
private volatile boolean myDisposed;
|
||||
private VirtualFileListener myVfsListener;
|
||||
private ResourceBundleEditorFileListener myVfsListener;
|
||||
private Editor mySelectedEditor;
|
||||
private String myPropertyToSelectWhenVisible;
|
||||
private ResourceBundleEditorHighlighter myHighlighter;
|
||||
@@ -333,6 +332,10 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
}
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
myVfsListener.flush();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPropertyName(@NotNull Document document, int line) {
|
||||
int startOffset = document.getLineStartOffset(line);
|
||||
@@ -379,7 +382,6 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> WriteCommandAction.runWriteCommandAction(myProject, () -> {
|
||||
try {
|
||||
|
||||
if (currentValue.isEmpty() &&
|
||||
ResourceBundleEditorKeepEmptyValueToggleAction.keepEmptyProperties() &&
|
||||
!propertiesFile.equals(myResourceBundle.getDefaultPropertiesFile().getVirtualFile())) {
|
||||
@@ -454,6 +456,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
public void focusLost(final Editor editor) {
|
||||
if (!editor.isViewer() && propertiesFile.getContainingFile().isValid()) {
|
||||
writeEditorPropertyValue(null, editor, propertiesFile.getVirtualFile());
|
||||
myVfsListener.flush();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -495,12 +498,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
valuesPanelComponent.add(new JPanel(), gc);
|
||||
selectionChanged();
|
||||
myValuesPanel.repaint();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateEditorsFromProperties(true);
|
||||
}
|
||||
});
|
||||
updateEditorsFromProperties(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+10
@@ -18,6 +18,7 @@ package com.intellij.lang.properties.editor;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -52,6 +53,11 @@ class ResourceBundleEditorFileListener extends VirtualFileAdapter {
|
||||
myProject = myEditor.getResourceBundle().getProject();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
myEventsProcessor.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileCreated(@NotNull VirtualFileEvent event) {
|
||||
myEventsProcessor.queue(event, EventType.FILE_CREATED);
|
||||
@@ -183,6 +189,10 @@ class ResourceBundleEditorFileListener extends VirtualFileAdapter {
|
||||
myMergeQueue.queue(new MyUpdate(new EventWithType(type, event)));
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
myMergeQueue.flush();
|
||||
}
|
||||
|
||||
private class MyUpdate extends Update {
|
||||
public MyUpdate(EventWithType identity) {
|
||||
super(identity);
|
||||
|
||||
Reference in New Issue
Block a user