PL-8145 Incorrect behavior of the CodeEditor component in the Report Editor screen

This commit is contained in:
Nikita Petunin 2016-12-27 11:45:08 +04:00
parent c2427c25e8
commit 44b8086009
7 changed files with 63 additions and 0 deletions

View File

@ -220,4 +220,8 @@ public class DesktopSourceCodeEditor extends DesktopAbstractTextField<RSyntaxTex
public String getRawValue() {
return impl.getText();
}
@Override
public void resetEditHistory() {
}
}

View File

@ -97,4 +97,9 @@ public interface SourceCodeEditor extends Field {
* Returns a string representation of the value.
*/
String getRawValue();
/**
* Reset the stack of undo/redo redo operations.
*/
void resetEditHistory();
}

View File

@ -27,6 +27,16 @@ import org.vaadin.aceeditor.client.AceEditorWidget;
@Connect(CubaSourceCodeEditor.class)
public class CubaSourceCodeEditorConnector extends AceEditorConnector {
private boolean resetEditHistory = false;
public CubaSourceCodeEditorConnector() {
registerRpc(CubaSourceCodeEditorClientRpc.class, new CubaSourceCodeEditorClientRpc() {
@Override
public void resetEditHistory() {
getWidget().resetEditHistory();
}
});
};
@Override
protected Widget createWidget() {

View File

@ -138,4 +138,15 @@ public class CubaSourceCodeEditorWidget extends AceEditorWidget {
protected native int getRendererPrintMarginColumn(GwtAceEditor editor) /*-{
return editor.renderer.getPrintMarginColumn();
}-*/;
public void resetEditHistory() {
resetEditHistory(editor);
}
public final native void resetEditHistory(GwtAceEditor editor) /*-{
setTimeout(function() {
var undoManager = editor.getSession().getUndoManager();
undoManager.reset();
}, 0);
}-*/;
}

View File

@ -120,6 +120,11 @@ public class WebSourceCodeEditor extends WebAbstractField<CubaSourceCodeEditor>
component.setMode(editorMode);
}
@Override
public void resetEditHistory() {
component.resetEditHistory();
}
@Override
public Suggester getSuggester() {
return suggester;

View File

@ -17,6 +17,7 @@
package com.haulmont.cuba.web.toolkit.ui;
import com.haulmont.cuba.web.toolkit.ui.client.sourcecodeeditor.CubaSourceCodeEditorClientRpc;
import com.haulmont.cuba.web.toolkit.ui.client.sourcecodeeditor.CubaSourceCodeEditorState;
import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.CompositeErrorMessage;
@ -90,4 +91,8 @@ public class CubaSourceCodeEditor extends AceEditor {
getState().printMarginColumn = printMarginColumn;
}
}
public void resetEditHistory() {
getRpcProxy(CubaSourceCodeEditorClientRpc.class).resetEditHistory();
}
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2008-2016 Haulmont.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.haulmont.cuba.web.toolkit.ui.client.sourcecodeeditor;
import com.vaadin.shared.communication.ClientRpc;
public interface CubaSourceCodeEditorClientRpc extends ClientRpc {
void resetEditHistory();
}