Message box enhancement:
* Follow standard UI convention - icon on the left, message on the right and button at bottom. * Set max-height and overflow:auto for the message content to make the messagebox usable even for very long message content. * Use shorter title text Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2979504
This commit is contained in:
parent
ba938efa6b
commit
37f28623cc
|
@ -38,12 +38,12 @@ import javax.servlet.ServletRequest;
|
||||||
|
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.compiere.acct.Doc;
|
import org.compiere.acct.Doc;
|
||||||
import org.compiere.model.GridWindowVO;
|
import org.compiere.model.GridWindowVO;
|
||||||
import org.compiere.model.Lookup;
|
import org.compiere.model.Lookup;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.compiere.model.MAcctSchema;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
import org.compiere.process.DocumentEngine;
|
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.CacheMgt;
|
import org.compiere.util.CacheMgt;
|
||||||
|
@ -699,4 +699,33 @@ public final class AEnv
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get title for dialog window
|
||||||
|
* @param ctx
|
||||||
|
* @param windowNo
|
||||||
|
* @return dialog header
|
||||||
|
*/
|
||||||
|
public static String getDialogHeader(Properties ctx, int windowNo) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if (windowNo > 0){
|
||||||
|
sb.append(Env.getContext(ctx, windowNo, "WindowName", false)).append(" ");
|
||||||
|
final String documentNo = Env.getContext(ctx, windowNo, "DocumentNo", false);
|
||||||
|
final String value = Env.getContext(ctx, windowNo, "Value", false);
|
||||||
|
final String name = Env.getContext(ctx, windowNo, "Name", false);
|
||||||
|
if(!"".equals(documentNo)) {
|
||||||
|
sb.append(documentNo).append(" ");
|
||||||
|
}
|
||||||
|
if(!"".equals(value)) {
|
||||||
|
sb.append(value).append(" ");
|
||||||
|
}
|
||||||
|
if(!"".equals(name)) {
|
||||||
|
sb.append(name).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String header = sb.toString().trim();
|
||||||
|
if (header.length() == 0)
|
||||||
|
header = ThemeManager.getBrowserTitle();
|
||||||
|
return header;
|
||||||
|
}
|
||||||
} // AEnv
|
} // AEnv
|
||||||
|
|
|
@ -42,13 +42,13 @@ import org.zkoss.zul.Separator;
|
||||||
public class Messagebox extends Window implements EventListener
|
public class Messagebox extends Window implements EventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* generated serial version ID
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4957498533838144942L;
|
private static final long serialVersionUID = -4957498533838144942L;
|
||||||
|
private static final String MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 350pt; min-width: 230pt; max-width: 450pt;";
|
||||||
private String msg = new String("");
|
private String msg = new String("");
|
||||||
private String imgSrc = new String("");
|
private String imgSrc = new String("");
|
||||||
|
|
||||||
// private Label lblMsg = new Label();
|
|
||||||
private Text lblMsg = new Text();
|
private Text lblMsg = new Text();
|
||||||
|
|
||||||
private Button btnOk = new Button();
|
private Button btnOk = new Button();
|
||||||
|
@ -130,12 +130,10 @@ public class Messagebox extends Window implements EventListener
|
||||||
LayoutUtils.addSclass("action-text-button", btnNo);
|
LayoutUtils.addSclass("action-text-button", btnNo);
|
||||||
|
|
||||||
btnAbort.setLabel("Abort");
|
btnAbort.setLabel("Abort");
|
||||||
//btnAbort.setImage("/images/");
|
|
||||||
btnAbort.addEventListener(Events.ON_CLICK, this);
|
btnAbort.addEventListener(Events.ON_CLICK, this);
|
||||||
LayoutUtils.addSclass("action-text-button", btnAbort);
|
LayoutUtils.addSclass("action-text-button", btnAbort);
|
||||||
|
|
||||||
btnRetry.setLabel("Retry");
|
btnRetry.setLabel("Retry");
|
||||||
//btnRetry.setImage("/images/");
|
|
||||||
btnRetry.addEventListener(Events.ON_CLICK, this);
|
btnRetry.addEventListener(Events.ON_CLICK, this);
|
||||||
LayoutUtils.addSclass("action-text-button", btnRetry);
|
LayoutUtils.addSclass("action-text-button", btnRetry);
|
||||||
|
|
||||||
|
@ -145,28 +143,29 @@ public class Messagebox extends Window implements EventListener
|
||||||
LayoutUtils.addSclass("action-text-button", btnIgnore);
|
LayoutUtils.addSclass("action-text-button", btnIgnore);
|
||||||
|
|
||||||
Panel pnlMessage = new Panel();
|
Panel pnlMessage = new Panel();
|
||||||
pnlMessage.setWidth("100%");
|
pnlMessage.setStyle(MESSAGE_PANEL_STYLE);
|
||||||
pnlMessage.setStyle("text-align:left");
|
|
||||||
pnlMessage.appendChild(lblMsg);
|
pnlMessage.appendChild(lblMsg);
|
||||||
|
|
||||||
Panel pnlImage = new Panel();
|
Hbox pnlImage = new Hbox();
|
||||||
|
|
||||||
img.setSrc(imgSrc);
|
img.setSrc(imgSrc);
|
||||||
|
|
||||||
pnlImage.setWidth("100%");
|
pnlImage.setWidth("72px");
|
||||||
pnlImage.setStyle("text-align:center");
|
pnlImage.setAlign("center");
|
||||||
|
pnlImage.setPack("center");
|
||||||
pnlImage.appendChild(img);
|
pnlImage.appendChild(img);
|
||||||
|
|
||||||
Hbox hbox = new Hbox();
|
Hbox north = new Hbox();
|
||||||
hbox.setWidth("100%");
|
north.setAlign("center");
|
||||||
hbox.setWidths("10%, 90%");
|
north.setStyle("margin: 20pt 10pt 20pt 10pt;"); //trbl
|
||||||
|
this.appendChild(north);
|
||||||
hbox.appendChild(pnlImage);
|
north.appendChild(pnlImage);
|
||||||
hbox.appendChild(pnlMessage);
|
north.appendChild(pnlMessage);
|
||||||
|
|
||||||
Hbox pnlButtons = new Hbox();
|
Hbox pnlButtons = new Hbox();
|
||||||
pnlButtons.setWidth("100%");
|
pnlButtons.setHeight("52px");
|
||||||
pnlButtons.setStyle("text-align:center");
|
pnlButtons.setAlign("center");
|
||||||
|
pnlButtons.setPack("end");
|
||||||
pnlButtons.appendChild(btnOk);
|
pnlButtons.appendChild(btnOk);
|
||||||
pnlButtons.appendChild(btnCancel);
|
pnlButtons.appendChild(btnCancel);
|
||||||
pnlButtons.appendChild(btnYes);
|
pnlButtons.appendChild(btnYes);
|
||||||
|
@ -175,19 +174,20 @@ public class Messagebox extends Window implements EventListener
|
||||||
pnlButtons.appendChild(btnRetry);
|
pnlButtons.appendChild(btnRetry);
|
||||||
pnlButtons.appendChild(btnIgnore);
|
pnlButtons.appendChild(btnIgnore);
|
||||||
|
|
||||||
this.setWidth("100%");
|
Separator separator = new Separator();
|
||||||
|
separator.setWidth("100%");
|
||||||
|
separator.setBar(true);
|
||||||
|
this.appendChild(separator);
|
||||||
|
|
||||||
|
Hbox south = new Hbox();
|
||||||
|
south.setPack("end");
|
||||||
|
south.setWidth("100%");
|
||||||
|
this.appendChild(south);
|
||||||
|
south.appendChild(pnlButtons);
|
||||||
|
|
||||||
this.setBorder("normal");
|
this.setBorder("normal");
|
||||||
this.setContentStyle("background-color:#ffffff");
|
this.setContentStyle("background-color:#ffffff;");
|
||||||
this.setPosition("left, top");
|
this.setPosition("left, top");
|
||||||
|
|
||||||
Separator blank = new Separator();
|
|
||||||
blank.setOrient("vertical");
|
|
||||||
blank.setHeight("5px");
|
|
||||||
|
|
||||||
hbox.appendChild(blank);
|
|
||||||
hbox.appendChild(pnlButtons);
|
|
||||||
|
|
||||||
this.appendChild(hbox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int show(String message, String title, int buttons, String icon)
|
public int show(String message, String title, int buttons, String icon)
|
||||||
|
@ -227,7 +227,6 @@ public class Messagebox extends Window implements EventListener
|
||||||
init();
|
init();
|
||||||
|
|
||||||
this.setTitle(title);
|
this.setTitle(title);
|
||||||
this.setWidth("500px");
|
|
||||||
this.setPosition("center");
|
this.setPosition("center");
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
if (Events.inEventListener())
|
if (Events.inEventListener())
|
||||||
|
|
Loading…
Reference in New Issue