IDEMPIERE-724 Zk: Make iDempiere theme more easily customizable. Move statusbar to top and modify to use css style.

This commit is contained in:
Heng Sin Low 2013-05-14 06:42:19 +08:00
parent 5a3e609189
commit 51cb5127bc
5 changed files with 304 additions and 309 deletions

View File

@ -134,13 +134,10 @@ public class ADWindowContent extends AbstractADWindowContent
} }
} }
}); });
//status bar
Div south = new Div();
south.setSclass("adwindow-south");
south.setVflex("0");
statusBar.setParent(south);
//status bar
div.appendChild(statusBar);
LayoutUtils.addSclass("adwindow-status", statusBar); LayoutUtils.addSclass("adwindow-status", statusBar);
contentArea = new Div(); contentArea = new Div();
@ -150,8 +147,6 @@ public class ADWindowContent extends AbstractADWindowContent
contentArea.setStyle("overflow: auto;"); contentArea.setStyle("overflow: auto;");
adTabbox.createPart(contentArea); adTabbox.createPart(contentArea);
layout.appendChild(south);
if (parent instanceof Tabpanel) { if (parent instanceof Tabpanel) {
TabOnCloseHanlder handler = new TabOnCloseHanlder(); TabOnCloseHanlder handler = new TabOnCloseHanlder();
((Tabpanel)parent).setOnCloseHandler(handler); ((Tabpanel)parent).setOnCloseHandler(handler);

View File

@ -1036,11 +1036,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
hideBusyMask(); hideBusyMask();
ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget(); ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget();
onModalClose(dialog.getProcessInfo()); onModalClose(dialog.getProcessInfo());
String s = breadCrumb.getStatusLine(); String s = statusBar.getStatusLine();
boolean b = breadCrumb.getStatusError(); boolean b = statusBar.getStatusError();
ProcessInfoLog[] logs = breadCrumb.getPLogs(); ProcessInfoLog[] logs = statusBar.getPLogs();
onRefresh(true, false); onRefresh(true, false);
breadCrumb.setStatusLine(s, b, logs); statusBar.setStatusLine(s, b, logs);
} }
else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName())) else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName()))
{ {
@ -1278,7 +1278,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (detailTab) { if (detailTab) {
adTabbox.setDetailPaneStatusMessage("", false); adTabbox.setDetailPaneStatusMessage("", false);
} else { } else {
breadCrumb.setStatusLine ("", false); statusBar.setStatusLine ("", false);
} }
} }
else else
@ -1345,7 +1345,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (detailTab) { if (detailTab) {
adTabbox.setDetailPaneStatusMessage(sb.toString (), e.isError ()); adTabbox.setDetailPaneStatusMessage(sb.toString (), e.isError ());
} else { } else {
breadCrumb.setStatusLine (sb.toString (), e.isError ()); statusBar.setStatusLine (sb.toString (), e.isError ());
} }
} }
} }
@ -1797,9 +1797,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{ {
if (result) if (result)
{ {
String statusLine = breadCrumb.getStatusLine(); String statusLine = statusBar.getStatusLine();
adTabbox.getSelectedGridTab().dataRefreshAll(true, true); adTabbox.getSelectedGridTab().dataRefreshAll(true, true);
breadCrumb.setStatusLine(statusLine); statusBar.setStatusLine(statusLine);
} }
if (dirtyTabpanel != null) { if (dirtyTabpanel != null) {
if (dirtyTabpanel == adTabbox.getSelectedDetailADTabpanel()) if (dirtyTabpanel == adTabbox.getSelectedDetailADTabpanel())
@ -1848,7 +1848,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
} }
if (!sortTab.isChanged()) { if (!sortTab.isChanged()) {
if (sortTab == adTabbox.getSelectedTabpanel()) { if (sortTab == adTabbox.getSelectedTabpanel()) {
breadCrumb.setStatusLine(Msg.getMsg(Env.getCtx(), "Saved")); statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "Saved"));
} else { } else {
adTabbox.setDetailPaneStatusMessage(Msg.getMsg(Env.getCtx(), "Saved"), false); adTabbox.setDetailPaneStatusMessage(Msg.getMsg(Env.getCtx(), "Saved"), false);
} }
@ -1958,7 +1958,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
String msg = CLogger.retrieveErrorString(null); String msg = CLogger.retrieveErrorString(null);
if (msg != null) if (msg != null)
{ {
breadCrumb.setStatusLine(Msg.getMsg(Env.getCtx(), msg), true); statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), msg), true);
} }
//other error will be catch in the dataStatusChanged event //other error will be catch in the dataStatusChanged event
} }
@ -2599,7 +2599,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
onRefresh(true, false); onRefresh(true, false);
if (error != null) if (error != null)
breadCrumb.setStatusLine(error, true); statusBar.setStatusLine(error, true);
} }
} }
}); });
@ -2747,7 +2747,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
String error = processButtonCallout((IProcessButton) event.getSource()); String error = processButtonCallout((IProcessButton) event.getSource());
if (error != null && error.trim().length() > 0) if (error != null && error.trim().length() > 0)
{ {
breadCrumb.setStatusLine(error, true); statusBar.setStatusLine(error, true);
return; return;
} }
actionButton((IProcessButton) event.getSource()); actionButton((IProcessButton) event.getSource());
@ -2865,7 +2865,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
// Get Log Info // Get Log Info
ProcessInfoUtil.setLogFromDB(pi); ProcessInfoUtil.setLogFromDB(pi);
ProcessInfoLog m_logs[] = pi.getLogs(); ProcessInfoLog m_logs[] = pi.getLogs();
breadCrumb.setStatusLine(pi.getSummary(), pi.isError(),m_logs); statusBar.setStatusLine(pi.getSummary(), pi.isError(),m_logs);
if (m_logs != null) { if (m_logs != null) {
ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(ctx, curWindowNo),Env.getHeader(ctx, curWindowNo), m_logs); ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(ctx, curWindowNo),Env.getHeader(ctx, curWindowNo), m_logs);
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {

View File

@ -21,13 +21,10 @@ import java.util.Map;
import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Menupopup; import org.adempiere.webui.component.Menupopup;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBar;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.component.ZkCssHelper; import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
@ -35,30 +32,21 @@ import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.WRecordInfo; import org.adempiere.webui.window.WRecordInfo;
import org.compiere.model.DataStatusEvent; import org.compiere.model.DataStatusEvent;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.process.ProcessInfoLog;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.zhtml.Text;
import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.Page;
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;
import org.zkoss.zk.ui.event.KeyEvent; import org.zkoss.zk.ui.event.KeyEvent;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.A;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
import org.zkoss.zul.Hlayout; import org.zkoss.zul.Hlayout;
import org.zkoss.zul.Image;
import org.zkoss.zul.Menuitem; import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;
/** /**
* @author hengsin * @author hengsin
@ -70,10 +58,6 @@ public class BreadCrumb extends Div implements EventListener<Event> {
private static final String ON_MOUSE_OUT_ECHO_EVENT = "onMouseOutEcho"; private static final String ON_MOUSE_OUT_ECHO_EVENT = "onMouseOutEcho";
private static final String INFO_INDICATOR_IMAGE = "images/InfoIndicator16.png";
private static final String ERROR_INDICATOR_IMAGE = "images/ErrorIndicator16.png";
/** /**
* generated serial id * generated serial id
*/ */
@ -97,24 +81,10 @@ public class BreadCrumb extends Div implements EventListener<Event> {
private String m_text; private String m_text;
private boolean m_statusError;
private String m_statusText;
private Window msgPopup;
private Div msgPopupCnt;
private ToolbarListener toolbarListener; private ToolbarListener toolbarListener;
private Hlayout toolbarContainer; private Hlayout toolbarContainer;
private Hbox messageContainer;
private Caption msgPopupCaption;
private ProcessInfoLog[] pInfoLogs = null;
protected Menupopup linkPopup; protected Menupopup linkPopup;
/** /**
@ -133,7 +103,8 @@ public class BreadCrumb extends Div implements EventListener<Event> {
this.setSclass("adwindow-breadcrumb"); this.setSclass("adwindow-breadcrumb");
toolbarContainer = new Hlayout(); toolbarContainer = new Hlayout();
layout.appendChild(toolbarContainer); toolbarContainer.setStyle("display: inline-block; float: right");
this.appendChild(toolbarContainer);
ToolBar toolbar = new ToolBar(); ToolBar toolbar = new ToolBar();
toolbarContainer.appendChild(toolbar); toolbarContainer.appendChild(toolbar);
@ -157,19 +128,11 @@ public class BreadCrumb extends Div implements EventListener<Event> {
btnLast.setTooltiptext(btnLast.getTooltiptext()+" Alt+End"); btnLast.setTooltiptext(btnLast.getTooltiptext()+" Alt+End");
toolbar.appendChild(btnLast); toolbar.appendChild(btnLast);
messageContainer = new Hbox();
messageContainer.setStyle("float: right; height: 30px;");
messageContainer.setAlign("center");
messageContainer.setId("messages");
appendChild(messageContainer);
altKeyMap.put(KeyEvent.UP, btnPrevious); altKeyMap.put(KeyEvent.UP, btnPrevious);
altKeyMap.put(KeyEvent.DOWN, btnNext); altKeyMap.put(KeyEvent.DOWN, btnNext);
altKeyMap.put(KeyEvent.PAGE_UP, btnFirst); altKeyMap.put(KeyEvent.PAGE_UP, btnFirst);
altKeyMap.put(KeyEvent.PAGE_DOWN, btnLast); altKeyMap.put(KeyEvent.PAGE_DOWN, btnLast);
createPopup();
toolbar.setStyle("background-image: none; background-color: transparent; border: none;"); toolbar.setStyle("background-image: none; background-color: transparent; border: none;");
setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "breadcrumb"); setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "breadcrumb");
@ -197,23 +160,23 @@ public class BreadCrumb extends Div implements EventListener<Event> {
a.setId("breadcrumb-"+label); a.setId("breadcrumb-"+label);
a.setPathId(id); a.setPathId(id);
a.addEventListener(Events.ON_CLICK, this); a.addEventListener(Events.ON_CLICK, this);
if (layout.getChildren().size() > 1) { if (layout.getChildren().size() > 0) {
Label symbol = new Label(); Label symbol = new Label();
symbol.setValue(" > "); symbol.setValue(" > ");
layout.insertBefore(symbol, toolbarContainer); layout.appendChild(symbol);
} }
layout.insertBefore(a, toolbarContainer); layout.appendChild(a);
} else { } else {
Label pathLabel = new Label(); Label pathLabel = new Label();
pathLabel.setId("breadcrumb-"+label); pathLabel.setId("breadcrumb-"+label);
pathLabel.setValue(label); pathLabel.setValue(label);
if (layout.getChildren().size() > 1) { if (layout.getChildren().size() > 0) {
Label symbol = new Label(); Label symbol = new Label();
symbol.setValue(" > "); symbol.setValue(" > ");
layout.insertBefore(symbol, toolbarContainer); layout.appendChild(symbol);
} }
pathLabel.setStyle("font-weight: bold"); pathLabel.setStyle("font-weight: bold");
layout.insertBefore(pathLabel, toolbarContainer); layout.appendChild(pathLabel);
} }
} }
@ -236,7 +199,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
*/ */
public void addLinks(LinkedHashMap<String, String> links) { public void addLinks(LinkedHashMap<String, String> links) {
this.links = links; this.links = links;
final Label pathLabel = (Label) layout.getChildren().get(layout.getChildren().size()-2); final Label pathLabel = (Label) layout.getChildren().get(layout.getChildren().size()-1);
pathLabel.setStyle("cursor: pointer; font-weight: bold; padding-right: 10px;"); pathLabel.setStyle("cursor: pointer; font-weight: bold; padding-right: 10px;");
EventListener<Event> listener = new EventListener<Event>() { EventListener<Event> listener = new EventListener<Event>() {
@Override @Override
@ -342,10 +305,6 @@ public class BreadCrumb extends Div implements EventListener<Event> {
String title = Msg.getMsg(Env.getCtx(), "Who") + m_text; String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
new WRecordInfo (title, m_dse); new WRecordInfo (title, m_dse);
} else if(event.getTarget() instanceof RecordLink){
doZoom((RecordLink)event.getTarget());
} else if (event.getTarget().getParent() == messageContainer) {
showPopup();
} else if (event.getTarget() == btnFirst) { } else if (event.getTarget() == btnFirst) {
if (toolbarListener != null) if (toolbarListener != null)
toolbarListener.onFirst(); toolbarListener.onFirst();
@ -396,11 +355,8 @@ public class BreadCrumb extends Div implements EventListener<Event> {
* remove all links * remove all links
*/ */
public void reset() { public void reset() {
if (layout.getChildren().size() == 0 || layout.getChildren().size() > 1) { layout.getChildren().clear();
layout.getChildren().clear(); this.links = null;
layout.appendChild(toolbarContainer);
this.links = null;
}
} }
/** /**
@ -474,193 +430,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
enableLastNavigation(m_dse.getTotalRows() > m_dse.getCurrentRow()+1); enableLastNavigation(m_dse.getTotalRows() > m_dse.getCurrentRow()+1);
} }
} }
/**
* @param text
*/
public void setStatusLine (String text)
{
setStatusLine(text, false,null);
}
/**
* @param text
* @param error
*/
public void setStatusLine (String text, boolean error)
{
setStatusLine(text, error, null);
}
/**
* @param text
* @param error
* @param m_logs
*/
public void setStatusLine (String text, boolean error, ProcessInfoLog[] m_logs)
{
pInfoLogs = m_logs;
Div div = null;
Execution execution = Executions.getCurrent();
if (execution != null) {
String key = this.getClass().getName()+"."+getUuid();
Object o = execution.getAttribute(key);
if (o != null) {
if (text == null || text.trim().length() == 0)
return;
} else {
execution.setAttribute(key, Boolean.TRUE);
}
}
m_statusText = text;
m_statusError = error;
messageContainer.getChildren().clear();
if (text == null || text.trim().length() == 0 )
return;
Image image = null;
if (error)
image = new Image(ThemeManager.getThemeResource(ERROR_INDICATOR_IMAGE));
else
image = new Image(ThemeManager.getThemeResource(INFO_INDICATOR_IMAGE));
image.setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE);
messageContainer.appendChild(image);
String labelText = buildLabelText(m_statusText);
if (error) {
Clients.showNotification(buildNotificationText(m_statusText), "error", findTabpanel(this), "top_left", 3500, true);
}
Label label = new Label(labelText);
messageContainer.appendChild(label);
if (m_logs != null) {
div = new Div();
for (int i = 0; i < m_logs.length; i++) {
if (m_logs[i].getP_Msg() != null) {
if (m_logs[i].getAD_Table_ID() > 0
&& m_logs[i].getRecord_ID() > 0) {
RecordLink recordLink = new RecordLink(m_logs[i].getAD_Table_ID(), m_logs[i].getRecord_ID());
recordLink.setLabel(m_logs[i].getP_Msg());
recordLink.addEventListener(Events.ON_CLICK, this);
if (!div.getChildren().isEmpty())
div.appendChild(new Separator("horizontal"));
div.appendChild(recordLink);
}
}
}
}
if (labelText.length() != m_statusText.length() || (div != null && div.getChildren().size() > 0)) {
image.addEventListener(Events.ON_CLICK, this);
image.setStyle("cursor: pointer");
label.addEventListener(Events.ON_CLICK, this);
label.setStyle("cursor: pointer");
label = new Label(" ...");
label.setStyle("cursor: pointer");
messageContainer.appendChild(label);
label.addEventListener(Events.ON_CLICK, this);
}
messageContainer.appendChild(new Space());
createPopupContent();
if(div!=null)
{
msgPopupCnt.appendChild(div);
}
}
private Component findTabpanel(BreadCrumb breadCrumb) {
Component parent = breadCrumb.getParent();
while (parent != null) {
if (parent instanceof Tabpanel)
return parent;
parent = parent.getParent();
}
return null;
}
private void doZoom(RecordLink link) {
int Record_ID = 0;
int AD_Table_ID = 0;
Record_ID = link.recordId;
AD_Table_ID = link.tableId;
if (Record_ID > 0 && AD_Table_ID > 0) {
AEnv.zoom(AD_Table_ID, Record_ID);
}
}
private String buildLabelText(String statusText) {
if (statusText == null)
return "";
if (statusText.length() <= 80)
return statusText;
int index = statusText.indexOf(" - java.lang.Exception");
if (index > 0)
return statusText.substring(0, index);
return statusText.substring(0, 80);
}
private String buildNotificationText(String statusText) {
if (statusText == null)
return "";
if (statusText.length() <= 140)
return statusText;
int index = statusText.indexOf(" - java.lang.Exception");
if (index > 0)
return statusText.substring(0, index);
return statusText.substring(0, 136) + " ...";
}
protected void createPopupContent() {
Text t = new Text(m_statusText);
msgPopupCnt.getChildren().clear();
msgPopupCnt.appendChild(t);
}
/**
*
* @return current status line text
*/
public String getStatusLine() {
return m_statusText;
}
public boolean getStatusError() {
return m_statusError;
}
private void createPopup() {
msgPopupCnt = new Div();
msgPopupCnt.setVflex("1");
msgPopup = new Window();
msgPopup.setBorder(true);
msgPopup.setClosable(true);
msgPopup.setSizable(true);
msgPopup.setContentStyle("overflow: auto");
msgPopup.setWidth("500px");
msgPopup.appendChild(msgPopupCnt);
msgPopup.setShadow(true);
msgPopupCaption = new Caption();
msgPopup.appendChild(msgPopupCaption);
}
private void showPopup() {
msgPopupCaption.setImage(m_statusError ? ThemeManager.getThemeResource(ERROR_INDICATOR_IMAGE)
: ThemeManager.getThemeResource(INFO_INDICATOR_IMAGE));
appendChild(msgPopup);
LayoutUtils.openOverlappedWindow(messageContainer, msgPopup, "overlap_end");
}
@Override @Override
public void onPageDetached(Page page) { public void onPageDetached(Page page) {
super.onPageDetached(page); super.onPageDetached(page);
@ -692,14 +462,6 @@ public class BreadCrumb extends Div implements EventListener<Event> {
return false; return false;
} }
/**
*
* @return process logs
*/
public ProcessInfoLog[] getPLogs() {
return pInfoLogs;
}
@Override @Override
public void onPageAttached(Page newpage, Page oldpage) { public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage); super.onPageAttached(newpage, oldpage);
@ -722,18 +484,5 @@ public class BreadCrumb extends Div implements EventListener<Event> {
public ToolBarButton getPreviousButton() { public ToolBarButton getPreviousButton() {
return btnPrevious; return btnPrevious;
} }
class RecordLink extends A {
private static final long serialVersionUID = 3793489614175751401L;
protected int recordId;
protected int tableId;
protected RecordLink(int AD_Table_ID, int Record_ID) {
super();
tableId = AD_Table_ID;
recordId = Record_ID;
}
}
} }

View File

@ -17,13 +17,26 @@
package org.adempiere.webui.adwindow; package org.adempiere.webui.adwindow;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.zkoss.zul.Cell; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Window;
import org.compiere.process.ProcessInfoLog;
import org.zkoss.zhtml.Text;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.A;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;
/** /**
* This class is based on org.compiere.apps.StatusBar written by Jorg Janke. * This class is based on org.compiere.apps.StatusBar written by Jorg Janke.
@ -33,7 +46,7 @@ import org.zkoss.zul.Vbox;
* @date Mar 12, 2007 * @date Mar 12, 2007
* @version $Revision: 0.10 $ * @version $Revision: 0.10 $
*/ */
public class StatusBar extends Panel public class StatusBar extends Panel implements EventListener<Event>
{ {
/** /**
* *
@ -43,37 +56,49 @@ public class StatusBar extends Panel
private Label infoLine; private Label infoLine;
private Div west; private Div west;
private Div east;
private ProcessInfoLog[] pInfoLogs;
private String m_statusText;
private boolean m_statusError;
private Window msgPopup;
private Div msgPopupCnt;
private Hbox messageContainer;
private Caption msgPopupCaption;
public StatusBar() public StatusBar()
{ {
super(); super();
init(); init();
createPopup();
} }
private void init() private void init()
{ {
Hbox hbox = new Hbox();
hbox.setWidth("100%");
hbox.setHeight("100%");
hbox.setHflex("1");
hbox.setPack("center");
Cell leftCell = new Cell();
hbox.appendChild(leftCell);
leftCell.setWidth("100%");
infoLine = new Label(); infoLine = new Label();
west = new Div(); east = new Div();
west.setStyle("text-align: left; "); east.setSclass("adwindow-status-docinfo");
west.appendChild(infoLine); east.appendChild(infoLine);
Vbox vbox = new Vbox();
vbox.setPack("center");
LayoutUtils.addSclass("status", vbox);
vbox.appendChild(west);
leftCell.appendChild(vbox);
this.appendChild(hbox);
west = new Div();
west.setSclass("adwindow-status-docstatus");
messageContainer = new Hbox();
messageContainer.setAlign("center");
messageContainer.setId("messages");
west.appendChild(messageContainer);
appendChild(west);
appendChild(east);
} }
/** /**
@ -87,4 +112,211 @@ public class StatusBar extends Panel
infoLine.setStyle("font-weight: bold;"); infoLine.setStyle("font-weight: bold;");
} // setInfo } // setInfo
/**
* @param text
*/
public void setStatusLine (String text)
{
setStatusLine(text, false,null);
}
/**
* @param text
* @param error
*/
public void setStatusLine (String text, boolean error)
{
setStatusLine(text, error, null);
}
/**
* @param text
* @param error
* @param m_logs
*/
public void setStatusLine (String text, boolean error, ProcessInfoLog[] m_logs)
{
pInfoLogs = m_logs;
Div div = null;
Execution execution = Executions.getCurrent();
if (execution != null) {
String key = this.getClass().getName()+"."+getUuid();
Object o = execution.getAttribute(key);
if (o != null) {
if (text == null || text.trim().length() == 0)
return;
} else {
execution.setAttribute(key, Boolean.TRUE);
}
}
m_statusText = text;
m_statusError = error;
messageContainer.getChildren().clear();
if (text == null || text.trim().length() == 0 )
return;
/*
Image image = null;
if (error)
image = new Image(ThemeManager.getThemeResource(ERROR_INDICATOR_IMAGE));
else
image = new Image(ThemeManager.getThemeResource(INFO_INDICATOR_IMAGE));
image.setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE);
*/
// messageContainer.appendChild(image);
String labelText = buildLabelText(m_statusText);
if (error) {
Clients.showNotification(buildNotificationText(m_statusText), "error", findTabpanel(this), "top_left", 3500, true);
}
Label label = new Label(labelText);
messageContainer.setSclass(error ? "docstatus-error" : "docstatus-normal");
messageContainer.appendChild(label);
if (m_logs != null) {
div = new Div();
for (int i = 0; i < m_logs.length; i++) {
if (m_logs[i].getP_Msg() != null) {
if (m_logs[i].getAD_Table_ID() > 0
&& m_logs[i].getRecord_ID() > 0) {
RecordLink recordLink = new RecordLink(m_logs[i].getAD_Table_ID(), m_logs[i].getRecord_ID());
recordLink.setLabel(m_logs[i].getP_Msg());
recordLink.addEventListener(Events.ON_CLICK, this);
if (!div.getChildren().isEmpty())
div.appendChild(new Separator("horizontal"));
div.appendChild(recordLink);
}
}
}
}
if (labelText.length() != m_statusText.length() || (div != null && div.getChildren().size() > 0)) {
label.addEventListener(Events.ON_CLICK, this);
label.setStyle("cursor: pointer");
label = new Label(" ...");
label.setStyle("cursor: pointer");
messageContainer.appendChild(label);
label.addEventListener(Events.ON_CLICK, this);
}
messageContainer.appendChild(new Space());
createPopupContent();
if(div!=null)
{
msgPopupCnt.appendChild(div);
}
}
private String buildLabelText(String statusText) {
if (statusText == null)
return "";
if (statusText.length() <= 80)
return statusText;
int index = statusText.indexOf(" - java.lang.Exception");
if (index > 0)
return statusText.substring(0, index);
return statusText.substring(0, 80);
}
protected void createPopupContent() {
Text t = new Text(m_statusText);
msgPopupCnt.getChildren().clear();
msgPopupCnt.appendChild(t);
}
private String buildNotificationText(String statusText) {
if (statusText == null)
return "";
if (statusText.length() <= 140)
return statusText;
int index = statusText.indexOf(" - java.lang.Exception");
if (index > 0)
return statusText.substring(0, index);
return statusText.substring(0, 136) + " ...";
}
private Component findTabpanel(Component comp) {
Component parent = comp.getParent();
while (parent != null) {
if (parent instanceof Tabpanel)
return parent;
parent = parent.getParent();
}
return null;
}
@Override
public void onEvent(Event event) throws Exception {
if(event.getTarget() instanceof RecordLink){
doZoom((RecordLink)event.getTarget());
}
}
private void doZoom(RecordLink link) {
int Record_ID = 0;
int AD_Table_ID = 0;
Record_ID = link.recordId;
AD_Table_ID = link.tableId;
if (Record_ID > 0 && AD_Table_ID > 0) {
AEnv.zoom(AD_Table_ID, Record_ID);
}
}
/**
*
* @return process logs
*/
public ProcessInfoLog[] getPLogs() {
return pInfoLogs;
}
/**
*
* @return current status line text
*/
public String getStatusLine() {
return m_statusText;
}
public boolean getStatusError() {
return m_statusError;
}
private void createPopup() {
msgPopupCnt = new Div();
msgPopupCnt.setVflex("1");
msgPopup = new Window();
msgPopup.setBorder(true);
msgPopup.setClosable(true);
msgPopup.setSizable(true);
msgPopup.setContentStyle("overflow: auto");
msgPopup.setWidth("500px");
msgPopup.appendChild(msgPopupCnt);
msgPopup.setShadow(true);
msgPopupCaption = new Caption();
msgPopup.appendChild(msgPopupCaption);
}
class RecordLink extends A {
private static final long serialVersionUID = 3793489614175751401L;
protected int recordId;
protected int tableId;
protected RecordLink(int AD_Table_ID, int Record_ID) {
super();
tableId = AD_Table_ID;
recordId = Record_ID;
}
}
} }

View File

@ -657,10 +657,29 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
} }
.adwindow-status { .adwindow-status {
background-color: #F4F4F4;
height: 20px; height: 20px;
} }
.adwindow-status-docinfo {
display: inline-block;
float: right;
padding-right: 4px;
}
.adwindow-status-docinfo .z-label, .adwindow-status-docstatus .z-label {
color: #6a6a6a;
}
.adwindow-status-docstatus .docstatus-error .z-label {
color: red;
}
.adwindow-status-docstatus {
display: inline-block;
float: left;
padding-left: 4px;
}
.adwindow-toolbar { .adwindow-toolbar {
border: 0px; border: 0px;
height: 26px; height: 26px;