IDEMPIERE-563 HTML Editor for text fields. Fixed layout and only mask out current tab.

This commit is contained in:
Heng Sin Low 2013-01-21 23:34:38 +08:00
parent c3288cdd41
commit 1395d8acb3
2 changed files with 47 additions and 10 deletions

View File

@ -19,7 +19,10 @@ package org.adempiere.webui.editor;
import java.util.List;
import org.adempiere.webui.LayoutUtils;
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.Textbox;
import org.adempiere.webui.component.Window;
@ -32,6 +35,7 @@ import org.adempiere.webui.window.WFieldRecordInfo;
import org.adempiere.webui.window.WTextEditorDialog;
import org.compiere.model.GridField;
import org.compiere.util.DisplayType;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -50,6 +54,8 @@ public class WStringEditor extends WEditor implements ContextMenuListener
private boolean tableEditor = false;
private AbstractADWindowContent adwindowContent;
/**
* 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()))
{
adwindowContent = findADWindowContent();
final WTextEditorDialog dialog = new WTextEditorDialog(this.getColumnName(), getDisplay(),
isReadWrite(), gridField.getFieldLength());
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>() {
@Override
public void onEvent(Event event) throws Exception {
if (adwindowContent != null) {
adwindowContent.hideBusyMask();
}
if (!dialog.isCancelled()) {
getComponent().setText(dialog.getText());
String newText = getComponent().getValue();
@ -238,8 +248,17 @@ public class WStringEditor extends WEditor implements ContextMenuListener
}
}
});
SessionManager.getAppDesktop().showWindow(dialog);
if (adwindowContent != null)
{
adwindowContent.getComponent().getParent().appendChild(dialog);
adwindowContent.showBusyMask();
LayoutUtils.openOverlappedWindow(adwindowContent.getComponent().getParent(), dialog, "middle_center");
}
else
{
SessionManager.getAppDesktop().showWindow(dialog);
}
dialog.focus();
}
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;
}
}

View File

@ -20,7 +20,6 @@ import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.component.Window;
import org.zkoss.zk.ui.event.Event;
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.Html;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Vlayout;
import fi.jawsy.jawwa.zk.cleditor.Cleditor;
@ -70,9 +70,14 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
private void init() {
setBorder("normal");
setHeight("450px");
setWidth("700px");
setStyle("position: absolute;");
VerticalBox vbox = new VerticalBox();
Vlayout vbox = new Vlayout();
appendChild(vbox);
vbox.setWidth("100%");
vbox.setVflex("true");
tabbox = new Tabbox();
vbox.appendChild(tabbox);
@ -80,6 +85,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
tabbox.appendChild(tabs);
Tabpanels tabPanels = new Tabpanels();
tabbox.appendChild(tabPanels);
tabbox.setVflex("true");
tabbox.setHflex("true");
Tab tab = new Tab("Text");
tabs.appendChild(tab);
@ -90,8 +97,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
textBox.setCols(80);
textBox.setRows(30);
textBox.setEnabled(editable);
textBox.setWidth("700px");
textBox.setHeight("500px");
textBox.setVflex("true");
textBox.setHflex("true");
tabPanel.appendChild(textBox);
tab = new Tab("HTML");
@ -102,13 +109,13 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
if (editable) {
editor = new Cleditor();
tabPanel.appendChild(editor);
editor.setWidth("700px");
editor.setHeight("500px");
editor.setWidth("100%");
editor.setHeight("100%");
editor.setValue(text);
} else {
Div div = new Div();
div.setHeight("500px");
div.setWidth("700px");
div.setHeight("100%");
div.setWidth("100%");
div.setStyle("overflow: auto; border: 1px solid");
tabPanel.appendChild(div);
Html html = new Html();