mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 10:17:43 +08:00
Get rid of Vaadin add-ons dependencies #958
This commit is contained in:
parent
892c72ed78
commit
8f4e527a75
@ -624,7 +624,7 @@ configure(webWidgetsModule) {
|
||||
compile(bom['org.webjars:jquery-ui'])
|
||||
compile(bom['org.webjars.bower:jquery-file-upload'])
|
||||
compile(bom['org.webjars.npm:object-fit-images'])
|
||||
compile(bom['org.webjars.bower:ace-builds'])
|
||||
compile(bom['org.webjars:ace-builds'])
|
||||
compile(bom['org.webjars:diff-match-patch'])
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ org.webjars/jquery = 1.12.4
|
||||
org.webjars/jquery-ui = 1.12.1
|
||||
org.webjars.bower/jquery-file-upload = 9.22.0.cuba.0
|
||||
org.webjars.npm/object-fit-images = 3.2.3
|
||||
org.webjars.bower/ace-builds = 1.1.9
|
||||
org.webjars/ace-builds = 1.1.9-1-cuba
|
||||
org.webjars/diff-match-patch = 0.1.cuba.1
|
||||
|
||||
com.haulmont.cuba-resources/cuba-png-icons = 1.0.1
|
||||
|
@ -38,8 +38,6 @@ import com.haulmont.cuba.web.widgets.client.addons.aceeditor.TransportDiff;
|
||||
import com.haulmont.cuba.web.widgets.client.addons.aceeditor.TransportDoc.TransportRange;
|
||||
import com.haulmont.cuba.web.widgets.client.addons.aceeditor.Util;
|
||||
|
||||
import com.vaadin.annotations.JavaScript;
|
||||
import com.vaadin.annotations.StyleSheet;
|
||||
import com.vaadin.event.FieldEvents.BlurEvent;
|
||||
import com.vaadin.event.FieldEvents.BlurListener;
|
||||
import com.vaadin.event.FieldEvents.BlurNotifier;
|
||||
@ -56,8 +54,8 @@ import com.vaadin.util.ReflectTools;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@WebJarResource(value = {
|
||||
"ace-builds:src-min/ace.js",
|
||||
"ace-builds:src-min/ext-searchbox.js",
|
||||
"ace-builds:ace.js",
|
||||
"ace-builds:ext-searchbox.js",
|
||||
"diff-match-patch:diff_match_patch.js"
|
||||
})
|
||||
public class AceEditor extends AbstractField<String> implements BlurNotifier,
|
||||
|
@ -23,10 +23,13 @@ import com.haulmont.cuba.gui.components.HighlightMode;
|
||||
import com.haulmont.cuba.gui.components.SourceCodeEditor;
|
||||
import com.haulmont.cuba.gui.components.autocomplete.AutoCompleteSupport;
|
||||
import com.haulmont.cuba.gui.components.autocomplete.Suggester;
|
||||
import com.haulmont.cuba.web.AppUI;
|
||||
import com.haulmont.cuba.web.widgets.CubaSourceCodeEditor;
|
||||
import com.haulmont.cuba.web.widgets.addons.aceeditor.AceEditor;
|
||||
import com.haulmont.cuba.web.widgets.addons.aceeditor.AceMode;
|
||||
import com.haulmont.cuba.web.widgets.addons.aceeditor.Suggestion;
|
||||
import com.haulmont.cuba.web.widgets.addons.aceeditor.SuggestionExtension;
|
||||
import com.vaadin.server.ClientConnector;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -44,12 +47,7 @@ public class WebSourceCodeEditor extends WebV8AbstractField<CubaSourceCodeEditor
|
||||
|
||||
public WebSourceCodeEditor() {
|
||||
component = createCubaSourceCodeEditor();
|
||||
|
||||
component.setMode(AceMode.text);
|
||||
// vaadin8
|
||||
// component.setInvalidCommitted(true);
|
||||
// component.setInvalidAllowed(false);
|
||||
// component.setBuffered(false);
|
||||
initComponent(component);
|
||||
|
||||
autoCompleteSupport = new AutoCompleteSupport() {
|
||||
@Override
|
||||
@ -70,6 +68,32 @@ public class WebSourceCodeEditor extends WebV8AbstractField<CubaSourceCodeEditor
|
||||
return new CubaSourceCodeEditor();
|
||||
}
|
||||
|
||||
protected void initComponent(CubaSourceCodeEditor component) {
|
||||
component.setMode(AceMode.text);
|
||||
component.addAttachListener(this::handleAttach);
|
||||
|
||||
// vaadin8
|
||||
// component.setInvalidCommitted(true);
|
||||
// component.setInvalidAllowed(false);
|
||||
// component.setBuffered(false);
|
||||
}
|
||||
|
||||
protected void handleAttach(ClientConnector.AttachEvent attachEvent) {
|
||||
AceEditor component = (AceEditor) attachEvent.getSource();
|
||||
AppUI appUi = (AppUI) component.getUI();
|
||||
if (appUi == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String acePath = appUi.getWebJarPath("ace-builds", "ace.js");
|
||||
String path = appUi.translateToWebPath(acePath.substring(0, acePath.lastIndexOf("/"))) + "/";
|
||||
|
||||
component.setBasePath(path);
|
||||
component.setThemePath(path);
|
||||
component.setWorkerPath(path);
|
||||
component.setModePath(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HighlightMode getMode() {
|
||||
return mode;
|
||||
|
Loading…
Reference in New Issue
Block a user