IDEMPIERE-2310 Improve description field with inline Html editor and html rendering
This commit is contained in:
parent
9367a062f2
commit
fed84e92e1
|
@ -756,14 +756,14 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected boolean isShowPreference() {
|
protected boolean isShowPreference() {
|
||||||
return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn();
|
return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn() && !gridField.isVirtualColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param popupMenu
|
* @param popupMenu
|
||||||
*/
|
*/
|
||||||
protected void addChangeLogMenu(WEditorPopupMenu popupMenu) {
|
protected void addChangeLogMenu(WEditorPopupMenu popupMenu) {
|
||||||
if (popupMenu != null && gridField != null && gridField.getGridTab() != null)
|
if (popupMenu != null && gridField != null && gridField.getGridTab() != null && !gridField.isVirtualColumn())
|
||||||
{
|
{
|
||||||
WFieldRecordInfo.addMenu(popupMenu);
|
WFieldRecordInfo.addMenu(popupMenu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.compiere.util.CLogger;
|
||||||
import org.zkoss.zk.ui.Component;
|
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.zul.Div;
|
import org.zkoss.zul.Div;
|
||||||
import org.zkoss.zul.Html;
|
import org.zkoss.zul.Html;
|
||||||
|
|
||||||
|
@ -82,9 +83,13 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
if (gridField != null)
|
if (gridField != null)
|
||||||
{
|
{
|
||||||
Div div = (Div) getComponent();
|
Div div = (Div) getComponent();
|
||||||
div.setHeight("100px");
|
if (gridField.getNumLines() > 1) {
|
||||||
|
int height = 24 * gridField.getNumLines();
|
||||||
|
div.setHeight(height + "px");
|
||||||
|
}
|
||||||
div.setWidth("100%");
|
div.setWidth("100%");
|
||||||
LayoutUtils.addSclass("html-field", div);
|
LayoutUtils.addSclass("html-field", div);
|
||||||
|
div.addEventListener(Events.ON_DOUBLE_CLICK, this);
|
||||||
|
|
||||||
box = new Html();
|
box = new Html();
|
||||||
box.setParent(div);
|
box.setParent(div);
|
||||||
|
@ -170,35 +175,7 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
else if (WEditorPopupMenu.EDITOR_EVENT.equals(evt.getContextEvent()))
|
else if (WEditorPopupMenu.EDITOR_EVENT.equals(evt.getContextEvent()))
|
||||||
{
|
{
|
||||||
adwindowContent = findADWindowContent();
|
editorEvent();
|
||||||
final WTextEditorDialog dialog = new WTextEditorDialog(gridField.getVO().Header, getDisplay(),
|
|
||||||
isReadWrite(), gridField.getFieldLength(), true);
|
|
||||||
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()) {
|
|
||||||
box.setContent(dialog.getText());
|
|
||||||
String newText = box.getContent();
|
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(WHtmlEditor.this, WHtmlEditor.this.getColumnName(), oldValue, newText);
|
|
||||||
WHtmlEditor.super.fireValueChange(changeEvent);
|
|
||||||
oldValue = newText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (adwindowContent != null)
|
|
||||||
{
|
|
||||||
adwindowContent.getComponent().getParent().appendChild(dialog);
|
|
||||||
adwindowContent.showBusyMask(dialog);
|
|
||||||
LayoutUtils.openOverlappedWindow(adwindowContent.getComponent().getParent(), dialog, "middle_center");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SessionManager.getAppDesktop().showWindow(dialog);
|
|
||||||
}
|
|
||||||
dialog.focus();
|
|
||||||
}
|
}
|
||||||
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
||||||
{
|
{
|
||||||
|
@ -206,6 +183,38 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void editorEvent() {
|
||||||
|
adwindowContent = findADWindowContent();
|
||||||
|
final WTextEditorDialog dialog = new WTextEditorDialog(gridField.getVO().Header, getDisplay(),
|
||||||
|
isReadWrite(), gridField.getFieldLength(), true);
|
||||||
|
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()) {
|
||||||
|
box.setContent(dialog.getText());
|
||||||
|
String newText = box.getContent();
|
||||||
|
ValueChangeEvent changeEvent = new ValueChangeEvent(WHtmlEditor.this, WHtmlEditor.this.getColumnName(), oldValue, newText);
|
||||||
|
WHtmlEditor.super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (adwindowContent != null)
|
||||||
|
{
|
||||||
|
adwindowContent.getComponent().getParent().appendChild(dialog);
|
||||||
|
adwindowContent.showBusyMask(dialog);
|
||||||
|
LayoutUtils.openOverlappedWindow(adwindowContent.getComponent().getParent(), dialog, "middle_center");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SessionManager.getAppDesktop().showWindow(dialog);
|
||||||
|
}
|
||||||
|
dialog.focus();
|
||||||
|
}
|
||||||
|
|
||||||
private AbstractADWindowContent findADWindowContent() {
|
private AbstractADWindowContent findADWindowContent() {
|
||||||
Component parent = getComponent().getParent();
|
Component parent = getComponent().getParent();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
|
@ -220,7 +229,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
|
if (Events.ON_DOUBLE_CLICK.equals(event.getName()) && readwrite) {
|
||||||
|
editorEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
||||||
}
|
}
|
||||||
} else if (event.getTarget().getId().equals(ConfirmPanel.A_RESET)) {
|
} else if (event.getTarget().getId().equals(ConfirmPanel.A_RESET)) {
|
||||||
textBox.setText(text);
|
textBox.setText(text);
|
||||||
editor.setValue(text);
|
if (editor != null)
|
||||||
|
editor.setValue(text);
|
||||||
} else if (event.getName().equals(Events.ON_SELECT)) {
|
} else if (event.getName().equals(Events.ON_SELECT)) {
|
||||||
if (editable) {
|
if (editable) {
|
||||||
if (tabbox.getSelectedIndex() == 0) {
|
if (tabbox.getSelectedIndex() == 0) {
|
||||||
|
|
Loading…
Reference in New Issue