Search in sources :

Example 6 with UndoManagerImpl

use of com.intellij.openapi.command.impl.UndoManagerImpl in project intellij-community by JetBrains.

the class ResourceBundleEditor method updateEditorsFromProperties.

void updateEditorsFromProperties(final boolean checkIsUnderUndoRedoAction) {
    String propertyName = getSelectedPropertyName();
    ((CardLayout) myValuesPanel.getLayout()).show(myValuesPanel, propertyName == null ? NO_PROPERTY_SELECTED : VALUES);
    if (propertyName == null)
        return;
    final UndoManagerImpl undoManager = (UndoManagerImpl) UndoManager.getInstance(myProject);
    for (final PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
        final EditorEx editor = myEditors.get(propertiesFile.getVirtualFile());
        if (editor == null)
            continue;
        final IProperty property = propertiesFile.findPropertyByKey(propertyName);
        final Document document = editor.getDocument();
        CommandProcessor.getInstance().executeCommand(null, () -> ApplicationManager.getApplication().runWriteAction(() -> {
            if (!checkIsUnderUndoRedoAction || !undoManager.isActive() || !(undoManager.isRedoInProgress() || undoManager.isUndoInProgress())) {
                updateDocumentFromPropertyValue(getPropertyEditorValue(property), document, propertiesFile.getVirtualFile());
            }
        }), "", this);
        JPanel titledPanel = myTitledPanels.get(propertiesFile.getVirtualFile());
        ((TitledBorder) titledPanel.getBorder()).setTitleColor(property == null ? JBColor.RED : UIUtil.getLabelTextForeground());
        titledPanel.repaint();
    }
}
Also used : UndoManagerImpl(com.intellij.openapi.command.impl.UndoManagerImpl) EditorEx(com.intellij.openapi.editor.ex.EditorEx) IProperty(com.intellij.lang.properties.IProperty) XmlPropertiesFile(com.intellij.lang.properties.xml.XmlPropertiesFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) TitledBorder(javax.swing.border.TitledBorder)

Aggregations

UndoManagerImpl (com.intellij.openapi.command.impl.UndoManagerImpl)6 ImportClassFix (com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFix)2 ImportClassFixBase (com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase)2 IProperty (com.intellij.lang.properties.IProperty)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 XmlPropertiesFile (com.intellij.lang.properties.xml.XmlPropertiesFile)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 DocumentReferenceManagerImpl (com.intellij.openapi.command.impl.DocumentReferenceManagerImpl)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 RangeMarkerEx (com.intellij.openapi.editor.ex.RangeMarkerEx)1 Project (com.intellij.openapi.project.Project)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)1 Pair (com.intellij.openapi.util.Pair)1 TextRange (com.intellij.openapi.util.TextRange)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)1 PsiFile (com.intellij.psi.PsiFile)1