IDEMPIERE-563 HTML Editor for text fields. Fixed layout and only mask out current tab.
This commit is contained in:
parent
c3288cdd41
commit
1395d8acb3
|
@ -19,7 +19,10 @@ package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.ValuePreference;
|
import org.adempiere.webui.ValuePreference;
|
||||||
|
import org.adempiere.webui.adwindow.ADWindow;
|
||||||
|
import org.adempiere.webui.adwindow.AbstractADWindowContent;
|
||||||
import org.adempiere.webui.component.Combobox;
|
import org.adempiere.webui.component.Combobox;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
@ -32,6 +35,7 @@ import org.adempiere.webui.window.WFieldRecordInfo;
|
||||||
import org.adempiere.webui.window.WTextEditorDialog;
|
import org.adempiere.webui.window.WTextEditorDialog;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
@ -50,6 +54,8 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
|
|
||||||
private boolean tableEditor = false;
|
private boolean tableEditor = false;
|
||||||
|
|
||||||
|
private AbstractADWindowContent adwindowContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to ease porting of swing form
|
* to ease porting of swing form
|
||||||
*/
|
*/
|
||||||
|
@ -222,6 +228,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
else if (WEditorPopupMenu.EDITOR_EVENT.equals(evt.getContextEvent()))
|
else if (WEditorPopupMenu.EDITOR_EVENT.equals(evt.getContextEvent()))
|
||||||
{
|
{
|
||||||
|
adwindowContent = findADWindowContent();
|
||||||
final WTextEditorDialog dialog = new WTextEditorDialog(this.getColumnName(), getDisplay(),
|
final WTextEditorDialog dialog = new WTextEditorDialog(this.getColumnName(), getDisplay(),
|
||||||
isReadWrite(), gridField.getFieldLength());
|
isReadWrite(), gridField.getFieldLength());
|
||||||
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||||
|
@ -229,6 +236,9 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
|
if (adwindowContent != null) {
|
||||||
|
adwindowContent.hideBusyMask();
|
||||||
|
}
|
||||||
if (!dialog.isCancelled()) {
|
if (!dialog.isCancelled()) {
|
||||||
getComponent().setText(dialog.getText());
|
getComponent().setText(dialog.getText());
|
||||||
String newText = getComponent().getValue();
|
String newText = getComponent().getValue();
|
||||||
|
@ -238,8 +248,17 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (adwindowContent != null)
|
||||||
|
{
|
||||||
|
adwindowContent.getComponent().getParent().appendChild(dialog);
|
||||||
|
adwindowContent.showBusyMask();
|
||||||
|
LayoutUtils.openOverlappedWindow(adwindowContent.getComponent().getParent(), dialog, "middle_center");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
SessionManager.getAppDesktop().showWindow(dialog);
|
SessionManager.getAppDesktop().showWindow(dialog);
|
||||||
|
}
|
||||||
|
dialog.focus();
|
||||||
}
|
}
|
||||||
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
||||||
{
|
{
|
||||||
|
@ -263,5 +282,16 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AbstractADWindowContent findADWindowContent() {
|
||||||
|
Component parent = getComponent().getParent();
|
||||||
|
while(parent != null) {
|
||||||
|
if (parent.getAttribute(ADWindow.AD_WINDOW_ATTRIBUTE_KEY) != null) {
|
||||||
|
ADWindow adwindow = (ADWindow) parent.getAttribute(ADWindow.AD_WINDOW_ATTRIBUTE_KEY);
|
||||||
|
return adwindow.getADWindowContent();
|
||||||
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.adempiere.webui.component.Tabpanel;
|
||||||
import org.adempiere.webui.component.Tabpanels;
|
import org.adempiere.webui.component.Tabpanels;
|
||||||
import org.adempiere.webui.component.Tabs;
|
import org.adempiere.webui.component.Tabs;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.component.VerticalBox;
|
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -28,6 +27,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Div;
|
import org.zkoss.zul.Div;
|
||||||
import org.zkoss.zul.Html;
|
import org.zkoss.zul.Html;
|
||||||
import org.zkoss.zul.Separator;
|
import org.zkoss.zul.Separator;
|
||||||
|
import org.zkoss.zul.Vlayout;
|
||||||
|
|
||||||
import fi.jawsy.jawwa.zk.cleditor.Cleditor;
|
import fi.jawsy.jawwa.zk.cleditor.Cleditor;
|
||||||
|
|
||||||
|
@ -70,9 +70,14 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setBorder("normal");
|
setBorder("normal");
|
||||||
|
setHeight("450px");
|
||||||
|
setWidth("700px");
|
||||||
|
setStyle("position: absolute;");
|
||||||
|
|
||||||
VerticalBox vbox = new VerticalBox();
|
Vlayout vbox = new Vlayout();
|
||||||
appendChild(vbox);
|
appendChild(vbox);
|
||||||
|
vbox.setWidth("100%");
|
||||||
|
vbox.setVflex("true");
|
||||||
|
|
||||||
tabbox = new Tabbox();
|
tabbox = new Tabbox();
|
||||||
vbox.appendChild(tabbox);
|
vbox.appendChild(tabbox);
|
||||||
|
@ -80,6 +85,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
||||||
tabbox.appendChild(tabs);
|
tabbox.appendChild(tabs);
|
||||||
Tabpanels tabPanels = new Tabpanels();
|
Tabpanels tabPanels = new Tabpanels();
|
||||||
tabbox.appendChild(tabPanels);
|
tabbox.appendChild(tabPanels);
|
||||||
|
tabbox.setVflex("true");
|
||||||
|
tabbox.setHflex("true");
|
||||||
|
|
||||||
Tab tab = new Tab("Text");
|
Tab tab = new Tab("Text");
|
||||||
tabs.appendChild(tab);
|
tabs.appendChild(tab);
|
||||||
|
@ -90,8 +97,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
||||||
textBox.setCols(80);
|
textBox.setCols(80);
|
||||||
textBox.setRows(30);
|
textBox.setRows(30);
|
||||||
textBox.setEnabled(editable);
|
textBox.setEnabled(editable);
|
||||||
textBox.setWidth("700px");
|
textBox.setVflex("true");
|
||||||
textBox.setHeight("500px");
|
textBox.setHflex("true");
|
||||||
tabPanel.appendChild(textBox);
|
tabPanel.appendChild(textBox);
|
||||||
|
|
||||||
tab = new Tab("HTML");
|
tab = new Tab("HTML");
|
||||||
|
@ -102,13 +109,13 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
||||||
if (editable) {
|
if (editable) {
|
||||||
editor = new Cleditor();
|
editor = new Cleditor();
|
||||||
tabPanel.appendChild(editor);
|
tabPanel.appendChild(editor);
|
||||||
editor.setWidth("700px");
|
editor.setWidth("100%");
|
||||||
editor.setHeight("500px");
|
editor.setHeight("100%");
|
||||||
editor.setValue(text);
|
editor.setValue(text);
|
||||||
} else {
|
} else {
|
||||||
Div div = new Div();
|
Div div = new Div();
|
||||||
div.setHeight("500px");
|
div.setHeight("100%");
|
||||||
div.setWidth("700px");
|
div.setWidth("100%");
|
||||||
div.setStyle("overflow: auto; border: 1px solid");
|
div.setStyle("overflow: auto; border: 1px solid");
|
||||||
tabPanel.appendChild(div);
|
tabPanel.appendChild(div);
|
||||||
Html html = new Html();
|
Html html = new Html();
|
||||||
|
|
Loading…
Reference in New Issue