Skip to content

Commit

Permalink
IDEMPIERE-6242 Info window, image fieldtype doesn't work (idempiere#2473
Browse files Browse the repository at this point in the history
)

* IDEMPIERE-6242 Info window, image fieldtype doesn't work

* IDEMPIERE-6242 Info window, image fieldtype doesn't work

- Fixed model generator and type description
- Fixed hover image sometime not remove

* IDEMPIERE-6242 Info window, image fieldtype doesn't work

- Fix use of web URL for AD_Form, AD_InfoWindow and AD_InfoProcess
- Fix font icon support for AD_Form and AD_InfoWindow

* IDEMPIERE-6242 Info window, image fieldtype doesn't work

- Fixed size of image for info window process button
- Fixed web url support for DPView

* IDEMPIERE-6242 Info window, image fieldtype doesn't work

- add no-image css class for no image place holder customization.
  • Loading branch information
hengsin authored Oct 5, 2024
1 parent 3dbc3f1 commit 8e065a5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.RowRendererExt;
import org.zkoss.zul.Span;
import org.zkoss.zul.impl.XulElement;

/**
Expand Down Expand Up @@ -339,17 +340,23 @@ private Component getDisplayComponent(int rowIndex, Object value, GridField grid
editor.addActionListener(buttonListener);
component = editor.getComponent();
} else if (gridField.getDisplayType() == DisplayType.Image) {
WImageEditor editor = new WImageEditor(gridField);
editor.setReadWrite(false);
editor.setValue(value);
Image image = editor.getComponent();
if (image.getContent() != null) {
image.setWidth(MSysConfig.getIntValue(MSysConfig.ZK_THUMBNAIL_IMAGE_WIDTH, 100, Env.getAD_Client_ID(Env.getCtx()))+"px");
image.setHeight(MSysConfig.getIntValue(MSysConfig.ZK_THUMBNAIL_IMAGE_HEIGHT, 100, Env.getAD_Client_ID(Env.getCtx()))+"px");
image.setClientAttribute("onmouseenter", "idempiere.showFullSizeImage(event)");
image.setClientAttribute("onmouseleave", "idempiere.hideFullSizeImage(event)");
if (value != null) {
WImageEditor editor = new WImageEditor(gridField);
editor.setReadWrite(false);
editor.setValue(value);
Image image = editor.getComponent();
if (image.getContent() != null) {
image.setWidth(MSysConfig.getIntValue(MSysConfig.ZK_THUMBNAIL_IMAGE_WIDTH, 100, Env.getAD_Client_ID(Env.getCtx()))+"px");
image.setHeight(MSysConfig.getIntValue(MSysConfig.ZK_THUMBNAIL_IMAGE_HEIGHT, 100, Env.getAD_Client_ID(Env.getCtx()))+"px");
image.setClientAttribute("onmouseenter", "idempiere.showFullSizeImage(event)");
image.setClientAttribute("onmouseleave", "idempiere.hideFullSizeImage(event)");
}
component = image;
} else {
Span span = new Span();
span.setSclass("no-image");
component = span;
}
component = image;
} else {
String text = getDisplayText(value, gridField, rowIndex, isForceGetValue);
WEditor editor = getEditorCell(gridField);
Expand All @@ -359,8 +366,17 @@ private Component getDisplayComponent(int rowIndex, Object value, GridField grid
component = label;
}else{
component = editor.getDisplayComponent();
if (component instanceof Html){
((Html)component).setContent(text);
if (component instanceof Html html){
if (Util.isEmpty(text) && value == null) {
String nullText = editor.getDisplayTextForGridView(value);
if (!Util.isEmpty(nullText)) {
html.setContent(nullText);
} else {
html.setContent(text);
}
} else {
html.setContent(text);
}
}else{
throw new UnsupportedOperationException("Only implemented for Html component.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Cell;
import org.zkoss.zul.Html;
import org.zkoss.zul.Image;

/**
Expand Down Expand Up @@ -178,8 +179,8 @@ public void setValue(Object value)

@Override
public String getDisplayTextForGridView(Object value) {
if (value == null) {
return "";
if (value == null || (value instanceof Integer && (Integer)value == 0)) {
return "<span class='no-image'/>";
} else {
return "...";
}
Expand Down Expand Up @@ -231,4 +232,12 @@ public void onEvent(Event event) throws Exception {
public void fillHorizontal() {
}

@Override
public Component getDisplayComponent() {
if (m_mImage == null)
return new Html();
else
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public String getDisplayTextForGridView(GridRowCtx gridRowCtx, Object value) {
.append("onmouseenter='idempiere.showFullSizeImage(event)' onmouseleave='idempiere.hideFullSizeImage(event)'/>");
return builder.toString();
} else {
return "";
return "<span class='no-image'/>";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,8 @@ protected void prepareTable(ColumnInfo[] layout, String from, String where,
image.setClientAttribute("onmouseenter", "idempiere.showFullSizeImage(event)");
image.setClientAttribute("onmouseleave", "idempiere.hideFullSizeImage(event)");
}
if (t.value == null)
LayoutUtils.addSclass("no-image", editor.getComponent());
return editor;
});
}
Expand Down

0 comments on commit 8e065a5

Please sign in to comment.